Hi,
I was using WebRat and I had view specs that looked like this:
describe “expenses/new.html.erb” do
it “displays ‘New Expense’” do
render
rendered.should include(“New Expense”)
end
end
I am now using Capybara and you cannot use those matchers in View
Specs.
What should my view specs look like?
If I try using: get “expenses/edit”
I end up with: undefined method `get’ for
#RSpec::Core::ExampleGroup::Nested_1:0xaf364ac
Am I meant to keep using render, rendered?
How should the spec above be re-written?
And the nested one below?
it “renders a form to create an expense” do
render
rendered.should have_selector(“form”,
:method => “post”,
:action => expenses_path
) do |form|
form.should have_selector("input",
:type => "text",
:name => "expense[name]")
form.should have_selector("input",
:type => "text",
:name => "expense[limit]")
form.should have_selector("input",
:type => "submit",
:value => "Add")
form.should have_selector("a",
:content => "Cancel",
:href => expenses_path)
end
end
Thanks, Daryn