assert 2.18.2 → 2.19.2

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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/README.md +7 -6
  4. data/assert.gemspec +5 -2
  5. data/bin/assert +1 -0
  6. data/lib/assert.rb +2 -0
  7. data/lib/assert/actual_value.rb +143 -0
  8. data/lib/assert/assert_runner.rb +2 -0
  9. data/lib/assert/assertions.rb +82 -20
  10. data/lib/assert/cli.rb +2 -0
  11. data/lib/assert/config.rb +2 -0
  12. data/lib/assert/config_helpers.rb +2 -0
  13. data/lib/assert/context.rb +33 -37
  14. data/lib/assert/context/let_dsl.rb +16 -0
  15. data/lib/assert/context/method_missing.rb +22 -0
  16. data/lib/assert/context/setup_dsl.rb +3 -0
  17. data/lib/assert/context/subject_dsl.rb +26 -24
  18. data/lib/assert/context/suite_dsl.rb +3 -0
  19. data/lib/assert/context/test_dsl.rb +3 -0
  20. data/lib/assert/context_info.rb +2 -0
  21. data/lib/assert/default_runner.rb +2 -0
  22. data/lib/assert/default_suite.rb +2 -0
  23. data/lib/assert/default_view.rb +2 -0
  24. data/lib/assert/factory.rb +2 -0
  25. data/lib/assert/file_line.rb +2 -0
  26. data/lib/assert/macro.rb +2 -0
  27. data/lib/assert/macros/methods.rb +6 -4
  28. data/lib/assert/result.rb +8 -1
  29. data/lib/assert/runner.rb +2 -0
  30. data/lib/assert/stub.rb +45 -0
  31. data/lib/assert/suite.rb +9 -10
  32. data/lib/assert/test.rb +3 -9
  33. data/lib/assert/utils.rb +3 -1
  34. data/lib/assert/version.rb +3 -1
  35. data/lib/assert/view.rb +2 -0
  36. data/lib/assert/view_helpers.rb +2 -0
  37. data/test/helper.rb +28 -28
  38. data/test/support/factory.rb +17 -0
  39. data/test/support/inherited_stuff.rb +2 -0
  40. data/test/system/stub_tests.rb +334 -333
  41. data/test/system/test_tests.rb +101 -109
  42. data/test/unit/actual_value_tests.rb +373 -0
  43. data/test/unit/assert_tests.rb +79 -61
  44. data/test/unit/assertions/assert_block_tests.rb +32 -31
  45. data/test/unit/assertions/assert_changes_tests.rb +99 -0
  46. data/test/unit/assertions/assert_empty_tests.rb +35 -32
  47. data/test/unit/assertions/assert_equal_tests.rb +96 -74
  48. data/test/unit/assertions/assert_file_exists_tests.rb +34 -33
  49. data/test/unit/assertions/assert_includes_tests.rb +40 -37
  50. data/test/unit/assertions/assert_instance_of_tests.rb +36 -33
  51. data/test/unit/assertions/assert_kind_of_tests.rb +36 -33
  52. data/test/unit/assertions/assert_match_tests.rb +36 -33
  53. data/test/unit/assertions/assert_nil_tests.rb +32 -31
  54. data/test/unit/assertions/assert_raises_tests.rb +57 -55
  55. data/test/unit/assertions/assert_respond_to_tests.rb +38 -35
  56. data/test/unit/assertions/assert_same_tests.rb +88 -81
  57. data/test/unit/assertions/assert_true_false_tests.rb +62 -60
  58. data/test/unit/assertions_tests.rb +28 -24
  59. data/test/unit/config_helpers_tests.rb +45 -38
  60. data/test/unit/config_tests.rb +40 -34
  61. data/test/unit/context/let_dsl_tests.rb +12 -0
  62. data/test/unit/context/setup_dsl_tests.rb +72 -81
  63. data/test/unit/context/subject_dsl_tests.rb +17 -43
  64. data/test/unit/context/suite_dsl_tests.rb +17 -16
  65. data/test/unit/context/test_dsl_tests.rb +52 -52
  66. data/test/unit/context_info_tests.rb +25 -15
  67. data/test/unit/context_tests.rb +186 -179
  68. data/test/unit/default_runner_tests.rb +4 -5
  69. data/test/unit/default_suite_tests.rb +59 -53
  70. data/test/unit/factory_tests.rb +7 -3
  71. data/test/unit/file_line_tests.rb +35 -35
  72. data/test/unit/macro_tests.rb +16 -10
  73. data/test/unit/result_tests.rb +161 -183
  74. data/test/unit/runner_tests.rb +67 -65
  75. data/test/unit/suite_tests.rb +58 -59
  76. data/test/unit/test_tests.rb +120 -139
  77. data/test/unit/utils_tests.rb +45 -45
  78. data/test/unit/view_helpers_tests.rb +56 -52
  79. data/test/unit/view_tests.rb +24 -23
  80. metadata +29 -6
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/config_helpers"
3
5
 
@@ -6,19 +8,24 @@ require "assert/config"
6
8
  module Assert::ConfigHelpers
7
9
  class UnitTests < Assert::Context
8
10
  desc "Assert::ConfigHelpers"
9
- setup do
10
- @helpers_class = Class.new do
11
+ subject { unit_class }
12
+
13
+ let(:unit_class) {
14
+ Class.new do
11
15
  include Assert::ConfigHelpers
12
16
 
13
17
  def config
14
18
  # use the assert config since it has tests, contexts, etc
15
- # also maybe use a fresh config that is empty
19
+ # also use a fresh config that is empty
16
20
  @config ||= [Assert.config, Assert::Config.new].sample
17
21
  end
18
22
  end
19
- @helpers = @helpers_class.new
20
- end
21
- subject{ @helpers }
23
+ }
24
+ end
25
+
26
+ class InitTests < UnitTests
27
+ desc "when init"
28
+ subject { unit_class.new }
22
29
 
23
30
  should have_imeths :runner, :suite, :view
24
31
  should have_imeths :runner_seed, :single_test?, :single_test_file_line
@@ -34,67 +41,67 @@ module Assert::ConfigHelpers
34
41
  should have_imeths :ocurring_result_types
35
42
 
36
43
  should "know the config's runner, suite and view" do
37
- assert_equal subject.config.runner, subject.runner
38
- assert_equal subject.config.suite, subject.suite
39
- assert_equal subject.config.view, subject.view
44
+ assert_that(subject.runner).equals(subject.config.runner)
45
+ assert_that(subject.suite).equals(subject.config.suite)
46
+ assert_that(subject.view).equals(subject.config.view)
40
47
  end
41
48
 
42
49
  should "know its runner seed" do
43
- assert_equal subject.config.runner_seed, subject.runner_seed
50
+ assert_that(subject.runner_seed).equals(subject.config.runner_seed)
44
51
  end
45
52
 
46
53
  should "know if it is in single test mode" do
47
- Assert.stub(subject.config, :single_test?){ true }
48
- assert_true subject.single_test?
54
+ Assert.stub(subject.config, :single_test?) { true }
55
+ assert_that(subject.single_test?).is_true
49
56
 
50
- Assert.stub(subject.config, :single_test?){ false }
51
- assert_false subject.single_test?
57
+ Assert.stub(subject.config, :single_test?) { false }
58
+ assert_that(subject.single_test?).is_false
52
59
  end
53
60
 
54
61
  should "know its single test file line" do
55
62
  exp = subject.config.single_test_file_line
56
- assert_equal exp, subject.single_test_file_line
63
+ assert_that(subject.single_test_file_line).equals(exp)
57
64
  end
58
65
 
59
66
  should "know its tests-to-run attrs" do
60
67
  exp = subject.config.suite.tests_to_run?
61
- assert_equal exp, subject.tests_to_run?
68
+ assert_that(subject.tests_to_run?).equals(exp)
62
69
 
63
70
  exp = subject.config.suite.tests_to_run_count
64
- assert_equal exp, subject.tests_to_run_count
71
+ assert_that(subject.tests_to_run_count).equals(exp)
65
72
  end
66
73
 
67
74
  should "know its test/result counts" do
68
75
  exp = subject.config.suite.test_count
69
- assert_equal exp, subject.test_count
76
+ assert_that(subject.test_count).equals(exp)
70
77
 
71
78
  exp = subject.config.suite.result_count
72
- assert_equal exp, subject.result_count
79
+ assert_that(subject.result_count).equals(exp)
73
80
 
74
81
  exp = subject.config.suite.pass_result_count
75
- assert_equal exp, subject.pass_result_count
82
+ assert_that(subject.pass_result_count).equals(exp)
76
83
 
77
84
  exp = subject.config.suite.fail_result_count
78
- assert_equal exp, subject.fail_result_count
85
+ assert_that(subject.fail_result_count).equals(exp)
79
86
 
80
87
  exp = subject.config.suite.error_result_count
81
- assert_equal exp, subject.error_result_count
88
+ assert_that(subject.error_result_count).equals(exp)
82
89
 
83
90
  exp = subject.config.suite.skip_result_count
84
- assert_equal exp, subject.skip_result_count
91
+ assert_that(subject.skip_result_count).equals(exp)
85
92
 
86
93
  exp = subject.config.suite.ignore_result_count
87
- assert_equal exp, subject.ignore_result_count
94
+ assert_that(subject.ignore_result_count).equals(exp)
88
95
  end
89
96
 
90
97
  should "know if all tests are passing or not" do
91
98
  result_count = Factory.integer
92
99
  Assert.stub(subject, :result_count){ result_count }
93
100
  Assert.stub(subject, :pass_result_count){ result_count }
94
- assert_true subject.all_pass?
101
+ assert_that(subject.all_pass?).is_true
95
102
 
96
103
  Assert.stub(subject, :pass_result_count){ Factory.integer }
97
- assert_false subject.all_pass?
104
+ assert_that(subject.all_pass?).is_false
98
105
  end
99
106
 
100
107
  should "know its formatted run time, test rate and result rate" do
@@ -102,39 +109,39 @@ module Assert::ConfigHelpers
102
109
 
103
110
  run_time = Factory.float
104
111
  exp = format % run_time
105
- assert_equal exp, subject.formatted_run_time(run_time, format)
106
- assert_equal exp, subject.formatted_run_time(run_time)
112
+ assert_that(subject.formatted_run_time(run_time, format)).equals(exp)
113
+ assert_that(subject.formatted_run_time(run_time)).equals(exp)
107
114
 
108
115
  test_rate = Factory.float
109
116
  exp = format % test_rate
110
- assert_equal exp, subject.formatted_result_rate(test_rate, format)
111
- assert_equal exp, subject.formatted_result_rate(test_rate)
117
+ assert_that(subject.formatted_result_rate(test_rate, format)).equals(exp)
118
+ assert_that(subject.formatted_result_rate(test_rate)).equals(exp)
112
119
 
113
120
  result_rate = Factory.float
114
121
  exp = format % result_rate
115
- assert_equal exp, subject.formatted_result_rate(result_rate, format)
116
- assert_equal exp, subject.formatted_result_rate(result_rate)
122
+ assert_that(subject.formatted_result_rate(result_rate, format)).equals(exp)
123
+ assert_that(subject.formatted_result_rate(result_rate)).equals(exp)
117
124
  end
118
125
 
119
126
  should "know its formatted suite run time, test rate and result rate" do
120
127
  format = "%.6f"
121
128
 
122
129
  exp = format % subject.config.suite.run_time
123
- assert_equal exp, subject.formatted_suite_run_time(format)
130
+ assert_that(subject.formatted_suite_run_time(format)).equals(exp)
124
131
 
125
132
  exp = format % subject.config.suite.test_rate
126
- assert_equal exp, subject.formatted_suite_test_rate(format)
133
+ assert_that(subject.formatted_suite_test_rate(format)).equals(exp)
127
134
 
128
135
  exp = format % subject.config.suite.result_rate
129
- assert_equal exp, subject.formatted_suite_result_rate(format)
136
+ assert_that(subject.formatted_suite_result_rate(format)).equals(exp)
130
137
  end
131
138
 
132
139
  should "know whether to show test profile info" do
133
- assert_equal !!subject.config.profile, subject.show_test_profile_info?
140
+ assert_that(subject.show_test_profile_info?).equals(!!subject.config.profile)
134
141
  end
135
142
 
136
143
  should "know whether to show verbose info" do
137
- assert_equal !!subject.config.verbose, subject.show_test_verbose_info?
144
+ assert_that(subject.show_test_verbose_info?).equals(!!subject.config.verbose)
138
145
  end
139
146
 
140
147
  should "know what result types occur in a suite's results" do
@@ -145,7 +152,7 @@ module Assert::ConfigHelpers
145
152
  exp = result_types.select do |type_sym|
146
153
  subject.send("#{type_sym}_result_count") > 0
147
154
  end
148
- assert_equal exp, subject.ocurring_result_types
155
+ assert_that(subject.ocurring_result_types).equals(exp)
149
156
  end
150
157
  end
151
158
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/config"
3
5
 
@@ -10,10 +12,14 @@ require "assert/runner"
10
12
  class Assert::Config
11
13
  class UnitTests < Assert::Context
12
14
  desc "Assert::Config"
13
- setup do
14
- @config = Assert::Config.new
15
- end
16
- subject{ @config }
15
+ subject { unit_class }
16
+
17
+ let(:unit_class) { Assert::Config }
18
+ end
19
+
20
+ class InitTests < UnitTests
21
+ desc "when init"
22
+ subject { unit_class.new }
17
23
 
18
24
  should have_imeths :view, :suite, :runner
19
25
  should have_imeths :test_dir, :test_helper, :test_file_suffixes
@@ -25,73 +31,73 @@ class Assert::Config
25
31
  should have_imeths :single_test_file_line, :single_test_file_path
26
32
 
27
33
  should "default the view, suite, and runner" do
28
- assert_kind_of Assert::DefaultView, subject.view
29
- assert_kind_of Assert::DefaultSuite, subject.suite
30
- assert_kind_of Assert::DefaultRunner, subject.runner
34
+ assert_that(subject.view).is_kind_of(Assert::DefaultView)
35
+ assert_that(subject.suite).is_kind_of(Assert::DefaultSuite)
36
+ assert_that(subject.runner).is_kind_of(Assert::DefaultRunner)
31
37
  end
32
38
 
33
39
  should "default the test dir/helper/suffixes" do
34
- assert_equal "test", subject.test_dir
35
- assert_equal "helper.rb", subject.test_helper
36
- assert_equal ["_tests.rb", "_test.rb"], subject.test_file_suffixes
40
+ assert_that(subject.test_dir).equals("test")
41
+ assert_that(subject.test_helper).equals("helper.rb")
42
+ assert_that(subject.test_file_suffixes).equals(["_tests.rb", "_test.rb"])
37
43
  end
38
44
 
39
45
  should "default the procs" do
40
- assert_not_nil subject.changed_proc
41
- assert_not_nil subject.pp_proc
42
- assert_not_nil subject.use_diff_proc
43
- assert_not_nil subject.run_diff_proc
46
+ assert_that(subject.changed_proc).is_not_nil
47
+ assert_that(subject.pp_proc).is_not_nil
48
+ assert_that(subject.use_diff_proc).is_not_nil
49
+ assert_that(subject.run_diff_proc).is_not_nil
44
50
  end
45
51
 
46
52
  should "default the option settings" do
47
- assert_not_nil subject.runner_seed
48
- assert_not subject.changed_only
49
- assert_empty subject.changed_ref
50
- assert_empty subject.single_test
51
- assert_not subject.pp_objects
52
- assert_not subject.capture_output
53
- assert subject.halt_on_fail
54
- assert_not subject.profile
55
- assert_not subject.verbose
56
- assert_not subject.list
57
- assert_not subject.debug
53
+ assert_that(subject.runner_seed).is_not_nil
54
+ assert_that(subject.changed_only).is_false
55
+ assert_that(subject.changed_ref).is_empty
56
+ assert_that(subject.single_test).is_empty
57
+ assert_that(subject.pp_objects).is_false
58
+ assert_that(subject.capture_output).is_false
59
+ assert_that(subject.halt_on_fail).is_true
60
+ assert_that(subject.profile).is_false
61
+ assert_that(subject.verbose).is_false
62
+ assert_that(subject.list).is_false
63
+ assert_that(subject.debug).is_false
58
64
  end
59
65
 
60
66
  should "apply settings given from a hash" do
61
67
  assert subject.halt_on_fail
62
68
  subject.apply(:halt_on_fail => false)
63
- assert_not subject.halt_on_fail
69
+ assert_that(subject.halt_on_fail).is_false
64
70
 
65
- assert Assert::Config.new.halt_on_fail
66
- assert_not Assert::Config.new(:halt_on_fail => false).halt_on_fail
71
+ assert_that(Assert::Config.new.halt_on_fail).is_true
72
+ assert_that(Assert::Config.new(:halt_on_fail => false).halt_on_fail).is_false
67
73
  end
68
74
 
69
75
  should "know if it is in single test mode" do
70
- assert_false subject.single_test?
76
+ assert_that(subject.single_test?).is_false
71
77
 
72
78
  subject.apply(:single_test => Factory.string)
73
- assert_true subject.single_test?
79
+ assert_that(subject.single_test?).is_true
74
80
  end
75
81
 
76
82
  should "know its single test file line" do
77
83
  exp = Assert::FileLine.parse(File.expand_path("", Dir.pwd))
78
- assert_equal exp, subject.single_test_file_line
84
+ assert_that(subject.single_test_file_line).equals(exp)
79
85
 
80
86
  file_line_path = "#{Factory.path}_tests.rb:#{Factory.integer}"
81
87
  subject.apply(:single_test => file_line_path)
82
88
 
83
89
  exp = Assert::FileLine.parse(File.expand_path(file_line_path, Dir.pwd))
84
- assert_equal exp, subject.single_test_file_line
90
+ assert_that(subject.single_test_file_line).equals(exp)
85
91
  end
86
92
 
87
93
  should "know its single test file path" do
88
94
  exp = Assert::FileLine.parse(File.expand_path("", Dir.pwd)).file
89
- assert_equal exp, subject.single_test_file_path
95
+ assert_that(subject.single_test_file_path).equals(exp)
90
96
 
91
97
  path = "#{Factory.path}_tests.rb"
92
98
  file_line_path = "#{path}:#{Factory.integer}"
93
99
  subject.apply(:single_test => file_line_path)
94
- assert_equal File.expand_path(path, Dir.pwd), subject.single_test_file_path
100
+ assert_that(subject.single_test_file_path).equals(File.expand_path(path, Dir.pwd))
95
101
  end
96
102
  end
97
103
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "assert"
4
+ require "assert/context/let_dsl"
5
+
6
+ module Assert::Context::LetDSL
7
+ class UnitTests < Assert::Context
8
+ desc "Assert::Context::LetDSL"
9
+
10
+ # This is tested implicitly by running Assert's test suite.
11
+ end
12
+ end
@@ -1,80 +1,70 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/context/setup_dsl"
3
5
 
4
6
  module Assert::Context::SetupDSL
5
7
  class UnitTests < Assert::Context
6
8
  desc "Assert::Context::SetupDSL"
7
- subject{ @context_class }
9
+ subject { Factory.modes_off_context_class }
10
+
11
+ let(:block1) { ::Proc.new {} }
8
12
  end
9
13
 
10
14
  class SetupTeardownOnceMethodsTests < UnitTests
11
15
  desc "once methods"
12
- setup do
13
- block = @block = ::Proc.new{ something_once = true }
14
- @context_class = Factory.modes_off_context_class do
15
- setup_once(&block)
16
- teardown_once(&block)
17
- end
18
- end
19
16
 
20
17
  should "add the block to the suite" do
21
- assert_includes @block, subject.suite.send(:setups)
22
- assert_includes @block, subject.suite.send(:teardowns)
18
+ subject.setup_once(&block1)
19
+ subject.teardown_once(&block1)
20
+
21
+ assert_that(subject.suite.send(:setups)).includes(block1)
22
+ assert_that(subject.suite.send(:teardowns)).includes(block1)
23
23
  end
24
24
  end
25
25
 
26
26
  class SetupTeardownMethodsTests < UnitTests
27
27
  desc "methods"
28
- setup do
29
- block = @block = ::Proc.new{ something = true }
30
- @context_class = Factory.modes_off_context_class do
31
- setup(&block)
32
- teardown(&block)
33
- end
34
- end
35
28
 
36
29
  should "add the block to the context" do
37
- assert_includes @block, subject.send(:setups)
38
- assert_includes @block, subject.send(:teardowns)
30
+ subject.setup(&block1)
31
+ subject.teardown(&block1)
32
+
33
+ assert_that(subject.send(:setups)).includes(block1)
34
+ assert_that(subject.send(:teardowns)).includes(block1)
39
35
  end
40
36
  end
41
37
 
42
38
  class SetupTeardownWithMethodNameTests < UnitTests
43
39
  desc "methods given a method name"
44
- setup do
45
- method_name = @method_name = :something_amazing
46
- @context_class = Factory.modes_off_context_class do
47
- setup(method_name)
48
- teardown(method_name)
49
- end
50
- end
40
+
41
+ let(:method_name1) { :something_amazing }
51
42
 
52
43
  should "add the method name to the context" do
53
- assert_includes @method_name, subject.send(:setups)
54
- assert_includes @method_name, subject.send(:teardowns)
44
+ subject.setup(method_name1)
45
+ subject.teardown(method_name1)
46
+
47
+ assert_that(subject.send(:setups)).includes(method_name1)
48
+ assert_that(subject.send(:teardowns)).includes(method_name1)
55
49
  end
56
50
  end
57
51
 
58
- class SetupTeardownMultipleTests < UnitTests
52
+ class ParentContextClassTests < UnitTests
53
+ subject { Factory.modes_off_context_class(parent_class1) }
54
+
55
+ let(:parent_class1) { Factory.modes_off_context_class }
56
+ end
57
+
58
+ class SetupTeardownMultipleTests < ParentContextClassTests
59
59
  desc "with multiple calls"
60
- setup do
61
- parent_setup_block = ::Proc.new{ self.setup_status = "the setup" }
62
- parent_teardown_block = ::Proc.new{ self.teardown_status += "the teardown" }
63
- @parent_class = Factory.modes_off_context_class do
64
- setup(&parent_setup_block)
65
- teardown(&parent_teardown_block)
66
- end
67
60
 
68
- context_setup_block = ::Proc.new{ self.setup_status += " has been run" }
69
- context_teardown_block = ::Proc.new{ self.teardown_status += "has been run " }
70
- @context_class = Factory.modes_off_context_class(@parent_class) do
71
- setup(&context_setup_block)
72
- setup(:setup_something)
73
- teardown(:teardown_something)
74
- teardown(&context_teardown_block)
75
- end
61
+ let(:parent_setup_block1) { ::Proc.new { self.setup_status = "the setup" } }
62
+ let(:parent_teardown_block1) { ::Proc.new { self.teardown_status += "the teardown" } }
63
+ let(:context_setup_block1) { ::Proc.new { self.setup_status += " has been run" } }
64
+ let(:context_teardown_block1) { ::Proc.new { self.teardown_status += "has been run " } }
76
65
 
77
- @test_status_class = Class.new do
66
+ let(:test_status_class) {
67
+ Class.new do
78
68
  attr_accessor :setup_status, :teardown_status
79
69
  define_method(:setup_something) do
80
70
  self.setup_status += " with something"
@@ -83,57 +73,58 @@ module Assert::Context::SetupDSL
83
73
  self.teardown_status = "with something "
84
74
  end
85
75
  end
86
- end
76
+ }
77
+
78
+ should "run its parent and its own blocks in the correct order" do
79
+ parent_class1.setup(&parent_setup_block1)
80
+ parent_class1.teardown(&parent_teardown_block1)
81
+ subject.setup(&context_setup_block1)
82
+ subject.setup(:setup_something)
83
+ subject.teardown(:teardown_something)
84
+ subject.teardown(&context_teardown_block1)
87
85
 
88
- should "run it's parent and it's own blocks in the correct order" do
89
- subject.send("run_setups", obj = @test_status_class.new)
90
- assert_equal "the setup has been run with something", obj.setup_status
86
+ subject.send("run_setups", obj = test_status_class.new)
87
+ assert_that(obj.setup_status).equals("the setup has been run with something")
91
88
 
92
- subject.send("run_teardowns", obj = @test_status_class.new)
93
- assert_equal "with something has been run the teardown", obj.teardown_status
89
+ subject.send("run_teardowns", obj = test_status_class.new)
90
+ assert_that(obj.teardown_status).equals("with something has been run the teardown")
94
91
  end
95
92
  end
96
93
 
97
- class AroundMethodTests < UnitTests
94
+ class AroundMethodTests < ParentContextClassTests
98
95
  desc "with multiple `around` calls"
99
- setup do
100
- @parent_class = Factory.modes_off_context_class do
101
- around do |block|
102
- self.out_status ||= ""
103
- self.out_status += "p-around start, "
104
- block.call
105
- self.out_status += "p-around end."
106
- end
107
- end
108
96
 
109
- @context_class = Factory.modes_off_context_class(@parent_class) do
110
- around do |block|
111
- self.out_status += "c-around1 start, "
112
- block.call
113
- self.out_status += "c-around1 end, "
114
- end
115
- around do |block|
116
- self.out_status += "c-around2 start, "
117
- block.call
118
- self.out_status += "c-around2 end, "
119
- end
97
+ let(:test_status_class) { Class.new { attr_accessor :out_status } }
98
+
99
+ should "run its parent and its own blocks in the correct order" do
100
+ parent_class1.around do |block|
101
+ self.out_status ||= ""
102
+ self.out_status += "p-around start, "
103
+ block.call
104
+ self.out_status += "p-around end."
120
105
  end
121
106
 
122
- @test_status_class = Class.new do
123
- attr_accessor :out_status
107
+ subject.around do |block|
108
+ self.out_status += "c-around1 start, "
109
+ block.call
110
+ self.out_status += "c-around1 end, "
111
+ end
112
+ subject.around do |block|
113
+ self.out_status += "c-around2 start, "
114
+ block.call
115
+ self.out_status += "c-around2 end, "
124
116
  end
125
- end
126
117
 
127
- should "run it's parent and it's own blocks in the correct order" do
128
- obj = @test_status_class.new
118
+ obj = test_status_class.new
129
119
  subject.send("run_arounds", obj) do
130
120
  obj.instance_eval{ self.out_status += "TEST, " }
131
121
  end
132
122
 
133
- exp = "p-around start, c-around1 start, c-around2 start, "\
134
- "TEST, "\
135
- "c-around2 end, c-around1 end, p-around end."
136
- assert_equal exp, obj.out_status
123
+ exp =
124
+ "p-around start, c-around1 start, c-around2 start, "\
125
+ "TEST, "\
126
+ "c-around2 end, c-around1 end, p-around end."
127
+ assert_that(obj.out_status).equals(exp)
137
128
  end
138
129
  end
139
130
  end