Skip to content

Commit

Permalink
Merge pull request #293 from hugobarauna/remove-have-n-items-matchers
Browse files Browse the repository at this point in the history
Remove have(n).items matchers
  • Loading branch information
myronmarston committed Aug 17, 2013
2 parents ef49f11 + 8f39d44 commit 4ccacb8
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 760 deletions.
109 changes: 0 additions & 109 deletions features/built_in_matchers/have.feature

This file was deleted.

57 changes: 0 additions & 57 deletions lib/rspec/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,63 +413,6 @@ def exist(*args)
BuiltIn::Exist.new(*args)
end

# Passes if receiver is a collection with the submitted number of items OR
# if the receiver OWNS a collection with the submitted number of items.
#
# If the receiver OWNS the collection, you must use the name of the
# collection. So if a `Team` instance has a collection named `#players`,
# you must use that name to set the expectation.
#
# If the receiver IS the collection, you can use any name you like for
# `named_collection`. We'd recommend using either "elements", "members", or
# "items" as these are all standard ways of describing the things IN a
# collection.
#
# This also works for Strings, letting you set expectations about their
# lengths.
#
# @example
#
# # Passes if team.players.size == 11
# expect(team).to have(11).players
#
# # Passes if [1,2,3].length == 3
# expect([1,2,3]).to have(3).items #"items" is pure sugar
#
# # Passes if ['a', 'b', 'c'].count == 3
# expect([1,2,3]).to have(3).items #"items" is pure sugar
#
# # Passes if "this string".length == 11
# expect("this string").to have(11).characters #"characters" is pure sugar
def have(n)
BuiltIn::Have.new(n)
end
alias :have_exactly :have

# Exactly like have() with >=.
#
# @example
# expect("this").to have_at_least(3).letters
#
# ### Warning:
#
# `expect(..).not_to have_at_least` is not supported
def have_at_least(n)
BuiltIn::Have.new(n, :at_least)
end

# Exactly like have() with <=.
#
# @example
# expect("this").to have_at_most(4).letters
#
# ### Warning:
#
# `expect(..).not_to have_at_most` is not supported
def have_at_most(n)
BuiltIn::Have.new(n, :at_most)
end

# Passes if actual includes expected. This works for
# collections and Strings. You can also pass in multiple args
# and it will only pass if all args are found in collection.
Expand Down
124 changes: 0 additions & 124 deletions lib/rspec/matchers/built_in/have.rb

This file was deleted.

15 changes: 0 additions & 15 deletions spec/rspec/matchers/description_generation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,6 @@ def object.has_taste_for?(*args); true; end
expect(RSpec::Matchers.generated_description).to eq 'should have taste for "wine", "cheese"'
end

it "expect(...).to have n items" do
expect(team).to have(3).players
expect(RSpec::Matchers.generated_description).to eq "should have 3 players"
end

it "expect(...).to have at least n items" do
expect(team).to have_at_least(2).players
expect(RSpec::Matchers.generated_description).to eq "should have at least 2 players"
end

it "expect(...).to have at most n items" do
expect(team).to have_at_most(4).players
expect(RSpec::Matchers.generated_description).to eq "should have at most 4 players"
end

it "expect(...).to include(x)" do
expect([1,2,3]).to include(3)
expect(RSpec::Matchers.generated_description).to eq "should include 3"
Expand Down
Loading

0 comments on commit 4ccacb8

Please sign in to comment.