assert 2.18.2 → 2.18.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -6
- data/assert.gemspec +1 -1
- data/lib/assert/actual_value.rb +127 -0
- data/lib/assert/assertions.rb +11 -20
- data/lib/assert/context.rb +13 -5
- data/lib/assert/context/let_dsl.rb +13 -0
- data/lib/assert/context/method_missing.rb +19 -0
- data/lib/assert/macros/methods.rb +4 -4
- data/lib/assert/stub.rb +4 -0
- data/lib/assert/version.rb +1 -1
- data/test/helper.rb +23 -25
- data/test/support/factory.rb +15 -0
- data/test/system/stub_tests.rb +348 -333
- data/test/system/test_tests.rb +111 -109
- data/test/unit/actual_value_tests.rb +335 -0
- data/test/unit/assert_tests.rb +84 -59
- data/test/unit/assertions/assert_block_tests.rb +32 -31
- data/test/unit/assertions/assert_empty_tests.rb +35 -32
- data/test/unit/assertions/assert_equal_tests.rb +81 -75
- data/test/unit/assertions/assert_file_exists_tests.rb +34 -33
- data/test/unit/assertions/assert_includes_tests.rb +40 -37
- data/test/unit/assertions/assert_instance_of_tests.rb +36 -33
- data/test/unit/assertions/assert_kind_of_tests.rb +36 -33
- data/test/unit/assertions/assert_match_tests.rb +36 -33
- data/test/unit/assertions/assert_nil_tests.rb +32 -31
- data/test/unit/assertions/assert_raises_tests.rb +55 -55
- data/test/unit/assertions/assert_respond_to_tests.rb +38 -35
- data/test/unit/assertions/assert_same_tests.rb +91 -80
- data/test/unit/assertions/assert_true_false_tests.rb +64 -60
- data/test/unit/assertions_tests.rb +15 -13
- data/test/unit/config_helpers_tests.rb +36 -35
- data/test/unit/config_tests.rb +33 -34
- data/test/unit/context/let_dsl_tests.rb +10 -0
- data/test/unit/context/setup_dsl_tests.rb +70 -81
- data/test/unit/context/subject_dsl_tests.rb +16 -43
- data/test/unit/context/suite_dsl_tests.rb +16 -16
- data/test/unit/context/test_dsl_tests.rb +50 -54
- data/test/unit/context_info_tests.rb +16 -15
- data/test/unit/context_tests.rb +170 -157
- data/test/unit/default_runner_tests.rb +2 -5
- data/test/unit/default_suite_tests.rb +51 -53
- data/test/unit/factory_tests.rb +3 -3
- data/test/unit/file_line_tests.rb +31 -33
- data/test/unit/macro_tests.rb +9 -10
- data/test/unit/result_tests.rb +150 -163
- data/test/unit/runner_tests.rb +63 -63
- data/test/unit/suite_tests.rb +57 -54
- data/test/unit/test_tests.rb +134 -126
- data/test/unit/utils_tests.rb +41 -45
- data/test/unit/view_helpers_tests.rb +55 -52
- data/test/unit/view_tests.rb +20 -22
- 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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
subject{ @test }
|
22
|
+
}
|
23
|
+
let(:config1) { test1.config }
|
23
24
|
|
24
25
|
should "produce results as expected" do
|
25
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
subject{ @test }
|
51
|
+
}
|
52
|
+
let(:config1) { test1.config }
|
51
53
|
|
52
54
|
should "produce results as expected" do
|
53
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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)
|
19
|
+
assert_includes(*args) # fail
|
17
20
|
end
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
subject{ @test }
|
21
|
+
}
|
22
|
+
let(:config1) { test1.config }
|
22
23
|
|
23
24
|
should "produce results as expected" do
|
24
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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)
|
51
|
+
assert_not_included(*args) # fail
|
47
52
|
end
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
subject{ @test }
|
53
|
+
}
|
54
|
+
let(:config1) { test1.config }
|
52
55
|
|
53
56
|
should "produce results as expected" do
|
54
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
subject{ @test }
|
21
|
+
}
|
22
|
+
let(:config1) { test1.config }
|
22
23
|
|
23
24
|
should "produce results as expected" do
|
24
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
subject{ @test }
|
52
|
+
}
|
53
|
+
let(:config1) { test1.config }
|
51
54
|
|
52
55
|
should "produce results as expected" do
|
53
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
subject{ @test }
|
21
|
+
}
|
22
|
+
let(:config1) { test1.config }
|
22
23
|
|
23
24
|
should "produce results as expected" do
|
24
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
subject{ @test }
|
52
|
+
}
|
53
|
+
let(:config1) { test1.config }
|
51
54
|
|
52
55
|
should "produce results as expected" do
|
53
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
subject{ @test }
|
21
|
+
}
|
22
|
+
let(:config1) { test1.config }
|
22
23
|
|
23
24
|
should "produce results as expected" do
|
24
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
subject{ @test }
|
52
|
+
}
|
53
|
+
let(:config1) { test1.config }
|
51
54
|
|
52
55
|
should "produce results as expected" do
|
53
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|