Skip to content

Instantly share code, notes, and snippets.

@koriroys
Created May 13, 2014 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save koriroys/531c84e1491fe42b3aaa to your computer and use it in GitHub Desktop.
Save koriroys/531c84e1491fe42b3aaa to your computer and use it in GitHub Desktop.
rspec boolean matcher
require 'rspec/expectations'
RSpec::Matchers.define :be_boolean do
match do |actual|
[true, false].include? actual
end
failure_message_for_should do |actual|
"expected that #{actual.inspect} would be a boolean(true or false)"
end
failure_message_for_should do |actual|
"expected that #{actual.inspect} would be not be a boolean(true or false)"
end
description do
"be a boolean(true or false)"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment