Last active
December 8, 2015 11:08
-
-
Save mistrikushal/eb3f03f6b840e5bc9e74 to your computer and use it in GitHub Desktop.
RSpec - Testing private methods of a model
This file contains 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
# RSpec allows us to test private methods of a model. | |
for example, | |
class User | |
def is_active? | |
true | |
end | |
private :is_active? | |
end | |
RSpec.describe 'private methods' do | |
subject { User.new } | |
# success pass | |
it { is_expected.to is_active? } | |
# deliberate failure | |
it { is_expected.to has_secret? } | |
end | |
# :) Happy Coding |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment