assert 2.4.0 → 2.5.0
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/README.md +8 -8
- data/lib/assert.rb +9 -62
- data/lib/assert/assert_runner.rb +15 -30
- data/lib/assert/assertions.rb +105 -41
- data/lib/assert/cli.rb +1 -1
- data/lib/assert/config.rb +56 -0
- data/lib/assert/context.rb +44 -150
- data/lib/assert/context/setup_dsl.rb +70 -0
- data/lib/assert/context/subject_dsl.rb +39 -0
- data/lib/assert/context/suite_dsl.rb +20 -0
- data/lib/assert/context/test_dsl.rb +51 -0
- data/lib/assert/runner.rb +8 -2
- data/lib/assert/suite.rb +33 -12
- data/lib/assert/test.rb +11 -8
- data/lib/assert/utils.rb +23 -11
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view.rb +9 -7
- data/lib/assert/view/base.rb +26 -4
- data/lib/assert/view/default_view.rb +1 -1
- data/lib/assert/view/helpers/ansi_styles.rb +1 -1
- data/lib/assert/view/helpers/common.rb +16 -6
- data/test/helper.rb +1 -94
- data/test/support/factory.rb +70 -0
- data/test/system/running_tests.rb +55 -28
- data/test/unit/assert_tests.rb +6 -33
- data/test/unit/assertions/assert_block_tests.rb +3 -3
- data/test/unit/assertions/assert_empty_tests.rb +6 -4
- data/test/unit/assertions/assert_equal_tests.rb +19 -22
- data/test/unit/assertions/assert_file_exists_tests.rb +6 -4
- data/test/unit/assertions/assert_includes_tests.rb +8 -4
- data/test/unit/assertions/assert_instance_of_tests.rb +8 -6
- data/test/unit/assertions/assert_kind_of_tests.rb +8 -5
- data/test/unit/assertions/assert_match_tests.rb +8 -4
- data/test/unit/assertions/assert_nil_tests.rb +6 -4
- data/test/unit/assertions/assert_raises_tests.rb +2 -2
- data/test/unit/assertions/assert_respond_to_tests.rb +7 -5
- data/test/unit/assertions/assert_same_tests.rb +75 -6
- data/test/unit/assertions/assert_true_false_tests.rb +116 -0
- data/test/unit/assertions_tests.rb +7 -5
- data/test/unit/config_tests.rb +58 -0
- data/test/unit/context/{setup_teardown_singleton_tests.rb → setup_dsl_tests.rb} +17 -19
- data/test/unit/context/subject_dsl_tests.rb +78 -0
- data/test/unit/context/suite_dsl_tests.rb +47 -0
- data/test/unit/context/{test_should_singleton_tests.rb → test_dsl_tests.rb} +33 -34
- data/test/unit/context_tests.rb +19 -15
- data/test/unit/runner_tests.rb +9 -3
- data/test/unit/suite_tests.rb +20 -23
- data/test/unit/test_tests.rb +22 -14
- data/test/unit/utils_tests.rb +15 -21
- data/test/unit/view_tests.rb +12 -5
- metadata +23 -10
- data/test/unit/context/basic_singleton_tests.rb +0 -86
@@ -6,7 +6,7 @@ require 'assert/utils'
|
|
6
6
|
module Assert::Assertions
|
7
7
|
|
8
8
|
class AssertSameTest < Assert::Context
|
9
|
-
desc "
|
9
|
+
desc "`assert_same`"
|
10
10
|
setup do
|
11
11
|
klass = Class.new; object = klass.new
|
12
12
|
desc = @desc = "assert same fail desc"
|
@@ -15,6 +15,7 @@ module Assert::Assertions
|
|
15
15
|
assert_same(object, object) # pass
|
16
16
|
assert_same(*args) # fail
|
17
17
|
end
|
18
|
+
@c = @test.config
|
18
19
|
@test.run
|
19
20
|
end
|
20
21
|
subject{ @test }
|
@@ -27,15 +28,17 @@ module Assert::Assertions
|
|
27
28
|
|
28
29
|
should "have a fail message with custom and generic explanations" do
|
29
30
|
exp = "#{@args[2]}\n"\
|
30
|
-
"Expected #{Assert::U.show(@args[1]
|
31
|
-
"
|
31
|
+
"Expected #{Assert::U.show(@args[1], @c)}"\
|
32
|
+
" (#<#{@args[1].class}:#{'0x0%x' % (@args[1].object_id << 1)}>)"\
|
33
|
+
" to be the same as #{Assert::U.show(@args[0], @c)}"\
|
34
|
+
" (#<#{@args[0].class}:#{'0x0%x' % (@args[0].object_id << 1)}>)."
|
32
35
|
assert_equal exp, subject.fail_results.first.message
|
33
36
|
end
|
34
37
|
|
35
38
|
end
|
36
39
|
|
37
40
|
class AssertNotSameTests < Assert::Context
|
38
|
-
desc "
|
41
|
+
desc "`assert_not_same`"
|
39
42
|
setup do
|
40
43
|
klass = Class.new; object = klass.new
|
41
44
|
desc = @desc = "assert not same fail desc"
|
@@ -44,6 +47,7 @@ module Assert::Assertions
|
|
44
47
|
assert_not_same(*args) # fail
|
45
48
|
assert_not_same(object, klass.new) # pass
|
46
49
|
end
|
50
|
+
@c = @test.config
|
47
51
|
@test.run
|
48
52
|
end
|
49
53
|
subject{ @test }
|
@@ -56,8 +60,73 @@ module Assert::Assertions
|
|
56
60
|
|
57
61
|
should "have a fail message with custom and generic explanations" do
|
58
62
|
exp = "#{@args[2]}\n"\
|
59
|
-
"#{Assert::U.show(@args[1]
|
60
|
-
"
|
63
|
+
"Expected #{Assert::U.show(@args[1], @c)}"\
|
64
|
+
" (#<#{@args[1].class}:#{'0x0%x' % (@args[1].object_id << 1)}>)"\
|
65
|
+
" to not be the same as #{Assert::U.show(@args[0], @c)}"\
|
66
|
+
" (#<#{@args[0].class}:#{'0x0%x' % (@args[0].object_id << 1)}>)."
|
67
|
+
assert_equal exp, subject.fail_results.first.message
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
class DiffTests < Assert::Context
|
73
|
+
desc "with objects that should use diff when showing"
|
74
|
+
setup do
|
75
|
+
@exp_obj = "I'm a\nstring"
|
76
|
+
@act_obj = "I am a \nstring"
|
77
|
+
|
78
|
+
@c = Factory.modes_off_config
|
79
|
+
@c.use_diff_proc(Assert::U.default_use_diff_proc)
|
80
|
+
@c.run_diff_proc(Assert::U.syscmd_diff_proc)
|
81
|
+
|
82
|
+
@exp_obj_show = Assert::U.show_for_diff(@exp_obj, @c)
|
83
|
+
@act_obj_show = Assert::U.show_for_diff(@act_obj, @c)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
class AssertSameDiffTests < DiffTests
|
89
|
+
desc "`assert_same`"
|
90
|
+
setup do
|
91
|
+
exp_obj, act_obj = @exp_obj, @act_obj
|
92
|
+
@test = Factory.test(@c) do
|
93
|
+
assert_same(exp_obj, act_obj)
|
94
|
+
end
|
95
|
+
@test.run
|
96
|
+
end
|
97
|
+
subject{ @test }
|
98
|
+
|
99
|
+
should "include diff output in the fail messages" do
|
100
|
+
exp = "Expected #<#{@act_obj.class}:#{'0x0%x' % (@act_obj.object_id << 1)}>"\
|
101
|
+
" to be the same as"\
|
102
|
+
" #<#{@exp_obj.class}:#{'0x0%x' % (@exp_obj.object_id << 1)}>"\
|
103
|
+
", diff:\n"\
|
104
|
+
"#{Assert::U.syscmd_diff_proc.call(@exp_obj_show, @act_obj_show)}"
|
105
|
+
assert_equal exp, subject.fail_results.first.message
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
class AssertNotSameDiffTests < DiffTests
|
111
|
+
desc "`assert_not_same`"
|
112
|
+
setup do
|
113
|
+
@exp_obj = @act_obj
|
114
|
+
@exp_obj_show = @act_obj_show
|
115
|
+
|
116
|
+
exp_obj, act_obj = @exp_obj, @act_obj
|
117
|
+
@test = Factory.test(@c) do
|
118
|
+
assert_not_same(exp_obj, exp_obj)
|
119
|
+
end
|
120
|
+
@test.run
|
121
|
+
end
|
122
|
+
subject{ @test }
|
123
|
+
|
124
|
+
should "include diff output in the fail messages" do
|
125
|
+
exp = "Expected #<#{@act_obj.class}:#{'0x0%x' % (@act_obj.object_id << 1)}>"\
|
126
|
+
" to not be the same as"\
|
127
|
+
" #<#{@exp_obj.class}:#{'0x0%x' % (@exp_obj.object_id << 1)}>"\
|
128
|
+
", diff:\n"\
|
129
|
+
"#{Assert::U.syscmd_diff_proc.call(@exp_obj_show, @act_obj_show)}"
|
61
130
|
assert_equal exp, subject.fail_results.first.message
|
62
131
|
end
|
63
132
|
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/assertions'
|
3
|
+
|
4
|
+
require 'assert/utils'
|
5
|
+
|
6
|
+
module Assert::Assertions
|
7
|
+
|
8
|
+
class AssertTrueTests < Assert::Context
|
9
|
+
desc "`assert_true`"
|
10
|
+
setup do
|
11
|
+
desc = @desc = "assert true fail desc"
|
12
|
+
args = @args = [ 'whatever', desc ]
|
13
|
+
@test = Factory.test do
|
14
|
+
assert_true(true) # pass
|
15
|
+
assert_true(*args) # fail
|
16
|
+
end
|
17
|
+
@c = @test.config
|
18
|
+
@test.run
|
19
|
+
end
|
20
|
+
subject{ @test }
|
21
|
+
|
22
|
+
should "produce results as expected" do
|
23
|
+
assert_equal 2, subject.result_count
|
24
|
+
assert_equal 1, subject.result_count(:pass)
|
25
|
+
assert_equal 1, subject.result_count(:fail)
|
26
|
+
end
|
27
|
+
|
28
|
+
should "have a fail message with custom and generic explanations" do
|
29
|
+
exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to be true."
|
30
|
+
assert_equal exp, subject.fail_results.first.message
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class AssertNotTrueTests < Assert::Context
|
36
|
+
desc "`assert_not_true`"
|
37
|
+
setup do
|
38
|
+
desc = @desc = "assert not true fail desc"
|
39
|
+
args = @args = [ true, desc ]
|
40
|
+
@test = Factory.test do
|
41
|
+
assert_not_true(false) # pass
|
42
|
+
assert_not_true(*args) # fail
|
43
|
+
end
|
44
|
+
@c = @test.config
|
45
|
+
@test.run
|
46
|
+
end
|
47
|
+
subject{ @test }
|
48
|
+
|
49
|
+
should "produce results as expected" do
|
50
|
+
assert_equal 2, subject.result_count
|
51
|
+
assert_equal 1, subject.result_count(:pass)
|
52
|
+
assert_equal 1, subject.result_count(:fail)
|
53
|
+
end
|
54
|
+
|
55
|
+
should "have a fail message with custom and generic explanations" do
|
56
|
+
exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to not be true."
|
57
|
+
assert_equal exp, subject.fail_results.first.message
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
class AssertFalseTests < Assert::Context
|
63
|
+
desc "`assert_false`"
|
64
|
+
setup do
|
65
|
+
desc = @desc = "assert false fail desc"
|
66
|
+
args = @args = [ 'whatever', desc ]
|
67
|
+
@test = Factory.test do
|
68
|
+
assert_false(false) # pass
|
69
|
+
assert_false(*args) # fail
|
70
|
+
end
|
71
|
+
@c = @test.config
|
72
|
+
@test.run
|
73
|
+
end
|
74
|
+
subject{ @test }
|
75
|
+
|
76
|
+
should "produce results as expected" do
|
77
|
+
assert_equal 2, subject.result_count
|
78
|
+
assert_equal 1, subject.result_count(:pass)
|
79
|
+
assert_equal 1, subject.result_count(:fail)
|
80
|
+
end
|
81
|
+
|
82
|
+
should "have a fail message with custom and generic explanations" do
|
83
|
+
exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to be false."
|
84
|
+
assert_equal exp, subject.fail_results.first.message
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
class AssertNotFalseTests < Assert::Context
|
90
|
+
desc "`assert_not_false`"
|
91
|
+
setup do
|
92
|
+
desc = @desc = "assert not false fail desc"
|
93
|
+
args = @args = [ false, desc ]
|
94
|
+
@test = Factory.test do
|
95
|
+
assert_not_false(true) # pass
|
96
|
+
assert_not_false(*args) # fail
|
97
|
+
end
|
98
|
+
@c = @test.config
|
99
|
+
@test.run
|
100
|
+
end
|
101
|
+
subject{ @test }
|
102
|
+
|
103
|
+
should "produce results as expected" do
|
104
|
+
assert_equal 2, subject.result_count
|
105
|
+
assert_equal 1, subject.result_count(:pass)
|
106
|
+
assert_equal 1, subject.result_count(:fail)
|
107
|
+
end
|
108
|
+
|
109
|
+
should "have a fail message with custom and generic explanations" do
|
110
|
+
exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to not be false."
|
111
|
+
assert_equal exp, subject.fail_results.first.message
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -3,12 +3,12 @@ require 'assert/assertions'
|
|
3
3
|
|
4
4
|
module Assert::Assertions
|
5
5
|
|
6
|
-
class
|
7
|
-
|
6
|
+
class UnitTests < Assert::Context
|
8
7
|
desc "An assert context"
|
9
8
|
setup do
|
10
|
-
@context_class = Factory.
|
11
|
-
@
|
9
|
+
@context_class = Factory.modes_off_context_class
|
10
|
+
@test = Factory.test
|
11
|
+
@context = @context_class.new(@test, @test.config)
|
12
12
|
end
|
13
13
|
subject{ @context }
|
14
14
|
|
@@ -28,11 +28,13 @@ module Assert::Assertions
|
|
28
28
|
should have_imeths :assert_included, :assert_not_included
|
29
29
|
should have_imeths :refute_includes, :refute_included
|
30
30
|
should have_imeths :assert_nil, :assert_not_nil, :refute_nil
|
31
|
+
should have_imeths :assert_true, :assert_not_true, :refute_true
|
32
|
+
should have_imeths :assert_false, :assert_not_false, :refute_false
|
31
33
|
should have_imeths :assert_file_exists, :assert_not_file_exists, :refute_file_exists
|
32
34
|
|
33
35
|
end
|
34
36
|
|
35
|
-
class IgnoredTests <
|
37
|
+
class IgnoredTests < UnitTests
|
36
38
|
desc "ignored assertions helpers"
|
37
39
|
setup do
|
38
40
|
@tests = Assert::Assertions::IGNORED_ASSERTION_HELPERS.map do |helper|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/config'
|
3
|
+
|
4
|
+
class Assert::Config
|
5
|
+
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Assert::Config"
|
8
|
+
setup do
|
9
|
+
@config = Assert::Config.new
|
10
|
+
end
|
11
|
+
subject{ @config }
|
12
|
+
|
13
|
+
should have_imeths :suite, :view, :runner
|
14
|
+
should have_imeths :test_dir, :test_helper, :test_file_suffixes, :runner_seed
|
15
|
+
should have_imeths :changed_proc, :pp_proc, :use_diff_proc, :run_diff_proc
|
16
|
+
should have_imeths :capture_output, :halt_on_fail, :changed_only, :pp_objects, :debug
|
17
|
+
should have_imeths :apply
|
18
|
+
|
19
|
+
should "default the view, suite, and runner" do
|
20
|
+
assert_kind_of Assert::View::DefaultView, subject.view
|
21
|
+
assert_kind_of Assert::Suite, subject.suite
|
22
|
+
assert_kind_of Assert::Runner, subject.runner
|
23
|
+
end
|
24
|
+
|
25
|
+
should "default the test dir/helper/suffixes/seed" do
|
26
|
+
assert_equal 'test', subject.test_dir
|
27
|
+
assert_equal 'helper.rb', subject.test_helper
|
28
|
+
assert_equal ['_tests.rb', "_test.rb"], subject.test_file_suffixes
|
29
|
+
assert_not_nil subject.runner_seed
|
30
|
+
end
|
31
|
+
|
32
|
+
should "default the procs" do
|
33
|
+
assert_not_nil subject.changed_proc
|
34
|
+
assert_not_nil subject.pp_proc
|
35
|
+
assert_not_nil subject.use_diff_proc
|
36
|
+
assert_not_nil subject.run_diff_proc
|
37
|
+
end
|
38
|
+
|
39
|
+
should "default the mode flags" do
|
40
|
+
assert_not subject.capture_output
|
41
|
+
assert subject.halt_on_fail
|
42
|
+
assert_not subject.changed_only
|
43
|
+
assert_not subject.pp_objects
|
44
|
+
assert_not subject.debug
|
45
|
+
end
|
46
|
+
|
47
|
+
should "apply settings given from a hash" do
|
48
|
+
assert subject.halt_on_fail
|
49
|
+
subject.apply(:halt_on_fail => false)
|
50
|
+
assert_not subject.halt_on_fail
|
51
|
+
|
52
|
+
assert Assert::Config.new.halt_on_fail
|
53
|
+
assert_not Assert::Config.new(:halt_on_fail => false).halt_on_fail
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -1,38 +1,36 @@
|
|
1
1
|
require 'assert'
|
2
|
-
require 'assert/context'
|
2
|
+
require 'assert/context/setup_dsl'
|
3
3
|
|
4
|
-
|
4
|
+
module Assert::Context::SetupDSL
|
5
|
+
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Assert::Context::SetupDSL"
|
8
|
+
subject{ @context_class }
|
5
9
|
|
6
|
-
# `ContextSingletonTests` defined in `test/helper.rb`
|
7
|
-
class SetupTeardownSingletonTests < ContextSingletonTests
|
8
|
-
desc "setup and teardown"
|
9
10
|
end
|
10
11
|
|
11
|
-
class SetupTeardownOnceMethodsTests <
|
12
|
+
class SetupTeardownOnceMethodsTests < UnitTests
|
12
13
|
desc "once methods"
|
13
14
|
setup do
|
14
15
|
block = @block = ::Proc.new{ something_once = true }
|
15
|
-
@context_class = Factory.
|
16
|
+
@context_class = Factory.modes_off_context_class do
|
16
17
|
setup_once(&block)
|
17
18
|
teardown_once(&block)
|
18
19
|
end
|
19
20
|
end
|
20
|
-
teardown do
|
21
|
-
Assert.suite.send(:setups).reject!{ |b| b == @block }
|
22
|
-
end
|
23
21
|
|
24
22
|
should "add the block to the suite" do
|
25
|
-
assert_includes @block,
|
26
|
-
assert_includes @block,
|
23
|
+
assert_includes @block, subject.suite.send(:setups)
|
24
|
+
assert_includes @block, subject.suite.send(:teardowns)
|
27
25
|
end
|
28
26
|
|
29
27
|
end
|
30
28
|
|
31
|
-
class SetupTeardownMethodsTests <
|
29
|
+
class SetupTeardownMethodsTests < UnitTests
|
32
30
|
desc "methods"
|
33
31
|
setup do
|
34
32
|
block = @block = ::Proc.new{ something = true }
|
35
|
-
@context_class = Factory.
|
33
|
+
@context_class = Factory.modes_off_context_class do
|
36
34
|
setup(&block)
|
37
35
|
teardown(&block)
|
38
36
|
end
|
@@ -45,11 +43,11 @@ class Assert::Context
|
|
45
43
|
|
46
44
|
end
|
47
45
|
|
48
|
-
class SetupTeardownWithMethodNameTests <
|
46
|
+
class SetupTeardownWithMethodNameTests < UnitTests
|
49
47
|
desc "methods given a method name"
|
50
48
|
setup do
|
51
49
|
method_name = @method_name = :something_amazing
|
52
|
-
@context_class = Factory.
|
50
|
+
@context_class = Factory.modes_off_context_class do
|
53
51
|
setup(method_name)
|
54
52
|
teardown(method_name)
|
55
53
|
end
|
@@ -62,19 +60,19 @@ class Assert::Context
|
|
62
60
|
|
63
61
|
end
|
64
62
|
|
65
|
-
class SetupTeardownMultipleTests <
|
63
|
+
class SetupTeardownMultipleTests < UnitTests
|
66
64
|
desc "with multiple calls"
|
67
65
|
setup do
|
68
66
|
parent_setup_block = ::Proc.new{ self.setup_status = "the setup" }
|
69
67
|
parent_teardown_block = ::Proc.new{ self.teardown_status += "the teardown" }
|
70
|
-
@parent_class = Factory.
|
68
|
+
@parent_class = Factory.modes_off_context_class do
|
71
69
|
setup(&parent_setup_block)
|
72
70
|
teardown(&parent_teardown_block)
|
73
71
|
end
|
74
72
|
|
75
73
|
context_setup_block = ::Proc.new{ self.setup_status += " has been run" }
|
76
74
|
context_teardown_block = ::Proc.new{ self.teardown_status += "has been run " }
|
77
|
-
@context_class = Factory.
|
75
|
+
@context_class = Factory.modes_off_context_class(@parent_class) do
|
78
76
|
setup(&context_setup_block)
|
79
77
|
setup(:setup_something)
|
80
78
|
teardown(:teardown_something)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/context/subject_dsl'
|
3
|
+
|
4
|
+
module Assert::Context::SubjectDSL
|
5
|
+
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Assert::Context::SubjectDSL"
|
8
|
+
subject{ @context_class }
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
class DescriptionsTests < UnitTests
|
13
|
+
desc "`descriptions` method"
|
14
|
+
setup do
|
15
|
+
descs = @descs = [ "something amazing", "it really is" ]
|
16
|
+
@context_class = Factory.modes_off_context_class do
|
17
|
+
descs.each{ |text| desc text }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
should "return a collection containing any descriptions defined on the class" do
|
22
|
+
assert_equal @descs, subject.send(:descriptions)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
class DescriptionTests < UnitTests
|
28
|
+
desc "`description` method"
|
29
|
+
setup do
|
30
|
+
parent_text = @parent_desc = "parent description"
|
31
|
+
@parent_class = Factory.modes_off_context_class do
|
32
|
+
desc parent_text
|
33
|
+
end
|
34
|
+
text = @desc = "and the description for this context"
|
35
|
+
@context_class = Factory.modes_off_context_class(@parent_class) do
|
36
|
+
desc text
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
should "return a string of all the inherited descriptions" do
|
41
|
+
exp_desc = "parent description and the description for this context"
|
42
|
+
assert_equal exp_desc, @context_class.description
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
class SubjectFromLocalTests < UnitTests
|
48
|
+
desc "`subject` method using local context"
|
49
|
+
setup do
|
50
|
+
subject_block = @subject_block = ::Proc.new{ @something }
|
51
|
+
@context_class = Factory.modes_off_context_class do
|
52
|
+
subject(&subject_block)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
should "set the subject block on the context class" do
|
57
|
+
assert_equal @subject_block, @context_class.subject
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
class SubjectFromParentTests < UnitTests
|
63
|
+
desc "`subject` method using parent context"
|
64
|
+
setup do
|
65
|
+
parent_block = @parent_block = ::Proc.new{ @something }
|
66
|
+
@parent_class = Factory.modes_off_context_class do
|
67
|
+
subject(&parent_block)
|
68
|
+
end
|
69
|
+
@context_class = Factory.modes_off_context_class(@parent_class)
|
70
|
+
end
|
71
|
+
|
72
|
+
should "default to it's parents subject block" do
|
73
|
+
assert_equal @parent_block, @context_class.subject
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|