Created
August 18, 2012 13:54
-
-
Save jasonrudolph/3386962 to your computer and use it in GitHub Desktop.
An alternative to the "ugly mirror" shown in http://vitobotta.com/applying-bitwise-operations-to-rspec-testing/
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
# A Ruby snippet posted as a comment on http://vitobotta.com/applying-bitwise-operations-to-rspec-testing/ | |
# [ activable?, persisted?, new?, suspended? ] | |
# ============================================= | |
combinations = [ | |
[ false, false, false, false ], | |
[ false, false, true, false ], | |
[ false, false, false, true ], | |
[ false, true, false, false ], | |
[ true, true, true, false ], | |
# and the remaining possible combinations ... | |
] | |
combinations.each do |activable, persisted, _new, suspended| | |
license.stub(:persisted?).and_return(persisted) | |
license.stub(:status_new?).and_return(_new) | |
license.stub(:status_suspended?).and_return(suspended) | |
license.activable?.should eq(activable) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment