Sha256: ad79f22963b6b64bb83e4453a4b982d8ab3b896f9181b19b6870c6ee0a978382

Contents?: true

Size: 621 Bytes

Versions: 13

Compression:

Stored size: 621 Bytes

Contents

require 'spec_helper'

describe Virtus::Coercion::String, '.to_boolean' do
  subject { object.to_boolean(string) }

  let(:object) { described_class }

  %w[ 1 on ON t true T TRUE y yes Y YES ].each do |value|
    context "with #{value.inspect}" do
      let(:string) { value }

      it { should be(true) }
    end
  end

  %w[ 0 off OFF f false F FALSE n no N NO ].each do |value|
    context "with #{value.inspect}" do
      let(:string) { value }

      it { should be(false) }
    end
  end

  context 'with an invalid boolean string' do
    let(:string) { 'non-boolean' }

    it { should equal(string) }
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
virtus-0.5.5 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.5.4 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.5.3 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/virtus-0.5.2/spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.5.2 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.5.1 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.5.0 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.4.2 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.4.1 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.4.0 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.3.0 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.2.0 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb
virtus-0.1.0 spec/unit/virtus/coercion/string/class_methods/to_boolean_spec.rb