Closed murphyslaw closed 11 years ago
A way seems to be
MyCell.view_context_class.any_instance.stub(...)
Thanks. I will close the issue, as I'm currently not working on it anymore. Your suggestion sounds good.
Reopening it - I have an idea how to fix that very easily: in the newest Cells release the way cells are constructed was simplified so it should be quite easy provide the cell instance that is then to be rendered. Thanks!
:+1:
I found out that this is working already! Just do the following:
it "renders empty posts list" do
posts = cell(:posts)
posts.stub(:recent_posts).and_return([])
posts.render_state(:count).should have_selector("p", :content => "No posts!")
end
I added this to the README: https://github.com/apotonick/rspec-cells#api
Anyone wants to format this to Markdown? :)
Hello,
I have a view helper method that is used in almost all of my cells.
How can I stub it? I tried
but this doesn't work and I have no clue what to look for to find the object that the method is later called on. Do you have an idea?