Today i got struck by simplicity, as a reviewer said:
what exactly is response.should render_template(“new”)
and my answer was: it says that it renders new
Usage
#delete this
flash[:error].should_not be_nil
response.should render_template("new")
response.should redirect_to('/')
response.should redirect_to(user_path(User.first))
#enjoy this
it_flashes :error
it_renders :new
it_redirects '/'
it_redirects User.first
Install
#spec/spec_helper.rb
def it_redirects_to(what)
what = send(what.class.to_s.underscore+'_path',what) if what.kind_of? ActiveRecord::Base
response.should redirect_to(what.to_s)
end
alias :it_redirects :it_redirects_to
def it_renders(what)
response.should render_template(what.to_s)
end
def it_has_flash(what)
flash[what].should_not be_blank
end
alias :it_flashes :it_has_flash
def it_assigns(what,to=nil)
if to
assigns[what].should == to
else
assigns[what].should_not be_blank
end
end
Shouldless convention as outlined in my groundbreaking paper. 😉