From 0ef2bd57c30f1ffc282e4878ac8957c0903bb43d Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Fri, 3 Jan 2014 23:01:18 +0100 Subject: [PATCH] Define custom predicate method to test description generation --- .../rspec/matchers/description_generation_spec.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spec/rspec/matchers/description_generation_spec.rb b/spec/rspec/matchers/description_generation_spec.rb index 928ad0921..e1ed9a823 100644 --- a/spec/rspec/matchers/description_generation_spec.rb +++ b/spec/rspec/matchers/description_generation_spec.rb @@ -45,11 +45,22 @@ expect(RSpec::Matchers.generated_description).to eq "should be > 3" end - it "expect(...).to be predicate arg1, arg2 and arg3" do - expect(5.0).to be_between(0,10) + it "expect(...).to be between min and max" do + expect(10).to be_between(0, 10) expect(RSpec::Matchers.generated_description).to eq "should be between 0 and 10" end + it "expect(...).to be predicate arg1, arg2 and arg3" do + class Parent; end + class Child < Parent + def child_of?(*parents) + parents.all? { |parent| self.is_a?(parent) } + end + end + expect(Child.new).to be_a_child_of(Parent, Object) + expect(RSpec::Matchers.generated_description).to eq "should be a child of Parent and Object" + end + it "expect(...).to equal" do expected = "expected" expect(expected).to equal(expected)