Rails/Cucumber/Webrat: redirect_to, flash[:notice] not working

北城以北 提交于 2019-12-01 14:38:19

I think you must add this line before Then I should see "New Article Created.":

And I press "Create"

So, here is your complete scenario:

Feature: Manage Articles

      Scenario: Create Valid Article
        Given I have no articles
        And I am on the list of articles
        When I follow "New Article"
        And I fill in "Title" with "Spuds"
        And I fill in "Content" with "Delicious potatoes"
        And I press "Create"
        Then I should see "New Article Created."
        And I should see "Spuds"
        And I should see "Delicious potatoes"
        And I should have 1 article

A good trick to debugging cucumber is to create some debugging steps.

In a debug_steps.rb file I have the following:

Then /^I debug$/ do
 breakpoint; 0
end

Then /^I open the page$/ do
  save_and_open_page
end

Note, that save_and_open_page requires: Webrat: webrat (0.5.3) and Launchy: launchy (0.3.3)

Then add the step:

Then I open the page

before Then I should see "New Article Created."

To see what is going on.

Good luck. Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!