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
  • Select an option

  • Save Kroid/ee6e509bd91acaa1907b78fc56b2147d to your computer and use it in GitHub Desktop.

Select an option

Save Kroid/ee6e509bd91acaa1907b78fc56b2147d to your computer and use it in GitHub Desktop.

Revisions

  1. @koriroys koriroys created this gist May 13, 2014.
    19 changes: 19 additions & 0 deletions rspec_boolean_matcher.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    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