I've followed all of the steps that I've been able to find online for configuring Rails 3 with Rspec 2 and Mocha. In my Gemfile:
group :development do
gem 'rails3-generators'
gem "rspec", '>= 2.0.0.beta.19'
gem "rspec-rails", '>= 2.0.0.beta.19'
end
group :test do
gem "faker"
gem "rspec", '>= 2.0.0.beta.19'
gem "rspec-rails", '>= 2.0.0.beta.19'
gem "machinist", '>= 2.0.0.beta1'
gem "mocha"
gem "capybara", ">= 0.3.9"
end
And in spec/spec_helper.rb:
RSpec.configure do |config|
config.mock_with :mocha
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
end
Still, when I use the Rails generator...
rails generate scaffold foo name:string
...I get the following in spec/controllers/foos_controller_spec.rb:
def mock_foo(stubs={})
@mock_foo ||= mock_model(Foo, stubs).as_null_object
end
...which of course causes all specs to fail.
Does anyone know what I'm missing?
Thanks in advance.
In application.rb you'll need something like the following:
config.generators do |g|
g.test_framework :rspec
end
Further information available here:
http://guides.rubyonrails.org/generators.html#customizing-your-workflow
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With