assert 2.16.5 → 2.18.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -7
  2. data/Gemfile +3 -1
  3. data/README.md +79 -54
  4. data/assert.gemspec +6 -5
  5. data/bin/assert +4 -4
  6. data/lib/assert.rb +8 -18
  7. data/lib/assert/actual_value.rb +127 -0
  8. data/lib/assert/assert_runner.rb +7 -10
  9. data/lib/assert/assertions.rb +15 -28
  10. data/lib/assert/cli.rb +41 -57
  11. data/lib/assert/config.rb +8 -12
  12. data/lib/assert/config_helpers.rb +6 -10
  13. data/lib/assert/context.rb +30 -24
  14. data/lib/assert/context/let_dsl.rb +13 -0
  15. data/lib/assert/context/method_missing.rb +19 -0
  16. data/lib/assert/context/setup_dsl.rb +0 -4
  17. data/lib/assert/context/subject_dsl.rb +0 -4
  18. data/lib/assert/context/suite_dsl.rb +0 -4
  19. data/lib/assert/context/test_dsl.rb +5 -9
  20. data/lib/assert/context_info.rb +2 -6
  21. data/lib/assert/default_runner.rb +1 -5
  22. data/lib/assert/default_suite.rb +1 -6
  23. data/lib/assert/default_view.rb +8 -12
  24. data/lib/assert/factory.rb +1 -4
  25. data/lib/assert/file_line.rb +0 -4
  26. data/lib/assert/macro.rb +1 -4
  27. data/lib/assert/macros/methods.rb +5 -11
  28. data/lib/assert/result.rb +19 -34
  29. data/lib/assert/runner.rb +12 -11
  30. data/lib/assert/stub.rb +16 -2
  31. data/lib/assert/suite.rb +3 -7
  32. data/lib/assert/test.rb +13 -18
  33. data/lib/assert/utils.rb +8 -12
  34. data/lib/assert/version.rb +1 -1
  35. data/lib/assert/view.rb +18 -21
  36. data/lib/assert/view_helpers.rb +6 -17
  37. data/log/{.gitkeep → .keep} +0 -0
  38. data/test/helper.rb +26 -41
  39. data/test/support/factory.rb +20 -6
  40. data/test/support/inherited_stuff.rb +0 -2
  41. data/test/system/stub_tests.rb +350 -354
  42. data/test/system/test_tests.rb +119 -133
  43. data/test/unit/actual_value_tests.rb +335 -0
  44. data/test/unit/assert_tests.rb +125 -52
  45. data/test/unit/assertions/assert_block_tests.rb +34 -37
  46. data/test/unit/assertions/assert_empty_tests.rb +38 -38
  47. data/test/unit/assertions/assert_equal_tests.rb +84 -86
  48. data/test/unit/assertions/assert_file_exists_tests.rb +37 -39
  49. data/test/unit/assertions/assert_includes_tests.rb +45 -46
  50. data/test/unit/assertions/assert_instance_of_tests.rb +39 -40
  51. data/test/unit/assertions/assert_kind_of_tests.rb +39 -40
  52. data/test/unit/assertions/assert_match_tests.rb +39 -40
  53. data/test/unit/assertions/assert_nil_tests.rb +35 -38
  54. data/test/unit/assertions/assert_raises_tests.rb +58 -62
  55. data/test/unit/assertions/assert_respond_to_tests.rb +41 -42
  56. data/test/unit/assertions/assert_same_tests.rb +94 -90
  57. data/test/unit/assertions/assert_true_false_tests.rb +67 -69
  58. data/test/unit/assertions_tests.rb +17 -19
  59. data/test/unit/config_helpers_tests.rb +41 -43
  60. data/test/unit/config_tests.rb +42 -46
  61. data/test/unit/context/let_dsl_tests.rb +10 -0
  62. data/test/unit/context/setup_dsl_tests.rb +72 -91
  63. data/test/unit/context/subject_dsl_tests.rb +18 -51
  64. data/test/unit/context/suite_dsl_tests.rb +19 -23
  65. data/test/unit/context/test_dsl_tests.rb +52 -59
  66. data/test/unit/context_info_tests.rb +19 -21
  67. data/test/unit/context_tests.rb +175 -178
  68. data/test/unit/default_runner_tests.rb +4 -10
  69. data/test/unit/default_suite_tests.rb +54 -59
  70. data/test/unit/factory_tests.rb +6 -9
  71. data/test/unit/file_line_tests.rb +34 -40
  72. data/test/unit/macro_tests.rb +11 -20
  73. data/test/unit/result_tests.rb +156 -182
  74. data/test/unit/runner_tests.rb +72 -79
  75. data/test/unit/suite_tests.rb +62 -63
  76. data/test/unit/test_tests.rb +143 -147
  77. data/test/unit/utils_tests.rb +49 -62
  78. data/test/unit/view_helpers_tests.rb +67 -70
  79. data/test/unit/view_tests.rb +26 -32
  80. metadata +54 -47
  81. data/.assert.rb +0 -3
  82. data/.gitignore +0 -19
@@ -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
@@ -1,85 +1,68 @@
1
- require 'assert'
2
- require 'assert/context/setup_dsl'
1
+ require "assert"
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 { context_class1 }
9
8
 
9
+ let(:block1) { ::Proc.new {} }
10
+ let(:context_class1) { Factory.modes_off_context_class }
10
11
  end
11
12
 
12
13
  class SetupTeardownOnceMethodsTests < UnitTests
13
14
  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
15
 
22
16
  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
17
+ subject.setup_once(&block1)
18
+ subject.teardown_once(&block1)
26
19
 
20
+ assert_that(subject.suite.send(:setups)).includes(block1)
21
+ assert_that(subject.suite.send(:teardowns)).includes(block1)
22
+ end
27
23
  end
28
24
 
29
25
  class SetupTeardownMethodsTests < UnitTests
30
26
  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
27
 
39
28
  should "add the block to the context" do
40
- assert_includes @block, subject.send(:setups)
41
- assert_includes @block, subject.send(:teardowns)
42
- end
29
+ subject.setup(&block1)
30
+ subject.teardown(&block1)
43
31
 
32
+ assert_that(subject.send(:setups)).includes(block1)
33
+ assert_that(subject.send(:teardowns)).includes(block1)
34
+ end
44
35
  end
45
36
 
46
37
  class SetupTeardownWithMethodNameTests < UnitTests
47
38
  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
39
+
40
+ let(:method_name1) { :something_amazing }
55
41
 
56
42
  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)
43
+ subject.setup(method_name1)
44
+ subject.teardown(method_name1)
45
+
46
+ assert_that(subject.send(:setups)).includes(method_name1)
47
+ assert_that(subject.send(:teardowns)).includes(method_name1)
59
48
  end
49
+ end
60
50
 
51
+ class ParentContextClassTests < UnitTests
52
+ let(:parent_class1) { Factory.modes_off_context_class }
53
+ let(:context_class1) { Factory.modes_off_context_class(parent_class1) }
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
135
- subject.send('run_arounds', obj) do
136
- obj.instance_eval{ self.out_status += 'TEST, ' }
116
+ obj = test_status_class.new
117
+ subject.send("run_arounds", obj) do
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
@@ -1,78 +1,45 @@
1
- require 'assert'
2
- require 'assert/context/subject_dsl'
1
+ require "assert"
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 { context_class1 }
24
8
 
9
+ let(:parent_class1) { Factory.modes_off_context_class }
10
+ let(:context_class1) { Factory.modes_off_context_class(parent_class1) }
11
+ let(:subject_block1) { Proc.new {} }
25
12
  end
26
13
 
27
14
  class DescriptionTests < UnitTests
28
15
  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
16
 
40
17
  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
18
+ parent_class1.desc("parent description")
19
+ subject.desc("and the description for this context")
44
20
 
21
+ exp = "parent description and the description for this context"
22
+ assert_that(subject.description).equals(exp)
23
+ end
45
24
  end
46
25
 
47
26
  class SubjectFromLocalTests < UnitTests
48
27
  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
28
 
56
29
  should "set the subject block on the context class" do
57
- assert_equal @subject_block, @context_class.subject
58
- end
30
+ subject.subject(&subject_block1)
59
31
 
32
+ assert_that(subject.subject).equals(subject_block1)
33
+ end
60
34
  end
61
35
 
62
36
  class SubjectFromParentTests < UnitTests
63
37
  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
38
 
72
- should "default to it's parents subject block" do
73
- assert_equal @parent_block, @context_class.subject
74
- end
39
+ should "default to its parents subject block" do
40
+ parent_class1.subject(&subject_block1)
75
41
 
42
+ assert_that(subject.subject).equals(subject_block1)
43
+ end
76
44
  end
77
-
78
45
  end
@@ -1,47 +1,43 @@
1
- require 'assert'
2
- require 'assert/context/suite_dsl'
1
+ require "assert"
2
+ require "assert/context/suite_dsl"
3
3
 
4
- require 'assert/suite'
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 { context_class1 }
10
+
11
+ let(:parent_class1) { Factory.context_class }
12
+ let(:context_class1) { Factory.context_class(parent_class1) }
13
+ let(:custom_suite1) { Factory.modes_off_suite }
15
14
 
16
15
  should "use `Assert.suite` by default" do
17
- assert_equal Assert.suite, subject.suite
16
+ assert_that(subject.suite).equals(Assert.suite)
18
17
  end
19
18
 
20
19
  should "use any given custom suite" do
21
- subject.suite(@custom_suite)
22
- assert_equal @custom_suite, subject.suite
20
+ subject.suite(custom_suite1)
21
+ assert_that(subject.suite).equals(custom_suite1)
23
22
  end
24
-
25
23
  end
26
24
 
27
25
  class SuiteFromParentTests < UnitTests
28
26
  desc "`suite` method using parent context"
27
+
29
28
  setup do
30
- @parent_class = Factory.context_class
31
- @parent_class.suite(@custom_suite)
32
- @context_class = Factory.context_class(@parent_class)
29
+ parent_class1.suite(custom_suite1)
33
30
  end
34
31
 
35
- should "default to it's parent's suite" do
36
- assert_equal @custom_suite, subject.suite
32
+ let(:custom_suite2) { Factory.modes_off_suite }
33
+
34
+ should "default to its parent's suite" do
35
+ assert_that(subject.suite).equals(custom_suite1)
37
36
  end
38
37
 
39
38
  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
39
+ subject.suite(custom_suite2)
40
+ assert_that(subject.suite).equals(custom_suite2)
43
41
  end
44
-
45
42
  end
46
-
47
43
  end
@@ -1,152 +1,147 @@
1
- require 'assert'
2
- require 'assert/context/test_dsl'
1
+ require "assert"
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