Sha256: 988d8522a082de68c0de5684b8686d87a1a835590a6ac36d91bbe5d5c1e9d71e

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

# encoding: utf-8

describe Assertion do

  describe ".about" do

    let(:john) { { age: 17, gender: :male } }
    let(:jack) { { age: 18, gender: :male } }

    context "with attributes and a block" do

      subject do
        Man = Assertion.about(:age, :gender) { age >= 18 && gender == :male }
      end

      it "provides the assertion class" do
        expect(subject.superclass).to eql Assertion::Base
      end

      it "implements the #check method" do
        expect(subject[john]).to be_invalid
        expect(subject[jack]).to be_valid
      end

    end # context

    context "without attributes" do

      subject do
        Man = Assertion.about { true }
      end

      it "provides the assertion class" do
        expect(subject.superclass).to eql Assertion::Base
      end

      it "implements the #check method" do
        expect(subject[john]).to be_valid
        expect(subject[jack]).to be_valid
      end

    end # context

    context "without a block" do

      subject do
        Man = Assertion.about(:age, :gender)
      end

      it "provides the assertion class" do
        expect(subject.superclass).to eql Assertion::Base
      end

      it "doesn't implement the #check method" do
        expect { subject[jack] }
          .to raise_error Assertion::NotImplementedError
      end

    end # context

    after { Object.send :remove_const, :Man }

  end # describe .about

end # describe Assertion

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
assertion-0.0.1 spec/unit/assertion_spec.rb