cucumber test ?小心得 二_Ruby_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > Ruby > cucumber test ?小心得 二

cucumber test ?小心得 二

 2012/3/17 15:30:45  夜鸣猪  程序员俱乐部  我要评论(0)
  • 摘要:Scenario:SigningupGivenIamonthehomepageWhenIfollow"Signup"AndIfillin"Email"with"user@ticketee
  • 标签:
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
  • 相关文章
发表评论
用户名: 匿名