shared_should 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/shared_should.rb +7 -5
- data/shared_should.gemspec +1 -1
- data/test/test_shared_should.rb +24 -22
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.5
|
data/lib/shared_should.rb
CHANGED
@@ -42,11 +42,12 @@ class Test::Unit::TestCase
|
|
42
42
|
return context_or_test_class.kind_of?(Shoulda::Context) ? context_or_test_class : Test::Unit::TestCase
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
def execute_class_shared_setups_if_not_executed
|
46
|
+
if !@shared_setups_executed
|
47
|
+
@shared_setups_executed = true
|
48
|
+
(@@setup_blocks[self.class] || []).each do |setup_block|
|
49
|
+
setup_block.bind(self).call
|
50
|
+
end
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
@@ -61,6 +62,7 @@ class Test::Unit::TestCase
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def call_block_with_shared_value(test_block)
|
65
|
+
execute_class_shared_setups_if_not_executed
|
64
66
|
if test_block.arity == 1
|
65
67
|
# check arity of 1 before checking if value is an array. If one parameter, never treat the shared_value as variable args
|
66
68
|
test_block.bind(self).call(self.shared_value)
|
data/shared_should.gemspec
CHANGED
data/test/test_shared_should.rb
CHANGED
@@ -10,6 +10,29 @@ class TestSharedShould < Test::Unit::TestCase
|
|
10
10
|
assert @setup_instance_method_executed
|
11
11
|
end
|
12
12
|
|
13
|
+
# test class as context
|
14
|
+
share_setup "for a true value in class" do
|
15
|
+
assert @setup_instance_method_executed # setup instance method should have been called first
|
16
|
+
@class_value = true
|
17
|
+
end
|
18
|
+
|
19
|
+
share_should "be a valid should test in class" do
|
20
|
+
assert @class_value
|
21
|
+
end
|
22
|
+
|
23
|
+
share_context "for a valid context test in class" do
|
24
|
+
should "have a true value" do
|
25
|
+
assert @class_value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
use_setup "for a true value in class"
|
30
|
+
|
31
|
+
use_should "be a valid should test in class"
|
32
|
+
|
33
|
+
use_context "for a valid context test in class"
|
34
|
+
|
35
|
+
|
13
36
|
context ".share_context" do
|
14
37
|
context "without params" do
|
15
38
|
share_context "for a valid value" do
|
@@ -380,28 +403,7 @@ class TestSharedShould < Test::Unit::TestCase
|
|
380
403
|
use_context "for a valid context test"
|
381
404
|
end
|
382
405
|
|
383
|
-
|
384
|
-
share_setup "for a true value in class" do
|
385
|
-
@class_value = true
|
386
|
-
end
|
387
|
-
|
388
|
-
share_should "be a valid should test in class" do
|
389
|
-
assert @class_value
|
390
|
-
end
|
391
|
-
|
392
|
-
share_context "for a valid context test in class" do
|
393
|
-
should "have a true value" do
|
394
|
-
assert @class_value
|
395
|
-
end
|
396
|
-
end
|
397
|
-
|
398
|
-
use_setup "for a true value in class"
|
399
|
-
|
400
|
-
use_should "be a valid should test in class"
|
401
|
-
|
402
|
-
use_context "for a valid context test in class"
|
403
|
-
|
404
|
-
|
406
|
+
|
405
407
|
# ensure should macros work
|
406
408
|
def self.should_be_a_valid_macro
|
407
409
|
should "be a valid macro" do
|
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:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 5
|
10
|
+
version: 0.6.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Pearce
|