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…
def add_category_link(name)
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(…)
end
end
Thanks! However, I am getting an error about ‘nil.render’ now, with
this backtrace:
Just for fun - try putting it in a view specs instead and include the
helper:
describe “FooHelper”, :type => :view do
include FooHelper
etc
end
It might be that view specs have services you need for this example
that don’t exist in helper specs. If it works, then you can use that
as a workaround for now and we know where the deficiency lies. If so,
please submit a ticket at http://rspec.lighthouseapp.com/.
Cheers,
David
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.