2013-03-25 55 views
0

我收到以下错误信息:如何通过黄瓜测试用例从数据库中获取与page.should have_content

expected there to be text "D87F1B373E528ECBE040D10A044A2E9A" in "Pending Forms to be completed Patient Medication Last Updated Prescription Id" (RSpec::Expectations::ExpectationNotMetError) 
    ./features/step_definitions/get_pending_forms.rb:10:in `/^I should see formId as "([^"]*)"$/' 
    features/get_pending_forms.feature:5:in `And I should see formId as "D87F1B373E528ECBE040D10A044A2E9A"' 


Feature: List all pending forms in json 
    Scenario: get pending forms 
    Given I visits the get pending forms page with token "121cb4c8e9c5133b4046db3e81f91c0d03f4735949daf6e1c129d613531f3954" 
    Then I should see pending forms with location_id "1234567890" 
    And I should see formId as "D87F1B373E528ECBE040D10A044A2E9A" 
    And I should see formCount as "5" 

步骤定义:

Given /^I visits the get pending forms page with token "([^"]*)"$/ do |token| 
    visit display_pending_forms_path(:authorization => "121cb4c8e9c5133b4046db3e81f91c0d03f4735949daf6e1c129d613531f3954") 
end 

Then /^I should see pending forms with location_id "([^"]*)"$/ do |location| 
    #page.should have_content(location) 
end 

And /^I should see formId as "([^"]*)"$/ do |formId| 
    page.should have_content(formId) 
end 

And /^I should see formCount as "([^"]*)"$/ do |formCount| 
    page.should have_content(formCount) 
end 

回答

0

在数据库中有一些记录。它工作正常..

0

您应该改用have_css您正在测试HTML元素时的have_content:

page.should have_css("#form_id") 

有关更多详细信息请参阅Capybara documentation