Sha256: 06e414cef76b0864f9209ac30ebd7dbf0d231214650609eef693060590e14ff3

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

require "spec_helper"

describe Arrthorizer::Context do
  describe :merge do
    let(:base_hash) { { key: 'value' } }
    let(:base_context) { Arrthorizer::Context.new(base_hash) }
    let(:other_hash) { { other_key: 'other_value' } }
    let(:merged_hash) { base_hash.merge(other_hash) }

    shared_examples_for "the return value of Arrthorizer::Context#merge" do
      it "returns an Arrthorizer::Context" do
        expect(result).to be_an Arrthorizer::Context
      end

      describe "the returned Arrthorizer::Context" do
        it "contains the merged contents" do
          merged_hash.each_pair do |key, value|
            expect(result.send(key)).to eql value
          end
        end
      end
    end

    context "when another Arrthorizer::Context is provided" do
      let(:other_context) { Arrthorizer::Context.new(other_hash) }
      let(:result) { base_context.merge(other_context) }

      include_examples "the return value of Arrthorizer::Context#merge"
    end

    context "when a Hash is provided" do
      let(:result) { base_context.merge(other_hash) }

      include_examples "the return value of Arrthorizer::Context#merge"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
arrthorizer-0.4.2 spec/context/merge_spec.rb
arrthorizer-0.4.1 spec/context/merge_spec.rb
arrthorizer-0.3.2 spec/context/merge_spec.rb
arrthorizer-0.3.1 spec/context/merge_spec.rb
arrthorizer-0.3.0 spec/context/merge_spec.rb
arrthorizer-0.2.1 spec/context/merge_spec.rb
arrthorizer-0.2.0 spec/context/merge_spec.rb