Open speckins opened 8 years ago
Yes, this was because of minitest-spec-rails checking Rails.env.test?
when conditionally defining initializers.
Using the following fixes my issue:
# custom_plan.rb
class CustomPlan < Zeus::Rails
def test_environment
::Rails.env = ENV['RAILS_ENV'] = 'test'
super
end
end
Zeus.plan = CustomPlan.new
Rails.env.test?
needs to be true before calling Bundler.require(:test)
. I'm not sure why they're enforcing initialization only when the Rails environment is "test". It seems like that should be handled by putting the gem in the :test
group in the Gemfile.
Would it be appropriate to move the RAILS_ENV line before the Bundler.require line in both test_enviroment and development_environment in zeus? If so, I can generate a patch.
OS X 10.9.5 Ruby 2.2.1 Rails 4.2.6 zeus 0.15.4
I'm using the minitest-spec-rails gem to enable the Minitest::Spec::DSL in my Rails tests. I can run spec-style tests when I use "rake test", but when running tests with "zeus test," they raise errors.
In my application, I'm getting
NoMethodError: undefined method 'assert_difference' for #<#<Class:0x007fc16604e8e8>:0x007fc165598d90>
andNoMethodError: undefined method 'users' for #<#<Class:0x007fc16604e8e8>:0x007fc1655db078>
errors. (Theundefined method 'users'
is referring to a fixture helper.)I checked ActionController::TestCase.ancestors in both cases, and when running with "zeus test", the following ancestors are missing: MiniTestSpecRails::Init::ActionControllerBehavior, MiniTestSpecRails::DSL, Minitest::Spec::DSL::InstanceMethods, MiniTestSpecRails::Init::ActiveSupportBehavior.
I have tried to reproduce this in a new Rails 4.2.6 application, pulling in only "minitest-spec-rails," and I get an
undefined method 'it' for ApplicationControllerTest:Class (NoMethodError)
error.I suspect I need to add something to the
custom_plan.rb
file, but I'm not sure what. Could this be related to the minitest-spec-rails Railtie's conditional onRails.env.test?
?I've been using zeus and "minitest-spec-rails" successfully together in a Rails 3 app, but Rails 4 is having none of it.