spec/unit/assertion/base_spec.rb in assertion-0.0.1 vs spec/unit/assertion/base_spec.rb in assertion-0.1.0
- old
+ new
@@ -3,74 +3,18 @@
describe Assertion::Base do
let(:klass) { Class.new(described_class) }
before { allow(klass).to receive(:name) { "Test" } }
- describe ".attributes" do
+ it "can declare attributes" do
+ expect(klass).to be_kind_of Assertion::Attributes
+ end
- subject(:attributes) { klass.attributes }
+ it "can translate states" do
+ expect(klass).to include Assertion::Messages
+ end
- it { is_expected.to eql [] }
-
- end # describe .attributes
-
- describe ".attribute" do
-
- subject(:attribute) { klass.attribute names }
-
- context "with valid name" do
-
- let(:names) { :foo }
-
- it "defines the attribute" do
- expect { subject }
- .to change { klass.attributes }
- .to [:foo]
- end
-
- end # context
-
- context "with array of names" do
-
- let(:names) { [:foo, "bar", "foo"] }
-
- it "defines the attribute" do
- expect { subject }
- .to change { klass.attributes }
- .to [:foo, :bar]
- end
-
- end # context
-
- context "with a :check name" do
-
- let(:names) { [:check] }
-
- it "fails" do
- expect { subject }.to raise_error do |error|
- expect(error).to be_kind_of Assertion::NameError
- expect(error.message).to include "check"
- end
- end
-
- end # context
-
- context "with a :call name" do
-
- let(:names) { [:call] }
-
- it "fails" do
- expect { subject }.to raise_error do |error|
- expect(error).to be_kind_of Assertion::NameError
- expect(error.message).to include "call"
- end
- end
-
- end # context
-
- end # describe .attribute
-
describe ".new" do
let(:klass) { Class.new(described_class) { attribute :foo, :bar } }
context "with attributes" do
@@ -136,50 +80,9 @@
subject { assertion.attributes }
it { is_expected.to eql attrs }
end # describe #attributes
-
- describe "#message" do
-
- let(:assertion) { klass.new }
-
- context "for the truthy state" do
-
- subject { assertion.message(true) }
- it { is_expected.to eql "translation missing: en.assertion.test.right" }
-
- end # context
-
- context "for the falsey state" do
-
- subject { assertion.message(false) }
- it { is_expected.to eql "translation missing: en.assertion.test.wrong" }
-
- end # context
-
- context "by default" do
-
- it "returns the message for the falsey state" do
- expect(assertion.message).to eql assertion.message(false)
- end
-
- end # context
-
- end # describe #message
-
- describe "#check" do
-
- subject { klass.new.check }
-
- it "raises NotImplementedError" do
- expect { subject }.to raise_error do |error|
- expect(error).to be_kind_of Assertion::NotImplementedError
- expect(error.message).to include("Test#check ")
- end
- end
-
- end # describe #check
describe "#call" do
subject { assertion.call }