rspec 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/.document +4 -4
  2. data/{History.txt → History.rdoc} +27 -4
  3. data/Manifest.txt +18 -7
  4. data/{README.txt → README.rdoc} +0 -0
  5. data/Rakefile +16 -9
  6. data/{Ruby1.9.markdown → Ruby1.9.rdoc} +3 -3
  7. data/TODO.txt +0 -7
  8. data/Upgrade.rdoc +110 -0
  9. data/features/matchers/create_matcher.feature +40 -0
  10. data/features/matchers/create_matcher_outside_rspec.feature +39 -0
  11. data/features/pending/pending_examples.feature +5 -5
  12. data/features/step_definitions/running_rspec.rb +13 -0
  13. data/features/subject/explicit_subject.feature +31 -0
  14. data/features/subject/implicit_subject.feature +31 -0
  15. data/lib/spec/adapters/mock_frameworks/flexmock.rb +1 -0
  16. data/lib/spec/adapters/mock_frameworks/mocha.rb +1 -0
  17. data/lib/spec/adapters/mock_frameworks/rr.rb +1 -0
  18. data/lib/spec/adapters/mock_frameworks/rspec.rb +12 -10
  19. data/lib/spec/dsl.rb +0 -1
  20. data/lib/spec/dsl/main.rb +3 -3
  21. data/lib/spec/example.rb +4 -3
  22. data/lib/spec/example/example_group_factory.rb +1 -3
  23. data/lib/spec/example/example_group_methods.rb +22 -28
  24. data/lib/spec/example/example_group_proxy.rb +64 -0
  25. data/lib/spec/example/example_methods.rb +8 -11
  26. data/lib/spec/example/example_proxy.rb +42 -0
  27. data/lib/spec/example/shared_example_group.rb +1 -1
  28. data/lib/spec/example/subject.rb +14 -3
  29. data/lib/spec/expectations.rb +1 -1
  30. data/lib/spec/expectations/differs/default.rb +46 -49
  31. data/lib/spec/expectations/differs/load-diff-lcs.rb +12 -0
  32. data/lib/spec/interop/test/unit/testcase.rb +2 -2
  33. data/lib/spec/matchers.rb +49 -9
  34. data/lib/spec/matchers/be.rb +12 -15
  35. data/lib/spec/matchers/change.rb +1 -0
  36. data/lib/spec/matchers/dsl.rb +15 -0
  37. data/lib/spec/matchers/have.rb +9 -8
  38. data/lib/spec/matchers/include.rb +2 -16
  39. data/lib/spec/matchers/match_array.rb +2 -14
  40. data/lib/spec/matchers/matcher.rb +16 -11
  41. data/lib/spec/matchers/pretty.rb +36 -0
  42. data/lib/spec/matchers/raise_error.rb +9 -8
  43. data/lib/spec/matchers/simple_matcher.rb +1 -0
  44. data/lib/spec/matchers/throw_symbol.rb +1 -1
  45. data/lib/spec/mocks/argument_expectation.rb +2 -0
  46. data/lib/spec/mocks/message_expectation.rb +2 -0
  47. data/lib/spec/mocks/proxy.rb +9 -10
  48. data/lib/spec/runner.rb +1 -0
  49. data/lib/spec/runner/extensions/kernel.rb +9 -0
  50. data/lib/spec/runner/formatter/base_formatter.rb +22 -9
  51. data/lib/spec/runner/formatter/html_formatter.rb +2 -1
  52. data/lib/spec/runner/heckle_runner.rb +1 -0
  53. data/lib/spec/runner/option_parser.rb +4 -1
  54. data/lib/spec/runner/options.rb +11 -0
  55. data/lib/spec/runner/spec_parser.rb +15 -22
  56. data/lib/spec/version.rb +4 -6
  57. data/spec/autotest/autotest_helper.rb +6 -1
  58. data/spec/spec/dsl/main_spec.rb +3 -3
  59. data/spec/spec/example/example_group_factory_spec.rb +11 -23
  60. data/spec/spec/example/example_group_methods_spec.rb +45 -20
  61. data/spec/spec/example/example_group_proxy_spec.rb +63 -0
  62. data/spec/spec/example/example_group_spec.rb +15 -0
  63. data/spec/spec/example/example_methods_spec.rb +5 -35
  64. data/spec/spec/example/example_proxy_spec.rb +47 -0
  65. data/spec/spec/example/nested_example_group_spec.rb +3 -3
  66. data/spec/spec/example/shared_example_group_spec.rb +4 -4
  67. data/spec/spec/example/subject_spec.rb +77 -0
  68. data/spec/spec/matchers/be_close_spec.rb +10 -10
  69. data/spec/spec/matchers/be_instance_of_spec.rb +13 -8
  70. data/spec/spec/matchers/be_kind_of_spec.rb +10 -8
  71. data/spec/spec/{dsl/matchers_spec.rb → matchers/dsl_spec.rb} +4 -4
  72. data/spec/spec/matchers/matcher_spec.rb +53 -1
  73. data/spec/spec/matchers/matchers_spec.rb +2 -0
  74. data/spec/spec/package/bin_spec_spec.rb +4 -4
  75. data/spec/spec/runner/command_line_spec.rb +2 -2
  76. data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +4 -4
  77. data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +2 -2
  78. data/spec/spec/runner/formatter/html_formatted-1.8.4.html +1 -1
  79. data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +1 -1
  80. data/spec/spec/runner/formatter/html_formatted-1.8.5.html +1 -1
  81. data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +1 -1
  82. data/spec/spec/runner/formatter/html_formatted-1.8.6.html +1 -1
  83. data/spec/spec/runner/formatter/html_formatted-1.8.7.html +1 -1
  84. data/spec/spec/runner/formatter/html_formatted-1.9.1.html +1 -1
  85. data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +12 -11
  86. data/spec/spec/runner/formatter/profile_formatter_spec.rb +2 -2
  87. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +2 -2
  88. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +2 -2
  89. data/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +1 -1
  90. data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +1 -1
  91. data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +1 -1
  92. data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +1 -1
  93. data/spec/spec/runner/option_parser_spec.rb +20 -0
  94. data/spec/spec/runner/options_spec.rb +23 -1
  95. data/spec/spec/runner/reporter_spec.rb +20 -17
  96. data/spec/spec/runner/spec_parser_spec.rb +1 -1
  97. metadata +33 -15
  98. data/Upgrade.markdown +0 -63
  99. data/lib/spec/dsl/matchers.rb +0 -13
  100. data/lib/spec/example/example_description.rb +0 -15
data/.document CHANGED
@@ -1,7 +1,7 @@
1
1
  features/**/*.feature
2
2
  lib/**/*.rb
3
- History.txt
3
+ History.rdoc
4
4
  License.txt
5
- README.txt
6
- Ruby1.9.markdown
7
- Upgrade.markdown
5
+ README.rdoc
6
+ Ruby1.9.rdoc
7
+ Upgrade.rdoc
@@ -1,6 +1,27 @@
1
- === Version 1.2.0
1
+ === Version 1.2.1 / 2009-03-22
2
+
3
+ * enhancments
4
+
5
+ * matchers, including the new DSL, easily added to your test/unit tests
6
+ * added support for 0 to n args in matcher DSL
7
+ * restored loading rubygems when necessary
8
+ * if you really don't want to use rubygems, you
9
+ can set an NO_RUBYGEMS environment
10
+ variable, and RSpec won't force it on you.
11
+ * added -u/--debugger option (Rick DeNatale) #262.
12
+ * just add "debugger" anywhere in your code and run spec path/to/code --debugger
13
+ * rename ExampleDescription to ExampleProxy
14
+ * pass ExampleProxy to example_started(). Closes #738, #743
15
+ * thanks to Tobias Grimm (Eclipse) fort the patch and Roman Chernyatchik
16
+ (JetBrains, RubyMine) for the assist
17
+
18
+ * bug fixes
19
+
20
+ * subject (implicit or explicit) is now properly inherited by nested groups. Closes #744.
2
21
 
3
- WARNINGS:
22
+ === Version 1.2.0 / 2009-03-15
23
+
24
+ * warnings:
4
25
 
5
26
  * If you use the ruby command to run specs instead of the spec command, you'll
6
27
  need to require 'spec/autorun' or they won't run. This won't affect you if
@@ -20,11 +41,13 @@ WARNINGS:
20
41
  matchers, or using extension libraries that do, this should not affect
21
42
  you. If you run into trouble, you'll just need to change:
22
43
 
23
- * failure_message => failure_message_for_should
24
- * negative_failure_message => failure_message_for_should_not
44
+ failure_message => failure_message_for_should
45
+ negative_failure_message => failure_message_for_should_not
25
46
 
26
47
  * All references to rubygems have been removed from within rspec's code.
27
48
 
49
+ * NOTE that they have been restored in 1.2.1, above
50
+
28
51
  * See http://gist.github.com/54177 for rationale and suggestions on
29
52
  alternative approaches to loading rubygems
30
53
 
@@ -1,13 +1,13 @@
1
1
  .autotest
2
2
  .document
3
- History.txt
3
+ History.rdoc
4
4
  License.txt
5
5
  Manifest.txt
6
- README.txt
6
+ README.rdoc
7
7
  Rakefile
8
- Ruby1.9.markdown
8
+ Ruby1.9.rdoc
9
9
  TODO.txt
10
- Upgrade.markdown
10
+ Upgrade.rdoc
11
11
  bin/autospec
12
12
  bin/spec
13
13
  cucumber.yml
@@ -66,12 +66,15 @@ features/interop/examples_and_tests_together.feature
66
66
  features/interop/test_but_not_test_unit.feature
67
67
  features/interop/test_case_with_should_methods.feature
68
68
  features/matchers/create_matcher.feature
69
+ features/matchers/create_matcher_outside_rspec.feature
69
70
  features/mock_framework_integration/use_flexmock.feature
70
71
  features/mock_framework_integration/use_mocha.feature
71
72
  features/mock_framework_integration/use_rr.feature
72
73
  features/mocks/mix_stubs_and_mocks.feature
73
74
  features/pending/pending_examples.feature
74
75
  features/step_definitions/running_rspec.rb
76
+ features/subject/explicit_subject.feature
77
+ features/subject/implicit_subject.feature
75
78
  features/support/env.rb
76
79
  features/support/matchers/smart_match.rb
77
80
  init.rb
@@ -85,17 +88,17 @@ lib/spec/adapters/mock_frameworks/rspec.rb
85
88
  lib/spec/autorun.rb
86
89
  lib/spec/dsl.rb
87
90
  lib/spec/dsl/main.rb
88
- lib/spec/dsl/matchers.rb
89
91
  lib/spec/example.rb
90
92
  lib/spec/example/before_and_after_hooks.rb
91
93
  lib/spec/example/errors.rb
92
- lib/spec/example/example_description.rb
93
94
  lib/spec/example/example_group.rb
94
95
  lib/spec/example/example_group_factory.rb
95
96
  lib/spec/example/example_group_hierarchy.rb
96
97
  lib/spec/example/example_group_methods.rb
98
+ lib/spec/example/example_group_proxy.rb
97
99
  lib/spec/example/example_matcher.rb
98
100
  lib/spec/example/example_methods.rb
101
+ lib/spec/example/example_proxy.rb
99
102
  lib/spec/example/module_reopening_fix.rb
100
103
  lib/spec/example/pending.rb
101
104
  lib/spec/example/predicate_matchers.rb
@@ -103,6 +106,7 @@ lib/spec/example/shared_example_group.rb
103
106
  lib/spec/example/subject.rb
104
107
  lib/spec/expectations.rb
105
108
  lib/spec/expectations/differs/default.rb
109
+ lib/spec/expectations/differs/load-diff-lcs.rb
106
110
  lib/spec/expectations/errors.rb
107
111
  lib/spec/expectations/extensions.rb
108
112
  lib/spec/expectations/extensions/object.rb
@@ -120,6 +124,7 @@ lib/spec/matchers/be_instance_of.rb
120
124
  lib/spec/matchers/be_kind_of.rb
121
125
  lib/spec/matchers/change.rb
122
126
  lib/spec/matchers/compatibility.rb
127
+ lib/spec/matchers/dsl.rb
123
128
  lib/spec/matchers/eql.rb
124
129
  lib/spec/matchers/equal.rb
125
130
  lib/spec/matchers/errors.rb
@@ -134,6 +139,7 @@ lib/spec/matchers/match_array.rb
134
139
  lib/spec/matchers/matcher.rb
135
140
  lib/spec/matchers/method_missing.rb
136
141
  lib/spec/matchers/operator_matcher.rb
142
+ lib/spec/matchers/pretty.rb
137
143
  lib/spec/matchers/raise_error.rb
138
144
  lib/spec/matchers/respond_to.rb
139
145
  lib/spec/matchers/satisfy.rb
@@ -165,6 +171,7 @@ lib/spec/runner/command_line.rb
165
171
  lib/spec/runner/configuration.rb
166
172
  lib/spec/runner/drb_command_line.rb
167
173
  lib/spec/runner/example_group_runner.rb
174
+ lib/spec/runner/extensions/kernel.rb
168
175
  lib/spec/runner/formatter/base_formatter.rb
169
176
  lib/spec/runner/formatter/base_text_formatter.rb
170
177
  lib/spec/runner/formatter/failing_example_groups_formatter.rb
@@ -204,19 +211,21 @@ spec/rspec_suite.rb
204
211
  spec/ruby_forker.rb
205
212
  spec/spec.opts
206
213
  spec/spec/dsl/main_spec.rb
207
- spec/spec/dsl/matchers_spec.rb
208
214
  spec/spec/example/example_group_class_definition_spec.rb
209
215
  spec/spec/example/example_group_factory_spec.rb
210
216
  spec/spec/example/example_group_methods_spec.rb
217
+ spec/spec/example/example_group_proxy_spec.rb
211
218
  spec/spec/example/example_group_spec.rb
212
219
  spec/spec/example/example_matcher_spec.rb
213
220
  spec/spec/example/example_methods_spec.rb
221
+ spec/spec/example/example_proxy_spec.rb
214
222
  spec/spec/example/helper_method_spec.rb
215
223
  spec/spec/example/nested_example_group_spec.rb
216
224
  spec/spec/example/pending_module_spec.rb
217
225
  spec/spec/example/predicate_matcher_spec.rb
218
226
  spec/spec/example/shared_example_group_spec.rb
219
227
  spec/spec/example/subclassing_example_group_spec.rb
228
+ spec/spec/example/subject_spec.rb
220
229
  spec/spec/expectations/differs/default_spec.rb
221
230
  spec/spec/expectations/extensions/object_spec.rb
222
231
  spec/spec/expectations/fail_with_spec.rb
@@ -241,6 +250,7 @@ spec/spec/matchers/be_spec.rb
241
250
  spec/spec/matchers/change_spec.rb
242
251
  spec/spec/matchers/compatibility_spec.rb
243
252
  spec/spec/matchers/description_generation_spec.rb
253
+ spec/spec/matchers/dsl_spec.rb
244
254
  spec/spec/matchers/eql_spec.rb
245
255
  spec/spec/matchers/equal_spec.rb
246
256
  spec/spec/matchers/exist_spec.rb
@@ -251,6 +261,7 @@ spec/spec/matchers/match_array_spec.rb
251
261
  spec/spec/matchers/match_spec.rb
252
262
  spec/spec/matchers/matcher_methods_spec.rb
253
263
  spec/spec/matchers/matcher_spec.rb
264
+ spec/spec/matchers/matchers_spec.rb
254
265
  spec/spec/matchers/operator_matcher_spec.rb
255
266
  spec/spec/matchers/raise_error_spec.rb
256
267
  spec/spec/matchers/respond_to_spec.rb
File without changes
data/Rakefile CHANGED
@@ -1,18 +1,13 @@
1
1
  # -*- ruby -*-
2
+ gem 'hoe', '>=1.9.0'
3
+ require 'hoe'
2
4
 
3
5
  $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
4
- require 'hoe'
6
+
5
7
  require 'spec/version'
6
8
  require 'spec/rake/spectask'
7
9
  require 'cucumber/rake/task'
8
10
 
9
- class Hoe
10
- def extra_deps
11
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
12
- @extra_deps
13
- end
14
- end
15
-
16
11
  Hoe.new('rspec', Spec::VERSION::STRING) do |p|
17
12
  p.summary = Spec::VERSION::SUMMARY
18
13
  p.url = 'http://rspec.info/'
@@ -22,6 +17,18 @@ Hoe.new('rspec', Spec::VERSION::STRING) do |p|
22
17
  p.extra_dev_deps = [["cucumber",">= 0.1.13"]]
23
18
  p.remote_rdoc_dir = "rspec/#{Spec::VERSION::STRING}"
24
19
  p.rspec_options = ['--options', 'spec/spec.opts']
20
+ p.history_file = 'History.rdoc'
21
+ p.readme_file = 'README.rdoc'
22
+ p.post_install_message = <<-POST_INSTALL_MESSAGE
23
+ #{'*'*50}
24
+
25
+ Thank you for installing rspec-#{Spec::VERSION::STRING}
26
+
27
+ Please be sure to read History.rdoc and Upgrade.rdoc
28
+ for useful information about this release.
29
+
30
+ #{'*'*50}
31
+ POST_INSTALL_MESSAGE
25
32
  end
26
33
 
27
34
  ['audit','test','test_deps','default','post_blog'].each do |task|
@@ -47,7 +54,7 @@ namespace :spec do
47
54
  t.spec_opts = ['--options', 'spec/spec.opts']
48
55
  t.rcov = true
49
56
  t.rcov_dir = 'coverage'
50
- t.rcov_opts = ['--exclude', "instance_exec\.rb,lib/spec.rb,lib/spec/runner.rb,spec/spec,bin/spec,examples,/gems,/Library/Ruby,\.autotest,#{ENV['GEM_HOME']}"]
57
+ t.rcov_opts = ['--exclude', "kernel,load-diff-lcs\.rb,instance_exec\.rb,lib/spec.rb,lib/spec/runner.rb,spec/spec,bin/spec,examples,/gems,/Library/Ruby,\.autotest,#{ENV['GEM_HOME']}"]
51
58
  end
52
59
  end
53
60
 
@@ -1,13 +1,13 @@
1
- # RSpec and Ruby 1.9
1
+ = RSpec and Ruby 1.9
2
2
 
3
3
  Currently, RSpec (core) is mostly compatible with Ruby 1.9.1. There are still
4
4
  outstanding issues, some of which we plan to address and some we don't.
5
5
 
6
- ## Test::Unit
6
+ == Test::Unit
7
7
 
8
8
  RSpec/Test::Unit interop will run with the test-unit-1.2.3 gem, but you must install it.
9
9
 
10
- ## Class Variables
10
+ == Class Variables
11
11
 
12
12
  Due to changes in scoping rules, class variables within example groups are not
13
13
  supported in Ruby 1.9.
data/TODO.txt CHANGED
@@ -1,7 +1,5 @@
1
1
  == Refactoring
2
2
 
3
- Refactoring for 1.2.0
4
-
5
3
  ** global predictate matchers should be stored in run_options
6
4
  * eliminate dependency on global options and configuration
7
5
  ** the only place they should exist is in the Runner, which should manage them
@@ -13,11 +11,6 @@ Refactoring for 1.2.0
13
11
  * be able to do everything with classes and methods
14
12
  * tweak raise_error rdoc to show only one arg
15
13
 
16
- == Ruby 1.9.1
17
-
18
- * one example remains failing
19
- * cucumber isn't working yet
20
-
21
14
  == rspec-2.0
22
15
 
23
16
  * rename top level namespace to Rspec and commands to 'rspec' and 'autorspec'
@@ -0,0 +1,110 @@
1
+ = Upgrade to rspec-1.2.1 (in dev)
2
+
3
+ == What's Changed
4
+
5
+ === <tt>require 'rubygems' unless ENV['NO_RUBYGEMS']</tt>
6
+
7
+ After minor public outcry and confusion, we restored necessary references to
8
+ rubygems in rspec. If you use a different mechanism for managing gems, just
9
+ set a <tt>NO_RUBYGEMS</tt> environment variable (to any non-nil value).
10
+
11
+ === Proxies and locations
12
+
13
+ This is probably only interesting to you if you use custom formatters.
14
+
15
+ Formatters now receive Spec::Example::ExampleGroupProxy and
16
+ Spec::Example::ExampleGroup objects with cohesive APIs for reporting. See the
17
+ RDoc for those classes and Spec::Runner::Formatter::BaseFormatter for more
18
+ information.
19
+
20
+ == What's new
21
+
22
+ === The new matcher DSL works with test/unit (without the rest of rspec)
23
+
24
+ We'll be separating this out to its own gem for rspec 2.0, but for now, just install
25
+ rspec >= 1.2.1 and add the following to your <tt>test_helper</tt> file:
26
+
27
+ require 'spec/expectations'
28
+ class Test::Unit::TestCase
29
+ include Spec::Matchers
30
+ end
31
+
32
+ This will add <tt>should()</tt> and <tt>should_not()</tt> to your objects, make all of
33
+ rspec's built-in matchers available to your tests, INCLUDING rspec's DSL for
34
+ creating matchers (see below, under Upgrade to rspec-1.2.0)
35
+
36
+ === debugger
37
+
38
+ If you have ruby-debug installed, you can set a breakpoint by adding <tt>debugger()</tt>
39
+ in your code:
40
+
41
+ # some code .....
42
+ debugger
43
+ # some more code ....
44
+
45
+ ... and using the <tt>--debugger</tt> or <tt>-u</tt> command line option.
46
+
47
+ spec path/to/file.rb --debugger
48
+
49
+ = Upgrade to rspec-1.2.0
50
+
51
+ == What's Changed
52
+
53
+ === WARNINGS
54
+
55
+ * If you use the ruby command to run specs instead of the spec command, you'll
56
+ need to require 'spec/autorun' or they won't run. This won't affect you if
57
+ you use the spec command or the Spec::Rake::SpecTask that ships with RSpec.
58
+
59
+ * require 'spec/test/unit' to invoke test/unit interop if you're using
60
+ RSpec's core (this is handled implicitly with spec-rails)
61
+
62
+ * setup and teardown are gone - use before and after instead
63
+
64
+ * you can still use setup and teardown if you're using
65
+ Test::Unit::TestCase as the base ExampleGroup class (which is implicit
66
+ in rspec-rails)
67
+
68
+ * The matcher protocol has been improved. The old protocol is still supported,
69
+ but we added support for two new methods that speak a bit more clearly:
70
+
71
+ failure_message => failure_message_for_should
72
+ negative_failure_message => failure_message_for_should_not
73
+
74
+ * All references to rubygems have been removed from within rspec's code.
75
+
76
+ * See http://gist.github.com/54177 for rationale and suggestions on
77
+ alternative approaches to loading rubygems
78
+
79
+ == What's New
80
+
81
+ === Ruby 1.9
82
+
83
+ RSpec now works with Ruby 1.9.1. See http://wiki.github.com/dchelimsky/rspec/ruby-191
84
+ for useful information.
85
+
86
+ === Improved heckle integration
87
+
88
+ RSpec works with heckle again! Gotta use heckle >= 1.4.2 for this to work
89
+ though, and it only works with ruby-1.8.6 and 1.8.7 (heckle doesn't support
90
+ 1.9.1 yet).
91
+
92
+ [sudo] gem install heckle --version ">=1.4.2"
93
+ spec spec/game/mastermind.rb --heckle Game::Mastermind
94
+
95
+ === New Matcher DSL
96
+
97
+ We've added a new DSL for generating custom matchers very simply and cleanly.
98
+ We'll still support the simple_matcher method, so never fear if you're using
99
+ that, but we recommend that you start developing your new matchers with this
100
+ new syntax.
101
+
102
+ Spec::Matchers.create do :be_a_multiple_of |smaller|
103
+ match do |bigger|
104
+ bigger % smaller == 0
105
+ end
106
+ end
107
+
108
+ 9.should be_a_multiple_of(3)
109
+
110
+ See <tt>features/matchers/create_matcher.feature</tt> for more examples
@@ -113,3 +113,43 @@ Feature: custom matcher shortcut
113
113
  And the stdout should match "2 examples, 0 failures"
114
114
  And the stdout should match "should be multiple of 3"
115
115
  And the stdout should match "should not be multiple of 4"
116
+
117
+ Scenario: with no args
118
+ Given the following spec:
119
+ """
120
+ Spec::Matchers.create :have_7_fingers do
121
+ match do |thing|
122
+ thing.fingers.length == 7
123
+ end
124
+ end
125
+
126
+ class Thing
127
+ def fingers; (1..7).collect {"finger"}; end
128
+ end
129
+
130
+ describe Thing do
131
+ it {should have_7_fingers}
132
+ end
133
+ """
134
+ When I run it with the spec command --format specdoc
135
+ Then the exit code should be 0
136
+ And the stdout should match "1 example, 0 failures"
137
+ And the stdout should match "should have 7 fingers"
138
+
139
+ Scenario: with multiple args
140
+ Given the following spec:
141
+ """
142
+ Spec::Matchers.create :be_the_sum_of do |a,b,c,d|
143
+ match do |sum|
144
+ a + b + c + d == sum
145
+ end
146
+ end
147
+
148
+ describe 10 do
149
+ it {should be_the_sum_of(1,2,3,4)}
150
+ end
151
+ """
152
+ When I run it with the spec command --format specdoc
153
+ Then the exit code should be 0
154
+ And the stdout should match "1 example, 0 failures"
155
+ And the stdout should match "should be the sum of 1, 2, 3, and 4"
@@ -0,0 +1,39 @@
1
+ Feature: custom matcher shortcut
2
+
3
+ In order to express my domain clearly in my code examples
4
+ As a non-rspec user
5
+ I want a shortcut for create custom matchers
6
+
7
+ Scenario: creating a matcher with default messages
8
+ Given a file named test_multiples.rb with:
9
+ """
10
+ $:.unshift File.join(File.dirname(__FILE__), "/../lib")
11
+ require 'test/unit'
12
+ require 'spec/expectations'
13
+
14
+ Spec::Matchers.create :be_a_multiple_of do |expected|
15
+ match do |actual|
16
+ actual % expected == 0
17
+ end
18
+ end
19
+
20
+ class Test::Unit::TestCase
21
+ include Spec::Matchers
22
+ end
23
+
24
+ class TestMultiples < Test::Unit::TestCase
25
+
26
+ def test_9_should_be_a_multiple_of_3
27
+ 9.should be_a_multiple_of(3)
28
+ end
29
+
30
+ def test_9_should_be_a_multiple_of_4
31
+ 9.should be_a_multiple_of(4)
32
+ end
33
+
34
+ end
35
+ """
36
+ When I run it with the ruby interpreter
37
+ Then the exit code should be 256
38
+ And the stdout should match "expected 9 to be a multiple of 4"
39
+ And the stdout should match "2 tests, 0 assertions, 1 failures, 0 errors"