Skip to content

Instantly share code, notes, and snippets.

@robwilliams
Forked from cblunt/application_helper_spec.rb
Created February 23, 2016 12:01
Show Gist options
  • Save robwilliams/f0428cad2345145a2907 to your computer and use it in GitHub Desktop.
Save robwilliams/f0428cad2345145a2907 to your computer and use it in GitHub Desktop.
Testing content_for Helper Methods with RSpec
# Solution from http://www.jamiepenney.co.nz/2011/09/23/testing-content_for-in-rails-3-x-helpers-with-rspec/
describe ApplicationHelper do
describe "title" do
it "should return an h2 tag with the given title" do
helper.title("Lorem Ipsum")
helper.content_for(:page_title).should eql "<h2>Lorem Ipsum</h2>"
end
it "should return the supplied block if a block was given" do
helper.title { "Some Block" }
helper.content_for(:page_title).should eql "Some Block"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment