Sha256: 05e321eb76b5266e7a6bc87ebdbb71959371a60a39d07eae1bda387444c34699

Contents?: true

Size: 837 Bytes

Versions: 2

Compression:

Stored size: 837 Bytes

Contents

require 'spec_helper'
require 'parameters/types/array'
require 'parameters/types/integer'

describe Parameters::Types::Array do
  let(:array) { [1, 2, 3] }

  subject { described_class }

  describe "coerce" do
    it "should call #to_a" do
      subject.coerce(array.enum_for).should == array
    end
  end

  context "instance" do
    let(:numbers) { %w[1 2 3] }

    subject { described_class.new(Parameters::Types::Integer.new) }

    it "should have a Ruby type" do
      subject.to_ruby.should == Array[Integer]
    end

    describe "#===" do
      it "should check the type of each element" do
        subject.should_not === numbers

        subject.should === array
      end
    end

    describe "#coerce" do
      it "should coerce each element" do
        subject.coerce(numbers).should == array
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parameters-0.3.1 spec/types/array_spec.rb
parameters-0.3.0 spec/types/array_spec.rb