Closed gma closed 12 years ago
Interestingly, when I removed turn
from Gemfile
I got a different error, indicating that ::MiniTest
hadn't been loaded (from line 55 of minitest_handler.rb
.
A bit more info on my setup:
Gemfile
; you get 0.0.1 via bundler due to dependency problems)I've been digging for about an hour. No clue…
@gma Can you send me a sample test file that you're using with mintiest rails. Ideally it'll be one that if you call it's class in TConsole by just passing the class name you see the same error you're seeing above. That'll help out with identifying what's going on.
Thanks!
@gma I think I may have actually reproduced the issue you were experiencing.
What file names do your tests have? Do they follow the normal pattern of _test.rb or are they using _spec.rb?
They're all named *_test.rb, but I'm using the spec dsl to create describe and it blocks (but using standard assertions within those blocks).
% tree test/
test/
├── controllers
│ ├── cards_controller_test.rb
│ ├── iterations_controller_test.rb
│ └── projects_controller_test.rb
├── domain
│ └── iteration_logic_test.rb
├── factories.rb
├── helpers
│ ├── cards_helper_test.rb
│ ├── iterations_helper_test.rb
│ └── projects_helper_test.rb
├── minitest_helper.rb
├── minitest_no_rails_helper.rb
├── models
│ ├── account_test.rb
│ ├── card_test.rb
│ ├── iteration_test.rb
│ └── project_test.rb
└── presenters
├── card_presenter_test.rb
└── iteration_presenter_test.rb
5 directories, 16 files
Here's card_test.rb (that fails with the db env problem when I just enter CardTest
):
require_relative '../minitest_helper'
describe Card do
it 'should return nil for number when unsaved' do
assert_nil FactoryGirl.build(:card).number
end
describe 'that exists' do
before do
@card = FactoryGirl.create(:card)
end
it 'should return id for number' do
assert_equal @card.id, @card.number
end
end
end
If file names could cause it, could it be something to do with the paths? I suspect minitest-rails
is responsible for my tests being in test/models
rather than test/units
, but haven't checked that.
That was it; I changed test/unit
and test/functionals
in lib/tconsole/config.rb
to test/models
and test/functionals
and then all
would run some tests.
Adding this .tconsole
file fixed it:
TConsole::Config.run do |config|
config.file_sets = {
"all" => ["#{config.test_dir}/**/*_test.rb"],
"models" => ["#{config.test_dir}/models/**/*_test.rb"],
"controllers" => ["#{config.test_dir}/controllers/**/*_test.rb"],
"helpers" => ["#{config.test_dir}/helpers/**/*_test.rb"],
"integration" => ["#{config.test_dir}/integration/**/*_test.rb"]
}
end
I wonder whether or not the if is_rails?
block ought to be replacing the file sets, or whether it should keep the existing one for all
(which would work better when people add tests outside of unit, functional or integration directories).
I rolled out an update in the latest prerelease to make sure that an error message shows up if no files match the file set being executed against. I'll try to get your code merged in once I can write up some tests for it.
I had a quick look at config_test.rb and didn't notice anything about changing file_sets in Rails, so I just patched it and tested it off my own branch.
Apologies for lack of tests; if you'd like to suggest an approach I'll take a look at it for you, but if you've got something in mind and would rather just crack on with it, that's fine by me...
@gma I'm thinking for these particular situations I'm almost going to have to do integration testing - it's definitely not your fault that tests aren't there - just something that's pretty hard to figure out on a crazy forking, super environment dependent tool like TConsole is.
Any thoughts on what could be causing this?
The "non production" part of my
Gemfile
look like this: