Ruby on rails 4 rspec命名错误';拥有'';有"头衔"和"x27 ;;
我是RubyonRails的新手。 我刚刚完成了本教程,我正在尝试从头开始创建自己的ruby网站 一旦我把我的罪恶税换成了不那么冗长的税,我就会犯错误: 我得到的错误是:Ruby on rails 4 rspec命名错误';拥有'';有"头衔"和"x27 ;;,ruby-on-rails-4,railstutorial.org,Ruby On Rails 4,Railstutorial.org,我是RubyonRails的新手。 我刚刚完成了本教程,我正在尝试从头开始创建自己的ruby网站 一旦我把我的罪恶税换成了不那么冗长的税,我就会犯错误: 我得到的错误是: 1) Pages Home page Failure/Error: it { should have_content('Home') } NoMethodError: undefined method `has_content?' for "Home page":String # ./spec/requests/page
1) Pages Home page
Failure/Error: it { should have_content('Home') }
NoMethodError:
undefined method `has_content?' for "Home page":String
# ./spec/requests/pages_spec.rb:7:in `block (3 levels) in <top (required)>'
我不知道发生了什么我是不是忘了在我的档案里写点什么?
如果您需要更多的信息评论,我会将其包括在这里试试
it 'has home title' do
expect(page).to have_title('Home')
end
it 'has home content' do
expect(page).to have_content('Home')
end
或
是的,这就是我的意思,把语法从更冗长的语法改过来。这个语法可以工作,但是以后会变得非常混乱,所以我只想使用较短的语法。谢谢你的建议thou@Xitcod13我编辑了我的答案,用
主题尝试一下
希望它能奏效
it 'has home title' do
expect(page).to have_title('Home')
end
it 'has home content' do
expect(page).to have_content('Home')
end
subject { page }
it { should have_title('Home') }
it { should have_content('Home') }