Sha256: d0e35007ff034235e42d65cfda423397678a97ef49308a577f1fa93b15125b05

Contents?: true

Size: 700 Bytes

Versions: 7

Compression:

Stored size: 700 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Necromancer::ArrayConverters::ArrayToBooleanConverter, '.call' do

  subject(:converter) { described_class.new(:array, :boolean) }

  it "converts `['t', 'f', 'yes', 'no']` to boolean array" do
    expect(converter.call(['t', 'f', 'yes', 'no'])).to eq([true, false, true, false])
  end

  it "fails to convert `['t', 'no', 5]` to boolean array in strict mode" do
    expect {
      converter.call(['t', 'no', 5], strict: true)
    }.to raise_error(Necromancer::ConversionTypeError)
  end

  it "converts `['t', 'no', 5]` to boolean array in non-strict mode" do
    expect(converter.call(['t', 'no', 5], strict: false)).to eql([true, false, 5])
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
pokedex-terminal-0.2.8 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/array/array_to_boolean_spec.rb
pokedex-terminal-0.2.7 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/array/array_to_boolean_spec.rb
pokedex-terminal-0.2.6 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/array/array_to_boolean_spec.rb
pokedex-terminal-0.2.5 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/array/array_to_boolean_spec.rb
pokedex-terminal-0.2.4 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/array/array_to_boolean_spec.rb
necromancer-0.5.1 spec/unit/converters/array/array_to_boolean_spec.rb
necromancer-0.5.0 spec/unit/converters/array/array_to_boolean_spec.rb