Sha256: 4a36c541f0c4e6cbc1137ae64b32525ae6ac4374ac34f9472b30aa2f27ad76d4

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

# encoding: utf-8

describe Assertion::Inverter do

  let(:source) do
    IsMan = Assertion.about(:age, :gender) { age.to_i >= 18 && gender == :male }
  end

  subject(:inverter) { described_class.new source }

  it "implements DSL::Caller" do
    expect(inverter).to be_kind_of Assertion::DSL::Caller
  end

  describe ".new" do

    it { is_expected.to be_frozen }

  end # describe .new

  describe ".source" do

    subject { inverter.source           }
    it      { is_expected.to eql source }

  end # describe .source

  describe "#new" do

    let(:assertion) { inversion.assertion }

    context "with attributes" do

      subject(:inversion) { inverter.new age: 17, gender: :male }

      it "returns an inversion" do
        expect(inversion).to be_kind_of Assertion::Inversion
        expect(assertion.attributes).to eql(age: 17, gender: :male)
      end

    end # context

    context "without attributes" do

      subject(:inversion) { inverter.new }

      it "returns an inversion" do
        expect(inversion).to be_kind_of Assertion::Inversion
        expect(assertion.attributes).to eql(age: nil, gender: nil)
      end

    end # context

  end # describe #new

  after { Object.send :remove_const, :IsMan }

end # describe Assertion::Inverter

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
assertion-0.2.5 spec/unit/assertion/inverter_spec.rb
assertion-0.2.4 spec/unit/assertion/inverter_spec.rb
assertion-0.2.3 spec/unit/assertion/inverter_spec.rb
assertion-0.2.2 spec/unit/assertion/inverter_spec.rb
assertion-0.2.1 spec/unit/assertion/inverter_spec.rb