Rails 4,Rspec干燥测试路线

时间:2013-10-17 21:35:58

标签: ruby-on-rails routes ruby-on-rails-4 rspec2

我正在试图让我的测试枯竭,并想检查路线。 app.send(“home_path”)在控制台中返回“/ home”,但是当我在测试中运行它时,它会以未定义的方式返回。

有什么想法吗?

1) StaticPages Check paths should have content Home
 Failure/Error: visit app.send("#{term.downcase}_path")
 NoMethodError:
   undefined method `home_path' for #<test::Application:0x007f917a48e078>
 # ./spec/requests/static_pages_spec.rb:18:in `block (4 levels) in <top (required)>'    

["Home", "About"].each do |term|
  describe "Check paths" do
    before(:each) do
      visit app.send("#{term.downcase}_path")
    end
    it "should have content #{term}" do
      expect(page).to have_content(term)
    end
  end
end

0 个答案:

没有答案
相关问题