3coins
3coins

Reputation: 1342

Capybara with cucumber giving false positive

I have these test steps. app_host is pointing to "google.com".

  Given /^I am on google\.com$/ do
      visit("/")
  end

  Then /^I should see something$/ do
      has_css?('a#something')
  end

Regardless of what I have in the 2nd step, test is passing. I am just wondering if I am missing something here.

Upvotes: 2

Views: 310

Answers (1)

Justin Ko
Justin Ko

Reputation: 46846

Cucumber steps will only fail if an assertion fails. They do not fail based on if the last line is true or false.

To use has_css? in an assertion you can do one of the following:

#If you are using RSpec assertions
page.should have_css('a#something')

#If you are using Test::Unit assertions
assert page.has_css?('a#something')

Upvotes: 5

Related Questions