Sha256: ab42fa9c29c7cb7681b65e2cf7a7d0aa9007b5b9231f88c14d5e9b8bfb0a1828

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'test_helper'
require 'montage_rails/boolean'

module MontageRails
  class BooleanTest < MiniTest::Test
    describe ".is_me?" do
      context "when a 'true' string is passed in" do
        should "return true" do
          assert Boolean.is_me?('true')
        end
      end

      context "when a 'false' string is passed in" do
        should "return true" do
          assert Boolean.is_me?('false')
        end
      end

      context "when a TrueClass is passed in" do
        should "return true" do
          assert Boolean.is_me?(true)
        end
      end

      context "when a FalseClass is passed in" do
        should "return true" do
          assert Boolean.is_me?(false)
        end
      end

      context "when a 0 or 1 is passed in" do
        should "return true" do
          assert Boolean.is_me?(1)
          assert Boolean.is_me?(0)
          assert Boolean.is_me?("1")
          assert Boolean.is_me?("0")
        end
      end

      context "when the value is not a boolean" do
        should "return false" do
          refute Boolean.is_me?("foo")
          refute Boolean.is_me?(2)
          refute Boolean.is_me?("2")
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
montage_rails-1.0.0 test/montage_rails/boolean_test.rb
montage_rails-0.7.4 test/montage_rails/boolean_test.rb
montage_rails-0.7.3 test/montage_rails/boolean_test.rb