Sha256: de541b0710df3d7268fdf818ae8b83896748be9114c5905c0940933dd3b1a5c0

Contents?: true

Size: 724 Bytes

Versions: 7

Compression:

Stored size: 724 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Necromancer::DateTimeConverters::StringToDateConverter, '.call' do

  subject(:converter) { described_class.new(:string, :date) }

  it "converts '1-1-2015' to date value" do
    expect(converter.call('1-1-2015')).to eq(Date.parse('2015/01/01'))
  end

  it "converts '2014/12/07' to date value" do
    expect(converter.call('2014/12/07')).to eq(Date.parse('2014/12/07'))
  end

  it "converts '2014-12-07' to date value" do
    expect(converter.call('2014-12-07')).to eq(Date.parse('2014/12/07'))
  end

  it "fails to convert in strict mode" do
    expect {
      converter.call('2014 - 12 - 07', strict: true)
    }.to raise_error(Necromancer::ConversionTypeError)
  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/date_time/string_to_date_spec.rb
pokedex-terminal-0.2.7 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/date_time/string_to_date_spec.rb
pokedex-terminal-0.2.6 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/date_time/string_to_date_spec.rb
pokedex-terminal-0.2.5 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/date_time/string_to_date_spec.rb
pokedex-terminal-0.2.4 vendor/bundle/ruby/2.7.0/gems/necromancer-0.5.1/spec/unit/converters/date_time/string_to_date_spec.rb
necromancer-0.5.1 spec/unit/converters/date_time/string_to_date_spec.rb
necromancer-0.5.0 spec/unit/converters/date_time/string_to_date_spec.rb