Skip to content

Instantly share code, notes, and snippets.

@jgaskins
Created July 26, 2012 18:41
Show Gist options
  • Save jgaskins/3183715 to your computer and use it in GitHub Desktop.
Save jgaskins/3183715 to your computer and use it in GitHub Desktop.
Testing Rails helpers
require 'ostruct'
require File.expand_path('../../../app/helpers/application_helper', __FILE__)
describe ApplicationHelper do
let(:current_user) { OpenStruct.new(email: 'me@example.com', name: 'Foo Bar') }
let(:view) { double('view') }
subject { view }
before do
view.extend ApplicationHelper
view.stub current_user: current_user
end
it 'does whatever an ApplicationHelper does' do
# Stub as necessary
# Insert expectations here
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment