Sha256: 8508ab64fa8644de6363dc48143b54d974bb259ac1e584dc8dee20a8e4a1bccf

Contents?: true

Size: 721 Bytes

Versions: 9

Compression:

Stored size: 721 Bytes

Contents

require 'spec_helper'
require 'command_mapper/types/enum'

describe CommandMapper::Types::Enum do
  let(:values) { [:foo, 42, :bar] }

  subject { described_class.new(values) }

  describe "#initialize" do
    it "must set #values" do
      expect(subject.values).to eq(values)
    end

    it "must populate #map with the values and their String forms" do
      expect(subject.map).to eq(
        Hash[values.map { |value|
          [value, value.to_s]
        }]
      )
    end
  end

  describe ".[]" do
    subject { described_class[*values] }

    it "must create a new Enum with the given values" do
      expect(subject).to be_kind_of(described_class)
      expect(subject.values).to eq(values)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
command_mapper-0.3.2 spec/types/enum_spec.rb
command_mapper-0.3.1 spec/types/enum_spec.rb
command_mapper-0.3.0 spec/types/enum_spec.rb
command_mapper-0.2.1 spec/types/enum_spec.rb
command_mapper-0.2.0 spec/types/enum_spec.rb
command_mapper-0.1.2 spec/types/enum_spec.rb
command_mapper-0.1.1 spec/types/enum_spec.rb
command_mapper-0.1.0 spec/types/enum_spec.rb
command_mapper-0.1.0.pre1 spec/types/enum_spec.rb