dchelimsky-rspec 1.1.11.1 → 1.1.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/History.txt +11 -3
  2. data/Manifest.txt +35 -46
  3. data/README.txt +30 -12
  4. data/Rakefile +9 -9
  5. data/{stories/configuration/before_blocks.story → features/configuration/before_blocks.feature} +2 -2
  6. data/{stories/example_groups/autogenerated_docstrings → features/example_groups/autogenerated_docstrings.feature} +1 -1
  7. data/{stories/example_groups/example_group_with_should_methods → features/example_groups/example_group_with_should_methods.feature} +3 -3
  8. data/{stories/example_groups/nested_groups → features/example_groups/nested_groups.feature} +1 -1
  9. data/{stories/example_groups/output → features/example_groups/output.feature} +3 -8
  10. data/{stories/interop/examples_and_tests_together → features/interop/examples_and_tests_together.feature} +5 -4
  11. data/{stories/interop/test_but_not_test_unit → features/interop/test_but_not_test_unit.feature} +2 -2
  12. data/{stories/interop/test_case_with_should_methods → features/interop/test_case_with_should_methods.feature} +2 -2
  13. data/{stories/mock_framework_integration/use_flexmock.story → features/mock_framework_integration/use_flexmock.feature} +1 -1
  14. data/features/step_definitions/running_rspec.rb +48 -0
  15. data/features/support/env.rb +25 -0
  16. data/{stories/resources → features/support}/helpers/cmdline.rb +0 -0
  17. data/{stories/resources → features/support}/helpers/story_helper.rb +0 -0
  18. data/{stories/resources → features/support}/matchers/smart_match.rb +0 -0
  19. data/{plugins → lib/adapters}/mock_frameworks/flexmock.rb +0 -0
  20. data/{plugins → lib/adapters}/mock_frameworks/mocha.rb +0 -0
  21. data/{plugins → lib/adapters}/mock_frameworks/rr.rb +0 -0
  22. data/{plugins → lib/adapters}/mock_frameworks/rspec.rb +1 -1
  23. data/lib/autotest/rspec.rb +3 -2
  24. data/lib/spec/dsl/main.rb +8 -4
  25. data/lib/spec/example/configuration.rb +1 -1
  26. data/lib/spec/example/example_group_factory.rb +6 -2
  27. data/lib/spec/example/example_group_methods.rb +47 -54
  28. data/lib/spec/example/shared_example_group.rb +2 -2
  29. data/lib/spec/example.rb +163 -14
  30. data/lib/spec/interop/test/unit/testresult.rb +1 -1
  31. data/lib/spec/interop/test/unit/testsuite_adapter.rb +1 -1
  32. data/lib/spec/matchers/match_array.rb +75 -0
  33. data/lib/spec/matchers/operator_matcher.rb +34 -7
  34. data/lib/spec/matchers.rb +2 -1
  35. data/lib/spec/mocks/argument_constraints.rb +43 -5
  36. data/lib/spec/runner/example_group_runner.rb +2 -2
  37. data/lib/spec/runner/option_parser.rb +12 -6
  38. data/lib/spec/runner/options.rb +9 -9
  39. data/lib/spec/runner/spec_parser.rb +3 -2
  40. data/lib/spec/runner.rb +54 -188
  41. data/lib/spec/version.rb +1 -1
  42. data/lib/spec.rb +0 -29
  43. data/{rake_tasks → resources/rake}/examples.rake +0 -0
  44. data/{rake_tasks → resources/rake}/examples_with_rcov.rake +0 -0
  45. data/{rake_tasks → resources/rake}/failing_examples_with_html.rake +0 -0
  46. data/{rake_tasks → resources/rake}/verify_rcov.rake +0 -0
  47. data/{stories/resources → resources}/spec/before_blocks_example.rb +1 -1
  48. data/{stories/resources → resources}/spec/example_group_with_should_methods.rb +1 -1
  49. data/{stories/resources → resources}/spec/simple_spec.rb +1 -1
  50. data/resources/spec/spec_with_flexmock.rb +19 -0
  51. data/{stories/resources → resources}/test/spec_and_test_together.rb +1 -1
  52. data/{stories/resources → resources}/test/spec_including_test_but_not_unit.rb +1 -1
  53. data/{stories/resources → resources}/test/test_case_with_should_methods.rb +2 -2
  54. data/rspec.gemspec +5 -4
  55. data/spec/autotest/rspec_spec.rb +2 -1
  56. data/spec/spec/dsl/main_spec.rb +8 -5
  57. data/spec/spec/example/configuration_spec.rb +9 -9
  58. data/spec/spec/example/example_group_factory_spec.rb +22 -3
  59. data/spec/spec/example/example_group_methods_spec.rb +19 -15
  60. data/spec/spec/example/example_group_spec.rb +41 -41
  61. data/spec/spec/example/example_methods_spec.rb +5 -5
  62. data/spec/spec/example/helper_method_spec.rb +24 -0
  63. data/spec/spec/example/pending_module_spec.rb +2 -8
  64. data/spec/spec/example/shared_example_group_spec.rb +5 -5
  65. data/spec/spec/matchers/description_generation_spec.rb +5 -0
  66. data/spec/spec/matchers/handler_spec.rb +7 -7
  67. data/spec/spec/matchers/match_array_spec.rb +83 -0
  68. data/spec/spec/matchers/raise_error_spec.rb +18 -0
  69. data/spec/spec/mocks/hash_including_matcher_spec.rb +39 -2
  70. data/spec/spec/mocks/hash_not_including_matcher_spec.rb +67 -0
  71. data/spec/spec/mocks/mock_spec.rb +5 -6
  72. data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
  73. data/spec/spec/runner/formatter/base_text_formatter_spec.rb +22 -0
  74. data/spec/spec/runner/option_parser_spec.rb +4 -17
  75. data/spec/spec/runner/options_spec.rb +19 -5
  76. data/spec/spec/runner/resources/custom_example_group_runner.rb +14 -0
  77. data/spec/spec/runner/spec_parser_spec.rb +10 -0
  78. data/spec/spec/spec_spec.rb +21 -0
  79. metadata +39 -49
  80. data/lib/spec/adapters/ruby_engine/mri.rb +0 -8
  81. data/lib/spec/adapters/ruby_engine/rubinius.rb +0 -8
  82. data/lib/spec/adapters/ruby_engine.rb +0 -26
  83. data/lib/spec/adapters.rb +0 -1
  84. data/lib/spec/extensions/class.rb +0 -24
  85. data/lib/spec/extensions.rb +0 -1
  86. data/spec/spec/adapters/ruby_engine_spec.rb +0 -16
  87. data/stories/all.rb +0 -5
  88. data/stories/configuration/stories.rb +0 -7
  89. data/stories/example_groups/stories.rb +0 -7
  90. data/stories/helper.rb +0 -6
  91. data/stories/interop/stories.rb +0 -7
  92. data/stories/mock_framework_integration/stories.rb +0 -7
  93. data/stories/pending_stories/README +0 -3
  94. data/stories/resources/spec/spec_with_flexmock.rb +0 -18
  95. data/stories/resources/steps/running_rspec.rb +0 -50
  96. data/stories/resources/stories/failing_story.rb +0 -15
  97. data/stories/stories/multiline_steps.story +0 -23
  98. data/stories/stories/steps/multiline_steps.rb +0 -13
  99. data/stories/stories/stories.rb +0 -6
data/History.txt CHANGED
@@ -5,25 +5,33 @@
5
5
  * deprecated ExampleMethods#implementation_backtrace - use ExampleMethods#backtrace instead
6
6
  * deprecated ExampleGroupMethods#example_group_backtrace - use ExampleGroupMethods#backtrace instead
7
7
 
8
- * 3 major enhancements
8
+ * 6 major enhancements
9
9
 
10
10
  * it { should matcher } - support for implicit receiver of #should (Joe Ferris of thoughtbot)
11
11
  * subject { ... } - works in conjunction with implicit receiver of #should
12
12
  * wrap_expectation (for wrapping multiple expectations and/or t/u assertions)
13
+ * added array.should =~ [1,2,3] # passes if array contains exactly the same elements in any order (Jeff Dean and Pat Maddox)
14
+ * hash_including mock argument matcher can now accept just keys, key/value pairs, or both (David Krmpotic)
15
+ * added hash_not_including mock argument matcher (David Krmpotic). Closes #634.
13
16
 
14
- * 4 minor enhancements
17
+ * 6 minor enhancements
15
18
 
16
19
  * should throw_symbol accepts an optional argument: should throw_symbol(:sym, arg)
17
20
  * fixed --line for jruby (Zach Moazeni)
18
21
  * assorted small changes to support Ruby 1.9 (got a way to go)
19
22
  * removed all instances of class << self - I do know who I am
23
+ * SpecParser can't handle backtrace paths with colons (John-Mason P. Shackelford). Closes #505.
24
+ * html formatter (and subsequently the textmate formatter) header fills in completely when running a single example
20
25
 
21
- * 4 bug fixes
26
+ * 7 bug fixes
22
27
 
23
28
  * fixed bug where {:a => 1, :b => 2}.should include(:a, :b) failed (Yossef Mendelssohn)
24
29
  * only try to load Test::Unit if Test::Unit is defined (not just Test)
25
30
  * Allow stubs on parent and child classes simultaneously (Jim Lindley). Fixes #600.
26
31
  * BaseTextFormatter will now create the directory in a WHERE string (Adam Anderson). Fixes #616.
32
+ * Removed incorrect -S flag on autospec commands. Added explicit spec command for ruby to run, guarantee running rspec (raggi). Closes #507.
33
+ * Check whether test/unit has really been loaded before calling a method it defines (Brian Donovan). Closes #503.
34
+ * Fix spec_path for shared groups (Zach Dennis). Closes #615.
27
35
 
28
36
  === Version 1.1.11 / 2008-10-24
29
37
 
data/Manifest.txt CHANGED
@@ -52,14 +52,28 @@ examples/passing/stack_spec.rb
52
52
  examples/passing/stack_spec_with_nested_example_groups.rb
53
53
  examples/passing/stubbing_example.rb
54
54
  examples/passing/yielding_example.rb
55
+ features/configuration/before_blocks.feature
56
+ features/example_groups/autogenerated_docstrings.feature
57
+ features/example_groups/example_group_with_should_methods.feature
58
+ features/example_groups/nested_groups.feature
59
+ features/example_groups/output.feature
60
+ features/interop/examples_and_tests_together.feature
61
+ features/interop/test_but_not_test_unit.feature
62
+ features/interop/test_case_with_should_methods.feature
63
+ features/mock_framework_integration/use_flexmock.feature
64
+ features/step_definitions/running_rspec.rb
65
+ features/support/env.rb
66
+ features/support/helpers/cmdline.rb
67
+ features/support/helpers/story_helper.rb
68
+ features/support/matchers/smart_match.rb
55
69
  init.rb
70
+ lib/adapters/mock_frameworks/flexmock.rb
71
+ lib/adapters/mock_frameworks/mocha.rb
72
+ lib/adapters/mock_frameworks/rr.rb
73
+ lib/adapters/mock_frameworks/rspec.rb
56
74
  lib/autotest/discover.rb
57
75
  lib/autotest/rspec.rb
58
76
  lib/spec.rb
59
- lib/spec/adapters.rb
60
- lib/spec/adapters/ruby_engine.rb
61
- lib/spec/adapters/ruby_engine/mri.rb
62
- lib/spec/adapters/ruby_engine/rubinius.rb
63
77
  lib/spec/dsl.rb
64
78
  lib/spec/dsl/main.rb
65
79
  lib/spec/example.rb
@@ -82,8 +96,6 @@ lib/spec/expectations/extensions/object.rb
82
96
  lib/spec/expectations/extensions/string_and_symbol.rb
83
97
  lib/spec/expectations/handler.rb
84
98
  lib/spec/expectations/wrap_expectation.rb
85
- lib/spec/extensions.rb
86
- lib/spec/extensions/class.rb
87
99
  lib/spec/interop/test.rb
88
100
  lib/spec/interop/test/unit/autorunner.rb
89
101
  lib/spec/interop/test/unit/testcase.rb
@@ -103,6 +115,7 @@ lib/spec/matchers/has.rb
103
115
  lib/spec/matchers/have.rb
104
116
  lib/spec/matchers/include.rb
105
117
  lib/spec/matchers/match.rb
118
+ lib/spec/matchers/match_array.rb
106
119
  lib/spec/matchers/method_missing.rb
107
120
  lib/spec/matchers/operator_matcher.rb
108
121
  lib/spec/matchers/raise_error.rb
@@ -173,14 +186,17 @@ lib/spec/story/step_mother.rb
173
186
  lib/spec/story/story.rb
174
187
  lib/spec/story/world.rb
175
188
  lib/spec/version.rb
176
- plugins/mock_frameworks/flexmock.rb
177
- plugins/mock_frameworks/mocha.rb
178
- plugins/mock_frameworks/rr.rb
179
- plugins/mock_frameworks/rspec.rb
180
- rake_tasks/examples.rake
181
- rake_tasks/examples_with_rcov.rake
182
- rake_tasks/failing_examples_with_html.rake
183
- rake_tasks/verify_rcov.rake
189
+ resources/rake/examples.rake
190
+ resources/rake/examples_with_rcov.rake
191
+ resources/rake/failing_examples_with_html.rake
192
+ resources/rake/verify_rcov.rake
193
+ resources/spec/before_blocks_example.rb
194
+ resources/spec/example_group_with_should_methods.rb
195
+ resources/spec/simple_spec.rb
196
+ resources/spec/spec_with_flexmock.rb
197
+ resources/test/spec_and_test_together.rb
198
+ resources/test/spec_including_test_but_not_unit.rb
199
+ resources/test/test_case_with_should_methods.rb
184
200
  rspec.gemspec
185
201
  spec/README.jruby
186
202
  spec/autotest/autotest_helper.rb
@@ -191,7 +207,6 @@ spec/autotest/rspec_spec.rb
191
207
  spec/rspec_suite.rb
192
208
  spec/ruby_forker.rb
193
209
  spec/spec.opts
194
- spec/spec/adapters/ruby_engine_spec.rb
195
210
  spec/spec/dsl/main_spec.rb
196
211
  spec/spec/example/configuration_spec.rb
197
212
  spec/spec/example/example_group_class_definition_spec.rb
@@ -201,6 +216,7 @@ spec/spec/example/example_group_spec.rb
201
216
  spec/spec/example/example_matcher_spec.rb
202
217
  spec/spec/example/example_methods_spec.rb
203
218
  spec/spec/example/example_runner_spec.rb
219
+ spec/spec/example/helper_method_spec.rb
204
220
  spec/spec/example/nested_example_group_spec.rb
205
221
  spec/spec/example/pending_module_spec.rb
206
222
  spec/spec/example/predicate_matcher_spec.rb
@@ -233,6 +249,7 @@ spec/spec/matchers/handler_spec.rb
233
249
  spec/spec/matchers/has_spec.rb
234
250
  spec/spec/matchers/have_spec.rb
235
251
  spec/spec/matchers/include_spec.rb
252
+ spec/spec/matchers/match_array_spec.rb
236
253
  spec/spec/matchers/match_spec.rb
237
254
  spec/spec/matchers/matcher_methods_spec.rb
238
255
  spec/spec/matchers/mock_constraint_matchers_spec.rb
@@ -258,6 +275,7 @@ spec/spec/mocks/bug_report_8165_spec.rb
258
275
  spec/spec/mocks/bug_report_8302_spec.rb
259
276
  spec/spec/mocks/failing_mock_argument_constraints_spec.rb
260
277
  spec/spec/mocks/hash_including_matcher_spec.rb
278
+ spec/spec/mocks/hash_not_including_matcher_spec.rb
261
279
  spec/spec/mocks/mock_ordering_spec.rb
262
280
  spec/spec/mocks/mock_space_spec.rb
263
281
  spec/spec/mocks/mock_spec.rb
@@ -314,6 +332,7 @@ spec/spec/runner/reporter_spec.rb
314
332
  spec/spec/runner/resources/a_bar.rb
315
333
  spec/spec/runner/resources/a_foo.rb
316
334
  spec/spec/runner/resources/a_spec.rb
335
+ spec/spec/runner/resources/custom_example_group_runner.rb
317
336
  spec/spec/runner/spec.opts
318
337
  spec/spec/runner/spec_drb.opts
319
338
  spec/spec/runner/spec_parser/spec_parser_fixture.rb
@@ -321,6 +340,7 @@ spec/spec/runner/spec_parser_spec.rb
321
340
  spec/spec/runner/spec_spaced.opts
322
341
  spec/spec/runner_spec.rb
323
342
  spec/spec/spec_classes.rb
343
+ spec/spec/spec_spec.rb
324
344
  spec/spec/story/builders.rb
325
345
  spec/spec/story/extensions/main_spec.rb
326
346
  spec/spec/story/extensions_spec.rb
@@ -340,37 +360,6 @@ spec/spec/story/story_helper.rb
340
360
  spec/spec/story/story_spec.rb
341
361
  spec/spec/story/world_spec.rb
342
362
  spec/spec_helper.rb
343
- stories/all.rb
344
- stories/configuration/before_blocks.story
345
- stories/configuration/stories.rb
346
- stories/example_groups/autogenerated_docstrings
347
- stories/example_groups/example_group_with_should_methods
348
- stories/example_groups/nested_groups
349
- stories/example_groups/output
350
- stories/example_groups/stories.rb
351
- stories/helper.rb
352
- stories/interop/examples_and_tests_together
353
- stories/interop/stories.rb
354
- stories/interop/test_but_not_test_unit
355
- stories/interop/test_case_with_should_methods
356
- stories/mock_framework_integration/stories.rb
357
- stories/mock_framework_integration/use_flexmock.story
358
- stories/pending_stories/README
359
- stories/resources/helpers/cmdline.rb
360
- stories/resources/helpers/story_helper.rb
361
- stories/resources/matchers/smart_match.rb
362
- stories/resources/spec/before_blocks_example.rb
363
- stories/resources/spec/example_group_with_should_methods.rb
364
- stories/resources/spec/simple_spec.rb
365
- stories/resources/spec/spec_with_flexmock.rb
366
- stories/resources/steps/running_rspec.rb
367
- stories/resources/stories/failing_story.rb
368
- stories/resources/test/spec_and_test_together.rb
369
- stories/resources/test/spec_including_test_but_not_unit.rb
370
- stories/resources/test/test_case_with_should_methods.rb
371
- stories/stories/multiline_steps.story
372
- stories/stories/steps/multiline_steps.rb
373
- stories/stories/stories.rb
374
363
  story_server/prototype/javascripts/builder.js
375
364
  story_server/prototype/javascripts/controls.js
376
365
  story_server/prototype/javascripts/dragdrop.js
data/README.txt CHANGED
@@ -1,31 +1,49 @@
1
1
  = RSpec
2
2
 
3
3
  * http://rspec.info
4
- * http://rspec.info/rdoc/
5
4
  * http://rubyforge.org/projects/rspec
6
5
  * http://github.com/dchelimsky/rspec/wikis
7
6
  * mailto:rspec-devel@rubyforge.org
8
7
 
9
8
  == DESCRIPTION:
10
9
 
11
- RSpec is a Behaviour Driven Development framework with tools to express User
12
- Stories with Executable Scenarios and Executable Examples at the code level.
10
+ RSpec is a Behaviour Driven Development framework for writing executable code
11
+ examples.
13
12
 
14
13
  == FEATURES:
15
14
 
16
- * Spec::Story provides a framework for expressing User Stories and Scenarios
17
- * Spec::Example provides a framework for expressing Isolated Examples
18
- * Spec::Matchers provides Expression Matchers for use with Spec::Expectations and Spec::Mocks.
15
+ * Spec::Example provides a framework for expressing executable code examples
16
+ * Spec::Expectations adds #should and #should_not to every object
17
+ * Spec::Matchers provides Expression Matchers for use with #should and #should_not
18
+ * Spec::Mocks is a full featured mocking/stubbing library
19
19
 
20
20
  == SYNOPSIS:
21
21
 
22
- Spec::Expectations supports setting expectations on your objects so you
23
- can do things like:
24
-
25
- result.should equal(expected_result)
22
+ describe Account do
23
+ context "transfering money" do
24
+ it "deposits transfer amount to the other account" do
25
+ source = Account.new(50, :USD)
26
+ target = mock('target account')
27
+ target.should_receive(:deposit).with(Money.new(5, :USD))
28
+ source.transfer(5, :USD).to(target)
29
+ end
30
+
31
+ it "reduces its balance by the transfer amount" do
32
+ source = Account.new(50, :USD)
33
+ target = stub('target account')
34
+ source.transfer(5, :USD).to(target)
35
+ source.balance.should == Money.new(45, :USD)
36
+ end
37
+ end
38
+ end
26
39
 
27
- Spec::Mocks supports creating Mock Objects, Stubs, and adding Mock/Stub
28
- behaviour to your existing objects.
40
+ $ spec spec/account_spec.rb --format nested
41
+ Account
42
+ transfering money
43
+ deposits transfer amount to the other account
44
+ reduces its balance by the transfer amount
45
+
46
+ 2 examples, 0 failures
29
47
 
30
48
  == INSTALL:
31
49
 
data/Rakefile CHANGED
@@ -5,6 +5,7 @@ require 'rubygems'
5
5
  require 'hoe'
6
6
  require 'spec/version'
7
7
  require 'spec/rake/spectask'
8
+ require 'cucumber/rake/task'
8
9
 
9
10
  class Hoe
10
11
  def extra_deps
@@ -19,6 +20,7 @@ Hoe.new('rspec', Spec::VERSION::STRING) do |p|
19
20
  p.description = "Behaviour Driven Development for Ruby."
20
21
  p.rubyforge_name = 'rspec'
21
22
  p.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
23
+ p.extra_deps = [["cucumber",">= 0.1.13"]]
22
24
  p.remote_rdoc_dir = "rspec/#{Spec::VERSION::STRING}"
23
25
  end
24
26
 
@@ -26,14 +28,14 @@ end
26
28
  Rake.application.instance_variable_get('@tasks').delete(task)
27
29
  end
28
30
 
29
- task :verify_rcov => [:spec, :stories]
31
+ task :verify_rcov => [:spec, :features]
30
32
  task :default => :verify_rcov
31
33
 
32
34
  # # Some of the tasks are in separate files since they are also part of the website documentation
33
- load File.dirname(__FILE__) + '/rake_tasks/examples.rake'
34
- load File.dirname(__FILE__) + '/rake_tasks/examples_with_rcov.rake'
35
- load File.dirname(__FILE__) + '/rake_tasks/failing_examples_with_html.rake'
36
- load File.dirname(__FILE__) + '/rake_tasks/verify_rcov.rake'
35
+ load File.dirname(__FILE__) + '/resources/rake/examples.rake'
36
+ load File.dirname(__FILE__) + '/resources/rake/examples_with_rcov.rake'
37
+ load File.dirname(__FILE__) + '/resources/rake/failing_examples_with_html.rake'
38
+ load File.dirname(__FILE__) + '/resources/rake/verify_rcov.rake'
37
39
 
38
40
  desc "Run all specs"
39
41
  Spec::Rake::SpecTask.new do |t|
@@ -46,10 +48,8 @@ Spec::Rake::SpecTask.new do |t|
46
48
  end
47
49
  end
48
50
 
49
- desc "Run all stories"
50
- task :stories do
51
- ruby "stories/all.rb --colour --format plain"
52
- end
51
+ desc "Run Cucumber features"
52
+ Cucumber::Rake::Task.new do; end
53
53
 
54
54
  desc "Run failing examples (see failure output)"
55
55
  Spec::Rake::SpecTask.new('failing_examples') do |t|
@@ -5,7 +5,7 @@ Story: before suite
5
5
 
6
6
  Scenario: running with ruby
7
7
 
8
- Given the file ../resources/spec/before_blocks_example.rb
8
+ Given the file ../../resources/spec/before_blocks_example.rb
9
9
 
10
10
  When I run it with the ruby interpreter
11
11
 
@@ -13,7 +13,7 @@ Story: before suite
13
13
 
14
14
  Scenario: running with spec
15
15
 
16
- Given the file ../resources/spec/before_blocks_example.rb
16
+ Given the file ../../resources/spec/before_blocks_example.rb
17
17
 
18
18
  When I run it with the spec script
19
19
 
@@ -1,4 +1,4 @@
1
- Story: autogenerated docstrings
1
+ Feature: autogenerated docstrings
2
2
 
3
3
  As an RSpec user
4
4
  I want examples to generate their own names
@@ -1,17 +1,17 @@
1
- Story: Spec::ExampleGroup with should methods
1
+ Feature: Spec::ExampleGroup with should methods
2
2
 
3
3
  As an RSpec adopter accustomed to classes and methods
4
4
  I want to use should_* methods in an ExampleGroup
5
5
  So that I use RSpec with classes and methods that look more like RSpec examples
6
6
 
7
7
  Scenario: Run with ruby
8
- Given the file spec/example_group_with_should_methods.rb
8
+ Given the file ../../resources/spec/example_group_with_should_methods.rb
9
9
  When I run it with the ruby interpreter
10
10
  Then the exit code should be 256
11
11
  And the stdout should match "2 examples, 1 failure"
12
12
 
13
13
  Scenario: Run with spec
14
- Given the file spec/example_group_with_should_methods.rb
14
+ Given the file ../../resources/spec/example_group_with_should_methods.rb
15
15
  When I run it with the spec script
16
16
  Then the exit code should be 256
17
17
  And the stdout should match "2 examples, 1 failure"
@@ -1,4 +1,4 @@
1
- Story: Nested example groups
1
+ Feature: Nested example groups
2
2
 
3
3
  As an RSpec user
4
4
  I want to nest examples groups
@@ -1,25 +1,20 @@
1
- Story: Getting correct output
1
+ Feature: Getting correct output
2
2
 
3
3
  As an RSpec user
4
4
  I want to see output only once
5
5
  So that I don't get confused
6
6
 
7
7
  Scenario: Run with ruby
8
- Given the file spec/simple_spec.rb
8
+ Given the file ../../resources/spec/simple_spec.rb
9
9
  When I run it with the ruby interpreter
10
10
  Then the exit code should be 0
11
11
  And the stdout should not match /\d+ tests, \d+ assertions, \d+ failures, \d+ errors/m
12
12
  And the stdout should match "1 example, 0 failures"
13
13
 
14
14
  Scenario: Run with CommandLine object
15
- Given the file spec/simple_spec.rb
15
+ Given the file ../../resources/spec/simple_spec.rb
16
16
  When I run it with the CommandLine object
17
17
  Then the exit code should be 0
18
18
  And the stdout should not match "Loaded suite"
19
19
  And the stdout should not match /\d+ tests, \d+ assertions, \d+ failures, \d+ errors/m
20
20
  And the stdout should match "1 example, 0 failures"
21
-
22
- Scenario: Tweak backtrace
23
- Given the file stories/failing_story.rb
24
- When I run it with the ruby interpreter
25
- Then the stdout should not match /\/lib\/spec\//
@@ -1,11 +1,11 @@
1
- Story: Spec and test together
1
+ Feature: Spec and test together
2
2
 
3
3
  As an RSpec adopter with existing Test::Unit tests
4
4
  I want to run a few specs alongside my existing Test::Unit tests
5
5
  So that I can experience a smooth, gradual migration path
6
6
 
7
7
  Scenario: Run with ruby
8
- Given the file test/spec_and_test_together.rb
8
+ Given the file ../../resources/test/spec_and_test_together.rb
9
9
 
10
10
  When I run it with the ruby interpreter -fs
11
11
 
@@ -16,13 +16,14 @@ Story: Spec and test together
16
16
  And the stdout should match "10 examples, 6 failures"
17
17
  And the stdout should match /expected: 40,\s*got: 4/m
18
18
  And the stdout should match /expected: 50,\s*got: 5/m
19
+
19
20
  Scenario: Run with spec
20
- Given the file test/spec_and_test_together.rb
21
+ Given the file ../../resources/test/spec_and_test_together.rb
21
22
 
22
23
  When I run it with the spec script -fs
23
24
 
24
25
  Then the exit code should be 256
25
- Ands the stdout should match "ATest"
26
+ And the stdout should match "ATest"
26
27
  And the stdout should match "Test::Unit::AssertionFailedError in 'An Example should fail with assert'"
27
28
  And the stdout should match "'An Example should fail with should' FAILED"
28
29
  And the stdout should match "10 examples, 6 failures"
@@ -4,11 +4,11 @@ Story: Test is defined, but not Test::Unit
4
4
  I want to run examples without getting Test::Unit NameErrors
5
5
 
6
6
  Scenario: Run with ruby
7
- Given the file test/spec_including_test_but_not_unit.rb
7
+ Given the file ../../resources/test/spec_including_test_but_not_unit.rb
8
8
  When I run it with the ruby interpreter
9
9
  Then the stderr should not match "Test::Unit"
10
10
 
11
11
  Scenario: Run with spec
12
- Given the file test/spec_including_test_but_not_unit.rb
12
+ Given the file ../../resources/test/spec_including_test_but_not_unit.rb
13
13
  When I run it with the spec script
14
14
  Then the stderr should not match "Test::Unit"
@@ -5,13 +5,13 @@ Story: Test::Unit::TestCase extended by rspec with should methods
5
5
  So that I use RSpec with classes and methods that look more like RSpec examples
6
6
 
7
7
  Scenario: Run with ruby
8
- Given the file test/test_case_with_should_methods.rb
8
+ Given the file ../../resources/test/test_case_with_should_methods.rb
9
9
  When I run it with the ruby interpreter
10
10
  Then the exit code should be 256
11
11
  And the stdout should match "5 examples, 3 failures"
12
12
 
13
13
  Scenario: Run with spec
14
- Given the file test/test_case_with_should_methods.rb
14
+ Given the file ../../resources/test/test_case_with_should_methods.rb
15
15
  When I run it with the spec script
16
16
  Then the exit code should be 256
17
17
  And the stdout should match "5 examples, 3 failures"
@@ -4,6 +4,6 @@ Story: Getting correct output with flexmock
4
4
  I want to be able to use flexmock without rspec mocks interfering
5
5
 
6
6
  Scenario: Mock with flexmock
7
- Given the file spec/spec_with_flexmock.rb
7
+ Given the file ../../resources/spec/spec_with_flexmock.rb
8
8
  When I run it with the ruby interpreter
9
9
  Then the exit code should be 0
@@ -0,0 +1,48 @@
1
+ Given /^the file (.*)$/ do |relative_path|
2
+ @path = File.expand_path(File.join(File.dirname(__FILE__), "..", "support", relative_path))
3
+ unless File.exist?(@path)
4
+ raise "could not find file at #{@path}"
5
+ end
6
+ end
7
+
8
+ When /^I run it with the (.*)$/ do |interpreter|
9
+ stderr_file = Tempfile.new('rspec')
10
+ stderr_file.close
11
+ @stdout = case(interpreter)
12
+ when /^ruby interpreter/
13
+ args = interpreter.gsub('ruby interpreter','')
14
+ ruby("#{@path}#{args}", stderr_file.path)
15
+ when /^spec script/
16
+ args = interpreter.gsub('spec script','')
17
+ spec("#{@path}#{args}", stderr_file.path)
18
+ when 'CommandLine object' then cmdline(@path, stderr_file.path)
19
+ else raise "Unknown interpreter: #{interpreter}"
20
+ end
21
+ @stderr = IO.read(stderr_file.path)
22
+ @exit_code = $?.to_i
23
+ end
24
+
25
+ Then /^the (.*) should match (.*)$/ do |stream, string_or_regex|
26
+ written = case(stream)
27
+ when 'stdout' then @stdout
28
+ when 'stderr' then @stderr
29
+ else raise "Unknown stream: #{stream}"
30
+ end
31
+ written.should smart_match(string_or_regex)
32
+ end
33
+
34
+ Then /^the (.*) should not match (.*)$/ do |stream, string_or_regex|
35
+ written = case(stream)
36
+ when 'stdout' then @stdout
37
+ when 'stderr' then @stderr
38
+ else raise "Unknown stream: #{stream}"
39
+ end
40
+ written.should_not smart_match(string_or_regex)
41
+ end
42
+
43
+
44
+ Then /^the exit code should be (\d+)$/ do |exit_code|
45
+ if @exit_code != exit_code.to_i
46
+ raise "Did not exit with #{exit_code}, but with #{@exit_code}. Standard error:\n#{@stderr}"
47
+ end
48
+ end
@@ -0,0 +1,25 @@
1
+ require 'tempfile'
2
+ require File.dirname(__FILE__) + '/../../spec/ruby_forker'
3
+ require File.dirname(__FILE__) + '/matchers/smart_match'
4
+
5
+ require 'spec/expectations'
6
+ require 'spec/matchers'
7
+
8
+ module RspecWorld
9
+ include Spec::Expectations
10
+ include Spec::Matchers
11
+ include RubyForker
12
+
13
+ def spec(args, stderr)
14
+ ruby("#{File.dirname(__FILE__) + '/../../bin/spec'} #{args}", stderr)
15
+ end
16
+
17
+ def cmdline(args, stderr)
18
+ ruby("#{File.dirname(__FILE__) + '/helpers/cmdline.rb'} #{args}", stderr)
19
+ end
20
+ end
21
+
22
+ World do |world|
23
+ world.extend(RspecWorld)
24
+ world
25
+ end
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "spec", "mocks"))
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec", "mocks"))
2
2
  require 'spec/mocks/framework'
3
3
  require 'spec/mocks/extensions'
4
4
 
@@ -28,7 +28,7 @@ class Autotest::Rspec < Autotest
28
28
  def consolidate_failures(failed)
29
29
  filters = new_hash_of_arrays
30
30
  failed.each do |spec, trace|
31
- if trace =~ /\n(\.\/)?(.*spec\.rb):[\d]+:\Z?/
31
+ if trace =~ /\n(\.\/)?(.*spec\.rb):[\d]+:/
32
32
  filters[$2] << spec
33
33
  end
34
34
  end
@@ -37,7 +37,8 @@ class Autotest::Rspec < Autotest
37
37
 
38
38
  def make_test_cmd(files_to_test)
39
39
  return '' if files_to_test.empty?
40
- return "#{ruby} -S #{files_to_test.keys.flatten.join(' ')} #{add_options_if_present}"
40
+ spec_program = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec'))
41
+ return "#{ruby} #{spec_program} #{files_to_test.keys.flatten.join(' ')} #{add_options_if_present}"
41
42
  end
42
43
 
43
44
  def add_options_if_present # :nodoc:
data/lib/spec/dsl/main.rb CHANGED
@@ -20,6 +20,7 @@ module Spec
20
20
  # register special implementations.
21
21
  #
22
22
  def describe(*args, &block)
23
+ Spec::Example::add_spec_path_to(args)
23
24
  Spec::Example::ExampleGroupFactory.create_example_group(*args, &block)
24
25
  end
25
26
  alias :context :describe
@@ -39,11 +40,12 @@ module Spec
39
40
  # ...
40
41
  # end
41
42
  # end
42
- def share_examples_for(name, &block)
43
- Spec::Example::SharedExampleGroup.register(name, &block)
43
+ def share_examples_for(*args, &block)
44
+ Spec::Example::add_spec_path_to(args)
45
+ Spec::Example::ExampleGroupFactory.create_shared_example_group(*args, &block)
44
46
  end
45
47
  alias :shared_examples_for :share_examples_for
46
-
48
+
47
49
  # Creates a Shared Example Group and assigns it to a constant
48
50
  #
49
51
  # share_as :AllEditions do
@@ -70,7 +72,9 @@ module Spec
70
72
  # end
71
73
  def share_as(name, &block)
72
74
  begin
73
- Object.const_set(name, Spec::Example::SharedExampleGroup.register(name, &block))
75
+ args = [name]
76
+ Spec::Example::add_spec_path_to(args)
77
+ Object.const_set(name, Spec::Example::ExampleGroupFactory.create_shared_example_group(*args, &block))
74
78
  rescue NameError => e
75
79
  raise NameError.new(e.message + "\nThe first argument to share_as must be a legal name for a constant\n")
76
80
  end
@@ -160,7 +160,7 @@ module Spec
160
160
  end
161
161
 
162
162
  def mock_framework_path(framework_name)
163
- File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "plugins", "mock_frameworks", framework_name))
163
+ File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "adapters", "mock_frameworks", framework_name))
164
164
  end
165
165
  end
166
166
  end
@@ -52,12 +52,16 @@ module Spec
52
52
  def create_example_group(*args, &block)
53
53
  raise ArgumentError if args.empty?
54
54
  raise ArgumentError unless block
55
- args << {} unless Hash === args.last
56
- args.last[:spec_path] ||= File.expand_path(caller(0)[2])
55
+ Spec::Example::add_spec_path_to(args)
57
56
  superclass = determine_superclass(args.last)
58
57
  superclass.describe(*args, &block)
59
58
  end
60
59
 
60
+ def create_shared_example_group(*args, &block)
61
+ Spec::Example::add_spec_path_to(args)
62
+ SharedExampleGroup.register(*args, &block)
63
+ end
64
+
61
65
  protected
62
66
 
63
67
  def determine_superclass(opts)