[rspec-users] How-to spec this helper method?...

David Chelimsky dchelimsky at gmail.com
Sun Dec 23 23:09:30 EST 2007

On Dec 20, 2007 4:31 AM, Bart Zonneveld <loop at superinfinite.com> wrote:
> Hey gang,
> I have this dead-simple method defined in a helper:
>    def add_category_link(name)
>      link_to_function name do |page|
>        page.insert_html :bottom, :categories, :partial =>
> 'category', :object => Category.new
>      end
>    end
> Where, and mostly how, would I spec this? I haven't been able to find
> how to stub the rjs in a helper spec, so I'd appreciate any pointers
> whatsoever..

If you can spec it in a template using rjs, you can do it in a helper:

describe FooHelper do
  it "should build a category link" do
    add_category_link(:foo).should have_rjs(...)

"should have_rjs" is a wrapper for assert_select_rjs in rails.


More information about the rspec-users mailing list