[rspec-users] Testing layouts with RSpec on Rails
Steve
vertebrate at gmail.com
Mon Oct 22 20:57:51 EDT 2007
On Mon, 22 Oct 2007 10:40:45 -0400, Jonathan Linowes wrote:
>
> I'm not sure if this is what you're after but I've created this
> custom matcher to my spec_helper.rb, then in my controller spec I can
> say
> # custom matchers
> #---------------------
> class UseLayout
> def initialize(expected)
> @expected = 'layouts/' + expected
> end
> def matches?(controller)
> @actual = controller.layout
> #@actual.equal?(@expected)
> @actual == @expected
> end
> def failure_message
> return "use_layout expected #{@expected.inspect}, got #
> {@actual.inspect}", @expected, @actual
> end
> def negeative_failure_message
> return "use_layout expected #{@expected.inspect} not to equal #
> {@actual.inspect}", @expected, @actual
> end
> end
>
> def use_layout(expected)
> UseLayout.new(expected)
> end
I didn't think ActionController exposed a "layout" property. When I went
to try calling controller.layout on some existing specs I got an undefined
method 'layout' exception. Did you modify ActionController to expose that
property?
Steve
More information about the rspec-users
mailing list