Sha256: f18080e3167e49d1c68febecd56f73d7f4439c0ea5b9b01761c3cdcfbc0b085d

Contents?: true

Size: 1.72 KB

Versions: 24

Compression:

Stored size: 1.72 KB

Contents

require "spec_helper"

describe Timber::CurrentContext, :rails_23 => true do
  describe ".add" do
    after(:each) do
      described_class.reset
    end

    it "should add the context" do
      expect(described_class.hash).to eq({})

      described_class.add({build: {version: "1.0.0"}})
      expect(described_class.hash).to eq({:custom=>{:build=>{:version=>"1.0.0"}}})

      described_class.add({testing: {key: "value"}})
      expect(described_class.hash).to eq({:custom=>{:build=>{:version=>"1.0.0"}, :testing=>{:key=>"value"}}})
    end
  end

  describe ".remove" do
    it "should remove the context by object" do
      context = {:build=>{:version=>"1.0.0"}}
      described_class.add(context)
      expect(described_class.hash).to eq({:custom => context})

      described_class.remove(context)
      expect(described_class.hash).to eq({})
    end

    it "should remove context by key" do
      context = {:build=>{:version=>"1.0.0"}}
      described_class.add(context)
      expect(described_class.hash).to eq({:custom => context})

      described_class.remove(:custom)
      expect(described_class.hash).to eq({})
    end
  end

  describe ".with" do
    it "should merge the context and cleanup on block exit" do
      expect(described_class.hash).to eq({})

      described_class.with({build: {version: "1.0.0"}}) do
        expect(described_class.hash).to eq({:custom=>{:build=>{:version=>"1.0.0"}}})

        described_class.with({testing: {key: "value"}}) do
          expect(described_class.hash).to eq({:custom=>{:build=>{:version=>"1.0.0"}, :testing=>{:key=>"value"}}})
        end

        expect(described_class.hash).to eq({:custom=>{:build=>{:version=>"1.0.0"}}})
      end

      expect(described_class.hash).to eq({})
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
timber-2.0.24 spec/timber/current_context_spec.rb
timber-2.0.23 spec/timber/current_context_spec.rb
timber-2.0.22 spec/timber/current_context_spec.rb
timber-2.0.21 spec/timber/current_context_spec.rb
timber-2.0.20 spec/timber/current_context_spec.rb
timber-2.0.19 spec/timber/current_context_spec.rb
timber-2.0.17 spec/timber/current_context_spec.rb
timber-2.0.16 spec/timber/current_context_spec.rb
timber-2.0.15 spec/timber/current_context_spec.rb
timber-2.0.14 spec/timber/current_context_spec.rb
timber-2.0.12 spec/timber/current_context_spec.rb
timber-2.0.11 spec/timber/current_context_spec.rb
timber-2.0.10 spec/timber/current_context_spec.rb
timber-2.0.9 spec/timber/current_context_spec.rb
timber-2.0.8 spec/timber/current_context_spec.rb
timber-2.0.7 spec/timber/current_context_spec.rb
timber-2.0.6 spec/timber/current_context_spec.rb
timber-2.0.5 spec/timber/current_context_spec.rb
timber-2.0.4 spec/timber/current_context_spec.rb
timber-2.0.3 spec/timber/current_context_spec.rb