shared_should 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.1
1
+ 0.8.2
data/lib/shared_should.rb CHANGED
@@ -1,25 +1,51 @@
1
1
  require 'shoulda'
2
2
 
3
+ # Ruby 1.9 with MiniTest
4
+ if defined?(MiniTest::Unit::TestCase)
5
+ class MiniTest::Unit::TestCase
6
+ class << self
7
+ # these methods need to be aliased for both the test class and the should context
8
+ alias_method :test_suites_without_shared_should_execute, :test_suites
9
+ end
10
+
11
+ def self.test_suites
12
+ Test::Unit::TestCase.execute_class_shared_proxies
13
+
14
+ test_suites_without_shared_should_execute
15
+ end
16
+ end
17
+ end
18
+
19
+ # Ruby 1.8 without MiniTest
20
+ if defined?(Test::Unit::TestCase.suite)
21
+ class Test::Unit::TestCase
22
+ class << self
23
+ # these methods need to be aliased for both the test class and the should context
24
+ alias_method :suite_without_shared_should_execute, :suite
25
+ end
26
+
27
+ def self.suite
28
+ # assuming 'suite' is called before executing any tests - may be a poor assumption. Find something better?
29
+ execute_class_shared_proxies
30
+
31
+ suite_without_shared_should_execute
32
+ end
33
+ end
34
+ end
35
+
36
+
3
37
  class Test::Unit::TestCase
4
38
  attr_accessor :shared_value
5
39
  @@shared_proxies_executed = {}
6
40
  @@setup_blocks = {}
7
41
 
8
- class << self
9
- # these methods need to be aliased for both the test class and the should context
10
- alias_method :suite_without_shared_should_execute, :suite
11
- end
12
-
13
- def self.suite
14
- # assuming 'suite' is called before executing any tests - may be a poor assumption. Find something better?
42
+ def self.execute_class_shared_proxies
15
43
  unless @@shared_proxies_executed[self]
16
44
  shared_proxies.each do |shared_proxy|
17
45
  shared_proxy.share_execute
18
46
  end
19
47
  @@shared_proxies_executed[self] = true
20
48
  end
21
-
22
- suite_without_shared_should_execute
23
49
  end
24
50
 
25
51
  def self.shared_context_block_owner(context_or_test_class)
@@ -327,7 +353,8 @@ class Shoulda::SharedProxy
327
353
  end
328
354
 
329
355
  # share_description called when creating test names
330
- eval("def share_description; #{shared_proxy.send(:escaped_test_description)}; end")
356
+ self.instance_variable_set("@share_description", shared_proxy.send(:test_description))
357
+ def self.share_description; @share_description; end
331
358
  merge_block(&shared_proxy.test_block)
332
359
  end
333
360
  else
@@ -342,10 +369,6 @@ class Shoulda::SharedProxy
342
369
 
343
370
  private
344
371
 
345
- def escaped_test_description
346
- test_description.nil? ? 'nil' : "'#{test_description.gsub('\\', '\\\\\\').gsub("'", "\\\\'")}'"
347
- end
348
-
349
372
  def setup_block_configs_description
350
373
  @setup_block_configs_description
351
374
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{shared_should}
8
- s.version = "0.8.1"
8
+ s.version = "0.8.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Pearce"]
12
- s.date = %q{2011-05-24}
12
+ s.date = %q{2011-11-30}
13
13
  s.description = %q{Share and reuse shoulds, contexts, and setup in Shoulda.}
14
14
  s.email = %q{michael.pearce@bookrenter.com}
15
15
  s.extra_rdoc_files = [
@@ -490,9 +490,16 @@ class TestSharedShould < Test::Unit::TestCase
490
490
  hash[expected_method_name] = true
491
491
  hash
492
492
  end
493
- actual_method_names = self.class.suite.tests.inject({}) do |hash, test_case|
494
- hash[test_case.method_name] = true
495
- hash
493
+ if defined?(self.class.suite)
494
+ actual_method_names = self.class.suite.tests.inject({}) do |hash, test_case|
495
+ hash[test_case.method_name] = true
496
+ hash
497
+ end
498
+ else
499
+ actual_method_names = self.class.test_methods.inject({}) do |hash, method_name|
500
+ hash[method_name] = true
501
+ hash
502
+ end
496
503
  end
497
504
 
498
505
  actual_methods_not_found = []
@@ -22,7 +22,6 @@ class Test::Unit::TestCase
22
22
  share_setup "for a true value for shared setup helper" do
23
23
  @value = true
24
24
  end
25
-
26
25
  end
27
26
 
28
27
  class TestSharedShouldHelper < SubclassTestCase
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shared_should
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 1
10
- version: 0.8.1
9
+ - 2
10
+ version: 0.8.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Pearce
@@ -15,11 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-24 00:00:00 -07:00
18
+ date: 2011-11-30 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: shoulda
23
22
  version_requirements: &id001 !ruby/object:Gem::Requirement
24
23
  none: false
25
24
  requirements:
@@ -32,8 +31,8 @@ dependencies:
32
31
  prerelease: false
33
32
  type: :development
34
33
  requirement: *id001
34
+ name: shoulda
35
35
  - !ruby/object:Gem::Dependency
36
- name: bundler
37
36
  version_requirements: &id002 !ruby/object:Gem::Requirement
38
37
  none: false
39
38
  requirements:
@@ -48,8 +47,8 @@ dependencies:
48
47
  prerelease: false
49
48
  type: :development
50
49
  requirement: *id002
50
+ name: bundler
51
51
  - !ruby/object:Gem::Dependency
52
- name: jeweler
53
52
  version_requirements: &id003 !ruby/object:Gem::Requirement
54
53
  none: false
55
54
  requirements:
@@ -64,8 +63,8 @@ dependencies:
64
63
  prerelease: false
65
64
  type: :development
66
65
  requirement: *id003
66
+ name: jeweler
67
67
  - !ruby/object:Gem::Dependency
68
- name: rcov
69
68
  version_requirements: &id004 !ruby/object:Gem::Requirement
70
69
  none: false
71
70
  requirements:
@@ -78,8 +77,8 @@ dependencies:
78
77
  prerelease: false
79
78
  type: :development
80
79
  requirement: *id004
80
+ name: rcov
81
81
  - !ruby/object:Gem::Dependency
82
- name: shoulda
83
82
  version_requirements: &id005 !ruby/object:Gem::Requirement
84
83
  none: false
85
84
  requirements:
@@ -92,8 +91,8 @@ dependencies:
92
91
  prerelease: false
93
92
  type: :runtime
94
93
  requirement: *id005
95
- - !ruby/object:Gem::Dependency
96
94
  name: shoulda
95
+ - !ruby/object:Gem::Dependency
97
96
  version_requirements: &id006 !ruby/object:Gem::Requirement
98
97
  none: false
99
98
  requirements:
@@ -106,6 +105,7 @@ dependencies:
106
105
  prerelease: false
107
106
  type: :development
108
107
  requirement: *id006
108
+ name: shoulda
109
109
  description: Share and reuse shoulds, contexts, and setup in Shoulda.
110
110
  email: michael.pearce@bookrenter.com
111
111
  executables: []