spec/unit/assertion/base_spec.rb in assertion-0.2.3 vs spec/unit/assertion/base_spec.rb in assertion-0.2.4

- old
+ new

@@ -17,11 +17,11 @@ expect(klass).to be_kind_of Assertion::DSL::Inversion end describe ".new" do - let(:klass) { Class.new(described_class) { attribute :foo, :bar } } + let(:klass) { Class.new(described_class) { attribute :foo, "bar" } } context "with attributes" do subject { klass.new foo: :FOO, bar: :BAR, baz: :BAZ } @@ -65,11 +65,12 @@ end subject end it "returns a translation" do - expect(subject).to eql translator.call(options[:as], attributes) + msg = options[:as] ? :truthy : :falsey + expect(subject).to eql translator.call(msg, attributes) end end # shared examples it_behaves_like "translating", as: true do @@ -81,9 +82,21 @@ end it_behaves_like "translating", as: false do subject { assertion.message } end + + context "when #truthy and #falsey defined" do + + before { klass.send(:define_method, :truthy) { "foo" } } + before { klass.send(:define_method, :falsey) { "bar" } } + + it "uses defined method" do + expect(assertion.message(true)).to eql "foo" + expect(assertion.message(false)).to eql "bar" + end + + end # context end # describe #message describe "#call" do