Sha256: 17fcd1a05f19dfe6f0c2152fb142f6fd5498645a5d3c566e7e6560508be52f39

Contents?: true

Size: 870 Bytes

Versions: 9

Compression:

Stored size: 870 Bytes

Contents

RSpec.describe Evil::Client::Policy do
  it "subsclasses Tram::Policy" do
    expect(described_class.superclass).to eq Tram::Policy
  end

  it "takes a parameter (settings) to validate" do
    expect(described_class[double]).to be_valid
  end

  it "delegates instance methods to settings" do
    settings = double :settings, foo: :BAR
    policy   = described_class[settings]
    expect(policy.foo).to eq :BAR
  end

  describe ".for" do
    let(:settings) { class_double Evil::Client::Settings, to_s: "Foo" }
    subject { described_class.for settings }

    it "builds a subclass of its own" do
      expect(subject.superclass).to eq described_class
    end

    it "keeps reference to the settings" do
      expect(subject.model).to eq settings
    end

    it "takes the name from settings class" do
      expect(subject.name).to eq "Foo.policy"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
evil-client-3.2.0 spec/unit/policy_spec.rb
evil-client-3.1.0 spec/unit/policy_spec.rb
evil-client-3.0.4 spec/unit/policy_spec.rb
evil-client-3.0.3 spec/unit/policy_spec.rb
evil-client-3.0.2 spec/unit/policy_spec.rb
evil-client-3.0.1 spec/unit/policy_spec.rb
evil-client-3.0.0 spec/unit/policy_spec.rb
evil-client-2.1.1 spec/unit/policy_spec.rb
evil-client-2.1.0 spec/unit/policy_spec.rb