У меня та же проблема, все мои «шаги» проходят, но мой сценарий не выполняется из-за смешения ActiveRecord с Database Cleaner.
Scenario: User is not signed up # features/users/sign_in.feature:6
Given I am not logged in # features/step_definitions/user_steps.rb:86
And no user exists with an email of "user@invalidemail.com" # features/step_definitions/user_steps.rb:1
When I go to the sign in page # features/step_definitions/web_steps.rb:48
And I sign in as "user@invalidemail.com/please" # features/step_definitions/user_steps.rb:61
Then I should see "Invalid email or password." # features/step_definitions/web_steps.rb:105
And I go to the home page # features/step_definitions/web_steps.rb:48
And I should be signed out # features/step_definitions/user_steps.rb:81
ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
/Users/ashr/.rvm/gems/ruby-1.9.3-p0@travel/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0@travel/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0@travel/gems/cucumber-rails-1.3.0/lib/cucumber/rails/hooks/active_record.rb:6:in `connection'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0@travel/gems/database_cleaner-0.7.2/lib/database_cleaner/active_record/truncation.rb:130:in `clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0@travel/gems/database_cleaner-0.7.2/lib/database_cleaner/base.rb:77:in `clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0@travel/gems/database_cleaner-0.7.2/lib/database_cleaner/configuration.rb:56:in `block in clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0@travel/gems/database_cleaner-0.7.2/lib/database_cleaner/configuration.rb:56:in `each'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0@travel/gems/database_cleaner- 0.7.2/lib/database_cleaner/configuration.rb:56:in `clean'
/Users/ashr/.rvm/gems/ruby-1.9.3-p0@travel/gems/cucumber-rails- 1.3.0/lib/cucumber/rails/hooks/database_cleaner.rb:9:in `After'
Failing Scenarios:
cucumber features/users/sign_in.feature:6 # Scenario: User is not signed up
1 scenario (1 failed)
7 steps (7 passed)
Я получаю подсказку при выполнении моих тестов на огурец:
$bundle exec cucumber --verbose features/users/sign_in.feature:15
WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb).
https://rspec.lighthouseapp.com/projects/16211/tickets/165 (связанный билет)
Как ни странно, это не дает сбоя на шаге До.
spec_helper.rb
RSpec.configure do |config|
# == Mock Framework
config.mock_with :rspec
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
...
end
...
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
...
end
функция / поддержка / config.rb
Class ...
...
End
begin
DatabaseCleaner.strategy = :truncation, { :except => %w[oauth_tokens client_applications] }
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end