assert 2.18.2 → 2.19.2

Sign up to get free protection for your applications and to get access to all the features.
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/assertions"
3
5
 
@@ -8,28 +10,29 @@ module Assert::Assertions
8
10
  include Assert::Test::TestHelpers
9
11
 
10
12
  desc "`assert_kind_of`"
11
- setup do
12
- desc = @desc = "assert kind of fail desc"
13
- args = @args = [Array, "object", desc]
14
- @test = Factory.test do
13
+ subject {
14
+ args = args1
15
+ Factory.test do
15
16
  assert_kind_of(String, "object") # pass
16
17
  assert_kind_of(*args) # fail
17
18
  end
18
- @c = @test.config
19
- @test.run(&test_run_callback)
20
- end
21
- subject{ @test }
19
+ }
20
+
21
+ let(:desc1) { "assert kind of fail desc" }
22
+ let(:args1) { [Array, "object", desc1] }
23
+ let(:config1) { subject.config }
22
24
 
23
25
  should "produce results as expected" do
24
- assert_equal 2, test_run_result_count
25
- assert_equal 1, test_run_result_count(:pass)
26
- assert_equal 1, test_run_result_count(:fail)
27
- end
26
+ subject.run(&test_run_callback)
27
+
28
+ assert_that(test_run_result_count).equals(2)
29
+ assert_that(test_run_result_count(:pass)).equals(1)
30
+ assert_that(test_run_result_count(:fail)).equals(1)
28
31
 
29
- should "have a fail message with custom and generic explanations" do
30
- exp = "#{@args[2]}\nExpected #{Assert::U.show(@args[1], @c)} (#{@args[1].class})"\
31
- " to be a kind of #{@args[0]}."
32
- assert_equal exp, test_run_results(:fail).first.message
32
+ exp =
33
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} (#{args1[1].class})"\
34
+ " to be a kind of #{args1[0]}."
35
+ assert_that(test_run_results(:fail).first.message).equals(exp)
33
36
  end
34
37
  end
35
38
 
@@ -37,29 +40,29 @@ module Assert::Assertions
37
40
  include Assert::Test::TestHelpers
38
41
 
39
42
  desc "`assert_not_kind_of`"
40
- setup do
41
- desc = @desc = "assert not kind of fail desc"
42
- args = @args = [String, "object", desc]
43
- @test = Factory.test do
43
+ subject {
44
+ args = args1
45
+ Factory.test do
44
46
  assert_not_kind_of(*args) # fail
45
47
  assert_not_kind_of(Array, "object") # pass
46
48
  end
47
- @c = @test.config
48
- @test.run(&test_run_callback)
49
- end
50
- subject{ @test }
49
+ }
50
+
51
+ let(:desc1) { "assert not kind of fail desc" }
52
+ let(:args1) { [String, "object", desc1] }
53
+ let(:config1) { subject.config }
51
54
 
52
55
  should "produce results as expected" do
53
- assert_equal 2, test_run_result_count
54
- assert_equal 1, test_run_result_count(:pass)
55
- assert_equal 1, test_run_result_count(:fail)
56
- end
56
+ subject.run(&test_run_callback)
57
57
 
58
- should "have a fail message with custom and generic explanations" do
59
- exp = "#{@args[2]}\nExpected #{Assert::U.show(@args[1], @c)} (#{@args[1].class})"\
60
- " to not be a kind of #{@args[0]}."
61
- assert_equal exp, test_run_results(:fail).first.message
58
+ assert_that(test_run_result_count).equals(2)
59
+ assert_that(test_run_result_count(:pass)).equals(1)
60
+ assert_that(test_run_result_count(:fail)).equals(1)
61
+
62
+ exp =
63
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} (#{args1[1].class})"\
64
+ " to not be a kind of #{args1[0]}."
65
+ assert_that(test_run_results(:fail).first.message).equals(exp)
62
66
  end
63
67
  end
64
68
  end
65
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/assertions"
3
5
 
@@ -8,28 +10,29 @@ module Assert::Assertions
8
10
  include Assert::Test::TestHelpers
9
11
 
10
12
  desc "`assert_match`"
11
- setup do
12
- desc = @desc = "assert match fail desc"
13
- args = @args = ["not", "a string", desc]
14
- @test = Factory.test do
13
+ subject {
14
+ args = args1
15
+ Factory.test do
15
16
  assert_match(/a/, "a string") # pass
16
17
  assert_match(*args) # fail
17
18
  end
18
- @c = @test.config
19
- @test.run(&test_run_callback)
20
- end
21
- subject{ @test }
19
+ }
20
+
21
+ let(:desc1) { "assert match fail desc" }
22
+ let(:args1) { ["not", "a string", desc1] }
23
+ let(:config1) { subject.config }
22
24
 
23
25
  should "produce results as expected" do
24
- assert_equal 2, test_run_result_count
25
- assert_equal 1, test_run_result_count(:pass)
26
- assert_equal 1, test_run_result_count(:fail)
27
- end
26
+ subject.run(&test_run_callback)
27
+
28
+ assert_that(test_run_result_count).equals(2)
29
+ assert_that(test_run_result_count(:pass)).equals(1)
30
+ assert_that(test_run_result_count(:fail)).equals(1)
28
31
 
29
- should "have a fail message with custom and generic explanations" do
30
- exp = "#{@args[2]}\nExpected #{Assert::U.show(@args[1], @c)}"\
31
- " to match #{Assert::U.show(@args[0], @c)}."
32
- assert_equal exp, test_run_results(:fail).first.message
32
+ exp =
33
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)}"\
34
+ " to match #{Assert::U.show(args1[0], config1)}."
35
+ assert_that(test_run_results(:fail).first.message).equals(exp)
33
36
  end
34
37
  end
35
38
 
@@ -37,29 +40,29 @@ module Assert::Assertions
37
40
  include Assert::Test::TestHelpers
38
41
 
39
42
  desc "`assert_not_match`"
40
- setup do
41
- desc = @desc = "assert not match fail desc"
42
- args = @args = [/a/, "a string", desc]
43
- @test = Factory.test do
43
+ subject {
44
+ args = args1
45
+ Factory.test do
44
46
  assert_not_match(*args) # fail
45
47
  assert_not_match("not", "a string") # pass
46
48
  end
47
- @c = @test.config
48
- @test.run(&test_run_callback)
49
- end
50
- subject{ @test }
49
+ }
50
+
51
+ let(:desc1) { "assert not match fail desc" }
52
+ let(:args1) { [/a/, "a string", desc1] }
53
+ let(:config1) { subject.config }
51
54
 
52
55
  should "produce results as expected" do
53
- assert_equal 2, test_run_result_count
54
- assert_equal 1, test_run_result_count(:pass)
55
- assert_equal 1, test_run_result_count(:fail)
56
- end
56
+ subject.run(&test_run_callback)
57
57
 
58
- should "have a fail message with custom and generic explanations" do
59
- exp = "#{@args[2]}\nExpected #{Assert::U.show(@args[1], @c)}"\
60
- " to not match #{Assert::U.show(@args[0], @c)}."
61
- assert_equal exp, test_run_results(:fail).first.message
58
+ assert_that(test_run_result_count).equals(2)
59
+ assert_that(test_run_result_count(:pass)).equals(1)
60
+ assert_that(test_run_result_count(:fail)).equals(1)
61
+
62
+ exp =
63
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)}"\
64
+ " to not match #{Assert::U.show(args1[0], config1)}."
65
+ assert_that(test_run_results(:fail).first.message).equals(exp)
62
66
  end
63
67
  end
64
68
  end
65
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/assertions"
3
5
 
@@ -8,27 +10,27 @@ module Assert::Assertions
8
10
  include Assert::Test::TestHelpers
9
11
 
10
12
  desc "`assert_nil`"
11
- setup do
12
- desc = @desc = "assert nil empty fail desc"
13
- args = @args = [1, desc]
14
- @test = Factory.test do
13
+ subject {
14
+ args = args1
15
+ Factory.test do
15
16
  assert_nil(nil) # pass
16
17
  assert_nil(*args) # fail
17
18
  end
18
- @c = @test.config
19
- @test.run(&test_run_callback)
20
- end
21
- subject{ @test }
19
+ }
20
+
21
+ let(:desc1) { "assert nil empty fail desc" }
22
+ let(:args1) { [1, desc1] }
23
+ let(:config1) { subject.config }
22
24
 
23
25
  should "produce results as expected" do
24
- assert_equal 2, test_run_result_count
25
- assert_equal 1, test_run_result_count(:pass)
26
- assert_equal 1, test_run_result_count(:fail)
27
- end
26
+ subject.run(&test_run_callback)
27
+
28
+ assert_that(test_run_result_count).equals(2)
29
+ assert_that(test_run_result_count(:pass)).equals(1)
30
+ assert_that(test_run_result_count(:fail)).equals(1)
28
31
 
29
- should "have a fail message with custom and generic explanations" do
30
- exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to be nil."
31
- assert_equal exp, test_run_results(:fail).first.message
32
+ exp = "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to be nil."
33
+ assert_that(test_run_results(:fail).first.message).equals(exp)
32
34
  end
33
35
  end
34
36
 
@@ -36,28 +38,27 @@ module Assert::Assertions
36
38
  include Assert::Test::TestHelpers
37
39
 
38
40
  desc "`assert_not_nil`"
39
- setup do
40
- desc = @desc = "assert not nil empty fail desc"
41
- args = @args = [nil, desc]
42
- @test = Factory.test do
41
+ subject {
42
+ args = args1
43
+ Factory.test do
43
44
  assert_not_nil(1) # pass
44
45
  assert_not_nil(*args) # fail
45
46
  end
46
- @c = @test.config
47
- @test.run(&test_run_callback)
48
- end
49
- subject{ @test }
47
+ }
48
+
49
+ let(:desc1) { "assert not nil empty fail desc" }
50
+ let(:args1) { [nil, desc1] }
51
+ let(:config1) { subject.config }
50
52
 
51
53
  should "produce results as expected" do
52
- assert_equal 2, test_run_result_count
53
- assert_equal 1, test_run_result_count(:pass)
54
- assert_equal 1, test_run_result_count(:fail)
55
- end
54
+ subject.run(&test_run_callback)
56
55
 
57
- should "have a fail message with custom and generic explanations" do
58
- exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to not be nil."
59
- assert_equal exp, test_run_results(:fail).first.message
56
+ assert_that(test_run_result_count).equals(2)
57
+ assert_that(test_run_result_count(:pass)).equals(1)
58
+ assert_that(test_run_result_count(:fail)).equals(1)
59
+
60
+ exp = "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to not be nil."
61
+ assert_that(test_run_results(:fail).first.message).equals(exp)
60
62
  end
61
63
  end
62
64
  end
63
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/assertions"
3
5
 
@@ -6,54 +8,55 @@ module Assert::Assertions
6
8
  include Assert::Test::TestHelpers
7
9
 
8
10
  desc "`assert_raises`"
9
- setup do
10
- d = @d = "assert raises fail desc"
11
- @test = Factory.test do
12
- assert_raises(StandardError, RuntimeError){ raise(StandardError) } # pass
13
- assert_raises(StandardError, RuntimeError, d){ raise(Exception) } # fail
14
- assert_raises(RuntimeError, d){ raise(StandardError) } # fail
15
- assert_raises(RuntimeError, d){ true } # fail
16
- assert_raises(d){ true } # fail
11
+ subject {
12
+ desc = desc1
13
+ Factory.test do
14
+ assert_raises(StandardError, RuntimeError) { raise(StandardError) } # pass
15
+ assert_raises(StandardError, RuntimeError, desc) { raise(Exception) } # fail
16
+ assert_raises(RuntimeError, desc) { raise(StandardError) } # fail
17
+ assert_raises(RuntimeError, desc) { true } # fail
18
+ assert_raises(desc) { true } # fail
17
19
  end
18
- @test.run(&test_run_callback)
19
- end
20
- subject{ @test }
20
+ }
21
+
22
+ let(:desc1) { "assert raises fail desc" }
21
23
 
22
24
  should "produce results as expected" do
23
- assert_equal 5, test_run_result_count
24
- assert_equal 1, test_run_result_count(:pass)
25
- assert_equal 4, test_run_result_count(:fail)
26
- end
25
+ subject.run(&test_run_callback)
27
26
 
28
- should "have a fail message with custom and generic explanations" do
29
- exp = [
30
- "#{@d}\nStandardError or RuntimeError exception expected, not:",
31
- "#{@d}\nRuntimeError exception expected, not:",
32
- "#{@d}\nRuntimeError exception expected but nothing raised.",
33
- "#{@d}\nAn exception expected but nothing raised."
34
- ]
27
+ assert_that(test_run_result_count).equals(5)
28
+ assert_that(test_run_result_count(:pass)).equals(1)
29
+ assert_that(test_run_result_count(:fail)).equals(4)
30
+
31
+ exp =
32
+ [
33
+ "#{desc1}\nStandardError or RuntimeError exception expected, not:",
34
+ "#{desc1}\nRuntimeError exception expected, not:",
35
+ "#{desc1}\nRuntimeError exception expected but nothing raised.",
36
+ "#{desc1}\nAn exception expected but nothing raised.",
37
+ ]
35
38
  messages = test_run_results(:fail).map(&:message)
36
- messages.each_with_index{ |msg, n| assert_match(/^#{exp[n]}/, msg) }
39
+ messages.each_with_index{ |msg, n| assert_that(msg).matches(/^#{exp[n]}/) }
37
40
  end
38
41
 
39
42
  should "return any raised exception instance" do
40
43
  error = nil
41
44
  error_msg = Factory.string
42
- test = Factory.test do
43
- error = assert_raises(RuntimeError){ raise(RuntimeError, error_msg) }
44
- end
45
+
46
+ test =
47
+ Factory.test do
48
+ error = assert_raises(RuntimeError) { raise(RuntimeError, error_msg) }
49
+ end
45
50
  test.run
46
51
 
47
- assert_not_nil error
48
- assert_kind_of RuntimeError, error
49
- assert_equal error_msg, error.message
52
+ assert_that(error).is_not_nil
53
+ assert_that(error).is_kind_of(RuntimeError)
54
+ assert_that(error.message).equals(error_msg)
50
55
 
51
- test = Factory.test do
52
- error = assert_raises(RuntimeError){ }
53
- end
56
+ test = Factory.test { error = assert_raises(RuntimeError) {} }
54
57
  test.run
55
58
 
56
- assert_nil error
59
+ assert_that(error).is_nil
57
60
  end
58
61
  end
59
62
 
@@ -61,33 +64,32 @@ module Assert::Assertions
61
64
  include Assert::Test::TestHelpers
62
65
 
63
66
  desc "`assert_nothing_raised`"
64
- setup do
65
- d = @d = "assert nothing raised fail desc"
66
- @test = Factory.test do
67
- anr = :assert_nothing_raised
68
- self.send(anr, StandardError, RuntimeError, d){ raise(StandardError) } # fail
69
- self.send(anr, RuntimeError){ raise(StandardError) } # pass
70
- self.send(anr, d){ raise(RuntimeError) } # fail
71
- self.send(anr){ true } # pass
67
+ subject {
68
+ desc = desc1
69
+ Factory.test do
70
+ assert_nothing_raised(StandardError, RuntimeError, desc) { raise(StandardError) } # fail
71
+ assert_nothing_raised(RuntimeError) { raise(StandardError) } # pass
72
+ assert_nothing_raised(desc) { raise(RuntimeError) } # fail
73
+ assert_nothing_raised { true } # pass
72
74
  end
73
- @test.run(&test_run_callback)
74
- end
75
- subject{ @test }
75
+ }
76
+
77
+ let(:desc1) { "assert nothing raised fail desc" }
76
78
 
77
79
  should "produce results as expected" do
78
- assert_equal 4, test_run_result_count
79
- assert_equal 2, test_run_result_count(:pass)
80
- assert_equal 2, test_run_result_count(:fail)
81
- end
80
+ subject.run(&test_run_callback)
81
+
82
+ assert_that(test_run_result_count).equals(4)
83
+ assert_that(test_run_result_count(:pass)).equals(2)
84
+ assert_that(test_run_result_count(:fail)).equals(2)
82
85
 
83
- should "have a fail message with custom and generic explanations" do
84
- exp = [
85
- "#{@d}\nStandardError or RuntimeError exception not expected, but raised:",
86
- "#{@d}\nAn exception not expected, but raised:"
87
- ]
86
+ exp =
87
+ [
88
+ "#{desc1}\nStandardError or RuntimeError exception not expected, but raised:",
89
+ "#{desc1}\nAn exception not expected, but raised:",
90
+ ]
88
91
  messages = test_run_results(:fail).map(&:message)
89
- messages.each_with_index{ |msg, n| assert_match(/^#{exp[n]}/, msg) }
92
+ messages.each_with_index{ |msg, n| assert_that(msg).matches(/^#{exp[n]}/) }
90
93
  end
91
94
  end
92
95
  end
93
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/assertions"
3
5
 
@@ -8,29 +10,30 @@ module Assert::Assertions
8
10
  include Assert::Test::TestHelpers
9
11
 
10
12
  desc "`assert_respond_to`"
11
- setup do
12
- desc = @desc = "assert respond to fail desc"
13
- args = @args = [:abs, "1", desc]
14
- @test = Factory.test do
13
+ subject {
14
+ args = args1
15
+ Factory.test do
15
16
  assert_respond_to(:abs, 1) # pass
16
17
  assert_respond_to(*args) # fail
17
18
  end
18
- @c = @test.config
19
- @test.run(&test_run_callback)
20
- end
21
- subject{ @test }
19
+ }
20
+
21
+ let(:desc1) { "assert respond to fail desc" }
22
+ let(:args1) { [:abs, "1", desc1] }
23
+ let(:config1) { subject.config }
22
24
 
23
25
  should "produce results as expected" do
24
- assert_equal 2, test_run_result_count
25
- assert_equal 1, test_run_result_count(:pass)
26
- assert_equal 1, test_run_result_count(:fail)
27
- end
26
+ subject.run(&test_run_callback)
27
+
28
+ assert_that(test_run_result_count).equals(2)
29
+ assert_that(test_run_result_count(:pass)).equals(1)
30
+ assert_that(test_run_result_count(:fail)).equals(1)
28
31
 
29
- should "have a fail message with custom and generic explanations" do
30
- exp = "#{@args[2]}\n"\
31
- "Expected #{Assert::U.show(@args[1], @c)} (#{@args[1].class})"\
32
- " to respond to `#{@args[0]}`."
33
- assert_equal exp, test_run_results(:fail).first.message
32
+ exp =
33
+ "#{args1[2]}\n"\
34
+ "Expected #{Assert::U.show(args1[1], config1)} (#{args1[1].class})"\
35
+ " to respond to `#{args1[0]}`."
36
+ assert_that(test_run_results(:fail).first.message).equals(exp)
34
37
  end
35
38
  end
36
39
 
@@ -38,30 +41,30 @@ module Assert::Assertions
38
41
  include Assert::Test::TestHelpers
39
42
 
40
43
  desc "`assert_not_respond_to`"
41
- setup do
42
- desc = @desc = "assert not respond to fail desc"
43
- args = @args = [:abs, 1, desc]
44
- @test = Factory.test do
44
+ subject {
45
+ args = args1
46
+ Factory.test do
45
47
  assert_not_respond_to(*args) # fail
46
48
  assert_not_respond_to(:abs, "1") # pass
47
49
  end
48
- @c = @test.config
49
- @test.run(&test_run_callback)
50
- end
51
- subject{ @test }
50
+ }
51
+
52
+ let(:desc1) { "assert not respond to fail desc" }
53
+ let(:args1) { [:abs, 1, desc1] }
54
+ let(:config1) { subject.config }
52
55
 
53
56
  should "produce results as expected" do
54
- assert_equal 2, test_run_result_count
55
- assert_equal 1, test_run_result_count(:pass)
56
- assert_equal 1, test_run_result_count(:fail)
57
- end
57
+ subject.run(&test_run_callback)
58
58
 
59
- should "have a fail message with custom and generic explanations" do
60
- exp = "#{@args[2]}\n"\
61
- "Expected #{Assert::U.show(@args[1], @c)} (#{@args[1].class})"\
62
- " to not respond to `#{@args[0]}`."
63
- assert_equal exp, test_run_results(:fail).first.message
59
+ assert_that(test_run_result_count).equals(2)
60
+ assert_that(test_run_result_count(:pass)).equals(1)
61
+ assert_that(test_run_result_count(:fail)).equals(1)
62
+
63
+ exp =
64
+ "#{args1[2]}\n"\
65
+ "Expected #{Assert::U.show(args1[1], config1)} (#{args1[1].class})"\
66
+ " to not respond to `#{args1[0]}`."
67
+ assert_that(test_run_results(:fail).first.message).equals(exp)
64
68
  end
65
69
  end
66
70
  end
67
-