Sha256: b5ec13d0a7073bb5e9dd46ffe2552548d6ce893cf47989dc8de84f8423dbc38b

Contents?: true

Size: 1.84 KB

Versions: 16

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'
require 'natives/catalog/merger'

describe Natives::Catalog::Merger do

  describe "#merge_catalog!" do
    let(:merger) { Natives::Catalog::Merger.new }

    it "validates both master_hash and hash_to_merge" do
      master_hash = {}
      hash_to_merge = {"rubygems" => {}}
      validator = double("Natives::Catalog::Validator")
      merger = Natives::Catalog::Merger.new(validator: validator)

      validator.should_receive(:ensure_valid_catalog_groups).with(master_hash)
      validator.should_receive(:ensure_valid_catalog_groups).with(hash_to_merge)

      merger.merge_catalog!(master_hash, hash_to_merge)
    end

    it "returns master_hash" do
      master_hash = {}
      expect(merger.merge_catalog!(master_hash, {})).to equal(master_hash)
    end

    it "adds new catalog group into master_hash" do
      master_hash = {}
      hash_to_merge = {"rubygems" => {}}

      merger.merge_catalog!(master_hash, hash_to_merge)

      expect(master_hash).to include("rubygems" => {})
    end

    it "adds new entries into existing catalog group" do
      master_hash = {"rubygems" => { "curb" => {} }}
      hash_to_merge = {"rubygems" => { "nokogiri" => {} }}

      merger.merge_catalog!(master_hash, hash_to_merge)

      expect(master_hash).to include(
        "rubygems" => {"curb" => {}, "nokogiri" => {}})
    end

    it "replaces existing entries in existing catalog group" do
      master_hash = {"rubygems" => {
                         "webkit-capybara" => {},
                         "curb" => {} }}
      hash_to_merge = {"rubygems" => {
                         "curb" => {"foo" => "bar"}, "nokogiri" => {} }}

      merger.merge_catalog!(master_hash, hash_to_merge)

      expect(master_hash).to include(
        "rubygems" => {
          "webkit-capybara" => {},
          "curb" => {"foo" => "bar"}, "nokogiri" => {}})
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
natives-0.6.2 spec/natives/catalog/merger_spec.rb
natives-0.6.1 spec/natives/catalog/merger_spec.rb
natives-0.6.0 spec/natives/catalog/merger_spec.rb
natives-0.5.5 spec/natives/catalog/merger_spec.rb
natives-0.5.4 spec/natives/catalog/merger_spec.rb
natives-0.5.3 spec/natives/catalog/merger_spec.rb
natives-0.5.2 spec/natives/catalog/merger_spec.rb
natives-0.5.1 spec/natives/catalog/merger_spec.rb
natives-0.5.0 spec/natives/catalog/merger_spec.rb
natives-catalog-0.3.4 spec/natives/catalog/merger_spec.rb
natives-catalog-0.3.3 spec/natives/catalog/merger_spec.rb
natives-catalog-0.3.2 spec/natives/catalog/merger_spec.rb
natives-catalog-0.3.1 spec/natives/catalog/merger_spec.rb
natives-catalog-0.3.0 spec/natives/catalog/merger_spec.rb
natives-catalog-0.2.1 spec/natives/catalog/merger_spec.rb
natives-catalog-0.2.0 spec/natives/catalog/merger_spec.rb