Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An alternative to the "ugly mirror" shown in http://vitobotta.com/applying-bitwise-operations-to-rspec-testing/
# 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