rspec 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/CHANGES +17 -0
  2. data/Rakefile +7 -4
  3. data/failing_examples/README.txt +7 -0
  4. data/failing_examples/diffing_spec.rb +36 -0
  5. data/failing_examples/failing_autogenerated_docstrings_example.rb +19 -0
  6. data/failing_examples/failure_in_setup.rb +10 -0
  7. data/failing_examples/failure_in_teardown.rb +10 -0
  8. data/failing_examples/mocking_example.rb +40 -0
  9. data/failing_examples/mocking_with_flexmock.rb +26 -0
  10. data/failing_examples/mocking_with_mocha.rb +25 -0
  11. data/failing_examples/mocking_with_rr.rb +27 -0
  12. data/failing_examples/partial_mock_example.rb +20 -0
  13. data/failing_examples/predicate_example.rb +29 -0
  14. data/failing_examples/raising_example.rb +47 -0
  15. data/failing_examples/spec_helper.rb +3 -0
  16. data/failing_examples/syntax_error_example.rb +7 -0
  17. data/failing_examples/team_spec.rb +44 -0
  18. data/failing_examples/timeout_behaviour.rb +7 -0
  19. data/lib/autotest/rspec.rb +21 -35
  20. data/lib/spec.rb +0 -7
  21. data/lib/spec/example/example_group_methods.rb +10 -4
  22. data/lib/spec/example/example_methods.rb +4 -0
  23. data/lib/spec/interop/test.rb +3 -1
  24. data/lib/spec/interop/test/unit/ui/console/testrunner.rb +1 -0
  25. data/lib/spec/matchers/raise_error.rb +19 -15
  26. data/lib/spec/runner.rb +14 -0
  27. data/lib/spec/runner/formatter/story/html_formatter.rb +3 -0
  28. data/lib/spec/runner/formatter/story/plain_text_formatter.rb +4 -1
  29. data/lib/spec/runner/option_parser.rb +5 -33
  30. data/lib/spec/runner/options.rb +51 -18
  31. data/lib/spec/runner/spec_parser.rb +49 -31
  32. data/lib/spec/story/runner.rb +0 -2
  33. data/lib/spec/story/step.rb +8 -6
  34. data/lib/spec/story/world.rb +1 -0
  35. data/lib/spec/version.rb +22 -22
  36. data/pre_commit/lib/pre_commit.rb +4 -0
  37. data/pre_commit/lib/pre_commit/core.rb +50 -0
  38. data/pre_commit/lib/pre_commit/pre_commit.rb +54 -0
  39. data/pre_commit/lib/pre_commit/rspec.rb +111 -0
  40. data/pre_commit/lib/pre_commit/rspec_on_rails.rb +313 -0
  41. data/pre_commit/spec/pre_commit/pre_commit_spec.rb +15 -0
  42. data/pre_commit/spec/pre_commit/rspec_on_rails_spec.rb +36 -0
  43. data/pre_commit/spec/spec_helper.rb +3 -0
  44. data/pre_commit/spec/spec_suite.rb +11 -0
  45. data/rake_tasks/examples.rake +7 -0
  46. data/rake_tasks/examples_with_rcov.rake +9 -0
  47. data/rake_tasks/failing_examples_with_html.rake +9 -0
  48. data/rake_tasks/verify_rcov.rake +7 -0
  49. data/spec/README.jruby +15 -0
  50. data/spec/autotest/rspec_spec.rb +11 -80
  51. data/spec/autotest_helper.rb +2 -1
  52. data/spec/autotest_matchers.rb +47 -0
  53. data/spec/rspec_suite.rb +1 -1
  54. data/spec/spec.opts +6 -0
  55. data/spec/spec/example/example_group_methods_spec.rb +11 -2
  56. data/spec/spec/example/example_methods_spec.rb +69 -56
  57. data/spec/spec/interop/test/unit/resources/spec_that_fails.rb +10 -0
  58. data/spec/spec/interop/test/unit/resources/spec_that_passes.rb +10 -0
  59. data/spec/spec/interop/test/unit/resources/spec_with_errors.rb +10 -0
  60. data/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +10 -0
  61. data/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +10 -0
  62. data/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +10 -0
  63. data/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +38 -0
  64. data/spec/spec/interop/test/unit/spec_spec.rb +45 -0
  65. data/spec/spec/interop/test/unit/testcase_spec.rb +39 -4
  66. data/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +1 -1
  67. data/spec/spec/matchers/raise_error_spec.rb +7 -1
  68. data/spec/spec/mocks/bug_report_10263.rb +1 -1
  69. data/spec/spec/runner/command_line_spec.rb +3 -2
  70. data/spec/spec/runner/empty_file.txt +0 -0
  71. data/spec/spec/runner/examples.txt +2 -0
  72. data/spec/spec/runner/failed.txt +3 -0
  73. data/spec/spec/runner/formatter/html_formatted-1.8.4.html +365 -0
  74. data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +387 -0
  75. data/spec/spec/runner/formatter/html_formatted-1.8.5.html +371 -0
  76. data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +381 -0
  77. data/spec/spec/runner/formatter/html_formatted-1.8.6.html +365 -0
  78. data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +54 -54
  79. data/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +365 -0
  80. data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +365 -0
  81. data/spec/spec/runner/option_parser_spec.rb +50 -49
  82. data/spec/spec/runner/options_spec.rb +72 -2
  83. data/spec/spec/runner/resources/a_bar.rb +0 -0
  84. data/spec/spec/runner/resources/a_foo.rb +0 -0
  85. data/spec/spec/runner/resources/a_spec.rb +1 -0
  86. data/spec/spec/runner/spec.opts +2 -0
  87. data/spec/spec/runner/spec_parser/spec_parser_fixture.rb +70 -0
  88. data/spec/spec/runner/spec_parser_spec.rb +31 -76
  89. data/spec/spec/runner/spec_spaced.opts +2 -0
  90. data/spec/spec/spec_classes.rb +4 -0
  91. data/spec/spec/story/step_spec.rb +22 -0
  92. data/spec/spec/story/world_spec.rb +7 -0
  93. data/stories/interop/test_case_with_should_methods +1 -1
  94. metadata +85 -5
  95. data/spec/spec/interop/test/unit/testcase_spec_with_test_unit.rb +0 -20
  96. data/spec/spec/interop/test/unit/testsuite_adapter_spec_with_test_unit.rb +0 -34
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ ##
4
+ # This is not a complete specification of PreCommit, but
5
+ # just a collection of bug fix regression tests.
6
+ describe "The helper method PreCommit#silent_sh" do
7
+ before do
8
+ @pre_commit = PreCommit.new(nil)
9
+ end
10
+
11
+ # bug in r1802
12
+ it "should return the command output" do
13
+ @pre_commit.send(:silent_sh, "echo foo").should ==("foo\n")
14
+ end
15
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+ require 'fileutils'
3
+
4
+ include FileUtils
5
+
6
+ ##
7
+ # This is not a complete specification of PreCommit.RSpecOnRails, but
8
+ # just a collection of bug fix regression tests.
9
+ describe "RSpecOnRails pre_commit" do
10
+ before do
11
+ @original_dir = File.expand_path(FileUtils.pwd)
12
+ @rails_app_dir = File.expand_path(File.dirname(__FILE__) + "/../../../example_rails_app/")
13
+
14
+ Dir.chdir(@rails_app_dir)
15
+ rm_rf('vendor/plugins/rspec_on_rails')
16
+ system("svn export ../rspec_on_rails vendor/plugins/rspec_on_rails")
17
+
18
+ @pre_commit = PreCommit::RspecOnRails.new(nil)
19
+ end
20
+
21
+ after do
22
+ rm('db/migrate/888_create_purchases.rb', :force => true)
23
+ @pre_commit.destroy_purchase
24
+ Dir.chdir(@original_dir)
25
+ end
26
+
27
+ # bug in r1802
28
+ it "should fail noisily if there is a migration name conflict" do
29
+ touch('db/migrate/888_create_purchases.rb')
30
+ lambda { @pre_commit.generate_purchase }.should raise_error
31
+ end
32
+
33
+ it "should not fail if tests run ok" do
34
+ lambda { @pre_commit.generate_purchase }.should_not raise_error
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
2
+ require 'pre_commit'
3
+
@@ -0,0 +1,11 @@
1
+ class SpecSuite
2
+ def run
3
+ system("ruby rspec/spec/rspec_suite.rb") || raise("Rspec Suite FAILED")
4
+ system("ruby rspec_on_rails/spec/rails_suite.rb") || raise("Rails Suite FAILED")
5
+ system("ruby cached_example_rails_app/spec/rails_app_suite.rb") || raise("Rails App Suite FAILED")
6
+ end
7
+ end
8
+
9
+ if $0 == __FILE__
10
+ SpecSuite.new.run
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'rake'
2
+ require 'spec/rake/spectask'
3
+
4
+ desc "Run all examples"
5
+ Spec::Rake::SpecTask.new('examples') do |t|
6
+ t.spec_files = FileList['examples/**/*.rb']
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'rake'
2
+ require 'spec/rake/spectask'
3
+
4
+ desc "Run all examples with RCov"
5
+ Spec::Rake::SpecTask.new('examples_with_rcov') do |t|
6
+ t.spec_files = FileList['examples/**/*.rb']
7
+ t.rcov = true
8
+ t.rcov_opts = ['--exclude', 'examples']
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'rake'
2
+ require 'spec/rake/spectask'
3
+
4
+ desc "Generate HTML report for failing examples"
5
+ Spec::Rake::SpecTask.new('failing_examples_with_html') do |t|
6
+ t.spec_files = FileList['failing_examples/**/*.rb']
7
+ t.spec_opts = ["--format", "html:../doc/output/documentation/tools/failing_examples.html", "--diff"]
8
+ t.fail_on_error = false
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'rake'
2
+ require 'spec/rake/verify_rcov'
3
+
4
+ RCov::VerifyTask.new(:verify_rcov => :spec) do |t|
5
+ t.threshold = 100.0 # Make sure you have rcov 0.7 or higher!
6
+ t.index_html = '../doc/output/coverage/index.html'
7
+ end
data/spec/README.jruby ADDED
@@ -0,0 +1,15 @@
1
+ = Running specs on JRuby =
2
+
3
+ svn co http://svn.codehaus.org/jruby/trunk jruby
4
+ cd jruby/jruby
5
+ ant clean
6
+ ant
7
+ # put JRuby's bin dir on your PATH
8
+ jruby -S gem install rake --no-ri --no-rdoc
9
+ jruby -S gem install diff-lcs
10
+ jruby -S gem install syntax
11
+ cd ../testsuites/rspec
12
+ mkdir target
13
+ jruby -S rake checkout_code
14
+ cd target/rspec
15
+ jruby bin/spec spec -c
@@ -88,11 +88,10 @@ HERE
88
88
  end
89
89
 
90
90
  it "should use the ALT_SEPARATOR if it is non-nil" do
91
- pending("autotest got re-worked so this is failing for the moment")
92
91
  @rspec_autotest = Rspec.new
93
92
  spec_command = File.expand_path("#{File.dirname(__FILE__)}/../../bin/spec")
94
93
  @rspec_autotest.stub!(:spec_commands).and_return [spec_command]
95
- @rspec_autotest.spec_command.should == spec_command.gsub('/', '\\')
94
+ @rspec_autotest.spec_command(@windows_alt_separator).should == spec_command.gsub('/', @windows_alt_separator)
96
95
  end
97
96
 
98
97
  it "should not use the ALT_SEPATOR if it is nil" do
@@ -143,93 +142,25 @@ HERE
143
142
  end
144
143
  end
145
144
 
146
- describe Rspec, "test mappings" do
147
- before :each do
148
- @rspec_autotest = Rspec.new
149
- @rspec_autotest.hook :initialize
150
- end
151
-
152
- it "should map all filenames in spec/ which end in .rb" do
153
- @rspec_autotest.instance_eval{@test_mappings}.should have_key(%r%^spec/.*\.rb$%)
154
- end
155
-
156
- it "should map all names in lib which end in .rb to the corresponding ones in spec/" do
157
- @rspec_autotest.instance_eval{@test_mappings}.should have_key(%r%^lib/(.*)\.rb$%)
158
- end
159
-
160
- it "should find all files in spec/shares/* and the spec helper in spec/spec_helper" do
161
- @rspec_autotest.instance_eval{@test_mappings}.should have_key(%r%^spec/(spec_helper|shared/.*)\.rb$%)
162
- end
163
- end
164
-
165
- describe Rspec, "handling results" do
166
- include AutotestHelper
167
-
168
- before :each do
169
- common_setup
170
- @rspec_autotest = Rspec.new
171
- @rspec_autotest.stub!(:hook)
172
-
173
- @results = mock String
174
- @results.stub!(:scan).and_return ""
175
- end
176
-
177
- it "should call hook(:red) if there are failures" do
178
- @rspec_autotest.stub!(:consolidate_failures).and_return ["spec/some_spec.rb"]
179
-
180
- @rspec_autotest.should_receive(:hook).with(:red)
181
- @rspec_autotest.handle_results(@results)
182
- end
145
+ describe Rspec, "mappings" do
183
146
 
184
- it "should call hook(:green) if there are no failures" do
185
- @rspec_autotest.stub!(:consolidate_failures).and_return []
186
- @rspec_autotest.should_receive(:hook).with(:green)
187
- @rspec_autotest.handle_results(@results)
188
- end
189
- end
190
-
191
- describe Rspec, "handling failed results" do
192
- include AutotestHelper
193
-
194
- before :each do
195
- common_setup
196
- end
197
-
198
- it %(should scan the output into a multi-dimensional array,
199
- consisting of the failing spec's name as the first element,
200
- and the failure as the second) do
201
- @rspec_autotest = Rspec.new
202
- @rspec_autotest.failed_results(@rspec_output).should == [
203
- [
204
- "false should be false",
205
- "expected: true,\n got: false (using ==)\n./spec/autotest/rspec_spec.rb:203:"
206
- ]
207
- ]
208
- end
209
- end
210
-
211
- describe Rspec, "specs for a given file" do
212
- before :each do
147
+ before(:each) do
213
148
  @lib_file = "lib/something.rb"
214
149
  @spec_file = "spec/something_spec.rb"
215
150
  @rspec_autotest = Rspec.new
216
151
  @rspec_autotest.hook :initialize
217
-
218
- @rspec_autotest.instance_variable_set("@files", {@lib_file => Time.now, @spec_file => Time.now})
219
- @rspec_autotest.stub!(:find_files_to_test).and_return true
220
152
  end
221
153
 
222
154
  it "should find the spec file for a given lib file" do
223
- @rspec_autotest.specs_for_file(@lib_file).should == [@spec_file]
155
+ @rspec_autotest.should map_specs([@spec_file]).to(@lib_file)
224
156
  end
225
157
 
226
158
  it "should find the spec file if given a spec file" do
227
- @rspec_autotest.specs_for_file(@spec_file).should == [@spec_file]
159
+ @rspec_autotest.should map_specs([@spec_file]).to(@spec_file)
228
160
  end
229
161
 
230
162
  it "should only find the file if the file is being tracked (in @file)" do
231
- @other_file = "lib/some_non_tracked_file"
232
- @rspec_autotest.specs_for_file(@other_file).should == []
163
+ @rspec_autotest.should map_specs([]).to("lib/untracked_file")
233
164
  end
234
165
  end
235
166
 
@@ -246,18 +177,18 @@ HERE
246
177
  end
247
178
 
248
179
  it "should return no failures if no failures were given in the output" do
249
- @rspec_autotest.stub!(:failed_results).and_return [[]]
250
- @rspec_autotest.consolidate_failures(@rspec_autotest.failed_results).should == {}
180
+ @rspec_autotest.consolidate_failures([[]]).should == {}
251
181
  end
252
182
 
253
183
  it "should return a hash with the spec filename => spec name for each failure or error" do
254
- @rspec_autotest.stub!(:failed_results).and_return([
184
+ @rspec_autotest.stub!(:test_files_for).and_return "./spec/autotest/rspec_spec.rb"
185
+ foo = [
255
186
  [
256
187
  "false should be false",
257
188
  "expected: true,\n got: false (using ==)\n./spec/autotest/rspec_spec.rb:203:"
258
189
  ]
259
- ])
260
- @rspec_autotest.consolidate_failures(@rspec_autotest.failed_results).should == {@spec_file => ["false should be false"]}
190
+ ]
191
+ @rspec_autotest.consolidate_failures(foo).should == {@spec_file => ["false should be false"]}
261
192
  end
262
193
 
263
194
  end
@@ -2,4 +2,5 @@ require "rubygems"
2
2
  require 'autotest'
3
3
  dir = File.dirname(__FILE__)
4
4
  require "#{dir}/spec_helper"
5
- require File.expand_path("#{dir}/../lib/autotest/rspec")
5
+ require File.expand_path("#{dir}/../lib/autotest/rspec")
6
+ require "#{dir}/autotest_matchers"
@@ -0,0 +1,47 @@
1
+ module Spec
2
+ module Matchers
3
+ class AutotestMappingMatcher
4
+ def initialize(specs)
5
+ @specs = specs
6
+ end
7
+
8
+ def to(file)
9
+ @file = file
10
+ self
11
+ end
12
+
13
+ def matches?(autotest)
14
+ @autotest = prepare autotest
15
+ @actual = autotest.test_files_for(@file)
16
+ @actual == @specs
17
+ end
18
+
19
+ def failure_message
20
+ "expected #{@autotest.class} to map #{@specs.inspect} to #{@file.inspect}\ngot #{@actual.inspect}"
21
+ end
22
+
23
+ private
24
+ def prepare autotest
25
+ stub_found_files autotest
26
+ stub_find_order autotest
27
+ autotest
28
+ end
29
+
30
+ def stub_found_files autotest
31
+ found_files = @specs.inject({}){|h,f| h[f] = Time.at(0)}
32
+ autotest.stub!(:find_files).and_return(found_files)
33
+ end
34
+
35
+ def stub_find_order autotest
36
+ find_order = @specs.dup << @file
37
+ autotest.instance_eval { @find_order = find_order }
38
+ end
39
+
40
+ end
41
+
42
+ def map_specs(specs)
43
+ AutotestMappingMatcher.new(specs)
44
+ end
45
+
46
+ end
47
+ end
data/spec/rspec_suite.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  if __FILE__ == $0
2
2
  dir = File.dirname(__FILE__)
3
- Dir["#{dir}/**/*_spec.rb"].each do |file|
3
+ Dir["#{dir}/**/*_spec.rb"].reverse.each do |file|
4
4
  # puts "require '#{file}'"
5
5
  require file
6
6
  end
data/spec/spec.opts ADDED
@@ -0,0 +1,6 @@
1
+ --colour
2
+ --format
3
+ profile
4
+ --timeout
5
+ 20
6
+ --diff
@@ -459,14 +459,16 @@ module Spec
459
459
 
460
460
  describe '#register' do
461
461
  it "should add ExampleGroup to set of ExampleGroups to be run" do
462
- example_group.register
462
+ options.example_groups.delete(example_group)
463
+ options.example_groups.should_not include(example_group)
464
+
465
+ example_group.register {}
463
466
  options.example_groups.should include(example_group)
464
467
  end
465
468
  end
466
469
 
467
470
  describe '#unregister' do
468
471
  before do
469
- example_group.register
470
472
  options.example_groups.should include(example_group)
471
473
  end
472
474
 
@@ -475,6 +477,13 @@ module Spec
475
477
  options.example_groups.should_not include(example_group)
476
478
  end
477
479
  end
480
+
481
+ describe "#registration_backtrace" do
482
+ it "returns the backtrace of where the ExampleGroup was registered" do
483
+ example_group = Class.new(ExampleGroup)
484
+ example_group.registration_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-1}")
485
+ end
486
+ end
478
487
  end
479
488
  end
480
489
  end
@@ -14,76 +14,89 @@ module Spec
14
14
  end
15
15
  end
16
16
 
17
- describe "ExampleMethods with an included module that is reopened" do
18
- it "should have repoened methods" do
19
- method(:module_that_is_reopened_method).should_not be_nil
20
- end
21
- end
22
-
23
- describe ExampleMethods, "lifecycle" do
24
- before do
25
- @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
26
- @options.formatters << mock("formatter", :null_object => true)
27
- @options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
28
- @reporter = FakeReporter.new(@options)
29
- @options.reporter = @reporter
30
-
31
- ExampleMethods.before_all_parts.should == []
32
- ExampleMethods.before_each_parts.should == []
33
- ExampleMethods.after_each_parts.should == []
34
- ExampleMethods.after_all_parts.should == []
35
- def ExampleMethods.count
36
- @count ||= 0
37
- @count = @count + 1
38
- @count
17
+ describe ExampleMethods do
18
+ describe "with an included module that is reopened" do
19
+ it "should have repoened methods" do
20
+ method(:module_that_is_reopened_method).should_not be_nil
39
21
  end
40
22
  end
41
23
 
42
- after do
43
- ExampleMethods.instance_variable_set("@before_all_parts", [])
44
- ExampleMethods.instance_variable_set("@before_each_parts", [])
45
- ExampleMethods.instance_variable_set("@after_each_parts", [])
46
- ExampleMethods.instance_variable_set("@after_all_parts", [])
47
- end
24
+ describe "lifecycle" do
25
+ before do
26
+ @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
27
+ @options.formatters << mock("formatter", :null_object => true)
28
+ @options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
29
+ @reporter = FakeReporter.new(@options)
30
+ @options.reporter = @reporter
48
31
 
49
- it "should pass before and after callbacks to all ExampleGroup subclasses" do
50
- ExampleMethods.before(:all) do
51
- ExampleMethods.count.should == 1
32
+ ExampleMethods.before_all_parts.should == []
33
+ ExampleMethods.before_each_parts.should == []
34
+ ExampleMethods.after_each_parts.should == []
35
+ ExampleMethods.after_all_parts.should == []
36
+ def ExampleMethods.count
37
+ @count ||= 0
38
+ @count = @count + 1
39
+ @count
40
+ end
52
41
  end
53
42
 
54
- ExampleMethods.before(:each) do
55
- ExampleMethods.count.should == 2
43
+ after do
44
+ ExampleMethods.instance_variable_set("@before_all_parts", [])
45
+ ExampleMethods.instance_variable_set("@before_each_parts", [])
46
+ ExampleMethods.instance_variable_set("@after_each_parts", [])
47
+ ExampleMethods.instance_variable_set("@after_all_parts", [])
56
48
  end
57
49
 
58
- ExampleMethods.after(:each) do
59
- ExampleMethods.count.should == 3
60
- end
50
+ it "should pass before and after callbacks to all ExampleGroup subclasses" do
51
+ ExampleMethods.before(:all) do
52
+ ExampleMethods.count.should == 1
53
+ end
54
+
55
+ ExampleMethods.before(:each) do
56
+ ExampleMethods.count.should == 2
57
+ end
58
+
59
+ ExampleMethods.after(:each) do
60
+ ExampleMethods.count.should == 3
61
+ end
61
62
 
62
- ExampleMethods.after(:all) do
63
- ExampleMethods.count.should == 4
63
+ ExampleMethods.after(:all) do
64
+ ExampleMethods.count.should == 4
65
+ end
66
+
67
+ @example_group = Class.new(ExampleGroup) do
68
+ it "should use ExampleMethods callbacks" do
69
+ end
70
+ end
71
+ @example_group.run
72
+ ExampleMethods.count.should == 5
64
73
  end
65
74
 
66
- @example_group = Class.new(ExampleGroup) do
67
- it "should use ExampleMethods callbacks" do
75
+ describe "run_with_description_capturing" do
76
+ before(:each) do
77
+ @example_group = Class.new(ExampleGroup) do end
78
+ @example = @example_group.new("foo", &(lambda { 2.should == 2 }))
79
+ @example.run_with_description_capturing
80
+ end
81
+
82
+ it "should provide the generated description" do
83
+ @example.instance_eval { @_matcher_description }.should == "should == 2"
84
+ end
85
+
86
+ it "should clear the global generated_description" do
87
+ Spec::Matchers.generated_description.should == nil
68
88
  end
69
89
  end
70
- @example_group.run
71
- ExampleMethods.count.should == 5
72
90
  end
73
-
74
- describe "run_with_description_capturing" do
75
- before(:each) do
76
- @example_group = Class.new(ExampleGroup) do end
77
- @example = @example_group.new("foo", &(lambda { 2.should == 2 }))
78
- @example.run_with_description_capturing
79
- end
80
-
81
- it "should provide the generated description" do
82
- @example.instance_eval { @_matcher_description }.should == "should == 2"
83
- end
84
-
85
- it "should clear the global generated_description" do
86
- Spec::Matchers.generated_description.should == nil
91
+
92
+ describe "#implementation_backtrace" do
93
+ it "returns the backtrace of where the implementation was defined" do
94
+ example_group = Class.new(ExampleGroup) do
95
+ it "should use ExampleMethods callbacks" do
96
+ end
97
+ end
98
+ example = example_group.examples.first
99
+ example.implementation_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-4}")
87
100
  end
88
101
  end
89
102
  end