Skip to content

Commit

Permalink
Define custom predicate method to test description generation
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jan 4, 2014
1 parent 596dc0a commit 0ef2bd5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions spec/rspec/matchers/description_generation_spec.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 0ef2bd5

Please sign in to comment.