Error Message 失败:
1) Banks GET /banks displays bank
Failure/Error: visit banks_path
ActionView::Template::Error:
undefined method `include?' for nil:NilClass
# ./config/initializers/assets.rb:2:in `block in <top (required)>'
# ./app/views/devise/sessions/new.html.erb:31:in `block in _app_views_devise_sessions_new_html_erb___985177529_129572070'
# ./app/views/devise/sessions/new.html.erb:23:in `_app_views_devise_sessions_new_html_erb___985177529_129572070'
# ./spec/requests/banks_spec.rb:8:in `block (3 levels) in <top (required)>'
2) Banks POST /banks creates bank
Failure/Error: fill_in "Bank Name", :with => "corporation"
NoMethodError:
undefined method `body' for nil:NilClass
# ./spec/requests/banks_spec.rb:29:in `block (3 levels) in <top (required)>'
3) Banks POST /banks Shows bank details
Failure/Error: page.should have_content("Successfully created bank.")
NameError:
undefined local variable or method `page' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_3:0x10077cd0>
# ./spec/requests/banks_spec.rb:49:in `block (3 levels) in <top (required)>'
bank_spec.rb
require 'spec_helper'
describe "Banks" do
describe "GET /banks" do
it "displays bank " do
Bank.create!(:user_id => "1", :name => "corporation", :branch=> "matikere", :account_number=> "023800101027128", :account_type=>"SB", :address=>"#xyz street, 15th cross,domlur", :city=>"bangalore", :state_id=>1, :country_id=>1)
visit banks_path
page.should have_content("Bank name.")
page.should have_content("A/c Number.")
page.should have_content("Branch name.")
# save_and_open_page
click_link("New bank")
visit new_bank_path
click_link("show")
visit bank_path
click_link("edit")
visit edit_bank_path
click_link("Destroy")
visit banks_path
end
end
describe "POST /banks" do
it "creates bank" do
fill_in "Bank Name", :with => "corporation"
fill_in "Branch Name", :with => "matikere"
fill_in "Account number", :with => "023800101027128"
fill_in "Account type", :with => "SB"
fill_in "address", :with => "#xyz street, 15th cross,domlur"
fill_in "City", :with => "bangalore"
fill_in "State", :with => 1
fill_in "country", :with => 1
click_button "create Bank"
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
page.should have_content("Successfully added bank.")
click_link "Back to List"
visit banks_path
end
end
describe "POST /banks" do
it "Shows bank details" do
# save_and_open_page
page.should have_content("Successfully created bank.")
page.should have_content("Name", with =>"corporation")
page.should have_content("Branch Name", with =>"matikere")
page.should have_content("Account type", with =>"SB")
page.should have_content("Account number", with =>"023800101027128")
page.should have_content("Address", with =>"#xyz street, 15th cross,domlur")
page.should have_content("City", with =>"bangalore")
page.should have_content("State", with =>"karnataka")
page.should have_content("Country", with =>"India")
click_link("edit")
visit edit_bank_path
click_link("Destroy")
visit banks_path
click_link("View All")
visit banks_path
end
end
end
宝石文件
宝石文件组:开发,:测试做宝石'rspec-rails','2.12.0'gem'capybara',:git =>'git://github.com/jnicklas/capybara.git'gem'punchy'gem 'database_cleaner'gem'autotest-growl','0.2.9'gem'autotest','4.4.6'gem'autotest-rails-pure','4.1.2'gem'factory_girl_rails','1.0'gem'growl 'gem'webrat','0.7.3'结束组:test do gem'rspec','2.12.0'gem's'rspec-rails','2.12.0'gem'valid_attribute'
gem'spork'gem'autotest','4.4.6'gem'ZenTest',:require => false,:group =>:test gem'autotest-rails-pure','4.1.2'gem'autootest-growl ','0.2.9'宝石'factory_girl_rails','1.0'宝石'capybara',:git =>'git://github.com/jnicklas/capybara.git'gem'heave-rails'gem'upity'宝石'guard'gem'guard-rspec'gemon'guard-spork'gem'simplecov',:require => false,:group =>:test gem'metrical'gem'mempision_fu'gem'database'cleaner'gem'growl'gem' email_spec'gem'scover_me','> = 1.0.0.rc2'
结束
1 回答
试试
expect(page).to have_content()
您确定在当前测试页中可以看到具有属性
name="Bank Name"
的输入 . 建议您在执行操作之前编写visit some_path
以转到您测试的网页 .