Sha256: b45256c1213fa0e3b7649b432cb6e1d844d3a7815d0053f527e4b78da201bbe5

Contents?: true

Size: 816 Bytes

Versions: 7

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Necromancer::RangeConverters::StringToRangeConverter, '.call' do

  subject(:converter) { described_class.new }

  it "raises error for empty string in strict mode" do
    expect {
      converter.call('', strict: true)
    }.to raise_error(Necromancer::ConversionTypeError)
  end

  it "returns value in non-strict mode" do
    expect(converter.call('', strict: false)).to eq('')
  end

  {
    '1'     => 1..1,
    '1..10' => 1..10,
    '1-10'  => 1..10,
    '1,10'  => 1..10,
    '1...10' => 1...10,
    '-1..10' => -1..10,
    '1..-10' => 1..-10,
    'a..z' => 'a'..'z',
    'a-z' => 'a'..'z',
    'A-Z' => 'A'..'Z'
  }.each do |actual, expected|
    it "converts '#{actual}' to range type" do
      expect(converter.call(actual)).to eql(expected)
    end
  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/range/string_to_range_spec.rb
pokedex-terminal-0.2.7 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/range/string_to_range_spec.rb
pokedex-terminal-0.2.6 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/range/string_to_range_spec.rb
pokedex-terminal-0.2.5 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/range/string_to_range_spec.rb
pokedex-terminal-0.2.4 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/range/string_to_range_spec.rb
necromancer-0.5.1 spec/unit/converters/range/string_to_range_spec.rb
necromancer-0.5.0 spec/unit/converters/range/string_to_range_spec.rb