Sha256: 73e1548e29674bcc98f923018f7319dad3980aa43ebb64605cd8ed8cda29eb54

Contents?: true

Size: 861 Bytes

Versions: 6

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal:true

RSpec.describe Strings::Padder, '#parse' do
  it "parses nil" do
    instance = Strings::Padder.parse(nil)
    expect(instance.padding).to eq([])
  end

  it 'parses self' do
    value = Strings::Padder.new([])
    instance = Strings::Padder.parse(value)
    expect(instance.padding).to eq([])
  end

  it "parses digit" do
    instance = Strings::Padder.parse(5)
    expect(instance.padding).to eq([5,5,5,5])
  end

  it "parses 2-element array" do
    instance = Strings::Padder.parse([2,3])
    expect(instance.padding).to eq([2,3,2,3])
  end

  it "parses 4-element array" do
    instance = Strings::Padder.parse([1,2,3,4])
    expect(instance.padding).to eq([1,2,3,4])
  end

  it "fails to parse unknown value" do
    expect {
      Strings::Padder.parse(:unknown)
    }.to raise_error(Strings::Padder::ParseError)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
strings-0.1.8 spec/unit/padder/parse_spec.rb
strings-0.1.7 spec/unit/padder/parse_spec.rb
strings-0.1.6 spec/unit/padder/parse_spec.rb
strings-0.1.5 spec/unit/padder/parse_spec.rb
strings-0.1.4 spec/unit/padder/parse_spec.rb
strings-0.1.3 spec/unit/padder/parse_spec.rb