开发者

Cucumber: scenario creating entry and deleting it before test => failure

I'm newbie in cucumber and I'm struggling with it in my Rails 3 app :)

Here are the gems included in my gemfile: cucumber, cucumber-rails, rspec, rspec-rails, capybara, capybara-envjs, database_cleaner, launchy

I set up the following:

require 'capybara/envjs'
Capybara.javascript_driver = :envjs

In my website, it's possible for anyone to subscribe to the news letter. It works fine through ajax and displays a nice growl-like message:

  • mail valid => Welcome...
  • mail invalid => Oops...

The following scenario works fine, when I comment the line: I should have 1 mail in my mailing list.

With this line, I have the following error message: And I should have 1 mail in my mailing list # features/step_definitions/mailing_steps.rb:1 expected: 1, got: 0 (using ==) (RSpec::Expectations::ExpectationNotMetError)

@javascript
Scenario: Entering Valid Mail
Given I am on the about page
When  I fill in "mailing[mail]" with "cucumber@cucumber.com"
And   I press "REGISTER"
Then  I should be on the about page
And   I should have 1 mail in my mailing list
And   I should see "Welcome" within "#gritter-开发者_Go百科notice-wrapper"

Here is the step I added:

Then /^I should have ([0-9]+) mail in my mailing list?$/ do |count|
  Mailing.count.should == count.to_i
end

Maybe it's due to database cleaner but I kept the default configuration :truncation

Any idea please?

PS: I should add that refreshing my database like a moron, I see the mail first added then being deleted.


I would drop the line debugger at

Then /^I should have ([0-9]+) mail in my mailing list?$/ do |count|
  debugger
  Mailing.count.should == count.to_i
end

And inspect how many Mailing's there are.

debugger will require the gem 'ruby-debug' or 'ruby-debug19' to be installed.

If Mailing.count is 0, I would move that debugger line into earlier in the test until I found where it was 1 and then isolate the point in time or code where its going to 0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜