assert 2.18.2 → 2.18.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -6
  3. data/assert.gemspec +1 -1
  4. data/lib/assert/actual_value.rb +127 -0
  5. data/lib/assert/assertions.rb +11 -20
  6. data/lib/assert/context.rb +13 -5
  7. data/lib/assert/context/let_dsl.rb +13 -0
  8. data/lib/assert/context/method_missing.rb +19 -0
  9. data/lib/assert/macros/methods.rb +4 -4
  10. data/lib/assert/stub.rb +4 -0
  11. data/lib/assert/version.rb +1 -1
  12. data/test/helper.rb +23 -25
  13. data/test/support/factory.rb +15 -0
  14. data/test/system/stub_tests.rb +348 -333
  15. data/test/system/test_tests.rb +111 -109
  16. data/test/unit/actual_value_tests.rb +335 -0
  17. data/test/unit/assert_tests.rb +84 -59
  18. data/test/unit/assertions/assert_block_tests.rb +32 -31
  19. data/test/unit/assertions/assert_empty_tests.rb +35 -32
  20. data/test/unit/assertions/assert_equal_tests.rb +81 -75
  21. data/test/unit/assertions/assert_file_exists_tests.rb +34 -33
  22. data/test/unit/assertions/assert_includes_tests.rb +40 -37
  23. data/test/unit/assertions/assert_instance_of_tests.rb +36 -33
  24. data/test/unit/assertions/assert_kind_of_tests.rb +36 -33
  25. data/test/unit/assertions/assert_match_tests.rb +36 -33
  26. data/test/unit/assertions/assert_nil_tests.rb +32 -31
  27. data/test/unit/assertions/assert_raises_tests.rb +55 -55
  28. data/test/unit/assertions/assert_respond_to_tests.rb +38 -35
  29. data/test/unit/assertions/assert_same_tests.rb +91 -80
  30. data/test/unit/assertions/assert_true_false_tests.rb +64 -60
  31. data/test/unit/assertions_tests.rb +15 -13
  32. data/test/unit/config_helpers_tests.rb +36 -35
  33. data/test/unit/config_tests.rb +33 -34
  34. data/test/unit/context/let_dsl_tests.rb +10 -0
  35. data/test/unit/context/setup_dsl_tests.rb +70 -81
  36. data/test/unit/context/subject_dsl_tests.rb +16 -43
  37. data/test/unit/context/suite_dsl_tests.rb +16 -16
  38. data/test/unit/context/test_dsl_tests.rb +50 -54
  39. data/test/unit/context_info_tests.rb +16 -15
  40. data/test/unit/context_tests.rb +170 -157
  41. data/test/unit/default_runner_tests.rb +2 -5
  42. data/test/unit/default_suite_tests.rb +51 -53
  43. data/test/unit/factory_tests.rb +3 -3
  44. data/test/unit/file_line_tests.rb +31 -33
  45. data/test/unit/macro_tests.rb +9 -10
  46. data/test/unit/result_tests.rb +150 -163
  47. data/test/unit/runner_tests.rb +63 -63
  48. data/test/unit/suite_tests.rb +57 -54
  49. data/test/unit/test_tests.rb +134 -126
  50. data/test/unit/utils_tests.rb +41 -45
  51. data/test/unit/view_helpers_tests.rb +55 -52
  52. data/test/unit/view_tests.rb +20 -22
  53. metadata +11 -4
@@ -9,27 +9,28 @@ module Assert::Assertions
9
9
  include Assert::Test::TestHelpers
10
10
 
11
11
  desc "`assert_file_exists`"
12
- setup do
13
- desc = @desc = "assert file exists empty fail desc"
14
- args = @args = ["/a/path/to/some/file/that/no/exists", desc]
15
- @test = Factory.test do
12
+ subject { test1 }
13
+
14
+ let(:desc1) { "assert file exists fail desc" }
15
+ let(:args1) { ["/a/path/to/some/file/that/no/exists", desc1] }
16
+ let(:test1) {
17
+ args = args1
18
+ Factory.test do
16
19
  assert_file_exists(__FILE__) # pass
17
20
  assert_file_exists(*args) # fail
18
21
  end
19
- @c = @test.config
20
- @test.run(&test_run_callback)
21
- end
22
- subject{ @test }
22
+ }
23
+ let(:config1) { test1.config }
23
24
 
24
25
  should "produce results as expected" do
25
- assert_equal 2, test_run_result_count
26
- assert_equal 1, test_run_result_count(:pass)
27
- assert_equal 1, test_run_result_count(:fail)
28
- end
26
+ subject.run(&test_run_callback)
29
27
 
30
- should "have a fail message with custom and generic explanations" do
31
- exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to exist."
32
- assert_equal exp, test_run_results(:fail).first.message
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)
31
+
32
+ exp = "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to exist."
33
+ assert_that(test_run_results(:fail).first.message).equals(exp)
33
34
  end
34
35
  end
35
36
 
@@ -37,28 +38,28 @@ module Assert::Assertions
37
38
  include Assert::Test::TestHelpers
38
39
 
39
40
  desc "`assert_not_file_exists`"
40
- setup do
41
- desc = @desc = "assert not file exists empty fail desc"
42
- args = @args = [__FILE__, desc]
43
- @test = Factory.test do
44
- assert_not_file_exists("/a/path/to/some/file/that/no/exists") # pass
45
- assert_not_file_exists(*args) # fail
41
+ subject { test1 }
42
+
43
+ let(:desc1) { "assert not file exists fail desc" }
44
+ let(:args1) { [__FILE__, desc1] }
45
+ let(:test1) {
46
+ args = args1
47
+ Factory.test do
48
+ assert_not_file_exists("/file/path") # pass
49
+ assert_not_file_exists(*args) # fail
46
50
  end
47
- @c = @test.config
48
- @test.run(&test_run_callback)
49
- end
50
- subject{ @test }
51
+ }
52
+ let(:config1) { test1.config }
51
53
 
52
54
  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
55
+ subject.run(&test_run_callback)
57
56
 
58
- should "have a fail message with custom and generic explanations" do
59
- exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to not exist."
60
- assert_equal exp, test_run_results(:fail).first.message
57
+ assert_that(test_run_result_count).equals(2)
58
+ assert_that(test_run_result_count(:pass)).equals(1)
59
+ assert_that(test_run_result_count(:fail)).equals(1)
60
+
61
+ exp = "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to not exist."
62
+ assert_that(test_run_results(:fail).first.message).equals(exp)
61
63
  end
62
64
  end
63
65
  end
64
-
@@ -8,29 +8,31 @@ module Assert::Assertions
8
8
  include Assert::Test::TestHelpers
9
9
 
10
10
  desc "`assert_includes`"
11
- setup do
12
- desc = @desc = "assert includes fail desc"
13
- args = @args = [2, [1], desc]
14
- @test = Factory.test do
11
+ subject { test1 }
12
+
13
+ let(:desc1) { "assert includes fail desc" }
14
+ let(:args1) { [2, [1], desc1] }
15
+ let(:test1) {
16
+ args = args1
17
+ Factory.test do
15
18
  assert_includes(1, [1]) # pass
16
- assert_includes(*args) # fail
19
+ assert_includes(*args) # fail
17
20
  end
18
- @c = @test.config
19
- @test.run(&test_run_callback)
20
- end
21
- subject{ @test }
21
+ }
22
+ let(:config1) { test1.config }
22
23
 
23
24
  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
25
+ subject.run(&test_run_callback)
28
26
 
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)}"\
32
- " to include #{Assert::U.show(@args[0], @c)}."
33
- assert_equal exp, test_run_results(:fail).first.message
27
+ assert_that(test_run_result_count).equals(2)
28
+ assert_that(test_run_result_count(:pass)).equals(1)
29
+ assert_that(test_run_result_count(:fail)).equals(1)
30
+
31
+ exp =
32
+ "#{args1[2]}\n"\
33
+ "Expected #{Assert::U.show(args1[1], config1)}"\
34
+ " to include #{Assert::U.show(args1[0], config1)}."
35
+ assert_that(test_run_results(:fail).first.message).equals(exp)
34
36
  end
35
37
  end
36
38
 
@@ -38,30 +40,31 @@ module Assert::Assertions
38
40
  include Assert::Test::TestHelpers
39
41
 
40
42
  desc "`assert_not_included`"
41
- setup do
42
- desc = @desc = "assert not included fail desc"
43
- args = @args = [1, [1], desc]
44
- @test = Factory.test do
43
+ subject { test1 }
44
+
45
+ let(:desc1) { "assert not included fail desc" }
46
+ let(:args1) { [1, [1], desc1] }
47
+ let(:test1) {
48
+ args = args1
49
+ Factory.test do
45
50
  assert_not_included(2, [1]) # pass
46
- assert_not_included(*args) # fail
51
+ assert_not_included(*args) # fail
47
52
  end
48
- @c = @test.config
49
- @test.run(&test_run_callback)
50
- end
51
- subject{ @test }
53
+ }
54
+ let(:config1) { test1.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)}"\
62
- " to not include #{Assert::U.show(@args[0], @c)}."
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)}"\
66
+ " to not include #{Assert::U.show(args1[0], config1)}."
67
+ assert_that(test_run_results(:fail).first.message).equals(exp)
64
68
  end
65
69
  end
66
70
  end
67
-
@@ -8,28 +8,30 @@ module Assert::Assertions
8
8
  include Assert::Test::TestHelpers
9
9
 
10
10
  desc "`assert_instance_of`"
11
- setup do
12
- desc = @desc = "assert instance of fail desc"
13
- args = @args = [Array, "object", desc]
14
- @test = Factory.test do
11
+ subject { test1 }
12
+
13
+ let(:desc1) { "assert instance of fail desc" }
14
+ let(:args1) { [Array, "object", desc1] }
15
+ let(:test1) {
16
+ args = args1
17
+ Factory.test do
15
18
  assert_instance_of(String, "object") # pass
16
19
  assert_instance_of(*args) # fail
17
20
  end
18
- @c = @test.config
19
- @test.run(&test_run_callback)
20
- end
21
- subject{ @test }
21
+ }
22
+ let(:config1) { test1.config }
22
23
 
23
24
  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
25
+ subject.run(&test_run_callback)
28
26
 
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 an instance of #{@args[0]}."
32
- assert_equal exp, test_run_results(:fail).first.message
27
+ assert_that(test_run_result_count).equals(2)
28
+ assert_that(test_run_result_count(:pass)).equals(1)
29
+ assert_that(test_run_result_count(:fail)).equals(1)
30
+
31
+ exp =
32
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} (#{args1[1].class})"\
33
+ " to be an instance of #{args1[0]}."
34
+ assert_that(test_run_results(:fail).first.message).equals(exp)
33
35
  end
34
36
  end
35
37
 
@@ -37,29 +39,30 @@ module Assert::Assertions
37
39
  include Assert::Test::TestHelpers
38
40
 
39
41
  desc "`assert_not_instance_of`"
40
- setup do
41
- desc = @desc = "assert not instance of fail desc"
42
- args = @args = [String, "object", desc]
43
- @test = Factory.test do
42
+ subject { test1 }
43
+
44
+ let(:desc1) { "assert not instance of fail desc" }
45
+ let(:args1) { [String, "object", desc1] }
46
+ let(:test1) {
47
+ args = args1
48
+ Factory.test do
44
49
  assert_not_instance_of(*args) # fail
45
50
  assert_not_instance_of(Array, "object") # pass
46
51
  end
47
- @c = @test.config
48
- @test.run(&test_run_callback)
49
- end
50
- subject{ @test }
52
+ }
53
+ let(:config1) { test1.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 an instance 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 an instance of #{args1[0]}."
65
+ assert_that(test_run_results(:fail).first.message).equals(exp)
62
66
  end
63
67
  end
64
68
  end
65
-
@@ -8,28 +8,30 @@ module Assert::Assertions
8
8
  include Assert::Test::TestHelpers
9
9
 
10
10
  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
11
+ subject { test1 }
12
+
13
+ let(:desc1) { "assert kind of fail desc" }
14
+ let(:args1) { [Array, "object", desc1] }
15
+ let(:test1) {
16
+ args = args1
17
+ Factory.test do
15
18
  assert_kind_of(String, "object") # pass
16
19
  assert_kind_of(*args) # fail
17
20
  end
18
- @c = @test.config
19
- @test.run(&test_run_callback)
20
- end
21
- subject{ @test }
21
+ }
22
+ let(:config1) { test1.config }
22
23
 
23
24
  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
25
+ subject.run(&test_run_callback)
28
26
 
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
27
+ assert_that(test_run_result_count).equals(2)
28
+ assert_that(test_run_result_count(:pass)).equals(1)
29
+ assert_that(test_run_result_count(:fail)).equals(1)
30
+
31
+ exp =
32
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)} (#{args1[1].class})"\
33
+ " to be a kind of #{args1[0]}."
34
+ assert_that(test_run_results(:fail).first.message).equals(exp)
33
35
  end
34
36
  end
35
37
 
@@ -37,29 +39,30 @@ module Assert::Assertions
37
39
  include Assert::Test::TestHelpers
38
40
 
39
41
  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
42
+ subject { test1 }
43
+
44
+ let(:desc1) { "assert not kind of fail desc" }
45
+ let(:args1) { [String, "object", desc1] }
46
+ let(:test1) {
47
+ args = args1
48
+ Factory.test do
44
49
  assert_not_kind_of(*args) # fail
45
50
  assert_not_kind_of(Array, "object") # pass
46
51
  end
47
- @c = @test.config
48
- @test.run(&test_run_callback)
49
- end
50
- subject{ @test }
52
+ }
53
+ let(:config1) { test1.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
-
@@ -8,28 +8,30 @@ module Assert::Assertions
8
8
  include Assert::Test::TestHelpers
9
9
 
10
10
  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
11
+ subject { test1 }
12
+
13
+ let(:desc1) { "assert match fail desc" }
14
+ let(:args1) { ["not", "a string", desc1] }
15
+ let(:test1) {
16
+ args = args1
17
+ Factory.test do
15
18
  assert_match(/a/, "a string") # pass
16
19
  assert_match(*args) # fail
17
20
  end
18
- @c = @test.config
19
- @test.run(&test_run_callback)
20
- end
21
- subject{ @test }
21
+ }
22
+ let(:config1) { test1.config }
22
23
 
23
24
  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
25
+ subject.run(&test_run_callback)
28
26
 
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
27
+ assert_that(test_run_result_count).equals(2)
28
+ assert_that(test_run_result_count(:pass)).equals(1)
29
+ assert_that(test_run_result_count(:fail)).equals(1)
30
+
31
+ exp =
32
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)}"\
33
+ " to match #{Assert::U.show(args1[0], config1)}."
34
+ assert_that(test_run_results(:fail).first.message).equals(exp)
33
35
  end
34
36
  end
35
37
 
@@ -37,29 +39,30 @@ module Assert::Assertions
37
39
  include Assert::Test::TestHelpers
38
40
 
39
41
  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
42
+ subject { test1 }
43
+
44
+ let(:desc1) { "assert not match fail desc" }
45
+ let(:args1) { [/a/, "a string", desc1] }
46
+ let(:test1) {
47
+ args = args1
48
+ Factory.test do
44
49
  assert_not_match(*args) # fail
45
50
  assert_not_match("not", "a string") # pass
46
51
  end
47
- @c = @test.config
48
- @test.run(&test_run_callback)
49
- end
50
- subject{ @test }
52
+ }
53
+ let(:config1) { test1.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
-