`

cucumber test  小心得 二

阅读更多
Scenario: Signing up
    Given I am on the homepage
    When I follow "Sign up"
    And I fill in "Email" with "user@ticketee.com"
    And I fill in "Password" with "password"
    And I fill in "Password confirmation" with "password"
    And I press "Sign up"
    Then show me the page
    Then I should see "You have signed up successfully."
      Failed assertion, no message given. (MiniTest::Assertion)
      /Users/ryanbigg/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/unit.rb:85:in `assert'
      /Users/ryanbigg/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/test/unit/assertions.rb:19:in `assert'
      ./features/step_definitions/web_steps.rb:105:in `block (2 levels) in <top (required)>'
      ./features/step_definitions/web_steps.rb:13:in `with_scope'
      ./features/step_definitions/web_steps.rb:101:in `/^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/'
      features/signing_up.feature:14:in `Then I should see "You have signed up successfully."'

Failing Scenarios:
cucumber features/signing_up.feature:6 # Scenario: Signing up


是你的web_steps.rb写的不好
 #写step 定义的时候,加上提示信息就会好了
Then /^(?:|I )should see "([^"]*)"$/ do |text|
  if page.respond_to? :should
    page.should have_content(text)
  else
    assert page.has_content?(text), "no text has been found"
  end
end


验证排序
Then /I should see "(.*)" before "(.*)"/ do |e1, e2|
  #  ensure that that e1 occurs before e2.
  #  page.content  is the entire content of the page as a string.
  movies_list = page.all("table#movies>tbody>tr>td").map(&:text)
  assert movies_list.index(e1) < movies_list.index(e2), "#{e1} is not before #{e2}"
  #assert false, "Unimplmemented"
end


Capybara.default_selector = :css
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics