Sha256: 2a3d21b7e6bf4357fe0b7d782a4351cc8fcd9cb43f0a7daf289438d67209deb5

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe AffairsOfState::Config do
  subject{ AffairsOfState::Config.new }

  describe "accessors" do
    let(:expected){ double }

    it "has :column" do
      subject.column = expected
      expect(subject.column).to eq(expected)
    end

    it "has :allow_blank" do
      subject.allow_blank = expected
      expect(subject.allow_blank).to eq(expected)
    end

    it "has :scopes" do
      subject.scopes = expected
      expect(subject.scopes).to eq(expected)
    end

    it "has :if" do
      subject.if = expected
      expect(subject.if).to eq(expected)
    end
  end

  describe "#statuses=" do
    it "converts to string" do
      subject.statuses = [:a, :b]
      expect(subject.statuses).to eq(["a", "b"])
    end

    it "flattens" do
      subject.statuses = ["a", [:b]]
      expect(subject.statuses).to eq(["a", "b"])
    end

    it "makes sure no invalid statuses are allowed" do
      expect(->{
        subject.statuses = [:new]
      }).to raise_error(ArgumentError, "Affairs of State: 'new' is not a valid status")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
affairs_of_state-0.6.0 spec/config_spec.rb
affairs_of_state-0.5.0 spec/config_spec.rb
affairs_of_state-0.4.1 spec/config_spec.rb