我的规格文件:
require 'spec_helper'
describe "State Contracts page" do
@state_data = {
:state_slug => 'Alabama',
:state_name => 'California'
}
before(:each) { visit state_path(:state=>"#{@state_data[:state_slug]}" )}
it 'should have header' do
page.should have_content("#{@state_data[:state_name]} Contracts")
end
# show statistics specification for State Contract
it "should have #{@state_data[:state_name]} Statistics details" do
page.should have_content("#{@state_data[:state_name]} Statistics")
page.should have_content('Total Obligated Amount')
page.should have_content('Total Transactions')
page.should have_content('Total Contractors')
page.should have_content('Total Contract Recipients')
page.should have_content('Total Offers')
end
end
# show State link
it "should have visible #{@state_data[:state_name]} Links" do
page.should have_content("#{@state_data[:state_name]} Links")
assert_equal(true, find_link("Agencies in #{@state_data[:state_name]}").visible?)
assert_equal(true, find_link("Contractors in "{@state_data[:state_name]}").visible?)
assert_equal(true, find_link("Contracts in #{@state_data[:state_name]}").visible?)
end
end
在我运行测试之后,我得到了下一个错误:
undefined method `[]' for nil class for "#{@state_data[:state_name]}"
我想我正在插入散列变量,但现在不正确。