I'm new to Cucumber and have been stepping through a railscast by Ryan Bates. http://railscasts.com/episodes/155-beginning-with-cucumber
Unfortunately my scenario is failing where the railscast passes. Specifically it is failing on the step: Then I should see "New Article Created."
I suspect it may have something to do with the differing versions of the gems we are using, currently I have the latest of each.
It gives me the following error:
*Then I should see "New Article Created." expected the following element's content to include "New Article Created.":
Title
Content
(Spec::Expectations::ExpectationNotMetError)
./features/step_definitions/web_steps.rb:144:in /^(?:|I )should see "([^\"]*)"$/'
features/manage_articles.feature:18:in
Then I should see "New Article Created."'*
This is the source:
manage_articles.feature
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" Then I should see "New Article Created." And I should see "Spuds" And I should see "Delicious potatoes" And I should have 1 article
articles_controller.rb
...
def create
@article = Article.create!(params[:article])
flash[:notice] = "New Article Created."
redirect_to articles_path
end
index.html.erb
<p><%= flash[:notice] %></p>
<% for article in @articles %>
<p><%=h article.title %></p>
<p><%=h article.content %></p>
<% end %>
<%= link_to "New Article", new_article_path %>
I think you must add this line before
Then I should see "New Article Created."
:So, here is your complete scenario:
A good trick to debugging cucumber is to create some debugging steps.
In a debug_steps.rb file I have the following:
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.