Sha256: b49c4fd5015517433a758178f7a2e17af44882dfa5e789945c0b1d4bfab2ef32

Contents?: true

Size: 691 Bytes

Versions: 7

Compression:

Stored size: 691 Bytes

Contents

# frozen_string_literal: true

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

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

  it "converts `['1','2.3','3.0']` to numeric array" do
    expect(converter.call(['1', '2.3', '3.0'])).to eq([1, 2.3, 3.0])
  end

  it "fails to convert `['1','2.3',false]` to numeric array in strict mode" do
    expect {
      converter.call(['1', '2.3', false], strict: true)
    }.to raise_error(Necromancer::ConversionTypeError)
  end

  it "converts `['1','2.3',false]` to numeric array in non-strict mode" do
    expect(converter.call(['1', '2.3', false], strict: false)).to eq([1, 2.3, false])
  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_numeric_spec.rb
pokedex-terminal-0.2.7 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/array/array_to_numeric_spec.rb
pokedex-terminal-0.2.6 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/array/array_to_numeric_spec.rb
pokedex-terminal-0.2.5 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/array/array_to_numeric_spec.rb
pokedex-terminal-0.2.4 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/array/array_to_numeric_spec.rb
necromancer-0.5.1 spec/unit/converters/array/array_to_numeric_spec.rb
necromancer-0.5.0 spec/unit/converters/array/array_to_numeric_spec.rb