Skip to content

Instantly share code, notes, and snippets.

@batasrki
Created December 17, 2011 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save batasrki/1488779 to your computer and use it in GitHub Desktop.
Save batasrki/1488779 to your computer and use it in GitHub Desktop.
Is this evil?
describe Something do
before do
@mock_view = mock("rails view")
proc_thing = @mock_view.stub(:content_tag).with(:span).and_return("<span></span>")
@mock_view.stub(:content_tag).with(:div).and_yield.and_return("<div>#{proc_thing.call}</div>")
end
it "should return a span inside a div" do
Something.new(@mock_view).render_custom_block.should match /\<div\>\<span\>\<\\span\>\<\\div\>/
end
end
class Something
def initialize(view)
@view = view
end
def render_custom_block
@view.content_tag :div do
@view.content_tag :span
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment