Sha256: 9bc4f426765b1f18fc9547777f84143b1a899eef5a4b2a93af86726fee75a2d0

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

require 'rails_helper'

RSpec.describe Journaled do
  it "is enabled in production" do
    allow(Rails).to receive(:env).and_return("production")
    expect(described_class).to be_enabled
  end

  it "is disabled in development" do
    allow(Rails).to receive(:env).and_return("development")
    expect(described_class).not_to be_enabled
  end

  it "is disabled in test" do
    allow(Rails).to receive(:env).and_return("test")
    expect(described_class).not_to be_enabled
  end

  it "is enabled in whatevs" do
    allow(Rails).to receive(:env).and_return("whatevs")
    expect(described_class).to be_enabled
  end

  it "is enabled when explicitly enabled in development" do
    with_env(JOURNALED_ENABLED: true) do
      allow(Rails).to receive(:env).and_return("development")
      expect(described_class).to be_enabled
    end
  end

  it "is disabled when explicitly disabled in production" do
    with_env(JOURNALED_ENABLED: false) do
      allow(Rails).to receive(:env).and_return("production")
      expect(described_class).not_to be_enabled
    end
  end

  it "is disabled when explicitly disabled with empty string" do
    with_env(JOURNALED_ENABLED: '') do
      allow(Rails).to receive(:env).and_return("production")
      expect(described_class).not_to be_enabled
    end
  end

  describe "#actor_uri" do
    it "delegates to ActorUriProvider" do
      allow(Journaled::ActorUriProvider).to receive(:instance)
        .and_return(instance_double(Journaled::ActorUriProvider, actor_uri: "my actor uri"))
      expect(described_class.actor_uri).to eq "my actor uri"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
journaled-2.5.0 spec/lib/journaled_spec.rb
journaled-2.4.0 spec/lib/journaled_spec.rb
journaled-2.3.1 spec/lib/journaled_spec.rb
journaled-2.3.0 spec/lib/journaled_spec.rb
journaled-2.2.0 spec/lib/journaled_spec.rb