i am just starting to use cucumber and like it so far however there is one issue that seems very basic that I can’t work out. I am doing a very basic test of my homepage with the following:
home_pages.feature
Feature: Viewer visits the Home Page
In order to read the page
As a viewer
I want to see the home page of my app
Scenario: View home page
Given I am on the home page
Then I should see "Test" in the selector "h1"
Scenario: Check Home Page Links
Given I am on the home page
Then I should see "How It Works" in a link
And I should see "Sign Up" in a link
And I should see "Log In" in a link
and cr1_steps.rb
Given /^I am on the home page$/ do
visit root_path
end
Then /^I should see "([^"]*)" in the selector "([^"]*)"$/ do |text, selector|
page.should have_selector selector, content: text
end
Then /^I should see "([^"]*)" in a link$/ do |text|
page.should have_link text
end
home.html.erb
<div class="center hero-unit">
<h1>Working</h1>
<p>testing testing testing</p>
<a class="btn btn-primary btn-large">
Click This
</a>
</div>
<ul class="thumbnails">
<li class="span3">
<div class="thumbnail">
<img src="http://placehold.it/360x268" alt="">
</div>
</li>
</ul>
However cucumber is passing even though the “h1” selector has “Working” in the home.html.erb, where as it should fail as I am testing for “h1″Test Any ideas why this could be
I don’t see a
:contentoption in the Capybara documentation for#has_selector?Try
text: textinstead.