rspec 1.1.12 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. data/.autotest +2 -1
  2. data/.document +7 -0
  3. data/History.txt +58 -0
  4. data/License.txt +1 -1
  5. data/Manifest.txt +45 -82
  6. data/README.txt +3 -6
  7. data/Rakefile +33 -13
  8. data/Ruby1.9.markdown +32 -0
  9. data/TODO.txt +10 -4
  10. data/Upgrade.markdown +63 -0
  11. data/bin/spec +1 -1
  12. data/cucumber.yml +3 -0
  13. data/examples/failing/{failing_autogenerated_docstrings_example.rb → failing_implicit_docstrings_example.rb} +0 -0
  14. data/examples/failing/pending_example.rb +9 -0
  15. data/examples/failing/spec_helper.rb +1 -1
  16. data/examples/passing/{custom_expectation_matchers.rb → custom_matchers.rb} +0 -0
  17. data/examples/passing/filtered_formatter.rb +18 -0
  18. data/examples/passing/filtered_formatter_example.rb +31 -0
  19. data/examples/passing/implicit_docstrings_example.rb +18 -0
  20. data/examples/passing/spec_helper.rb +1 -1
  21. data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +17 -18
  22. data/features/before_and_after_blocks/before_and_after_blocks.feature +4 -4
  23. data/features/example_groups/example_group_with_should_methods.feature +1 -1
  24. data/features/example_groups/{autogenerated_docstrings.feature → implicit_docstrings.feature} +7 -9
  25. data/features/example_groups/nested_groups.feature +1 -1
  26. data/features/heckle/heckle.feature +56 -0
  27. data/features/interop/examples_and_tests_together.feature +1 -1
  28. data/features/interop/test_but_not_test_unit.feature +1 -1
  29. data/features/interop/test_case_with_should_methods.feature +1 -1
  30. data/features/matchers/create_matcher.feature +115 -0
  31. data/features/mock_framework_integration/use_flexmock.feature +22 -4
  32. data/features/mock_framework_integration/use_mocha.feature +27 -0
  33. data/features/mock_framework_integration/use_rr.feature +27 -0
  34. data/features/mocks/mix_stubs_and_mocks.feature +22 -0
  35. data/features/pending/pending_examples.feature +81 -0
  36. data/features/step_definitions/running_rspec.rb +5 -3
  37. data/features/support/env.rb +1 -1
  38. data/features/support/matchers/smart_match.rb +2 -2
  39. data/lib/autotest/rspec.rb +1 -1
  40. data/lib/spec.rb +1 -1
  41. data/lib/{adapters → spec/adapters}/mock_frameworks/flexmock.rb +0 -0
  42. data/lib/{adapters → spec/adapters}/mock_frameworks/mocha.rb +0 -0
  43. data/lib/{adapters → spec/adapters}/mock_frameworks/rr.rb +0 -0
  44. data/lib/{adapters → spec/adapters}/mock_frameworks/rspec.rb +0 -1
  45. data/lib/spec/autorun.rb +3 -0
  46. data/lib/spec/dsl.rb +3 -1
  47. data/lib/spec/dsl/matchers.rb +13 -0
  48. data/lib/spec/example.rb +4 -0
  49. data/lib/spec/example/before_and_after_hooks.rb +5 -20
  50. data/lib/spec/example/errors.rb +3 -3
  51. data/lib/spec/example/example_description.rb +15 -0
  52. data/lib/spec/example/example_group.rb +0 -15
  53. data/lib/spec/example/example_group_factory.rb +34 -46
  54. data/lib/spec/example/example_group_hierarchy.rb +53 -0
  55. data/lib/spec/example/example_group_methods.rb +101 -211
  56. data/lib/spec/example/example_methods.rb +61 -81
  57. data/lib/spec/example/module_reopening_fix.rb +23 -1
  58. data/lib/spec/example/pending.rb +3 -2
  59. data/lib/spec/example/predicate_matchers.rb +47 -0
  60. data/lib/spec/example/subject.rb +91 -0
  61. data/lib/spec/expectations.rb +1 -1
  62. data/lib/spec/expectations/differs/default.rb +0 -1
  63. data/lib/spec/expectations/extensions.rb +0 -1
  64. data/lib/spec/expectations/handler.rb +13 -6
  65. data/lib/spec/interop/test.rb +5 -0
  66. data/lib/spec/interop/test/unit/testcase.rb +5 -22
  67. data/lib/spec/matchers.rb +22 -8
  68. data/lib/spec/matchers/be.rb +4 -9
  69. data/lib/spec/matchers/be_close.rb +20 -5
  70. data/lib/spec/matchers/be_instance_of.rb +45 -0
  71. data/lib/spec/matchers/be_kind_of.rb +45 -0
  72. data/lib/spec/matchers/change.rb +8 -6
  73. data/lib/spec/matchers/compatibility.rb +14 -0
  74. data/lib/spec/matchers/eql.rb +24 -6
  75. data/lib/spec/matchers/equal.rb +24 -6
  76. data/lib/spec/matchers/exist.rb +21 -5
  77. data/lib/spec/matchers/extensions/instance_exec.rb +25 -0
  78. data/lib/spec/matchers/generated_descriptions.rb +2 -2
  79. data/lib/spec/matchers/has.rb +28 -11
  80. data/lib/spec/matchers/have.rb +2 -2
  81. data/lib/spec/matchers/include.rb +2 -2
  82. data/lib/spec/matchers/match.rb +25 -7
  83. data/lib/spec/matchers/match_array.rb +3 -3
  84. data/lib/spec/matchers/matcher.rb +51 -0
  85. data/lib/spec/matchers/method_missing.rb +2 -2
  86. data/lib/spec/matchers/operator_matcher.rb +12 -5
  87. data/lib/spec/matchers/raise_error.rb +3 -3
  88. data/lib/spec/matchers/respond_to.rb +3 -3
  89. data/lib/spec/matchers/satisfy.rb +7 -7
  90. data/lib/spec/matchers/throw_symbol.rb +3 -5
  91. data/lib/spec/mocks.rb +3 -3
  92. data/lib/spec/mocks/argument_expectation.rb +15 -15
  93. data/lib/spec/mocks/{argument_constraints.rb → argument_matchers.rb} +19 -23
  94. data/lib/spec/mocks/error_generator.rb +5 -8
  95. data/lib/spec/mocks/framework.rb +1 -1
  96. data/lib/spec/mocks/message_expectation.rb +5 -13
  97. data/lib/spec/mocks/mock.rb +4 -5
  98. data/lib/spec/mocks/proxy.rb +9 -5
  99. data/lib/spec/mocks/spec_methods.rb +10 -1
  100. data/lib/spec/rake/spectask.rb +0 -1
  101. data/lib/spec/runner.rb +6 -28
  102. data/lib/spec/runner/configuration.rb +3 -3
  103. data/lib/spec/runner/drb_command_line.rb +2 -1
  104. data/lib/spec/runner/example_group_runner.rb +3 -2
  105. data/lib/spec/runner/formatter/base_text_formatter.rb +34 -19
  106. data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +3 -5
  107. data/lib/spec/runner/formatter/html_formatter.rb +2 -3
  108. data/lib/spec/runner/formatter/nested_text_formatter.rb +7 -25
  109. data/lib/spec/runner/formatter/progress_bar_formatter.rb +1 -1
  110. data/lib/spec/runner/formatter/snippet_extractor.rb +1 -1
  111. data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -7
  112. data/lib/spec/runner/heckle_runner.rb +3 -6
  113. data/lib/spec/runner/heckle_runner_unsupported.rb +1 -1
  114. data/lib/spec/runner/option_parser.rb +19 -21
  115. data/lib/spec/runner/options.rb +32 -27
  116. data/lib/spec/runner/reporter.rb +8 -9
  117. data/lib/spec/test/unit.rb +10 -0
  118. data/lib/spec/version.rb +2 -2
  119. data/{features/support → resources}/helpers/cmdline.rb +2 -2
  120. data/resources/rake/verify_rcov.rake +1 -1
  121. data/resources/spec/example_group_with_should_methods.rb +1 -1
  122. data/resources/spec/simple_spec.rb +1 -1
  123. data/resources/test/spec_and_test_together.rb +2 -3
  124. data/resources/test/spec_including_test_but_not_unit.rb +1 -1
  125. data/resources/test/test_case_with_should_methods.rb +2 -3
  126. data/spec/autotest/autotest_helper.rb +0 -1
  127. data/spec/autotest/rspec_spec.rb +95 -98
  128. data/spec/spec/dsl/main_spec.rb +3 -3
  129. data/spec/spec/dsl/matchers_spec.rb +25 -0
  130. data/spec/spec/example/example_group_class_definition_spec.rb +14 -15
  131. data/spec/spec/example/example_group_factory_spec.rb +31 -44
  132. data/spec/spec/example/example_group_methods_spec.rb +86 -52
  133. data/spec/spec/example/example_group_spec.rb +32 -79
  134. data/spec/spec/example/example_matcher_spec.rb +10 -10
  135. data/spec/spec/example/example_methods_spec.rb +108 -242
  136. data/spec/spec/example/nested_example_group_spec.rb +2 -2
  137. data/spec/spec/example/pending_module_spec.rb +66 -41
  138. data/spec/spec/example/shared_example_group_spec.rb +4 -4
  139. data/spec/spec/{matchers → expectations}/handler_spec.rb +52 -4
  140. data/spec/spec/interop/test/unit/resources/spec_that_fails.rb +2 -2
  141. data/spec/spec/interop/test/unit/resources/spec_that_passes.rb +2 -2
  142. data/spec/spec/interop/test/unit/resources/spec_with_errors.rb +2 -2
  143. data/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb +2 -2
  144. data/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +2 -2
  145. data/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +2 -2
  146. data/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +2 -2
  147. data/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +2 -2
  148. data/spec/spec/interop/test/unit/testcase_spec.rb +0 -4
  149. data/spec/spec/matchers/be_close_spec.rb +1 -1
  150. data/spec/spec/matchers/be_instance_of_spec.rb +29 -0
  151. data/spec/spec/matchers/be_kind_of_spec.rb +29 -0
  152. data/spec/spec/matchers/change_spec.rb +20 -0
  153. data/spec/spec/matchers/compatibility_spec.rb +34 -0
  154. data/spec/spec/matchers/description_generation_spec.rb +0 -12
  155. data/spec/spec/matchers/eql_spec.rb +2 -2
  156. data/spec/spec/matchers/equal_spec.rb +2 -2
  157. data/spec/spec/matchers/exist_spec.rb +8 -4
  158. data/spec/spec/matchers/have_spec.rb +4 -4
  159. data/spec/spec/matchers/match_spec.rb +2 -2
  160. data/spec/spec/matchers/matcher_methods_spec.rb +1 -1
  161. data/spec/spec/matchers/matcher_spec.rb +97 -0
  162. data/spec/spec/matchers/throw_symbol_spec.rb +8 -8
  163. data/spec/spec/mocks/{bug_report_496.rb → bug_report_496_spec.rb} +0 -0
  164. data/spec/spec/mocks/{failing_mock_argument_constraints_spec.rb → failing_argument_matchers_spec.rb} +2 -2
  165. data/spec/spec/mocks/hash_including_matcher_spec.rb +4 -4
  166. data/spec/spec/mocks/hash_not_including_matcher_spec.rb +3 -3
  167. data/spec/spec/mocks/mock_spec.rb +27 -2
  168. data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
  169. data/spec/spec/mocks/partial_mock_spec.rb +18 -3
  170. data/spec/spec/mocks/{passing_mock_argument_constraints_spec.rb → passing_argument_matchers_spec.rb} +6 -6
  171. data/spec/spec/mocks/stubbed_message_expectations_spec.rb +13 -1
  172. data/spec/spec/package/bin_spec_spec.rb +2 -2
  173. data/spec/spec/runner/configuration_spec.rb +12 -12
  174. data/spec/spec/runner/drb_command_line_spec.rb +71 -73
  175. data/spec/spec/runner/formatter/base_text_formatter_spec.rb +82 -1
  176. data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +8 -8
  177. data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +4 -4
  178. data/spec/spec/runner/formatter/html_formatted-1.8.6.html +8 -8
  179. data/spec/spec/runner/formatter/html_formatted-1.8.7.html +38 -26
  180. data/spec/spec/runner/formatter/html_formatted-1.9.1.html +61 -53
  181. data/spec/spec/runner/formatter/html_formatter_spec.rb +100 -48
  182. data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +20 -34
  183. data/spec/spec/runner/formatter/profile_formatter_spec.rb +2 -1
  184. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +9 -6
  185. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +6 -6
  186. data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +20 -20
  187. data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +38 -26
  188. data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +55 -47
  189. data/spec/spec/runner/formatter/{spec_mate_formatter_spec.rb → text_mate_formatter_spec.rb} +11 -9
  190. data/spec/spec/runner/heckle_runner_spec.rb +1 -1
  191. data/spec/spec/runner/heckler_spec.rb +1 -1
  192. data/spec/spec/runner/option_parser_spec.rb +28 -11
  193. data/spec/spec/runner/options_spec.rb +34 -0
  194. data/spec/spec/runner/reporter_spec.rb +66 -62
  195. data/spec/spec/runner/resources/utf8_encoded.rb +1 -0
  196. data/spec/spec/runner/spec_drb.opts +1 -0
  197. data/spec/spec/runner_spec.rb +7 -5
  198. data/spec/spec_helper.rb +24 -2
  199. metadata +49 -90
  200. data/examples/passing/autogenerated_docstrings_example.rb +0 -25
  201. data/examples/passing/before_and_after_example.rb +0 -40
  202. data/examples/passing/behave_as_example.rb +0 -45
  203. data/examples/passing/legacy_spec.rb +0 -11
  204. data/examples/passing/priority.txt +0 -1
  205. data/features/support/helpers/story_helper.rb +0 -16
  206. data/lib/spec/expectations/extensions/string_and_symbol.rb +0 -17
  207. data/lib/spec/runner/formatter/story/html_formatter.rb +0 -174
  208. data/lib/spec/runner/formatter/story/plain_text_formatter.rb +0 -194
  209. data/lib/spec/runner/formatter/story/progress_bar_formatter.rb +0 -42
  210. data/lib/spec/story.rb +0 -10
  211. data/lib/spec/story/extensions.rb +0 -3
  212. data/lib/spec/story/extensions/main.rb +0 -86
  213. data/lib/spec/story/extensions/regexp.rb +0 -9
  214. data/lib/spec/story/extensions/string.rb +0 -9
  215. data/lib/spec/story/given_scenario.rb +0 -14
  216. data/lib/spec/story/runner.rb +0 -57
  217. data/lib/spec/story/runner/plain_text_story_runner.rb +0 -48
  218. data/lib/spec/story/runner/scenario_collector.rb +0 -18
  219. data/lib/spec/story/runner/scenario_runner.rb +0 -54
  220. data/lib/spec/story/runner/story_mediator.rb +0 -137
  221. data/lib/spec/story/runner/story_parser.rb +0 -247
  222. data/lib/spec/story/runner/story_runner.rb +0 -74
  223. data/lib/spec/story/scenario.rb +0 -14
  224. data/lib/spec/story/step.rb +0 -70
  225. data/lib/spec/story/step_group.rb +0 -89
  226. data/lib/spec/story/step_mother.rb +0 -38
  227. data/lib/spec/story/story.rb +0 -39
  228. data/lib/spec/story/world.rb +0 -124
  229. data/resources/spec/spec_with_flexmock.rb +0 -19
  230. data/rspec.gemspec +0 -32
  231. data/spec/spec/matchers/mock_constraint_matchers_spec.rb +0 -24
  232. data/spec/spec/runner/formatter/story/html_formatter_spec.rb +0 -135
  233. data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +0 -600
  234. data/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +0 -82
  235. data/spec/spec/spec_spec.rb +0 -21
  236. data/spec/spec/story/builders.rb +0 -46
  237. data/spec/spec/story/extensions/main_spec.rb +0 -161
  238. data/spec/spec/story/extensions_spec.rb +0 -14
  239. data/spec/spec/story/given_scenario_spec.rb +0 -27
  240. data/spec/spec/story/runner/plain_text_story_runner_spec.rb +0 -90
  241. data/spec/spec/story/runner/scenario_collector_spec.rb +0 -27
  242. data/spec/spec/story/runner/scenario_runner_spec.rb +0 -214
  243. data/spec/spec/story/runner/story_mediator_spec.rb +0 -143
  244. data/spec/spec/story/runner/story_parser_spec.rb +0 -401
  245. data/spec/spec/story/runner/story_runner_spec.rb +0 -294
  246. data/spec/spec/story/runner_spec.rb +0 -93
  247. data/spec/spec/story/scenario_spec.rb +0 -18
  248. data/spec/spec/story/step_group_spec.rb +0 -157
  249. data/spec/spec/story/step_mother_spec.rb +0 -84
  250. data/spec/spec/story/step_spec.rb +0 -272
  251. data/spec/spec/story/story_helper.rb +0 -2
  252. data/spec/spec/story/story_spec.rb +0 -84
  253. data/spec/spec/story/world_spec.rb +0 -423
  254. data/story_server/prototype/javascripts/builder.js +0 -136
  255. data/story_server/prototype/javascripts/controls.js +0 -972
  256. data/story_server/prototype/javascripts/dragdrop.js +0 -976
  257. data/story_server/prototype/javascripts/effects.js +0 -1117
  258. data/story_server/prototype/javascripts/prototype.js +0 -4140
  259. data/story_server/prototype/javascripts/rspec.js +0 -149
  260. data/story_server/prototype/javascripts/scriptaculous.js +0 -58
  261. data/story_server/prototype/javascripts/slider.js +0 -276
  262. data/story_server/prototype/javascripts/sound.js +0 -55
  263. data/story_server/prototype/javascripts/unittest.js +0 -568
  264. data/story_server/prototype/lib/server.rb +0 -24
  265. data/story_server/prototype/stories.html +0 -176
  266. data/story_server/prototype/stylesheets/rspec.css +0 -136
  267. data/story_server/prototype/stylesheets/test.css +0 -90
@@ -32,15 +32,14 @@ module Spec
32
32
  end
33
33
  end
34
34
 
35
- def failure(example, error)
35
+ def example_failed(example, error)
36
36
  backtrace_tweaker.tweak_backtrace(error)
37
- failure = Failure.new(example, error)
37
+ failure = Failure.new(example_groups.empty? ? "" : example_groups.last.description, example, error)
38
38
  @failures << failure
39
39
  formatters.each do |f|
40
40
  f.example_failed(example, @failures.length, failure)
41
41
  end
42
42
  end
43
- alias_method :example_failed, :failure
44
43
 
45
44
  def start(number_of_examples)
46
45
  clear
@@ -134,11 +133,10 @@ module Spec
134
133
  class Failure
135
134
  attr_reader :example, :exception
136
135
 
137
- def initialize(example, exception)
138
- @example = example
139
- @exception = exception
136
+ def initialize(group, example, exception)
137
+ @group, @example, @exception = group, example, exception
140
138
  end
141
-
139
+
142
140
  def header
143
141
  if expectation_not_met?
144
142
  "'#{example_name}' FAILED"
@@ -157,9 +155,10 @@ module Spec
157
155
  @exception.is_a?(Spec::Expectations::ExpectationNotMetError)
158
156
  end
159
157
 
160
- protected
158
+ protected
159
+
161
160
  def example_name
162
- @example.full_description
161
+ "#{@group} #{@example.description}"
163
162
  end
164
163
  end
165
164
  end
@@ -0,0 +1,10 @@
1
+ require 'spec/interop/test'
2
+
3
+ # Hack to stop active_support/dependencies from complaining about
4
+ # 'spec/test/unit' not defining Spec::Test::Unit
5
+ module Spec
6
+ module Test
7
+ module Unit
8
+ end
9
+ end
10
+ end
@@ -2,8 +2,8 @@ module Spec
2
2
  module VERSION
3
3
  unless defined? MAJOR
4
4
  MAJOR = 1
5
- MINOR = 1
6
- TINY = 12
5
+ MINOR = 2
6
+ TINY = 0
7
7
  MINESCULE = nil
8
8
 
9
9
 
@@ -1,7 +1,7 @@
1
- $:.push File.join(File.dirname(__FILE__), *%w[.. .. .. lib])
1
+ $:.push File.join(File.dirname(__FILE__), *%w[.. .. lib])
2
2
  require 'spec'
3
3
 
4
- # Uncommenting next line will break the output story (no output!!)
4
+ # Uncommenting next line will break the output feature (no output!!)
5
5
  # rspec_options
6
6
  options = Spec::Runner::OptionParser.parse(
7
7
  ARGV, $stderr, $stdout
@@ -1,7 +1,7 @@
1
1
  require 'rake'
2
2
  require 'spec/rake/verify_rcov'
3
3
 
4
- RCov::VerifyTask.new(:verify_rcov => :spec) do |t|
4
+ RCov::VerifyTask.new(:verify_rcov => 'spec:rcov') do |t|
5
5
  t.threshold = 100.0
6
6
  t.index_html = 'coverage/index.html'
7
7
  end
@@ -1,5 +1,5 @@
1
1
  $:.push File.join(File.dirname(__FILE__), *%w[.. .. lib])
2
- require 'spec'
2
+ require 'spec/autorun'
3
3
 
4
4
  class MySpec < Spec::ExampleGroup
5
5
  def should_pass_with_should
@@ -1,5 +1,5 @@
1
1
  $:.push File.join(File.dirname(__FILE__), *%w[.. .. lib])
2
- require 'spec'
2
+ require 'spec/autorun'
3
3
 
4
4
  describe "Running an Example" do
5
5
  it "should not output twice" do
@@ -1,7 +1,6 @@
1
1
  $:.push File.join(File.dirname(__FILE__), *%w[.. .. lib])
2
- require 'spec'
3
- # TODO - this should not be necessary, ay?
4
- require 'spec/interop/test'
2
+ require 'spec/autorun'
3
+ require 'spec/test/unit'
5
4
 
6
5
  describe "An Example" do
7
6
  it "should pass with assert" do
@@ -1,5 +1,5 @@
1
1
  $:.push File.join(File.dirname(__FILE__), *%w[.. .. lib])
2
- require 'spec'
2
+ require 'spec/autorun'
3
3
 
4
4
  module Test
5
5
  end
@@ -1,7 +1,6 @@
1
1
  $:.push File.join(File.dirname(__FILE__), *%w[.. .. lib])
2
- require 'test/unit'
3
- require 'spec'
4
- require 'spec/interop/test'
2
+ require 'spec/autorun'
3
+ require 'spec/test/unit'
5
4
 
6
5
  class MyTest < Test::Unit::TestCase
7
6
  def should_pass_with_should
@@ -1,4 +1,3 @@
1
- require "rubygems"
2
1
  require 'autotest'
3
2
  dir = File.dirname(__FILE__)
4
3
  require File.expand_path("#{dir}/../spec_helper")
@@ -1,114 +1,111 @@
1
1
  require File.dirname(__FILE__) + "/autotest_helper"
2
2
 
3
- class Autotest
4
-
5
- describe Rspec do
6
- describe "adding spec.opts --options" do
7
- before(:each) do
8
- @rspec_autotest = Rspec.new
9
- end
3
+ describe Autotest::Rspec do
4
+ describe "adding spec.opts --options" do
5
+ before(:each) do
6
+ @rspec_autotest = Autotest::Rspec.new
7
+ end
10
8
 
11
- it "should return the command line option to add spec.opts if the options file exists" do
12
- File.stub!(:exist?).and_return true
13
- @rspec_autotest.add_options_if_present.should == "-O spec/spec.opts "
14
- end
9
+ it "should return the command line option to add spec.opts if the options file exists" do
10
+ File.stub!(:exist?).and_return true
11
+ @rspec_autotest.add_options_if_present.should == "-O spec/spec.opts "
12
+ end
15
13
 
16
- it "should return an empty string if no spec.opts exists" do
17
- File.stub!(:exist?).and_return false
18
- Rspec.new.add_options_if_present.should == ""
19
- end
20
- end
21
-
22
- describe "commands" do
23
- before(:each) do
24
- @rspec_autotest = Rspec.new
25
- @rspec_autotest.stub!(:ruby).and_return "ruby"
26
- @rspec_autotest.stub!(:add_options_if_present).and_return "-O spec/spec.opts"
27
-
28
- @ruby = @rspec_autotest.ruby
29
- @spec_cmd = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec'))
30
- @options = @rspec_autotest.add_options_if_present
31
- @files_to_test = {
32
- :spec => ["file_one", "file_two"]
33
- }
34
- # this is not the inner representation of Autotest!
35
- @rspec_autotest.stub!(:files_to_test).and_return @files_to_test
36
- @files_to_test.stub!(:keys).and_return @files_to_test[:spec]
37
- @to_test = @files_to_test.keys.flatten.join ' '
38
- end
14
+ it "should return an empty string if no spec.opts exists" do
15
+ File.stub!(:exist?).and_return false
16
+ Autotest::Rspec.new.add_options_if_present.should == ""
17
+ end
18
+ end
19
+
20
+ describe "commands" do
21
+ before(:each) do
22
+ @rspec_autotest = Autotest::Rspec.new
23
+ @rspec_autotest.stub!(:ruby).and_return "ruby"
24
+ @rspec_autotest.stub!(:add_options_if_present).and_return "-O spec/spec.opts"
39
25
 
40
- it "should make the appropriate test command" do
41
- @rspec_autotest.make_test_cmd(@files_to_test).should == "#{@ruby} #{@spec_cmd} #{@to_test} #{@options}"
42
- end
26
+ @ruby = @rspec_autotest.ruby
27
+ @spec_cmd = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec'))
28
+ @options = @rspec_autotest.add_options_if_present
29
+ @files_to_test = {
30
+ :spec => ["file_one", "file_two"]
31
+ }
32
+ # this is not the inner representation of Autotest!
33
+ @rspec_autotest.stub!(:files_to_test).and_return @files_to_test
34
+ @files_to_test.stub!(:keys).and_return @files_to_test[:spec]
35
+ @to_test = @files_to_test.keys.flatten.join ' '
36
+ end
37
+
38
+ it "should make the appropriate test command" do
39
+ @rspec_autotest.make_test_cmd(@files_to_test).should == "#{@ruby} #{@spec_cmd} --autospec #{@to_test} #{@options}"
40
+ end
43
41
 
44
- it "should return a blank command for no files" do
45
- @rspec_autotest.make_test_cmd({}).should == ''
46
- end
42
+ it "should return a blank command for no files" do
43
+ @rspec_autotest.make_test_cmd({}).should == ''
47
44
  end
45
+ end
46
+
47
+ describe "mappings" do
48
48
 
49
- describe "mappings" do
50
-
51
- before(:each) do
52
- @lib_file = "lib/something.rb"
53
- @spec_file = "spec/something_spec.rb"
54
- @rspec_autotest = Rspec.new
55
- @rspec_autotest.hook :initialize
56
- end
57
-
58
- it "should find the spec file for a given lib file" do
59
- @rspec_autotest.should map_specs([@spec_file]).to(@lib_file)
60
- end
61
-
62
- it "should find the spec file if given a spec file" do
63
- @rspec_autotest.should map_specs([@spec_file]).to(@spec_file)
64
- end
65
-
66
- it "should ignore files in spec dir that aren't specs" do
67
- @rspec_autotest.should map_specs([]).to("spec/spec_helper.rb")
68
- end
69
-
70
- it "should ignore untracked files (in @file)" do
71
- @rspec_autotest.should map_specs([]).to("lib/untracked_file")
72
- end
49
+ before(:each) do
50
+ @lib_file = "lib/something.rb"
51
+ @spec_file = "spec/something_spec.rb"
52
+ @rspec_autotest = Autotest::Rspec.new
53
+ @rspec_autotest.hook :initialize
73
54
  end
74
55
 
75
- describe "consolidating failures" do
76
- before(:each) do
77
- @rspec_autotest = Rspec.new
78
-
79
- @spec_file = "spec/autotest/some_spec.rb"
80
- @rspec_autotest.instance_variable_set("@files", {@spec_file => Time.now})
81
- @rspec_autotest.stub!(:find_files_to_test).and_return true
82
- end
83
-
84
- it "should return no failures if no failures were given in the output" do
85
- @rspec_autotest.consolidate_failures([[]]).should == {}
86
- end
56
+ it "should find the spec file for a given lib file" do
57
+ @rspec_autotest.should map_specs([@spec_file]).to(@lib_file)
58
+ end
59
+
60
+ it "should find the spec file if given a spec file" do
61
+ @rspec_autotest.should map_specs([@spec_file]).to(@spec_file)
62
+ end
63
+
64
+ it "should ignore files in spec dir that aren't specs" do
65
+ @rspec_autotest.should map_specs([]).to("spec/spec_helper.rb")
66
+ end
67
+
68
+ it "should ignore untracked files (in @file)" do
69
+ @rspec_autotest.should map_specs([]).to("lib/untracked_file")
70
+ end
71
+ end
72
+
73
+ describe "consolidating failures" do
74
+ before(:each) do
75
+ @rspec_autotest = Autotest::Rspec.new
87
76
 
88
- it "should return a hash with the spec filename => spec name for each failure or error" do
89
- @rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb"
90
- failures = [
91
- [
92
- "false should be false",
93
- "expected: true,\n got: false (using ==)\n#{@spec_file}:203:"
94
- ]
77
+ @spec_file = "spec/autotest/some_spec.rb"
78
+ @rspec_autotest.instance_variable_set("@files", {@spec_file => Time.now})
79
+ @rspec_autotest.stub!(:find_files_to_test).and_return true
80
+ end
81
+
82
+ it "should return no failures if no failures were given in the output" do
83
+ @rspec_autotest.consolidate_failures([[]]).should == {}
84
+ end
85
+
86
+ it "should return a hash with the spec filename => spec name for each failure or error" do
87
+ @rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb"
88
+ failures = [
89
+ [
90
+ "false should be false",
91
+ "expected: true,\n got: false (using ==)\n#{@spec_file}:203:"
95
92
  ]
96
- @rspec_autotest.consolidate_failures(failures).should == {
97
- @spec_file => ["false should be false"]
98
- }
99
- end
100
-
101
- it "should not include the subject file" do
102
- subject_file = "lib/autotest/some.rb"
103
- @rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb"
104
- failures = [
105
- [
106
- "false should be false",
107
- "expected: true,\n got: false (using ==)\n#{subject_file}:143:\n#{@spec_file}:203:"
108
- ]
93
+ ]
94
+ @rspec_autotest.consolidate_failures(failures).should == {
95
+ @spec_file => ["false should be false"]
96
+ }
97
+ end
98
+
99
+ it "should not include the subject file" do
100
+ subject_file = "lib/autotest/some.rb"
101
+ @rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb"
102
+ failures = [
103
+ [
104
+ "false should be false",
105
+ "expected: true,\n got: false (using ==)\n#{subject_file}:143:\n#{@spec_file}:203:"
109
106
  ]
110
- @rspec_autotest.consolidate_failures(failures).keys.should_not include(subject_file)
111
- end
107
+ ]
108
+ @rspec_autotest.consolidate_failures(failures).keys.should_not include(subject_file)
112
109
  end
113
110
  end
114
111
  end
@@ -10,7 +10,7 @@ module Spec
10
10
  [:describe, :context].each do |method|
11
11
  describe "##{method}" do
12
12
  it "should delegate to Spec::Example::ExampleGroupFactory.create_example_group" do
13
- block = lambda {}
13
+ block = lambda {|a,b|}
14
14
  Spec::Example::ExampleGroupFactory.should_receive(:create_example_group).with(
15
15
  "The ExampleGroup", hash_including(:spec_path), &block
16
16
  )
@@ -22,7 +22,7 @@ module Spec
22
22
  [:share_examples_for, :shared_examples_for].each do |method|
23
23
  describe "##{method}" do
24
24
  it "should create a shared ExampleGroup" do
25
- block = lambda {}
25
+ block = lambda {|a,b|}
26
26
  Spec::Example::ExampleGroupFactory.should_receive(:create_shared_example_group).with(
27
27
  "shared group", hash_including(:spec_path), &block
28
28
  )
@@ -63,7 +63,7 @@ module Spec
63
63
  end
64
64
 
65
65
  it "registers a shared ExampleGroup" do
66
- block = lambda {}
66
+ block = lambda {|a,b|}
67
67
  Spec::Example::ExampleGroupFactory.should_receive(:create_shared_example_group).with(
68
68
  group_name, hash_including(:spec_path), &block
69
69
  )
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Spec
4
+ module DSL
5
+ module Matchers
6
+ describe "#create" do
7
+ it "creates a method that initializes a new matcher with the submitted name and expected arg" do
8
+ # FIXME - this expects new to be called, but we need something
9
+ # more robust - that expects new to be called with a specific
10
+ # block (lambda, proc, whatever)
11
+ mod = Module.new
12
+ mod.extend Spec::DSL::Matchers
13
+ mod.create(:foo)
14
+
15
+ obj = Object.new
16
+ obj.extend mod
17
+
18
+ Spec::Matchers::Matcher.should_receive(:new).with(:foo, 3)
19
+
20
+ obj.foo(3)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,18 +3,14 @@ require File.dirname(__FILE__) + '/../../spec_helper'
3
3
  module Spec
4
4
  module Example
5
5
  class ExampleGroupSubclass < ExampleGroup
6
- def self.examples_ran
7
- @examples_ran
8
- end
9
-
10
- def self.examples_ran=(examples_ran)
11
- @examples_ran = examples_ran
6
+ class << self
7
+ attr_accessor :examples_ran
12
8
  end
13
9
 
14
10
  @@class_variable = :class_variable
15
11
  CONSTANT = :constant
16
12
 
17
- before do
13
+ before(:each) do
18
14
  @instance_variable = :instance_variable
19
15
  end
20
16
 
@@ -22,25 +18,28 @@ module Spec
22
18
  self.class.examples_ran = true
23
19
  end
24
20
 
25
- it "should have access to instance variables" do
21
+ def a_method
22
+ 22
23
+ end
24
+
25
+ it "can access instance variables defined before(:each)" do
26
26
  @instance_variable.should == :instance_variable
27
27
  end
28
28
 
29
- it "should have access to class variables" do
30
- @@class_variable.should == :class_variable
29
+ it "can access class variables (Ruby 1.8 only)" do
30
+ with_ruby 1.8 do
31
+ @@class_variable.should == :class_variable
32
+ end
31
33
  end
32
34
 
33
- it "should have access to constants" do
35
+ it "can access constants" do
34
36
  CONSTANT.should == :constant
35
37
  end
36
38
 
37
- it "should have access to methods defined in the Example Group" do
39
+ it "can access methods defined in the Example Group" do
38
40
  a_method.should == 22
39
41
  end
40
42
 
41
- def a_method
42
- 22
43
- end
44
43
  end
45
44
 
46
45
  describe ExampleGroupSubclass do