Skip to content

Instantly share code, notes, and snippets.

@jasonrudolph
Created August 18, 2012 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonrudolph/3386962 to your computer and use it in GitHub Desktop.
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/
# 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