Tuesday, September 4, 2012

[Rails] Re: get & post methods in controller's test

> The problem isn't in the route, but in the strange behavior of get and
> post, instance methods of ActionController::TestCase::Behavior

My rspec tests seem to work as you would expect. I used a controller
named Dogs to test the routes:


require 'spec_helper'

describe "Dogs Pages" do

describe "POST to /login" do
it "returns http success" do
post '/login'
response.should be_success
response.should render_template 'dogs/login_create'
response.body.should include('hello world')
end
end


describe "GET to /login" do
it "should have h1 of 'Doggie'" do
visit '/login'
page.should have_selector('h1', text: "Login")
end
end


end


If I change the 'post' to 'get', that test fails.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate