Skip to content

Instantly share code, notes, and snippets.

@Kroid
Forked from koriroys/rspec_boolean_matcher.rb
Created March 25, 2018 09:15
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 Kroid/ee6e509bd91acaa1907b78fc56b2147d to your computer and use it in GitHub Desktop.
Save Kroid/ee6e509bd91acaa1907b78fc56b2147d 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