assert 2.17.0 → 2.18.4

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 +2 -2
  3. data/README.md +66 -41
  4. data/assert.gemspec +2 -3
  5. data/lib/assert.rb +0 -10
  6. data/lib/assert/actual_value.rb +127 -0
  7. data/lib/assert/assert_runner.rb +0 -3
  8. data/lib/assert/assertions.rb +10 -23
  9. data/lib/assert/cli.rb +30 -46
  10. data/lib/assert/config.rb +0 -4
  11. data/lib/assert/config_helpers.rb +0 -4
  12. data/lib/assert/context.rb +18 -9
  13. data/lib/assert/context/let_dsl.rb +13 -0
  14. data/lib/assert/context/method_missing.rb +19 -0
  15. data/lib/assert/context/setup_dsl.rb +0 -4
  16. data/lib/assert/context/subject_dsl.rb +23 -28
  17. data/lib/assert/context/suite_dsl.rb +0 -4
  18. data/lib/assert/context/test_dsl.rb +0 -4
  19. data/lib/assert/context_info.rb +0 -4
  20. data/lib/assert/default_runner.rb +0 -4
  21. data/lib/assert/default_suite.rb +0 -5
  22. data/lib/assert/default_view.rb +0 -4
  23. data/lib/assert/factory.rb +0 -3
  24. data/lib/assert/file_line.rb +0 -4
  25. data/lib/assert/macro.rb +0 -3
  26. data/lib/assert/macros/methods.rb +4 -10
  27. data/lib/assert/result.rb +2 -17
  28. data/lib/assert/runner.rb +0 -3
  29. data/lib/assert/stub.rb +15 -1
  30. data/lib/assert/suite.rb +0 -4
  31. data/lib/assert/test.rb +2 -7
  32. data/lib/assert/utils.rb +0 -4
  33. data/lib/assert/version.rb +1 -1
  34. data/lib/assert/view.rb +0 -3
  35. data/lib/assert/view_helpers.rb +0 -11
  36. data/log/{.gitkeep → .keep} +0 -0
  37. data/test/helper.rb +23 -29
  38. data/test/support/factory.rb +14 -0
  39. data/test/support/inherited_stuff.rb +0 -2
  40. data/test/system/stub_tests.rb +332 -352
  41. data/test/system/test_tests.rb +98 -124
  42. data/test/unit/actual_value_tests.rb +335 -0
  43. data/test/unit/assert_tests.rb +121 -46
  44. data/test/unit/assertions/assert_block_tests.rb +30 -35
  45. data/test/unit/assertions/assert_empty_tests.rb +33 -35
  46. data/test/unit/assertions/assert_equal_tests.rb +75 -83
  47. data/test/unit/assertions/assert_file_exists_tests.rb +32 -36
  48. data/test/unit/assertions/assert_includes_tests.rb +38 -41
  49. data/test/unit/assertions/assert_instance_of_tests.rb +34 -37
  50. data/test/unit/assertions/assert_kind_of_tests.rb +34 -37
  51. data/test/unit/assertions/assert_match_tests.rb +34 -37
  52. data/test/unit/assertions/assert_nil_tests.rb +30 -35
  53. data/test/unit/assertions/assert_raises_tests.rb +54 -60
  54. data/test/unit/assertions/assert_respond_to_tests.rb +36 -39
  55. data/test/unit/assertions/assert_same_tests.rb +86 -88
  56. data/test/unit/assertions/assert_true_false_tests.rb +60 -66
  57. data/test/unit/assertions_tests.rb +14 -17
  58. data/test/unit/config_helpers_tests.rb +41 -39
  59. data/test/unit/config_tests.rb +38 -37
  60. data/test/unit/context/let_dsl_tests.rb +10 -0
  61. data/test/unit/context/setup_dsl_tests.rb +68 -87
  62. data/test/unit/context/subject_dsl_tests.rb +15 -49
  63. data/test/unit/context/suite_dsl_tests.rb +15 -20
  64. data/test/unit/context/test_dsl_tests.rb +50 -57
  65. data/test/unit/context_info_tests.rb +23 -18
  66. data/test/unit/context_tests.rb +183 -194
  67. data/test/unit/default_runner_tests.rb +1 -7
  68. data/test/unit/default_suite_tests.rb +57 -56
  69. data/test/unit/factory_tests.rb +5 -6
  70. data/test/unit/file_line_tests.rb +33 -39
  71. data/test/unit/macro_tests.rb +14 -18
  72. data/test/unit/result_tests.rb +159 -196
  73. data/test/unit/runner_tests.rb +64 -71
  74. data/test/unit/suite_tests.rb +58 -59
  75. data/test/unit/test_tests.rb +125 -136
  76. data/test/unit/utils_tests.rb +43 -54
  77. data/test/unit/view_helpers_tests.rb +54 -58
  78. data/test/unit/view_tests.rb +22 -27
  79. metadata +15 -10
  80. data/tmp/.gitkeep +0 -0
@@ -0,0 +1,10 @@
1
+ require "assert"
2
+ require "assert/context/let_dsl"
3
+
4
+ module Assert::Context::LetDSL
5
+ class UnitTests < Assert::Context
6
+ desc "Assert::Context::LetDSL"
7
+
8
+ # This is tested implicitly by running Assert's test suite.
9
+ end
10
+ end
@@ -2,84 +2,67 @@ require "assert"
2
2
  require "assert/context/setup_dsl"
3
3
 
4
4
  module Assert::Context::SetupDSL
5
-
6
5
  class UnitTests < Assert::Context
7
6
  desc "Assert::Context::SetupDSL"
8
- subject{ @context_class }
7
+ subject { Factory.modes_off_context_class }
9
8
 
9
+ let(:block1) { ::Proc.new {} }
10
10
  end
11
11
 
12
12
  class SetupTeardownOnceMethodsTests < UnitTests
13
13
  desc "once methods"
14
- setup do
15
- block = @block = ::Proc.new{ something_once = true }
16
- @context_class = Factory.modes_off_context_class do
17
- setup_once(&block)
18
- teardown_once(&block)
19
- end
20
- end
21
14
 
22
15
  should "add the block to the suite" do
23
- assert_includes @block, subject.suite.send(:setups)
24
- assert_includes @block, subject.suite.send(:teardowns)
25
- end
16
+ subject.setup_once(&block1)
17
+ subject.teardown_once(&block1)
26
18
 
19
+ assert_that(subject.suite.send(:setups)).includes(block1)
20
+ assert_that(subject.suite.send(:teardowns)).includes(block1)
21
+ end
27
22
  end
28
23
 
29
24
  class SetupTeardownMethodsTests < UnitTests
30
25
  desc "methods"
31
- setup do
32
- block = @block = ::Proc.new{ something = true }
33
- @context_class = Factory.modes_off_context_class do
34
- setup(&block)
35
- teardown(&block)
36
- end
37
- end
38
26
 
39
27
  should "add the block to the context" do
40
- assert_includes @block, subject.send(:setups)
41
- assert_includes @block, subject.send(:teardowns)
42
- end
28
+ subject.setup(&block1)
29
+ subject.teardown(&block1)
43
30
 
31
+ assert_that(subject.send(:setups)).includes(block1)
32
+ assert_that(subject.send(:teardowns)).includes(block1)
33
+ end
44
34
  end
45
35
 
46
36
  class SetupTeardownWithMethodNameTests < UnitTests
47
37
  desc "methods given a method name"
48
- setup do
49
- method_name = @method_name = :something_amazing
50
- @context_class = Factory.modes_off_context_class do
51
- setup(method_name)
52
- teardown(method_name)
53
- end
54
- end
38
+
39
+ let(:method_name1) { :something_amazing }
55
40
 
56
41
  should "add the method name to the context" do
57
- assert_includes @method_name, subject.send(:setups)
58
- assert_includes @method_name, subject.send(:teardowns)
42
+ subject.setup(method_name1)
43
+ subject.teardown(method_name1)
44
+
45
+ assert_that(subject.send(:setups)).includes(method_name1)
46
+ assert_that(subject.send(:teardowns)).includes(method_name1)
59
47
  end
48
+ end
49
+
50
+ class ParentContextClassTests < UnitTests
51
+ subject { Factory.modes_off_context_class(parent_class1) }
60
52
 
53
+ let(:parent_class1) { Factory.modes_off_context_class }
61
54
  end
62
55
 
63
- class SetupTeardownMultipleTests < UnitTests
56
+ class SetupTeardownMultipleTests < ParentContextClassTests
64
57
  desc "with multiple calls"
65
- setup do
66
- parent_setup_block = ::Proc.new{ self.setup_status = "the setup" }
67
- parent_teardown_block = ::Proc.new{ self.teardown_status += "the teardown" }
68
- @parent_class = Factory.modes_off_context_class do
69
- setup(&parent_setup_block)
70
- teardown(&parent_teardown_block)
71
- end
72
58
 
73
- context_setup_block = ::Proc.new{ self.setup_status += " has been run" }
74
- context_teardown_block = ::Proc.new{ self.teardown_status += "has been run " }
75
- @context_class = Factory.modes_off_context_class(@parent_class) do
76
- setup(&context_setup_block)
77
- setup(:setup_something)
78
- teardown(:teardown_something)
79
- teardown(&context_teardown_block)
80
- end
59
+ let(:parent_setup_block1) { ::Proc.new { self.setup_status = "the setup" } }
60
+ let(:parent_teardown_block1) { ::Proc.new { self.teardown_status += "the teardown" } }
61
+ let(:context_setup_block1) { ::Proc.new { self.setup_status += " has been run" } }
62
+ let(:context_teardown_block1) { ::Proc.new { self.teardown_status += "has been run " } }
81
63
 
82
- @test_status_class = Class.new do
64
+ let(:test_status_class) {
65
+ Class.new do
83
66
  attr_accessor :setup_status, :teardown_status
84
67
  define_method(:setup_something) do
85
68
  self.setup_status += " with something"
@@ -88,60 +71,58 @@ module Assert::Context::SetupDSL
88
71
  self.teardown_status = "with something "
89
72
  end
90
73
  end
91
- end
74
+ }
92
75
 
93
- should "run it's parent and it's own blocks in the correct order" do
94
- subject.send("run_setups", obj = @test_status_class.new)
95
- assert_equal "the setup has been run with something", obj.setup_status
76
+ should "run its parent and its own blocks in the correct order" do
77
+ parent_class1.setup(&parent_setup_block1)
78
+ parent_class1.teardown(&parent_teardown_block1)
79
+ subject.setup(&context_setup_block1)
80
+ subject.setup(:setup_something)
81
+ subject.teardown(:teardown_something)
82
+ subject.teardown(&context_teardown_block1)
96
83
 
97
- subject.send("run_teardowns", obj = @test_status_class.new)
98
- assert_equal "with something has been run the teardown", obj.teardown_status
99
- end
84
+ subject.send("run_setups", obj = test_status_class.new)
85
+ assert_that(obj.setup_status).equals("the setup has been run with something")
100
86
 
87
+ subject.send("run_teardowns", obj = test_status_class.new)
88
+ assert_that(obj.teardown_status).equals("with something has been run the teardown")
89
+ end
101
90
  end
102
91
 
103
- class AroundMethodTests < UnitTests
92
+ class AroundMethodTests < ParentContextClassTests
104
93
  desc "with multiple `around` calls"
105
- setup do
106
- @parent_class = Factory.modes_off_context_class do
107
- around do |block|
108
- self.out_status ||= ""
109
- self.out_status += "p-around start, "
110
- block.call
111
- self.out_status += "p-around end."
112
- end
113
- end
114
94
 
115
- @context_class = Factory.modes_off_context_class(@parent_class) do
116
- around do |block|
117
- self.out_status += "c-around1 start, "
118
- block.call
119
- self.out_status += "c-around1 end, "
120
- end
121
- around do |block|
122
- self.out_status += "c-around2 start, "
123
- block.call
124
- self.out_status += "c-around2 end, "
125
- end
95
+ let(:test_status_class) { Class.new { attr_accessor :out_status } }
96
+
97
+ should "run its parent and its own blocks in the correct order" do
98
+ parent_class1.around do |block|
99
+ self.out_status ||= ""
100
+ self.out_status += "p-around start, "
101
+ block.call
102
+ self.out_status += "p-around end."
126
103
  end
127
104
 
128
- @test_status_class = Class.new do
129
- attr_accessor :out_status
105
+ subject.around do |block|
106
+ self.out_status += "c-around1 start, "
107
+ block.call
108
+ self.out_status += "c-around1 end, "
109
+ end
110
+ subject.around do |block|
111
+ self.out_status += "c-around2 start, "
112
+ block.call
113
+ self.out_status += "c-around2 end, "
130
114
  end
131
- end
132
115
 
133
- should "run it's parent and it's own blocks in the correct order" do
134
- obj = @test_status_class.new
116
+ obj = test_status_class.new
135
117
  subject.send("run_arounds", obj) do
136
118
  obj.instance_eval{ self.out_status += "TEST, " }
137
119
  end
138
120
 
139
- exp = "p-around start, c-around1 start, c-around2 start, "\
140
- "TEST, "\
141
- "c-around2 end, c-around1 end, p-around end."
142
- assert_equal exp, obj.out_status
121
+ exp =
122
+ "p-around start, c-around1 start, c-around2 start, "\
123
+ "TEST, "\
124
+ "c-around2 end, c-around1 end, p-around end."
125
+ assert_that(obj.out_status).equals(exp)
143
126
  end
144
-
145
127
  end
146
-
147
128
  end
@@ -2,77 +2,43 @@ require "assert"
2
2
  require "assert/context/subject_dsl"
3
3
 
4
4
  module Assert::Context::SubjectDSL
5
-
6
5
  class UnitTests < Assert::Context
7
6
  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
7
+ subject { Factory.modes_off_context_class(parent_class1) }
24
8
 
9
+ let(:parent_class1) { Factory.modes_off_context_class }
10
+ let(:subject_block1) { Proc.new {} }
25
11
  end
26
12
 
27
13
  class DescriptionTests < UnitTests
28
14
  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
15
 
40
16
  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
17
+ parent_class1.desc("parent description")
18
+ subject.desc("and the description for this context")
44
19
 
20
+ exp = "parent description and the description for this context"
21
+ assert_that(subject.description).equals(exp)
22
+ end
45
23
  end
46
24
 
47
25
  class SubjectFromLocalTests < UnitTests
48
26
  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
27
 
56
28
  should "set the subject block on the context class" do
57
- assert_equal @subject_block, @context_class.subject
58
- end
29
+ subject.subject(&subject_block1)
59
30
 
31
+ assert_that(subject.subject).equals(subject_block1)
32
+ end
60
33
  end
61
34
 
62
35
  class SubjectFromParentTests < UnitTests
63
36
  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
37
 
72
- should "default to it's parents subject block" do
73
- assert_equal @parent_block, @context_class.subject
74
- end
38
+ should "default to its parents subject block" do
39
+ parent_class1.subject(&subject_block1)
75
40
 
41
+ assert_that(subject.subject).equals(subject_block1)
42
+ end
76
43
  end
77
-
78
44
  end
@@ -4,44 +4,39 @@ require "assert/context/suite_dsl"
4
4
  require "assert/suite"
5
5
 
6
6
  module Assert::Context::SuiteDSL
7
-
8
7
  class UnitTests < Assert::Context
9
8
  desc "Assert::Context::SuiteDSL"
10
- setup do
11
- @custom_suite = Factory.modes_off_suite
12
- @context_class = Factory.context_class
13
- end
14
- subject{ @context_class }
9
+ subject { Factory.context_class(parent_class1) }
10
+
11
+ let(:parent_class1) { Factory.context_class }
12
+ let(:custom_suite1) { Factory.modes_off_suite }
15
13
 
16
14
  should "use `Assert.suite` by default" do
17
- assert_equal Assert.suite, subject.suite
15
+ assert_that(subject.suite).equals(Assert.suite)
18
16
  end
19
17
 
20
18
  should "use any given custom suite" do
21
- subject.suite(@custom_suite)
22
- assert_equal @custom_suite, subject.suite
19
+ subject.suite(custom_suite1)
20
+ assert_that(subject.suite).equals(custom_suite1)
23
21
  end
24
-
25
22
  end
26
23
 
27
24
  class SuiteFromParentTests < UnitTests
28
25
  desc "`suite` method using parent context"
26
+
29
27
  setup do
30
- @parent_class = Factory.context_class
31
- @parent_class.suite(@custom_suite)
32
- @context_class = Factory.context_class(@parent_class)
28
+ parent_class1.suite(custom_suite1)
33
29
  end
34
30
 
35
- should "default to it's parent's suite" do
36
- assert_equal @custom_suite, subject.suite
31
+ let(:custom_suite2) { Factory.modes_off_suite }
32
+
33
+ should "default to its parent's suite" do
34
+ assert_that(subject.suite).equals(custom_suite1)
37
35
  end
38
36
 
39
37
  should "use any given custom suite" do
40
- another_suite = Factory.modes_off_suite
41
- subject.suite(another_suite)
42
- assert_equal another_suite, subject.suite
38
+ subject.suite(custom_suite2)
39
+ assert_that(subject.suite).equals(custom_suite2)
43
40
  end
44
-
45
41
  end
46
-
47
42
  end
@@ -2,151 +2,146 @@ require "assert"
2
2
  require "assert/context/test_dsl"
3
3
 
4
4
  module Assert::Context::TestDSL
5
-
6
5
  class UnitTests < Assert::Context
7
6
  desc "Assert::Context::TestDSL"
8
- setup do
9
- @test_desc = "be true"
10
- @test_block = ::Proc.new{ assert(true) }
11
- end
7
+
8
+ let(:test_desc1) { "be true" }
9
+ let(:test_block1) { Proc.new{ assert(true) } }
12
10
 
13
11
  should "build a test using `test` with a desc and code block" do
14
- d, b = @test_desc, @test_block
12
+ d, b = test_desc1, test_block1
15
13
  context, test = build_eval_context{ test(d, &b) }
16
14
 
17
- assert_equal 1, context.class.suite.tests_to_run_count
15
+ assert_that(context.class.suite.tests_to_run_count).equals(1)
18
16
 
19
- assert_kind_of Assert::Test, test
20
- assert_equal @test_desc, test.name
21
- assert_equal @test_block, test.code
17
+ assert_that(test).is_kind_of(Assert::Test)
18
+ assert_that(test.name).equals(test_desc1)
19
+ assert_that(test.code).equals(test_block1)
22
20
  end
23
21
 
24
22
  should "build a test using `should` with a desc and code block" do
25
- d, b = @test_desc, @test_block
23
+ d, b = test_desc1, test_block1
26
24
  context, test = build_eval_context{ should(d, &b) }
27
25
 
28
- assert_equal 1, context.class.suite.tests_to_run_count
26
+ assert_that(context.class.suite.tests_to_run_count).equals(1)
29
27
 
30
- assert_kind_of Assert::Test, test
31
- assert_equal "should #{@test_desc}", test.name
32
- assert_equal @test_block, test.code
28
+ assert_that(test).is_kind_of(Assert::Test)
29
+ assert_that(test.name).equals("should #{test_desc1}")
30
+ assert_that(test.code).equals(test_block1)
33
31
  end
34
32
 
35
33
  should "build a test that skips with no msg when `test_eventually` called" do
36
- d, b = @test_desc, @test_block
34
+ d, b = test_desc1, test_block1
37
35
  context, test = build_eval_context{ test_eventually(d, &b) }
38
36
  err = capture_err(Assert::Result::TestSkipped) do
39
37
  context.instance_eval(&test.code)
40
38
  end
41
39
 
42
- assert_equal 1, context.class.suite.tests_to_run_count
43
- assert_equal "TODO", err.message
44
- assert_equal 1, err.backtrace.size
40
+ assert_that(context.class.suite.tests_to_run_count).equals(1)
41
+ assert_that(err.message).equals("TODO")
42
+ assert_that(err.backtrace.size).equals(1)
45
43
  end
46
44
 
47
45
  should "build a test that skips with no msg when `should_eventually` called" do
48
- d, b = @test_desc, @test_block
46
+ d, b = test_desc1, test_block1
49
47
  context, test = build_eval_context{ should_eventually(d, &b) }
50
48
  err = capture_err(Assert::Result::TestSkipped) do
51
49
  context.instance_eval(&test.code)
52
50
  end
53
51
 
54
- assert_equal 1, context.class.suite.tests_to_run_count
55
- assert_equal "TODO", err.message
56
- assert_equal 1, err.backtrace.size
52
+ assert_that(context.class.suite.tests_to_run_count).equals(1)
53
+ assert_that(err.message).equals("TODO")
54
+ assert_that(err.backtrace.size).equals(1)
57
55
  end
58
56
 
59
57
  should "skip with the msg \"TODO\" when `test` called with no block" do
60
- d = @test_desc
58
+ d = test_desc1
61
59
  context, test = build_eval_context { test(d) } # no block passed
62
60
  err = capture_err(Assert::Result::TestSkipped) do
63
61
  context.instance_eval(&test.code)
64
62
  end
65
63
 
66
- assert_equal 1, context.class.suite.tests_to_run_count
67
- assert_equal "TODO", err.message
68
- assert_equal 1, err.backtrace.size
64
+ assert_that(context.class.suite.tests_to_run_count).equals(1)
65
+ assert_that(err.message).equals("TODO")
66
+ assert_that(err.backtrace.size).equals(1)
69
67
  end
70
68
 
71
69
  should "skip with the msg \"TODO\" when `should` called with no block" do
72
- d = @test_desc
70
+ d = test_desc1
73
71
  context, test = build_eval_context { should(d) } # no block passed
74
72
  err = capture_err(Assert::Result::TestSkipped) do
75
73
  context.instance_eval(&test.code)
76
74
  end
77
75
 
78
- assert_equal 1, context.class.suite.tests_to_run_count
79
- assert_equal "TODO", err.message
80
- assert_equal 1, err.backtrace.size
76
+ assert_that(context.class.suite.tests_to_run_count).equals(1)
77
+ assert_that(err.message).equals("TODO")
78
+ assert_that(err.backtrace.size).equals(1)
81
79
  end
82
80
 
83
81
  should "skip with the msg \"TODO\" when `test_eventually` called with no block" do
84
- d = @test_desc
82
+ d = test_desc1
85
83
  context, test = build_eval_context{ test_eventually(d) } # no block given
86
84
  err = capture_err(Assert::Result::TestSkipped) do
87
85
  context.instance_eval(&test.code)
88
86
  end
89
87
 
90
- assert_equal 1, context.class.suite.tests_to_run_count
91
- assert_equal "TODO", err.message
92
- assert_equal 1, err.backtrace.size
88
+ assert_that(context.class.suite.tests_to_run_count).equals(1)
89
+ assert_that(err.message).equals("TODO")
90
+ assert_that(err.backtrace.size).equals(1)
93
91
  end
94
92
 
95
93
  should "skip with the msg \"TODO\" when `should_eventually` called with no block" do
96
- d = @test_desc
94
+ d = test_desc1
97
95
  context, test = build_eval_context{ should_eventually(d) } # no block given
98
96
  err = capture_err(Assert::Result::TestSkipped) do
99
97
  context.instance_eval(&test.code)
100
98
  end
101
99
 
102
- assert_equal 1, context.class.suite.tests_to_run_count
103
- assert_equal "TODO", err.message
104
- assert_equal 1, err.backtrace.size
100
+ assert_that(context.class.suite.tests_to_run_count).equals(1)
101
+ assert_that(err.message).equals("TODO")
102
+ assert_that(err.backtrace.size).equals(1)
105
103
  end
106
104
 
107
105
  should "build a test from a macro using `test`" do
108
- d, b = @test_desc, @test_block
106
+ d, b = test_desc1, test_block1
109
107
  m = Assert::Macro.new{ test(d, &b); test(d, &b) }
110
108
  context_class = Factory.modes_off_context_class{ test(m) }
111
109
 
112
- assert_equal 2, context_class.suite.tests_to_run_count
110
+ assert_that(context_class.suite.tests_to_run_count).equals(2)
113
111
  end
114
112
 
115
113
  should "build a test from a macro using `should`" do
116
- d, b = @test_desc, @test_block
114
+ d, b = test_desc1, test_block1
117
115
  m = Assert::Macro.new{ should(d, &b); should(d, &b) }
118
116
  context_class = Factory.modes_off_context_class{ should(m) }
119
117
 
120
- assert_equal 2, context_class.suite.tests_to_run_count
118
+ assert_that(context_class.suite.tests_to_run_count).equals(2)
121
119
  end
122
120
 
123
121
  should "build a test that skips from a macro using `test_eventually`" do
124
- d, b = @test_desc, @test_block
122
+ d, b = test_desc1, test_block1
125
123
  m = Assert::Macro.new{ test(d, &b); test(d, &b) }
126
124
  context, test = build_eval_context{ test_eventually(m) }
127
125
 
128
- assert_equal 1, context.class.suite.tests_to_run_count
129
- assert_raises(Assert::Result::TestSkipped) do
130
- context.instance_eval(&test.code)
131
- end
126
+ assert_that(context.class.suite.tests_to_run_count).equals(1)
127
+ assert_that(-> { context.instance_eval(&test.code) }).
128
+ raises(Assert::Result::TestSkipped)
132
129
  end
133
130
 
134
131
  should "build a test that skips from a macro using `should_eventually`" do
135
- d, b = @test_desc, @test_block
132
+ d, b = test_desc1, test_block1
136
133
  m = Assert::Macro.new{ should(d, &b); should(d, &b) }
137
134
  context, test = build_eval_context{ should_eventually(m) }
138
135
 
139
- assert_equal 1, context.class.suite.tests_to_run_count
140
- assert_raises(Assert::Result::TestSkipped) do
141
- context.instance_eval(&test.code)
142
- end
143
-
136
+ assert_that(context.class.suite.tests_to_run_count).equals(1)
137
+ assert_that(-> { context.instance_eval(&test.code) }).
138
+ raises(Assert::Result::TestSkipped)
144
139
  end
145
140
 
146
141
  private
147
142
 
148
143
  def build_eval_context(&build_block)
149
- context_class = Factory.modes_off_context_class &build_block
144
+ context_class = Factory.modes_off_context_class(&build_block)
150
145
  test = context_class.suite.sorted_tests_to_run.to_a.last
151
146
  [context_class.new(test, test.config, proc{ |r| }), test]
152
147
  end
@@ -158,7 +153,5 @@ module Assert::Context::TestDSL
158
153
  e
159
154
  end
160
155
  end
161
-
162
156
  end
163
-
164
157
  end