0
這裏是我的測試:爲什麼我找不到h1標籤?
require "rspec"
describe HomeController do
render_views
it "should renders the home" do
get :home
response.should render_template("home")
find('H1').should have_content("Simulate Circuits Online")
end
end
,但我得到:
1) HomeController should renders the home
Failure/Error: find('H1').should have_content("Simulate Circuits Online")
Capybara::ElementNotFound:
Unable to find css "H1"
# ./spec/controllers/home_controller_spec.rb:9:in `block (2 levels) in <top (required)>'
# (eval):6:in `block in fork'
如何找到一個標籤,或ID,或CSS?
很好的答案..謝謝 – simo
但如何訪問一個動作,而不硬編碼呢? – simo
您可以使用例如'訪問home_path',假設在你的路由中定義了'home_path'。 –