Last active
April 29, 2016 17:03
-
-
Save bignimbus/13edc506987fbc28916f9a448cb98e34 to your computer and use it in GitHub Desktop.
Testing protected and private methods in rspec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ThingController < ApplicationController do | |
# ... | |
protected | |
def protected_thing | |
'foo' | |
end | |
private | |
def private_thing | |
'bar' | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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