[rspec-users] rspec 1.0.x and liquid?
dchelimsky at gmail.com
Tue Jun 12 07:51:01 EDT 2007
On 6/12/07, Courtenay <court3nay at gmail.com> wrote:
> rspec thinks that response.should render_template comes AFTER the get :show
Yeah - there was a time when RSpec supported should_render before or
after the action. This was an attempt to make things more 'mockish',
which was cool, but the code was bloody invasive (lots of rails
monkey patching) and kept breaking every time there was a new
changeset committed to Rails Edge. So we (I) gave it up and now these
only work after the action.
Perhaps we should alias it with have_rendered:
> Thanks to Dylan (abcde) for this gotcha.
> Also solves my should_redirect problems :)
> On 6/12/07, Courtenay <court3nay at gmail.com> wrote:
> > Is anyone else using liquid with the > 1 rspec? This seems to fail:
> > it 'should render show' do
> > response.should render_template('buyers/show')
> > get :show, :id => 1
> > end
> > with an error like
> > 1)
> > NoMethodError in '/buyer GET should render show'
> > You have a nil object when you didn't expect it!
> > The error occurred while evaluating nil.first_render
> > /rails/store/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb:12:in
> > `matches?'
> > spec/controllers/buyer_controller_spec.rb:57:
> > spec/controllers/buyer_controller_spec.rb:63:
> > should render_template is looking for
> > 11: def matches?(response)
> > 12: @actual = response.rendered_file(!expected.include?('/'))
> > 13: actual == expected
> > 14: end
> > TestResponse.rendered_file looks like
> > 208: def rendered_file(with_controller=false)
> > 209: unless template.first_render.nil?
> > 210: unless with_controller
> > 211: template.first_render
> > so TestResponse is missing 'template'. Any clues?
> > Courtenay
> > http://blog.caboo.se
> > http://entp.com
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users