rspec-expectations 2.7.0 → 2.8.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/README.md +117 -9
  2. data/lib/rspec/expectations.rb +24 -16
  3. data/lib/rspec/expectations/handler.rb +1 -1
  4. data/lib/rspec/expectations/version.rb +1 -1
  5. data/lib/rspec/matchers.rb +91 -91
  6. data/lib/rspec/matchers/base_matcher.rb +41 -0
  7. data/lib/rspec/matchers/be.rb +31 -12
  8. data/lib/rspec/matchers/be_instance_of.rb +10 -12
  9. data/lib/rspec/matchers/be_kind_of.rb +10 -12
  10. data/lib/rspec/matchers/be_within.rb +36 -26
  11. data/lib/rspec/matchers/block_aliases.rb +2 -1
  12. data/lib/rspec/matchers/change.rb +1 -1
  13. data/lib/rspec/matchers/cover.rb +20 -19
  14. data/lib/rspec/matchers/eq.rb +22 -32
  15. data/lib/rspec/matchers/eql.rb +22 -28
  16. data/lib/rspec/matchers/equal.rb +37 -27
  17. data/lib/rspec/matchers/exist.rb +26 -18
  18. data/lib/rspec/matchers/have.rb +22 -28
  19. data/lib/rspec/matchers/include.rb +45 -37
  20. data/lib/rspec/matchers/match.rb +10 -10
  21. data/lib/rspec/matchers/match_array.rb +1 -7
  22. data/lib/rspec/matchers/matcher.rb +0 -8
  23. data/lib/rspec/matchers/operator_matcher.rb +0 -2
  24. data/lib/rspec/matchers/pretty.rb +25 -2
  25. data/lib/rspec/matchers/raise_error.rb +2 -16
  26. data/lib/rspec/matchers/respond_to.rb +1 -6
  27. data/lib/rspec/matchers/satisfy.rb +1 -6
  28. data/lib/rspec/matchers/throw_symbol.rb +2 -11
  29. data/spec/rspec/expectations/handler_spec.rb +1 -1
  30. data/spec/rspec/matchers/change_spec.rb +1 -1
  31. data/spec/rspec/matchers/description_generation_spec.rb +2 -2
  32. data/spec/rspec/matchers/eq_spec.rb +1 -1
  33. data/spec/rspec/matchers/eql_spec.rb +2 -2
  34. data/spec/rspec/matchers/equal_spec.rb +1 -1
  35. data/spec/rspec/matchers/include_spec.rb +4 -0
  36. data/spec/rspec/matchers/raise_error_spec.rb +2 -2
  37. data/spec/spec_helper.rb +1 -0
  38. metadata +15 -10
@@ -1,6 +1,5 @@
1
1
  module RSpec
2
2
  module Matchers
3
-
4
3
  class RespondTo
5
4
  def initialize(*names)
6
5
  @names = names
@@ -69,14 +68,10 @@ module RSpec
69
68
  end
70
69
  end
71
70
 
72
- # :call-seq:
73
- # should respond_to(*names)
74
- # should_not respond_to(*names)
75
- #
76
71
  # Matches if the target object responds to all of the names
77
72
  # provided. Names can be Strings or Symbols.
78
73
  #
79
- # == Examples
74
+ # @example
80
75
  #
81
76
  def respond_to(*names)
82
77
  Matchers::RespondTo.new(*names)
@@ -1,6 +1,5 @@
1
1
  module RSpec
2
2
  module Matchers
3
-
4
3
  class Satisfy
5
4
  def initialize(&block)
6
5
  @block = block
@@ -25,10 +24,6 @@ module RSpec
25
24
  end
26
25
  end
27
26
 
28
- # :call-seq:
29
- # should satisfy {}
30
- # should_not satisfy {}
31
- #
32
27
  # Passes if the submitted block returns true. Yields target to the
33
28
  # block.
34
29
  #
@@ -39,7 +34,7 @@ module RSpec
39
34
  # If you do find yourself in such a situation, you could always write
40
35
  # a custom matcher, which would likely make your specs more expressive.
41
36
  #
42
- # == Examples
37
+ # @example
43
38
  #
44
39
  # 5.should satisfy { |n|
45
40
  # n > 3
@@ -1,6 +1,5 @@
1
1
  module RSpec
2
2
  module Matchers
3
-
4
3
  class ThrowSymbol
5
4
  def initialize(expected_symbol = nil, expected_arg=nil)
6
5
  @expected_symbol = expected_symbol
@@ -90,14 +89,6 @@ module RSpec
90
89
 
91
90
  end
92
91
 
93
- # :call-seq:
94
- # should throw_symbol()
95
- # should throw_symbol(:sym)
96
- # should throw_symbol(:sym, arg)
97
- # should_not throw_symbol()
98
- # should_not throw_symbol(:sym)
99
- # should_not throw_symbol(:sym, arg)
100
- #
101
92
  # Given no argument, matches if a proc throws any Symbol.
102
93
  #
103
94
  # Given a Symbol, matches if the given proc throws the specified Symbol.
@@ -105,7 +96,7 @@ module RSpec
105
96
  # Given a Symbol and an arg, matches if the given proc throws the
106
97
  # specified Symbol with the specified arg.
107
98
  #
108
- # == Examples
99
+ # @example
109
100
  #
110
101
  # lambda { do_something_risky }.should throw_symbol
111
102
  # lambda { do_something_risky }.should throw_symbol(:that_was_risky)
@@ -114,7 +105,7 @@ module RSpec
114
105
  # lambda { do_something_risky }.should_not throw_symbol
115
106
  # lambda { do_something_risky }.should_not throw_symbol(:that_was_risky)
116
107
  # lambda { do_something_risky }.should_not throw_symbol(:that_was_risky, culprit)
117
- def throw_symbol(expected_symbol = nil, expected_arg=nil)
108
+ def throw_symbol(expected_symbol=nil, expected_arg=nil)
118
109
  Matchers::ThrowSymbol.new(expected_symbol, expected_arg)
119
110
  end
120
111
  end
@@ -76,7 +76,7 @@ module RSpec
76
76
  :diffable? => true,
77
77
  :failure_message_for_should => "message",
78
78
  :matches? => false,
79
- :expected => [1],
79
+ :expected => 1,
80
80
  :actual => 2
81
81
  )
82
82
  actual = Object.new
@@ -113,7 +113,7 @@ describe "should change(actual, message)" do
113
113
  end
114
114
 
115
115
  def dup
116
- self.class.new *elements
116
+ self.class.new(*elements)
117
117
  end
118
118
 
119
119
  def ==(other)
@@ -7,12 +7,12 @@ describe "Matchers should be able to generate their own descriptions" do
7
7
 
8
8
  it "should eq expected" do
9
9
  "this".should eq "this"
10
- RSpec::Matchers.generated_description.should eq "should eq this"
10
+ RSpec::Matchers.generated_description.should eq "should eq \"this\""
11
11
  end
12
12
 
13
13
  it "should not eq expected" do
14
14
  "this".should_not eq "that"
15
- RSpec::Matchers.generated_description.should eq "should not eq that"
15
+ RSpec::Matchers.generated_description.should eq "should not eq \"that\""
16
16
  end
17
17
 
18
18
  it "should be empty (arbitrary predicate)" do
@@ -30,7 +30,7 @@ module RSpec
30
30
  it "provides message, expected and actual on #negative_failure_message" do
31
31
  matcher = eq(1)
32
32
  matcher.matches?(1)
33
- matcher.failure_message_for_should_not.should == "\nexpected 1 not to equal 1\n\n(compared using ==)\n"
33
+ matcher.failure_message_for_should_not.should == "\nexpected: value != 1\n got: 1\n\n(compared using ==)\n"
34
34
  end
35
35
  end
36
36
  end
@@ -24,13 +24,13 @@ module RSpec
24
24
  it "provides message, expected and actual on #failure_message" do
25
25
  matcher = eql("1")
26
26
  matcher.matches?(1)
27
- matcher.failure_message_for_should.should == "\nexpected \"1\"\n got 1\n\n(compared using eql?)\n"
27
+ matcher.failure_message_for_should.should == "\nexpected: \"1\"\n got: 1\n\n(compared using eql?)\n"
28
28
  end
29
29
 
30
30
  it "provides message, expected and actual on #negative_failure_message" do
31
31
  matcher = eql(1)
32
32
  matcher.matches?(1)
33
- matcher.failure_message_for_should_not.should == "\nexpected 1 not to equal 1\n\n(compared using eql?)\n"
33
+ matcher.failure_message_for_should_not.should == "\nexpected: value != 1\n got: 1\n\n(compared using eql?)\n"
34
34
  end
35
35
  end
36
36
  end
@@ -12,7 +12,7 @@ module RSpec
12
12
  end
13
13
 
14
14
  it "does not match when !actual.equal?(expected)" do
15
- 1.should_not equal("1")
15
+ "1".should_not equal("1")
16
16
  end
17
17
 
18
18
  it "describes itself" do
@@ -39,6 +39,10 @@ describe "should include(expected)" do
39
39
  end
40
40
 
41
41
  describe "should include(with, multiple, args)" do
42
+ it "has a description" do
43
+ matcher = include("a")
44
+ matcher.description.should eq("include \"a\"")
45
+ end
42
46
  context "for a string target" do
43
47
  it "passes if target includes all items" do
44
48
  "a string".should include("str", "a")
@@ -181,8 +181,8 @@ describe "should raise_error(NamedError, error_message) { |err| ... }" do
181
181
  }
182
182
  }.should fail_with(/expected: 4/m)
183
183
 
184
- ran.should be(true)
185
- passed.should be(false)
184
+ ran.should be_true
185
+ passed.should be_false
186
186
  end
187
187
 
188
188
  it "does NOT yield exception if no error was thrown" do
@@ -23,4 +23,5 @@ RSpec::configure do |config|
23
23
  config.color_enabled = true
24
24
  config.filter_run :focused => true
25
25
  config.run_all_when_everything_filtered = true
26
+ config.order = :random
26
27
  end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease:
4
+ hash: 15424215
5
+ prerelease: 6
6
6
  segments:
7
7
  - 2
8
- - 7
8
+ - 8
9
9
  - 0
10
- version: 2.7.0
10
+ - rc
11
+ - 1
12
+ version: 2.8.0.rc1
11
13
  platform: ruby
12
14
  authors:
13
15
  - David Chelimsky
@@ -16,7 +18,7 @@ autorequire:
16
18
  bindir: bin
17
19
  cert_chain: []
18
20
 
19
- date: 2011-10-16 00:00:00 Z
21
+ date: 2011-11-06 00:00:00 Z
20
22
  dependencies:
21
23
  - !ruby/object:Gem::Dependency
22
24
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -56,6 +58,7 @@ files:
56
58
  - lib/rspec/expectations/handler.rb
57
59
  - lib/rspec/expectations/version.rb
58
60
  - lib/rspec/matchers.rb
61
+ - lib/rspec/matchers/base_matcher.rb
59
62
  - lib/rspec/matchers/be.rb
60
63
  - lib/rspec/matchers/be_close.rb
61
64
  - lib/rspec/matchers/be_instance_of.rb
@@ -172,19 +175,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
175
  required_rubygems_version: !ruby/object:Gem::Requirement
173
176
  none: false
174
177
  requirements:
175
- - - ">="
178
+ - - ">"
176
179
  - !ruby/object:Gem::Version
177
- hash: 3
180
+ hash: 25
178
181
  segments:
179
- - 0
180
- version: "0"
182
+ - 1
183
+ - 3
184
+ - 1
185
+ version: 1.3.1
181
186
  requirements: []
182
187
 
183
188
  rubyforge_project: rspec
184
189
  rubygems_version: 1.8.11
185
190
  signing_key:
186
191
  specification_version: 3
187
- summary: rspec-expectations-2.7.0
192
+ summary: rspec-expectations-2.8.0.rc1
188
193
  test_files:
189
194
  - features/README.markdown
190
195
  - features/Upgrade.md