rr 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +3 -43
  3. data/CHANGES.md +46 -0
  4. data/CREDITS.md +5 -0
  5. data/Gemfile +3 -12
  6. data/README.md +25 -24
  7. data/Rakefile +16 -38
  8. data/doc/02_syntax_comparison.md +1 -0
  9. data/lib/rr/core_ext/array.rb +2 -0
  10. data/lib/rr/core_ext/hash.rb +2 -0
  11. data/lib/rr/deprecations.rb +97 -0
  12. data/lib/rr/double_definitions/double_injections/any_instance_of.rb +1 -1
  13. data/lib/rr/double_definitions/double_injections/instance.rb +2 -2
  14. data/lib/rr/dsl.rb +152 -0
  15. data/lib/rr/injections/method_missing_injection.rb +6 -2
  16. data/lib/rr/integrations/minitest_4.rb +1 -1
  17. data/lib/rr/integrations/minitest_4_active_support.rb +1 -1
  18. data/lib/rr/integrations/rspec/invocation_matcher.rb +0 -8
  19. data/lib/rr/integrations/rspec_2.rb +20 -2
  20. data/lib/rr/recorded_call.rb +29 -0
  21. data/lib/rr/recorded_calls.rb +8 -4
  22. data/lib/rr/space.rb +1 -1
  23. data/lib/rr/spy_verification.rb +13 -5
  24. data/lib/rr/version.rb +1 -1
  25. data/lib/rr/wildcard_matchers.rb +10 -10
  26. data/lib/rr/without_autohook.rb +5 -13
  27. data/rr.gemspec +3 -3
  28. data/spec/defines_spec_suite_tasks.rb +12 -0
  29. data/spec/global_helper.rb +5 -0
  30. data/spec/spec_suite_configuration.rb +1 -7
  31. data/spec/suites.yml +1 -1
  32. data/spec/suites/rspec_2/functional/any_instance_of_spec.rb +133 -33
  33. data/spec/suites/rspec_2/functional/dont_allow_spec.rb +13 -8
  34. data/spec/suites/rspec_2/functional/mock_bang_spec.rb +20 -0
  35. data/spec/suites/rspec_2/functional/mock_instance_of_spec.rb +14 -0
  36. data/spec/suites/rspec_2/functional/mock_instance_of_strong_spec.rb +15 -0
  37. data/spec/suites/rspec_2/functional/mock_proxy_instance_of_spec.rb +15 -0
  38. data/spec/suites/rspec_2/functional/mock_proxy_spec.rb +14 -0
  39. data/spec/suites/rspec_2/functional/mock_spec.rb +8 -232
  40. data/spec/suites/rspec_2/functional/mock_strong_spec.rb +14 -0
  41. data/spec/suites/rspec_2/functional/received_spec.rb +16 -0
  42. data/spec/suites/rspec_2/functional/spy_spec.rb +89 -28
  43. data/spec/suites/rspec_2/functional/stub_bang_spec.rb +20 -0
  44. data/spec/suites/rspec_2/functional/stub_instance_of_spec.rb +15 -0
  45. data/spec/suites/rspec_2/functional/stub_instance_of_strong_spec.rb +15 -0
  46. data/spec/suites/rspec_2/functional/stub_proxy_instance_of_spec.rb +16 -0
  47. data/spec/suites/rspec_2/functional/stub_proxy_spec.rb +45 -0
  48. data/spec/suites/rspec_2/functional/stub_spec.rb +42 -161
  49. data/spec/suites/rspec_2/functional/stub_strong_spec.rb +15 -0
  50. data/spec/suites/rspec_2/helper.rb +2 -2
  51. data/spec/suites/rspec_2/support/mixins/double_definition_creator_helpers.rb +173 -0
  52. data/spec/suites/rspec_2/support/mixins/mock_definition_creator_helpers.rb +45 -0
  53. data/spec/suites/rspec_2/support/mixins/proxy_definition_creator_helpers.rb +33 -0
  54. data/spec/suites/rspec_2/support/mixins/stub_creator_helpers.rb +43 -0
  55. data/spec/suites/rspec_2/support/mixins/stub_definition_creator_helpers.rb +45 -0
  56. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_with_never_called_qualifier.rb +39 -0
  57. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_with_times_called_qualifier.rb +50 -0
  58. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/argument_expectations_without_qualifiers.rb +131 -0
  59. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/dont_allow.rb +148 -0
  60. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_instance_of.rb +26 -0
  61. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_instance_of_strong.rb +28 -0
  62. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_proxy.rb +11 -0
  63. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mock_strong.rb +37 -0
  64. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/mocking.rb +107 -0
  65. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_instance_of.rb +32 -0
  66. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_instance_of_strong.rb +39 -0
  67. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_proxy.rb +11 -0
  68. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stub_strong.rb +37 -0
  69. data/spec/suites/rspec_2/support/shared_contexts/double_definition_creators/stubbing.rb +57 -0
  70. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/array_flatten_bug.rb +35 -0
  71. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/block_form.rb +31 -0
  72. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/comparing_arity.rb +63 -0
  73. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/object_is_proxy.rb +43 -0
  74. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/sequential_invocations.rb +26 -0
  75. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/setting_implementation.rb +51 -0
  76. data/spec/suites/rspec_2/support/shared_examples/double_definition_creators/yields.rb +81 -0
  77. data/spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb +0 -28
  78. data/spec/suites/rspec_2/unit/deprecations_spec.rb +27 -0
  79. data/spec/suites/rspec_2/unit/dsl/double_creators_spec.rb +133 -0
  80. data/spec/suites/rspec_2/unit/dsl/space_spec.rb +99 -0
  81. data/spec/suites/rspec_2/unit/dsl/wildcard_matchers_spec.rb +67 -0
  82. data/spec/suites/rspec_2/unit/integrations/rspec_spec.rb +4 -19
  83. data/spec/suites/rspec_2/unit/space_spec.rb +5 -3
  84. data/spec/suites/rspec_2/unit/spy_verification_spec.rb +1 -1
  85. data/spec/support/adapter.rb +1 -1
  86. data/spec/support/adapter_tests/rspec.rb +19 -15
  87. data/spec/support/project/generator.rb +0 -4
  88. metadata +55 -48
  89. data/gemfiles/ruby_18_rspec_1.gemfile +0 -14
  90. data/gemfiles/ruby_18_rspec_1.gemfile.lock +0 -38
  91. data/gemfiles/ruby_18_rspec_1_rails_2.gemfile +0 -18
  92. data/gemfiles/ruby_18_rspec_1_rails_2.gemfile.lock +0 -64
  93. data/gemfiles/ruby_19_rspec_2_rails_3.gemfile +0 -15
  94. data/gemfiles/ruby_19_rspec_2_rails_3.gemfile.lock +0 -123
  95. data/lib/rr/adapters.rb +0 -34
  96. data/lib/rr/adapters/rr_methods.rb +0 -142
  97. data/lib/rr/integrations/rspec_1.rb +0 -46
  98. data/lib/rr/integrations/test_unit_1.rb +0 -63
  99. data/lib/rr/integrations/test_unit_2.rb +0 -17
  100. data/lib/rr/integrations/test_unit_200.rb +0 -27
  101. data/lib/rr/integrations/test_unit_200_active_support.rb +0 -25
  102. data/lib/rr/integrations/test_unit_2_active_support.rb +0 -38
  103. data/spec/suites/rspec_1/helper.rb +0 -24
  104. data/spec/suites/rspec_1/integration/rspec_1_spec.rb +0 -93
  105. data/spec/suites/rspec_1/integration/test_unit_1_spec.rb +0 -102
  106. data/spec/suites/rspec_1/integration/test_unit_2_spec.rb +0 -109
  107. data/spec/suites/rspec_1/spec_helper.rb +0 -3
  108. data/spec/suites/rspec_1_rails_2/integration/astc_rails_2_spec.rb +0 -141
  109. data/spec/suites/rspec_1_rails_2/integration/rspec_1_rails_2_spec.rb +0 -132
  110. data/spec/suites/rspec_1_rails_2/integration/test_unit_1_rails_2_spec.rb +0 -141
  111. data/spec/suites/rspec_1_rails_2/integration/test_unit_2_rails_2_spec.rb +0 -148
  112. data/spec/suites/rspec_1_rails_2/spec_helper.rb +0 -3
  113. data/spec/suites/rspec_2/functional/dsl_spec.rb +0 -13
  114. data/spec/suites/rspec_2/functional/instance_of_spec.rb +0 -14
  115. data/spec/suites/rspec_2/functional/proxy_spec.rb +0 -136
  116. data/spec/suites/rspec_2/functional/strong_spec.rb +0 -79
  117. data/spec/suites/rspec_2/integration/test_unit_200_spec.rb +0 -102
  118. data/spec/suites/rspec_2/integration/test_unit_2_spec.rb +0 -109
  119. data/spec/suites/rspec_2/unit/adapters/rr_methods/double_creators_spec.rb +0 -135
  120. data/spec/suites/rspec_2/unit/adapters/rr_methods/space_spec.rb +0 -101
  121. data/spec/suites/rspec_2/unit/adapters/rr_methods/wildcard_matchers_spec.rb +0 -69
  122. data/spec/suites/rspec_2_rails_3/integration/astc_rails_3_spec.rb +0 -141
  123. data/spec/suites/rspec_2_rails_3/integration/minitest_4_rails_3_spec.rb +0 -148
  124. data/spec/suites/rspec_2_rails_3/integration/rspec_2_rails_3_spec.rb +0 -172
  125. data/spec/suites/rspec_2_rails_3/integration/test_unit_200_rails_3_spec.rb +0 -141
  126. data/spec/suites/rspec_2_rails_3/integration/test_unit_2_rails_3_spec.rb +0 -148
  127. data/spec/suites/rspec_2_rails_3/spec_helper.rb +0 -3
  128. data/spec/suites/rspec_2_rails_4/integration/test_unit_200_rails_4_spec.rb +0 -142
  129. data/spec/suites/rspec_2_rails_4/integration/test_unit_2_rails_4_spec.rb +0 -149
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b16f1f300c83ac27387ef72db6fc1514b27a1e9
4
- data.tar.gz: 7c082dad820121cb7c9c44cb0f0f1400085b4442
3
+ metadata.gz: 2135e46b66d09100c220437bb40f2989ccff6afc
4
+ data.tar.gz: 6307d6b090c14938825eaa4c5c474ba97788c770
5
5
  SHA512:
6
- metadata.gz: ab2c7e8209606ee44e8cd7ae29eaee652090dc4cfd81d802475fd84c73058cc3e0de9ad36915a8c39111ecc5c0565c6145f886b248610ff078f70d896c88f012
7
- data.tar.gz: 46d2b0399555904b5d6b2d81bc7875cc204fe1875f90e6b8069e75970eaac4a7129ebc45b79b7c45d3388664f94c81d635ea4b5abf1bf04fbe9963fbe92cec13
6
+ metadata.gz: ba91e27957d4ba1876e17f0a21480265b088234e3b5ad05638d33e2591bb8fe1df1373849c89c420d0a47f61a3f1091a117326ec91acd94c51de16b82e5b2fd3
7
+ data.tar.gz: d63946c4a0a43c25484d11b430831e306535e83600fc026834a02cc535417fa9b9ac2d5fb46ae61ed2b093e5930417c3f04d818b275bcc432f403d9d55271691
data/Appraisals CHANGED
@@ -1,46 +1,6 @@
1
- ruby_18_stuff = proc do
2
- ruby_18_rails_2 = proc do
3
- gem 'rails', '~> 2.3'
4
- gem 'mocha', '~> 0.12.0'
5
- gem 'sqlite3', '~> 1.3', :platforms => :ruby
6
- gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
7
- end
8
-
9
- #---
10
-
11
- appraise 'ruby_18_rspec_1' do
12
- end
13
-
14
- appraise 'ruby_18_rspec_1_rails_2' do
15
- instance_eval &ruby_18_rails_2
16
- end
17
- end
18
-
19
- ruby_19_stuff = proc do
20
- ruby_19_rails_3 = proc do
21
- gem 'rails', '~> 3.0'
22
- end
23
-
24
- ruby_19_rails_4 = proc do
25
- gem 'rails', '4.0.0'
26
- end
27
-
28
- #---
29
-
30
- appraise 'ruby_19_rspec_2' do
31
- end
32
-
33
- appraise 'ruby_19_rspec_2_rails_3' do
34
- instance_eval &ruby_19_rails_3
35
- end
36
-
37
- appraise 'ruby_19_rspec_2_rails_4' do
38
- instance_eval &ruby_19_rails_4
39
- end
1
+ appraise 'ruby_19_rspec_2' do
40
2
  end
41
3
 
42
- if RUBY_VERSION =~ /^1\.8/
43
- instance_eval &ruby_18_stuff
44
- else
45
- instance_eval &ruby_19_stuff
4
+ appraise 'ruby_19_rspec_2_rails_4' do
5
+ gem 'rails', '4.0.0'
46
6
  end
data/CHANGES.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0 - 2016-05-30
4
+
5
+ ### Improvements
6
+
7
+ * Renamed RR::Adapters::RRMethods to RR::DSL.
8
+
9
+ * Deprecated RRMethods.
10
+
11
+ * Updated document. [GitHub#57][Patch by Nikolay Shebanov]
12
+
13
+ * Dropped Ruby 1.8 support.
14
+
15
+ * Dropped Ruby 1.9 support.
16
+
17
+ * Dropped Rails 3 support.
18
+
19
+ * Dropped test-unit integration support. Use
20
+ [test-unit-rr](https://test-unit.github.io/#test-unit-rr).
21
+
22
+ * Supported OpenStruct in Ruby 2.3
23
+ [GitHub#64][Reported by soylent][Reported by Arthur Le Maitre]
24
+
25
+ ### Fixes
26
+
27
+ * Fixed using RSpec's RR adapter to not override our RSpec adapter.
28
+ If RR is required and then you use `mock_with :rr` you would not be able to
29
+ use `have_received`.
30
+
31
+ * Fixed a bug that `Hash` argument is too wild.
32
+ [GitHub#54][Reported by Yutaka HARA]
33
+
34
+ * Fixed a bug that `Array` argument is too wild.
35
+ [GitHub#54][Reported by Skye Shaw]
36
+
37
+ ### Thanks
38
+
39
+ * Nikolay Shebanov
40
+
41
+ * Yutaka HARA
42
+
43
+ * Skye Shaw
44
+
45
+ * soylent
46
+
47
+ * Arthur Le Maitre
48
+
3
49
  ## 1.1.2 (August 17, 2013)
4
50
 
5
51
  * Add tests, appraisals, etc. back to the published gem ([#32][i32]).
data/CREDITS.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Credits
2
2
 
3
+ ## Maintainer
4
+
5
+ * Kouhei Sutou ([@kou](https://github.com/kou))
6
+
7
+
3
8
  ## Authors
4
9
 
5
10
  * Brian Takita ([@btakita](http://github.com/btakita))
data/Gemfile CHANGED
@@ -1,19 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake', '~> 10.0'
4
- gem 'aws-sdk', '~> 1.0'
5
- gem 'minitar', '~> 0.5'
6
- gem 'dotenv', '~> 0.7'
7
4
  gem 'simplecov', '~> 0.7'
8
5
  gem 'appraisal', '~> 0.5'
9
6
  gem 'posix-spawn', :platforms => :mri
10
7
  gem 'open4', :platforms => :mri
11
-
12
- # Put this here instead of in Appraisals so that when running a single test file
13
- # in development we can say `rspec ...` or `spec ...` instead of having to
14
- # prepend it with BUNDLE_GEMFILE=...
15
- if RUBY_VERSION =~ /^1\.8/
16
- gem 'rspec', '~> 1.3'
17
- else
18
- gem 'rspec', '~> 2.14'
19
- end
8
+ gem 'test-unit'
9
+ gem 'test-unit-rr'
10
+ gem 'rspec', '~> 2.14'
data/README.md CHANGED
@@ -3,6 +3,15 @@
3
3
  RR is a test double framework for Ruby that features a rich selection of double
4
4
  techniques and a terse syntax.
5
5
 
6
+ ---
7
+
8
+ ## Learning more
9
+
10
+ 1. [A whirlwind tour of RR](#a-whirlwind-tour-of-rr)
11
+ 2. [What is a test double?](doc/01_test_double.md)
12
+ 3. [Syntax between RR and other double/mock frameworks](doc/02_syntax_comparison.md)
13
+ 4. [API overview - Full listing of DSL methods](doc/03_api_overview.md)
14
+
6
15
 
7
16
  ## A whirlwind tour of RR
8
17
 
@@ -87,6 +96,11 @@ end
87
96
 
88
97
  ## Installing RR into your project
89
98
 
99
+ NOTE: If you want to use RR with
100
+ [test-unit](https://test-unit.github.io/), use
101
+ [test-unit-rr](https://test-unit.github.io/#test-unit-rr). You don't
102
+ need to read the following subsections.
103
+
90
104
  For minimal setup, RR looks for an existing test framework and then hooks itself
91
105
  into it. Hence, RR works best when loaded *after* the test framework that you
92
106
  are using is loaded.
@@ -129,39 +143,25 @@ require 'your/test/framework' # if you are using something other than MiniTest
129
143
  require 'rr'
130
144
  ~~~
131
145
 
132
-
133
- ## Learning more
134
-
135
- 1. [What is a test double?](doc/01_test_double.md)
136
- 2. [Syntax between RR and other double/mock frameworks](doc/02_syntax_comparison.md)
137
- 3. [API overview](doc/03_api_overview.md)
138
-
139
-
140
146
  ## Compatibility
141
147
 
142
148
  RR is designed and tested to work against the following Ruby versions:
143
149
 
144
- * 1.8.7-p374
145
- * 1.9.3-p392
146
- * 2.0.0-p195
150
+ * 2.1
151
+ * 2.2
152
+ * 2.3
147
153
  * JRuby 1.7.4
148
154
 
149
155
  as well as the following test frameworks:
150
156
 
151
- * RSpec 1 (Ruby 1.8.7)
152
- * RSpec 2 (Ruby 1.9+)
153
- * Test::Unit 1 (Ruby 1.8.7)
154
- * Test::Unit 2.4.x (Ruby 1.8.7)
155
- * Test::Unit 2.0.0 (Ruby 1.9+)
156
- * Test::Unit 2.5.x (Ruby 1.9+)
157
- * MiniTest 4 (Ruby 1.9+)
158
- * Minitest 5 (Ruby 1.9+)
157
+ * RSpec 2
158
+ * Test::Unit via [test-unit-rr](https://test-unit.github.io/#test-unit-rr)
159
+ * MiniTest 4
160
+ * Minitest 5
159
161
 
160
162
  and the following Rails versions:
161
163
 
162
- * Rails 2.3.x (Ruby 1.8.7)
163
- * Rails 3.2.x (Ruby 1.9+)
164
- * Rails 4.0.x (Ruby 1.9+)
164
+ * Rails 4
165
165
 
166
166
 
167
167
  ## Help!
@@ -205,8 +205,9 @@ To run all the suites, simply say:
205
205
 
206
206
  ## Author/Contact
207
207
 
208
- RR was originally written by Brian Takita. It is currently maintained by Elliot
209
- Winkler (<elliot.winkler@gmail.com>).
208
+ RR was originally written by Brian Takita. And it was maintained by
209
+ Elliot Winkler (<elliot.winkler@gmail.com>). It is currently
210
+ maintained by Kouhei Sutou (<kou@cozmixng.org>).
210
211
 
211
212
 
212
213
  ## Credits
data/Rakefile CHANGED
@@ -4,52 +4,30 @@ require 'rake'
4
4
 
5
5
  require 'pp'
6
6
 
7
- # appraisal
8
- require 'appraisal'
9
-
10
7
  # build, install, release
11
8
  require 'bundler/gem_tasks'
12
9
 
13
- # appraisals
14
- Appraisal::File.each do |appraisal|
15
- desc "Resolve and install dependencies for the #{appraisal.name} appraisal"
16
- task "appraisal:#{appraisal.name}:install" do
17
- appraisal.install
10
+ begin
11
+ # appraisal
12
+ require 'appraisal'
13
+
14
+ # appraisals
15
+ Appraisal::File.each do |appraisal|
16
+ desc "Resolve and install dependencies for the #{appraisal.name} appraisal"
17
+ task "appraisal:#{appraisal.name}:install" do
18
+ appraisal.install
19
+ end
18
20
  end
21
+ rescue LoadError
19
22
  end
20
23
 
21
24
  # spec
22
25
  require File.expand_path('../spec/defines_spec_suite_tasks', __FILE__)
23
26
  DefinesSpecSuiteTasks.call
24
- task :default => ['appraisal:install', :spec]
25
-
26
- task :package_tests do
27
- require File.expand_path('../lib/rr/version', __FILE__)
28
- require 'aws/s3'
29
- require 'archive/tar/minitar'
30
- require 'dotenv'
31
-
32
- Dotenv.load
33
- AWS.config(
34
- :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
35
- :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
36
- )
37
27
 
38
- file_path = File.join(Dir.tmpdir, "rr-#{RR.version}-tests.tar")
39
- File.open(file_path, 'wb') do |fh|
40
- Zlib::GzipWriter.open(fh) do |zfh|
41
- Archive::Tar::Minitar.pack('spec', zfh)
42
- end
43
- end
44
- puts "Wrote to #{file_path}."
45
-
46
- remote_file_path = "v#{RR.version}.tar.gz"
47
- bucket_name = 'rubygem-rr/tests'
48
- puts "Uploading #{file_path} to s3.amazonaws.com/#{bucket_name}/#{remote_file_path} ..."
49
- s3 = AWS::S3.new
50
- bucket = s3.buckets[bucket_name]
51
- object = bucket.objects[remote_file_path]
52
- File.open(file_path, 'rb') {|f| object.write(f) }
53
- object.acl = :public_read
28
+ desc "Run tests"
29
+ task :test do
30
+ ruby("test/run-test.rb")
54
31
  end
55
- task :release => :package_tests
32
+
33
+ task :default => ['appraisal:install', :spec, :test]
@@ -94,3 +94,4 @@ my_object.should_receive(:hello).with('bob', 'jane').and_return('Hello Bob and J
94
94
  # RR
95
95
  mock(my_object).hello('bob', 'jane') { 'Hello Bob and Jane' }
96
96
  mock(my_object).hello('bob', 'jane').returns('Hello Bob and Jane') # same thing, just more verbose
97
+ ~~~
@@ -1,6 +1,8 @@
1
1
  class Array
2
2
  def wildcard_match?(other)
3
3
  return false unless other.is_a?(Array)
4
+ return false unless size == other.size
5
+
4
6
  each_with_index do |value, i|
5
7
  if value.respond_to?(:wildcard_match?)
6
8
  return false unless value.wildcard_match?(other[i])
@@ -3,6 +3,8 @@ class Hash
3
3
  return false unless other.is_a?(Hash)
4
4
 
5
5
  other_keys = other.keys
6
+ return false if keys.size != other_keys.size
7
+
6
8
  other_values = other.values
7
9
  each_with_index do |(key, value), i|
8
10
  if key.respond_to?(:wildcard_match?)
@@ -0,0 +1,97 @@
1
+ module RR
2
+ module Adapters
3
+ # People who manually include RR into their test framework will use
4
+ # these constants
5
+
6
+ module MiniTest
7
+ def self.included(base)
8
+ RR::Deprecations.show_warning_for_deprecated_adapter
9
+ RR.autohook
10
+ end
11
+ end
12
+
13
+ module TestUnit
14
+ def self.included(base)
15
+ RR::Deprecations.show_warning_for_deprecated_adapter
16
+ RR.autohook
17
+ end
18
+ end
19
+
20
+ module RSpec2
21
+ def self.included(base)
22
+ RR::Deprecations.show_warning_for_deprecated_adapter
23
+ RR.autohook
24
+ end
25
+ end
26
+
27
+ module Rspec
28
+ def self.const_missing(name)
29
+ if name == :InvocationMatcher
30
+ # Old versions of the RSpec-2 adapter for RR floating out in the wild
31
+ # still refer to this constant
32
+ RR::Deprecations.constant_deprecated_in_favor_of(
33
+ 'RR::Adapters::Rspec::InvocationMatcher',
34
+ 'RR::Integrations::RSpec::InvocationMatcher'
35
+ )
36
+ RR::Integrations::RSpec::InvocationMatcher
37
+ else
38
+ super
39
+ end
40
+ end
41
+ end
42
+
43
+ module RRMethods
44
+ include RR::DSL
45
+
46
+ def self.included(base)
47
+ # This was once here but is now deprecated
48
+ RR::Deprecations.constant_deprecated_in_favor_of(
49
+ 'RR::Adapters::RRMethods',
50
+ 'RR::DSL'
51
+ )
52
+ end
53
+ end
54
+ end
55
+
56
+ # This is here because RSpec-2's RR adapters uses it
57
+ module Extensions
58
+ def self.const_missing(name)
59
+ if name == :InstanceMethods
60
+ RR.autohook
61
+ RR::Integrations::RSpec2::Mixin
62
+ else
63
+ super
64
+ end
65
+ end
66
+ end
67
+
68
+ module Deprecations
69
+ def self.show_warning(msg, options = {})
70
+ start_backtrace_at_frame = options.fetch(:start_backtrace_at_frame, 2)
71
+ backtrace = caller(start_backtrace_at_frame)
72
+
73
+ lines = []
74
+ lines << ('-' * 80)
75
+ lines << 'Warning from RR:'
76
+ lines.concat msg.split(/\n/).map {|l| " #{l}" }
77
+ lines << ""
78
+ lines << "Called from:"
79
+ lines.concat backtrace[0..2].map {|l| " - #{l}" }
80
+ lines << ('-' * 80)
81
+
82
+ Kernel.warn lines.join("\n")
83
+ end
84
+
85
+ def self.constant_deprecated_in_favor_of(old_name, new_name)
86
+ show_warning "#{old_name} is deprecated;\nplease use #{new_name} instead.",
87
+ :start_backtrace_at_frame => 3
88
+ end
89
+
90
+ def self.show_warning_for_deprecated_adapter
91
+ RR::Deprecations.show_warning(<<EOT.strip)
92
+ RR now has an autohook system. You don't need to `include RR::Adapters::*` in
93
+ your test framework's base class anymore.
94
+ EOT
95
+ end
96
+ end
97
+ end
@@ -3,7 +3,7 @@ module RR
3
3
  module DoubleInjections
4
4
  class AnyInstanceOf
5
5
  extend(Module.new do
6
- include RR::Adapters::RRMethods
6
+ include RR::DSL
7
7
 
8
8
  def call(subject_class, stubbed_methods=nil, &block)
9
9
  strategy_lambda = lambda do |double_definition_create|
@@ -3,7 +3,7 @@ module RR
3
3
  module DoubleInjections
4
4
  class Instance
5
5
  extend(Module.new do
6
- include ::RR::Adapters::RRMethods
6
+ include ::RR::DSL
7
7
 
8
8
  def call(double_method_name, *args, &definition_eval_block)
9
9
  double_definition_create = DoubleDefinitions::DoubleDefinitionCreate.new
@@ -13,4 +13,4 @@ module RR
13
13
  end
14
14
  end
15
15
  end
16
- end
16
+ end