Sha256: cc5b87458fafffff3cc9d6e17d4bce2a7cd1b62f3c5156ec1c31d74fb4d112ea

Contents?: true

Size: 1.25 KB

Versions: 46

Compression:

Stored size: 1.25 KB

Contents

require "spec_helper"

include Liquidscript

describe ICR::Set do

  its(:metadata) { should be_a Hash }

  describe "#to_a" do
    specify { expect(subject.to_a).to be_an Array }
    specify { expect(subject.to_a).to have(1).item }

    context "with metadata" do
      subject do
        set = ICR::Set.new
        set.metadata.merge! :hello => "world"
        set
      end

      specify { expect(subject.to_a).to have(2).items }
      specify { expect(subject.to_a).to eq [:exec, [:_hello, "world"]] }

    end

    context "with codes" do
      subject do
        set = ICR::Set.new
        set << "test"
        set
      end

      specify { expect(subject.to_a).to have(2).item }
      specify { expect(subject.to_a).to eq [:exec, "test"] }

    end

    context "with both" do
      subject do
        set = ICR::Set.new
        set.metadata.merge! :hello => "world"
        set << "test"
        set
      end

      specify { expect(subject.to_a).to have(3).items }
      specify { expect(subject.to_a).to eq [:exec, [:_hello, "world"], "test"] }

    end
  end

  describe "#add" do
    it "adds a code to the set" do
      subject.add(:number, "32")

      expect(subject.to_a).to have(2).items
      expect(subject.to_a.last).to be_a ICR::Code
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
liquidscript-0.11.0.rc1 spec/liquidscript/icr/set_spec.rb
liquidscript-0.10.4 spec/liquidscript/icr/set_spec.rb
liquidscript-0.10.3 spec/liquidscript/icr/set_spec.rb
liquidscript-0.10.2 spec/liquidscript/icr/set_spec.rb
liquidscript-0.10.1 spec/liquidscript/icr/set_spec.rb
liquidscript-0.10.0 spec/liquidscript/icr/set_spec.rb
liquidscript-0.9.2 spec/liquidscript/icr/set_spec.rb
liquidscript-0.9.1 spec/liquidscript/icr/set_spec.rb
liquidscript-0.9.0 spec/liquidscript/icr/set_spec.rb
liquidscript-0.8.2 spec/liquidscript/icr/set_spec.rb
liquidscript-0.8.1 spec/liquidscript/icr/set_spec.rb
liquidscript-0.8.0 spec/liquidscript/icr/set_spec.rb
liquidscript-0.7.12 spec/liquidscript/icr/set_spec.rb
liquidscript-0.7.11 spec/liquidscript/icr/set_spec.rb
liquidscript-0.7.10 spec/liquidscript/icr/set_spec.rb
liquidscript-0.7.9 spec/liquidscript/icr/set_spec.rb
liquidscript-0.7.8 spec/liquidscript/icr/set_spec.rb
liquidscript-0.7.7 spec/liquidscript/icr/set_spec.rb
liquidscript-0.7.6 spec/liquidscript/icr/set_spec.rb
liquidscript-0.7.5 spec/liquidscript/icr/set_spec.rb