rspec-unit 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source :gemcutter
2
2
 
3
3
  # gem 'bundler', '>= 0.9.16'
4
- gem 'rspec', '= 2.0.0'
4
+ gem 'rspec', '= 2.1.0'
5
5
 
6
6
  group :test do
7
7
  gem 'rake', '>= 0.8.7'
@@ -10,16 +10,14 @@ GEM
10
10
  rubyforge (>= 2.0.0)
11
11
  json_pure (1.4.6)
12
12
  rake (0.8.7)
13
- rspec (2.0.0)
14
- rspec-core (= 2.0.0)
15
- rspec-expectations (= 2.0.0)
16
- rspec-mocks (= 2.0.0)
17
- rspec-core (2.0.0)
18
- rspec-expectations (2.0.0)
19
- diff-lcs (>= 1.1.2)
20
- rspec-mocks (2.0.0)
21
- rspec-core (= 2.0.0)
22
- rspec-expectations (= 2.0.0)
13
+ rspec (2.1.0)
14
+ rspec-core (~> 2.1.0)
15
+ rspec-expectations (~> 2.1.0)
16
+ rspec-mocks (~> 2.1.0)
17
+ rspec-core (2.1.0)
18
+ rspec-expectations (2.1.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.1.0)
23
21
  rubyforge (2.0.4)
24
22
  json_pure (>= 1.1.7)
25
23
 
@@ -30,4 +28,4 @@ PLATFORMS
30
28
  DEPENDENCIES
31
29
  jeweler (>= 1.4.0)
32
30
  rake (>= 0.8.7)
33
- rspec (= 2.0.0)
31
+ rspec (= 2.1.0)
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ begin
10
10
  gem.homepage = "http://github.com/glv/rspec-unit"
11
11
  gem.authors = ["Glenn Vanderburg"]
12
12
  gem.rubyforge_project = "rspec-unit"
13
- gem.add_dependency('rspec', '~> 2.0')
13
+ gem.add_dependency('rspec', '~> 2.1')
14
14
  gem.has_rdoc = false
15
15
  gem.files = FileList["[A-Z]*", "{bin,lib,spec}/**/*"].exclude('**/*.rbc')
16
16
  gem.rubyforge_project = 'glv'
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
- :minor: 0
3
+ :minor: 1
4
4
  :patch: 0
@@ -63,6 +63,16 @@ module RSpec
63
63
  @_caller_lines ||= {}
64
64
  end
65
65
 
66
+ def self.find_caller_lines(name)
67
+ klass = self
68
+ while klass.respond_to?(:caller_lines)
69
+ lines = klass.caller_lines[name]
70
+ return lines unless lines.nil?
71
+ klass = klass.superclass
72
+ end
73
+ []
74
+ end
75
+
66
76
  def self.test_method_metadata
67
77
  @_test_method_metadata ||= {}
68
78
  end
@@ -94,7 +104,7 @@ module RSpec
94
104
 
95
105
  def self.tests
96
106
  @tests ||= test_methods.sort.map do |m|
97
- meta = (test_method_metadata[m] || {}).merge({:caller => caller_lines[m],
107
+ meta = (test_method_metadata[m] || {}).merge({:caller => find_caller_lines(m),
98
108
  :full_description => "#{display_name}##{m}",
99
109
  :test_unit => true})
100
110
  Core::Example.new(self, m, meta, proc{execute(m)})
@@ -102,9 +112,10 @@ module RSpec
102
112
  end
103
113
 
104
114
  class <<self
105
- private :test_case_name, :caller_lines, :test_method_metadata,
115
+ private :test_case_name, :test_method_metadata,
106
116
  :install_setup_and_teardown, :test_method?, :test_methods,
107
117
  :number_of_tests, :tests
118
+ protected :caller_lines, :find_caller_lines
108
119
  end
109
120
 
110
121
  def initialize
@@ -197,6 +197,31 @@ describe "RSpec::Unit::TestCase" do
197
197
  end
198
198
  end
199
199
 
200
+ describe "find_caller_lines" do
201
+ it "returns [] if the method name is not found" do
202
+ @foo.send(:find_caller_lines, 'wrong').should be_empty
203
+ bar = Class.new(@foo)
204
+ bar.send(:find_caller_lines, 'wrong').should be_empty
205
+ end
206
+
207
+ it "returns a stack trace array if the name is found in caller_lines" do
208
+ @foo.class_eval do
209
+ def test_bar; end
210
+ end
211
+
212
+ @foo.send(:find_caller_lines, 'test_bar').should_not be_empty
213
+ end
214
+
215
+ it "returns a stack trace array if the name is found in the parent's caller_lines" do
216
+ @foo.class_eval do
217
+ def test_bar; end
218
+ end
219
+ bar = Class.new(@foo)
220
+
221
+ bar.send(:find_caller_lines, 'test_bar').should_not be_empty
222
+ end
223
+ end
224
+
200
225
  describe "test class metadata" do
201
226
  before do
202
227
  class SampleTestCaseForName < RSpec::Unit::TestCase
@@ -226,12 +251,7 @@ describe "RSpec::Unit::TestCase" do
226
251
  it "sets :location to file_path and line_number" do
227
252
  @foo.metadata[:example_group][:location].should == "#{__FILE__}:#{@foo_definition_line}"
228
253
  end
229
-
230
- it "sets :caller" do
231
- @foo.metadata[:example_group][:caller].first.should =~ Regexp.new(Regexp.escape(@foo.metadata[:example_group][:location]))
232
- @foo.metadata[:example_group][:caller].size.should be_>(@caller_at_foo_definition.size)
233
- end
234
-
254
+
235
255
  it "has nil for :block and :describes" do
236
256
  @foo.metadata[:example_group][:block].should be_nil
237
257
  @foo.metadata[:example_group][:describes].should be_nil
@@ -304,14 +324,6 @@ describe "RSpec::Unit::TestCase" do
304
324
  test_baz_metadata[:example_group].should == @foo.metadata[:example_group]
305
325
  end
306
326
 
307
- it "sets :caller" do
308
- @foo.class_eval do
309
- def test_baz; end
310
- end
311
- test_baz_metadata[:caller].first.should match(/^#{Regexp.escape(@foo.examples.first.metadata[:location])}/)
312
- test_baz_metadata[:caller].size.should be_>(caller.size)
313
- end
314
-
315
327
  it "records test_info metadata for next test method" do
316
328
  @foo.class_eval do
317
329
  test_info :foo => :bar
@@ -327,6 +339,39 @@ describe "RSpec::Unit::TestCase" do
327
339
  def test_quux; end
328
340
  end
329
341
  find_example(@foo, 'test_quux').metadata[:foo].should be_nil
342
+ end
343
+
344
+ context "inherited methods" do
345
+ def test_baz_metadata
346
+ find_example(@bar, 'test_baz').metadata
347
+ end
348
+
349
+ it "sets :file_path to the file where the method is defined" do
350
+ @foo.class_eval do
351
+ def test_baz; end
352
+ end
353
+ @bar = Class.new(@foo)
354
+
355
+ test_baz_metadata[:file_path].should == __FILE__
356
+ end
357
+
358
+ it "sets :line_number to the line where the method definition begins" do
359
+ @foo.class_eval do
360
+ def test_baz; end
361
+ end
362
+ @bar = Class.new(@foo)
363
+
364
+ test_baz_metadata[:line_number].should == (__LINE__ - 4)
365
+ end
366
+
367
+ it "sets :location to file path and line number" do
368
+ @foo.class_eval do
369
+ def test_baz; end
370
+ end
371
+ @bar = Class.new(@foo)
372
+
373
+ test_baz_metadata[:location].should == "#{__FILE__}:#{__LINE__-4}"
374
+ end
330
375
  end
331
376
  end
332
377
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
+ - 1
7
8
  - 0
8
- - 0
9
- version: 1.0.0
9
+ version: 1.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Glenn Vanderburg
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-10 00:00:00 -05:00
17
+ date: 2010-11-07 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -26,8 +26,8 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  segments:
28
28
  - 2
29
- - 0
30
- version: "2.0"
29
+ - 1
30
+ version: "2.1"
31
31
  requirement: *id001
32
32
  prerelease: false
33
33
  description: test/unit compatibility for RSpec 2.