rspec-expectations 2.0.0.beta.8 → 2.0.0.beta.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/README.markdown +1 -1
  2. data/Rakefile +8 -7
  3. data/Upgrade.markdown +6 -6
  4. data/VERSION +1 -1
  5. data/features/expectations/customized_message.feature +1 -1
  6. data/features/expectations/implicit_docstrings.feature +2 -2
  7. data/features/matchers/access_running_example.feature +5 -5
  8. data/features/matchers/define_diffable_matcher.feature +2 -2
  9. data/features/matchers/define_matcher.feature +14 -14
  10. data/features/matchers/define_matcher_outside_rspec.feature +2 -2
  11. data/features/matchers/define_matcher_with_fluent_interface.feature +2 -2
  12. data/features/matchers/expect_change.feature +2 -2
  13. data/features/matchers/expect_error.feature +2 -2
  14. data/lib/rspec/expectations.rb +7 -5
  15. data/lib/rspec/expectations/backward_compatibility.rb +16 -0
  16. data/lib/rspec/expectations/differ.rb +58 -0
  17. data/lib/rspec/expectations/errors.rb +1 -1
  18. data/lib/rspec/expectations/extensions/kernel.rb +4 -4
  19. data/lib/rspec/expectations/extensions/rspec/core/example_group.rb +1 -1
  20. data/lib/rspec/expectations/fail_with.rb +6 -4
  21. data/lib/rspec/expectations/handler.rb +11 -11
  22. data/lib/rspec/expectations/version.rb +1 -1
  23. data/lib/rspec/matchers.rb +7 -8
  24. data/lib/rspec/matchers/be.rb +6 -6
  25. data/lib/rspec/matchers/be_close.rb +1 -1
  26. data/lib/rspec/matchers/be_instance_of.rb +1 -1
  27. data/lib/rspec/matchers/be_kind_of.rb +1 -1
  28. data/lib/rspec/matchers/change.rb +1 -1
  29. data/lib/rspec/matchers/compatibility.rb +2 -2
  30. data/lib/rspec/matchers/dsl.rb +4 -4
  31. data/lib/rspec/matchers/eq.rb +1 -1
  32. data/lib/rspec/matchers/eql.rb +1 -1
  33. data/lib/rspec/matchers/equal.rb +1 -1
  34. data/lib/rspec/matchers/errors.rb +1 -1
  35. data/lib/rspec/matchers/exist.rb +1 -1
  36. data/lib/rspec/matchers/extensions/instance_exec.rb +1 -1
  37. data/lib/rspec/matchers/generated_descriptions.rb +1 -1
  38. data/lib/rspec/matchers/has.rb +1 -1
  39. data/lib/rspec/matchers/have.rb +1 -1
  40. data/lib/rspec/matchers/include.rb +1 -1
  41. data/lib/rspec/matchers/match.rb +1 -1
  42. data/lib/rspec/matchers/match_array.rb +3 -3
  43. data/lib/rspec/matchers/matcher.rb +13 -13
  44. data/lib/rspec/matchers/method_missing.rb +1 -1
  45. data/lib/rspec/matchers/operator_matcher.rb +4 -4
  46. data/lib/rspec/matchers/pretty.rb +1 -1
  47. data/lib/rspec/matchers/raise_error.rb +1 -1
  48. data/lib/rspec/matchers/respond_to.rb +1 -1
  49. data/lib/rspec/matchers/satisfy.rb +1 -1
  50. data/lib/rspec/matchers/throw_symbol.rb +1 -1
  51. data/rspec-expectations.gemspec +17 -14
  52. data/spec/rspec/expectations/{differs/default_spec.rb → differ_spec.rb} +4 -36
  53. data/spec/rspec/expectations/fail_with_spec.rb +6 -50
  54. data/spec/rspec/expectations/handler_spec.rb +22 -22
  55. data/spec/rspec/matchers/be_close_spec.rb +1 -1
  56. data/spec/rspec/matchers/be_instance_of_spec.rb +1 -1
  57. data/spec/rspec/matchers/be_kind_of_spec.rb +1 -1
  58. data/spec/rspec/matchers/change_spec.rb +3 -3
  59. data/spec/rspec/matchers/compatibility_spec.rb +3 -3
  60. data/spec/rspec/matchers/description_generation_spec.rb +28 -28
  61. data/spec/rspec/matchers/dsl_spec.rb +3 -3
  62. data/spec/rspec/matchers/eq_spec.rb +1 -1
  63. data/spec/rspec/matchers/eql_spec.rb +1 -1
  64. data/spec/rspec/matchers/equal_spec.rb +1 -1
  65. data/spec/rspec/matchers/exist_spec.rb +1 -1
  66. data/spec/rspec/matchers/have_spec.rb +3 -3
  67. data/spec/rspec/matchers/match_array_spec.rb +3 -0
  68. data/spec/rspec/matchers/matcher_spec.rb +25 -25
  69. data/spec/rspec/matchers/operator_matcher_spec.rb +12 -12
  70. data/spec/rspec/matchers/throw_symbol_spec.rb +1 -1
  71. data/spec/spec_helper.rb +6 -7
  72. data/spec/support/classes.rb +1 -1
  73. metadata +35 -21
  74. data/lib/rspec/expectations/differs/default.rb +0 -62
  75. data/lib/rspec/expectations/differs/load-diff-lcs.rb +0 -7
@@ -15,7 +15,7 @@ describe "should ==" do
15
15
 
16
16
  it "should fail when target.==(actual) returns false" do
17
17
  subject = "apple"
18
- Rspec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ==)], "orange", "apple")
18
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ==)], "orange", "apple")
19
19
  subject.should == "orange"
20
20
  end
21
21
 
@@ -36,7 +36,7 @@ describe "should_not ==" do
36
36
 
37
37
  it "should fail when target.==(actual) returns false" do
38
38
  subject = "apple"
39
- Rspec::Expectations.should_receive(:fail_with).with(%[expected not: == "apple",\n got: "apple"], "apple", "apple")
39
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected not: == "apple",\n got: "apple"], "apple", "apple")
40
40
  subject.should_not == "apple"
41
41
  end
42
42
 
@@ -53,7 +53,7 @@ describe "should ===" do
53
53
  it "should fail when target.===(actual) returns false" do
54
54
  subject = "apple"
55
55
  subject.should_receive(:===).with("orange").and_return(false)
56
- Rspec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ===)], "orange", "apple")
56
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ===)], "orange", "apple")
57
57
  subject.should === "orange"
58
58
  end
59
59
 
@@ -70,7 +70,7 @@ describe "should_not ===" do
70
70
  it "should fail when target.===(actual) returns false" do
71
71
  subject = "apple"
72
72
  subject.should_receive(:===).with("apple").and_return(true)
73
- Rspec::Expectations.should_receive(:fail_with).with(%[expected not: === "apple",\n got: "apple"], "apple", "apple")
73
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected not: === "apple",\n got: "apple"], "apple", "apple")
74
74
  subject.should_not === "apple"
75
75
  end
76
76
 
@@ -87,7 +87,7 @@ describe "should =~" do
87
87
  it "should fail when target.=~(actual) returns false" do
88
88
  subject = "fu"
89
89
  subject.should_receive(:=~).with(/oo/).and_return(false)
90
- Rspec::Expectations.should_receive(:fail_with).with(%[expected: /oo/,\n got: "fu" (using =~)], /oo/, "fu")
90
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected: /oo/,\n got: "fu" (using =~)], /oo/, "fu")
91
91
  subject.should =~ /oo/
92
92
  end
93
93
 
@@ -104,7 +104,7 @@ describe "should_not =~" do
104
104
  it "should fail when target.=~(actual) returns false" do
105
105
  subject = "foo"
106
106
  subject.should_receive(:=~).with(/oo/).and_return(true)
107
- Rspec::Expectations.should_receive(:fail_with).with(%[expected not: =~ /oo/,\n got: "foo"], /oo/, "foo")
107
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected not: =~ /oo/,\n got: "foo"], /oo/, "foo")
108
108
  subject.should_not =~ /oo/
109
109
  end
110
110
 
@@ -117,7 +117,7 @@ describe "should >" do
117
117
  end
118
118
 
119
119
  it "should fail if > fails" do
120
- Rspec::Expectations.should_receive(:fail_with).with(%[expected: > 5,\n got: 4], 5, 4)
120
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected: > 5,\n got: 4], 5, 4)
121
121
  4.should > 5
122
122
  end
123
123
 
@@ -131,7 +131,7 @@ describe "should >=" do
131
131
  end
132
132
 
133
133
  it "should fail if > fails" do
134
- Rspec::Expectations.should_receive(:fail_with).with(%[expected: >= 5,\n got: 4], 5, 4)
134
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected: >= 5,\n got: 4], 5, 4)
135
135
  4.should >= 5
136
136
  end
137
137
 
@@ -144,7 +144,7 @@ describe "should <" do
144
144
  end
145
145
 
146
146
  it "should fail if > fails" do
147
- Rspec::Expectations.should_receive(:fail_with).with(%[expected: < 3,\n got: 4], 3, 4)
147
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected: < 3,\n got: 4], 3, 4)
148
148
  4.should < 3
149
149
  end
150
150
 
@@ -158,13 +158,13 @@ describe "should <=" do
158
158
  end
159
159
 
160
160
  it "should fail if > fails" do
161
- Rspec::Expectations.should_receive(:fail_with).with(%[expected: <= 3,\n got: 4], 3, 4)
161
+ RSpec::Expectations.should_receive(:fail_with).with(%[expected: <= 3,\n got: 4], 3, 4)
162
162
  4.should <= 3
163
163
  end
164
164
 
165
165
  end
166
166
 
167
- describe Rspec::Matchers::PositiveOperatorMatcher do
167
+ describe RSpec::Matchers::PositiveOperatorMatcher do
168
168
 
169
169
  it "should work when the target has implemented #send" do
170
170
  o = Object.new
@@ -176,7 +176,7 @@ describe Rspec::Matchers::PositiveOperatorMatcher do
176
176
 
177
177
  end
178
178
 
179
- describe Rspec::Matchers::NegativeOperatorMatcher do
179
+ describe RSpec::Matchers::NegativeOperatorMatcher do
180
180
 
181
181
  it "should work when the target has implemented #send" do
182
182
  o = Object.new
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Rspec
3
+ module RSpec
4
4
  module Matchers
5
5
  describe ThrowSymbol do
6
6
  describe "with no args" do
@@ -13,7 +13,6 @@ add_to_load_path("../../rspec-mocks/lib")
13
13
 
14
14
  require 'rspec/core'
15
15
  require 'rspec/mocks'
16
- require 'rspec/expectations/differs/default'
17
16
 
18
17
  Dir['./spec/support/**/*'].each do |f|
19
18
  require f
@@ -23,7 +22,7 @@ def with_ruby(version)
23
22
  yield if RUBY_PLATFORM =~ Regexp.compile("^#{version}")
24
23
  end
25
24
 
26
- module Rspec
25
+ module RSpec
27
26
  module Ruby
28
27
  class << self
29
28
  def version
@@ -33,20 +32,20 @@ module Rspec
33
32
  end
34
33
  end
35
34
 
36
- module Rspec
35
+ module RSpec
37
36
  module Matchers
38
37
  def fail
39
- raise_error(Rspec::Expectations::ExpectationNotMetError)
38
+ raise_error(RSpec::Expectations::ExpectationNotMetError)
40
39
  end
41
40
 
42
41
  def fail_with(message)
43
- raise_error(Rspec::Expectations::ExpectationNotMetError, message)
42
+ raise_error(RSpec::Expectations::ExpectationNotMetError, message)
44
43
  end
45
44
  end
46
45
  end
47
46
 
48
- Rspec::configure do |config|
47
+ RSpec::configure do |config|
49
48
  config.mock_with(:rspec)
50
- config.include Rspec::Mocks::Methods
49
+ config.include RSpec::Mocks::Methods
51
50
  config.color_enabled = true
52
51
  end
@@ -1,5 +1,5 @@
1
1
  # This file contains various classes used by the specs.
2
- module Rspec
2
+ module RSpec
3
3
  module Expectations
4
4
  module Helper
5
5
  class CollectionWithSizeMethod
metadata CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
7
7
  - 0
8
8
  - 0
9
9
  - beta
10
- - 8
11
- version: 2.0.0.beta.8
10
+ - 9
11
+ version: 2.0.0.beta.9
12
12
  platform: ruby
13
13
  authors:
14
14
  - David Chelimsky
@@ -17,13 +17,27 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-04-27 00:00:00 -05:00
20
+ date: 2010-05-27 00:00:00 -05:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- name: cucumber
24
+ name: diff-lcs
25
25
  prerelease: false
26
26
  requirement: &id001 !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ segments:
31
+ - 1
32
+ - 1
33
+ - 2
34
+ version: 1.1.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: cucumber
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
27
41
  requirements:
28
42
  - - ">="
29
43
  - !ruby/object:Gem::Version
@@ -33,11 +47,11 @@ dependencies:
33
47
  - 2
34
48
  version: 0.6.2
35
49
  type: :development
36
- version_requirements: *id001
50
+ version_requirements: *id002
37
51
  - !ruby/object:Gem::Dependency
38
52
  name: aruba
39
53
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
54
+ requirement: &id003 !ruby/object:Gem::Requirement
41
55
  requirements:
42
56
  - - ">="
43
57
  - !ruby/object:Gem::Version
@@ -47,11 +61,11 @@ dependencies:
47
61
  - 1
48
62
  version: 0.1.1
49
63
  type: :development
50
- version_requirements: *id002
64
+ version_requirements: *id003
51
65
  - !ruby/object:Gem::Dependency
52
66
  name: rspec-core
53
67
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
68
+ requirement: &id004 !ruby/object:Gem::Requirement
55
69
  requirements:
56
70
  - - ">="
57
71
  - !ruby/object:Gem::Version
@@ -60,14 +74,14 @@ dependencies:
60
74
  - 0
61
75
  - 0
62
76
  - beta
63
- - 8
64
- version: 2.0.0.beta.8
77
+ - 9
78
+ version: 2.0.0.beta.9
65
79
  type: :development
66
- version_requirements: *id003
80
+ version_requirements: *id004
67
81
  - !ruby/object:Gem::Dependency
68
82
  name: rspec-mocks
69
83
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
84
+ requirement: &id005 !ruby/object:Gem::Requirement
71
85
  requirements:
72
86
  - - ">="
73
87
  - !ruby/object:Gem::Version
@@ -76,10 +90,10 @@ dependencies:
76
90
  - 0
77
91
  - 0
78
92
  - beta
79
- - 8
80
- version: 2.0.0.beta.8
93
+ - 9
94
+ version: 2.0.0.beta.9
81
95
  type: :development
82
- version_requirements: *id004
96
+ version_requirements: *id005
83
97
  description: rspec expectations (should[_not] and matchers)
84
98
  email: dchelimsky@gmail.com;chad.humphries@gmail.com
85
99
  executables: []
@@ -108,8 +122,8 @@ files:
108
122
  - features/matchers/expect_error.feature
109
123
  - features/support/env.rb
110
124
  - lib/rspec/expectations.rb
111
- - lib/rspec/expectations/differs/default.rb
112
- - lib/rspec/expectations/differs/load-diff-lcs.rb
125
+ - lib/rspec/expectations/backward_compatibility.rb
126
+ - lib/rspec/expectations/differ.rb
113
127
  - lib/rspec/expectations/errors.rb
114
128
  - lib/rspec/expectations/extensions.rb
115
129
  - lib/rspec/expectations/extensions/kernel.rb
@@ -146,7 +160,7 @@ files:
146
160
  - lib/rspec/matchers/satisfy.rb
147
161
  - lib/rspec/matchers/throw_symbol.rb
148
162
  - rspec-expectations.gemspec
149
- - spec/rspec/expectations/differs/default_spec.rb
163
+ - spec/rspec/expectations/differ_spec.rb
150
164
  - spec/rspec/expectations/extensions/kernel_spec.rb
151
165
  - spec/rspec/expectations/fail_with_spec.rb
152
166
  - spec/rspec/expectations/handler_spec.rb
@@ -185,7 +199,7 @@ licenses: []
185
199
  post_install_message: |
186
200
  **************************************************
187
201
 
188
- Thank you for installing rspec-expectations-2.0.0.beta.8
202
+ Thank you for installing rspec-expectations-2.0.0.beta.9
189
203
 
190
204
  This is beta software. If you are looking
191
205
  for a supported production release, please
@@ -219,9 +233,9 @@ rubyforge_project: rspec
219
233
  rubygems_version: 1.3.6
220
234
  signing_key:
221
235
  specification_version: 3
222
- summary: rspec-expectations-2.0.0.beta.8
236
+ summary: rspec-expectations-2.0.0.beta.9
223
237
  test_files:
224
- - spec/rspec/expectations/differs/default_spec.rb
238
+ - spec/rspec/expectations/differ_spec.rb
225
239
  - spec/rspec/expectations/extensions/kernel_spec.rb
226
240
  - spec/rspec/expectations/fail_with_spec.rb
227
241
  - spec/rspec/expectations/handler_spec.rb
@@ -1,62 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "/load-diff-lcs")
2
- require 'pp'
3
-
4
- module Rspec
5
- module Expectations
6
- module Differs
7
- unless defined?(Default)
8
- class Default
9
- def initialize(options)
10
- @options = options
11
- end
12
-
13
- # This is snagged from diff/lcs/ldiff.rb (which is a commandline tool)
14
- def diff_as_string(data_new, data_old)
15
- data_old = data_old.split(/\n/).map! { |e| e.chomp }
16
- data_new = data_new.split(/\n/).map! { |e| e.chomp }
17
- output = ""
18
- diffs = Diff::LCS.diff(data_old, data_new)
19
- return output if diffs.empty?
20
- oldhunk = hunk = nil
21
- file_length_difference = 0
22
- diffs.each do |piece|
23
- begin
24
- hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, context_lines,
25
- file_length_difference)
26
- file_length_difference = hunk.file_length_difference
27
- next unless oldhunk
28
- # Hunks may overlap, which is why we need to be careful when our
29
- # diff includes lines of context. Otherwise, we might print
30
- # redundant lines.
31
- if (context_lines > 0) and hunk.overlaps?(oldhunk)
32
- hunk.unshift(oldhunk)
33
- else
34
- output << oldhunk.diff(format)
35
- end
36
- ensure
37
- oldhunk = hunk
38
- output << "\n"
39
- end
40
- end
41
- #Handle the last remaining hunk
42
- output << oldhunk.diff(format) << "\n"
43
- end
44
-
45
- def diff_as_object(target,expected)
46
- diff_as_string(PP.pp(target,""), PP.pp(expected,""))
47
- end
48
-
49
- protected
50
- def format
51
- @options.diff_format
52
- end
53
-
54
- def context_lines
55
- @options.context_lines
56
- end
57
- end
58
-
59
- end
60
- end
61
- end
62
- end
@@ -1,7 +0,0 @@
1
- begin
2
- require 'diff/lcs'
3
- rescue LoadError
4
- raise "You must gem install diff-lcs to use diffing"
5
- end
6
-
7
- require 'diff/lcs/hunk'