Skip to content

Instantly share code, notes, and snippets.

@bignimbus
Last active April 29, 2016 17:03
Show Gist options
  • Save bignimbus/13edc506987fbc28916f9a448cb98e34 to your computer and use it in GitHub Desktop.
Save bignimbus/13edc506987fbc28916f9a448cb98e34 to your computer and use it in GitHub Desktop.
Testing protected and private methods in rspec
class ThingController < ApplicationController do
# ...
protected
def protected_thing
'foo'
end
private
def private_thing
'bar'
end
end
describe ThingController, type: controller do
# ...
describe '#protected_thing' do
it { expect(subject.send(:protected_thing)).to eq 'foo'
end
describe '#private_thing' do
it { expect(subject.send(:private_thing)).to eq 'bar'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment