Skip to content

Instantly share code, notes, and snippets.

@tomtt
Created March 11, 2009 10:44
Show Gist options
  • Save tomtt/77409 to your computer and use it in GitHub Desktop.
Save tomtt/77409 to your computer and use it in GitHub Desktop.
## Cucumber step
Then /^I should see a link called "([^"]*)" in the (.*)$/ do |link_text, section_name|
response.should have_xpath(xpath_of_section(section_name)) do |section|
section.should have_selector("a", :content => link_text)
end
end
## cucumber feature
Feature: Related article links
In order to find more things I am interested in
As a user
I want to see articles related to the one I'm viewing
Scenario: User sees the related links box
Given a news article
And the news article has "First related article" in the title
And a news article
And the news article has "Zombies attack" in the title
When I go to the news article page for "Zombies attack"
Then I should see a link called "First related article" in the related links box
## error message
>: ./script/cucumber features/test.feature
Feature: Related article links
In order to find more things I am interested in
As a user
I want to see articles related to the one I'm viewing
Scenario: User sees the related links box # features/test.feature:6
Given a news article # features/step_definitions/article_steps.rb:1
And the news article has "First related article" in the title # features/step_definitions/article_steps.rb:5
And a news article # features/step_definitions/article_steps.rb:1
And the news article has "Zombies attack" in the title # features/step_definitions/article_steps.rb:5
When I go to the news article page for "Zombies attack" # features/step_definitions/webrat_steps.rb:10
Then I should see a link called "First related article" in the related links box # features/step_definitions/inspection_steps.rb:31
expected following output to contain a <a>First related article</a> tag:
<div class="block related_content_block generic_block">
<div class="top"></div>
<h3>See Also</h3>
<div class="item_list">
<div class="item">
<img src="/images/dev_temp/related_content.jpg" alt=""><!-- quote --><a>First related article</a><!-- just to see why cucumber screws up -->
<h4><a href="/news_articles/2">First related article</a></h4>
<p>Some body</p>
</div>
</div>
<div class="bottom"> </div>
</div> (Spec::Expectations::ExpectationNotMetError)
vendor/plugins/rspec/lib/spec/expectations.rb:57:in `fail_with'
vendor/plugins/rspec/lib/spec/expectations/handler.rb:13:in `handle_matcher'
vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb:31:in `should'
./features/step_definitions/inspection_steps.rb:33:in `__instance_exec0'
vendor/plugins/rspec/lib/spec/expectations/handler.rb:12:in `handle_matcher'
vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb:31:in `should'
./features/step_definitions/inspection_steps.rb:32:in `/^I should see a link called "([^"]*)" in the (.*)$/'
features/test.feature:12:in `Then I should see a link called "First related article" in the related links box'
1 scenario
1 failed step
5 passed steps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment