assert 2.16.5 → 2.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/Gemfile +3 -1
- data/README.md +20 -20
- data/assert.gemspec +5 -3
- data/bin/assert +4 -4
- data/lib/assert.rb +8 -8
- data/lib/assert/assert_runner.rb +7 -7
- data/lib/assert/assertions.rb +5 -5
- data/lib/assert/cli.rb +35 -35
- data/lib/assert/config.rb +8 -8
- data/lib/assert/config_helpers.rb +6 -6
- data/lib/assert/context.rb +17 -17
- data/lib/assert/context/test_dsl.rb +5 -5
- data/lib/assert/context_info.rb +2 -2
- data/lib/assert/default_runner.rb +1 -1
- data/lib/assert/default_suite.rb +1 -1
- data/lib/assert/default_view.rb +8 -8
- data/lib/assert/factory.rb +1 -1
- data/lib/assert/macro.rb +1 -1
- data/lib/assert/macros/methods.rb +1 -1
- data/lib/assert/result.rb +17 -17
- data/lib/assert/runner.rb +12 -8
- data/lib/assert/stub.rb +1 -1
- data/lib/assert/suite.rb +3 -3
- data/lib/assert/test.rb +11 -11
- data/lib/assert/utils.rb +8 -8
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view.rb +19 -19
- data/lib/assert/view_helpers.rb +6 -6
- data/test/helper.rb +2 -11
- data/test/support/factory.rb +6 -6
- data/test/system/stub_tests.rb +204 -204
- data/test/system/test_tests.rb +13 -13
- data/test/unit/assert_tests.rb +9 -9
- data/test/unit/assertions/assert_block_tests.rb +2 -2
- data/test/unit/assertions/assert_empty_tests.rb +6 -6
- data/test/unit/assertions/assert_equal_tests.rb +5 -5
- data/test/unit/assertions/assert_file_exists_tests.rb +6 -6
- data/test/unit/assertions/assert_includes_tests.rb +7 -7
- data/test/unit/assertions/assert_instance_of_tests.rb +5 -5
- data/test/unit/assertions/assert_kind_of_tests.rb +5 -5
- data/test/unit/assertions/assert_match_tests.rb +5 -5
- data/test/unit/assertions/assert_nil_tests.rb +5 -5
- data/test/unit/assertions/assert_raises_tests.rb +2 -2
- data/test/unit/assertions/assert_respond_to_tests.rb +5 -5
- data/test/unit/assertions/assert_same_tests.rb +13 -13
- data/test/unit/assertions/assert_true_false_tests.rb +7 -7
- data/test/unit/assertions_tests.rb +2 -2
- data/test/unit/config_helpers_tests.rb +5 -5
- data/test/unit/config_tests.rb +12 -12
- data/test/unit/context/setup_dsl_tests.rb +7 -7
- data/test/unit/context/subject_dsl_tests.rb +3 -3
- data/test/unit/context/suite_dsl_tests.rb +3 -3
- data/test/unit/context/test_dsl_tests.rb +8 -8
- data/test/unit/context_info_tests.rb +6 -6
- data/test/unit/context_tests.rb +16 -16
- data/test/unit/default_runner_tests.rb +3 -3
- data/test/unit/default_suite_tests.rb +3 -3
- data/test/unit/factory_tests.rb +3 -3
- data/test/unit/file_line_tests.rb +12 -12
- data/test/unit/macro_tests.rb +2 -2
- data/test/unit/result_tests.rb +18 -18
- data/test/unit/runner_tests.rb +9 -9
- data/test/unit/suite_tests.rb +5 -5
- data/test/unit/test_tests.rb +19 -19
- data/test/unit/utils_tests.rb +18 -18
- data/test/unit/view_helpers_tests.rb +15 -15
- data/test/unit/view_tests.rb +11 -11
- data/tmp/.gitkeep +0 -0
- metadata +46 -44
- data/.assert.rb +0 -3
- data/.gitignore +0 -19
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "assert/assertions"
|
3
3
|
|
4
|
-
require
|
4
|
+
require "assert/utils"
|
5
5
|
|
6
6
|
module Assert::Assertions
|
7
7
|
|
@@ -11,7 +11,7 @@ module Assert::Assertions
|
|
11
11
|
desc "`assert_true`"
|
12
12
|
setup do
|
13
13
|
desc = @desc = "assert true fail desc"
|
14
|
-
args = @args = [
|
14
|
+
args = @args = ["whatever", desc]
|
15
15
|
@test = Factory.test do
|
16
16
|
assert_true(true) # pass
|
17
17
|
assert_true(*args) # fail
|
@@ -40,7 +40,7 @@ module Assert::Assertions
|
|
40
40
|
desc "`assert_not_true`"
|
41
41
|
setup do
|
42
42
|
desc = @desc = "assert not true fail desc"
|
43
|
-
args = @args = [
|
43
|
+
args = @args = [true, desc]
|
44
44
|
@test = Factory.test do
|
45
45
|
assert_not_true(false) # pass
|
46
46
|
assert_not_true(*args) # fail
|
@@ -69,7 +69,7 @@ module Assert::Assertions
|
|
69
69
|
desc "`assert_false`"
|
70
70
|
setup do
|
71
71
|
desc = @desc = "assert false fail desc"
|
72
|
-
args = @args = [
|
72
|
+
args = @args = ["whatever", desc]
|
73
73
|
@test = Factory.test do
|
74
74
|
assert_false(false) # pass
|
75
75
|
assert_false(*args) # fail
|
@@ -98,7 +98,7 @@ module Assert::Assertions
|
|
98
98
|
desc "`assert_not_false`"
|
99
99
|
setup do
|
100
100
|
desc = @desc = "assert not false fail desc"
|
101
|
-
args = @args = [
|
101
|
+
args = @args = [false, desc]
|
102
102
|
@test = Factory.test do
|
103
103
|
assert_not_false(true) # pass
|
104
104
|
assert_not_false(*args) # fail
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "assert/config_helpers"
|
3
3
|
|
4
|
-
require
|
4
|
+
require "assert/config"
|
5
5
|
|
6
6
|
module Assert::ConfigHelpers
|
7
7
|
|
@@ -99,7 +99,7 @@ module Assert::ConfigHelpers
|
|
99
99
|
end
|
100
100
|
|
101
101
|
should "know its formatted run time, test rate and result rate" do
|
102
|
-
format =
|
102
|
+
format = "%.6f"
|
103
103
|
|
104
104
|
run_time = Factory.float
|
105
105
|
exp = format % run_time
|
@@ -118,7 +118,7 @@ module Assert::ConfigHelpers
|
|
118
118
|
end
|
119
119
|
|
120
120
|
should "know its formatted suite run time, test rate and result rate" do
|
121
|
-
format =
|
121
|
+
format = "%.6f"
|
122
122
|
|
123
123
|
exp = format % subject.config.suite.run_time
|
124
124
|
assert_equal exp, subject.formatted_suite_run_time(format)
|
data/test/unit/config_tests.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "assert/config"
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
4
|
+
require "assert/default_runner"
|
5
|
+
require "assert/default_suite"
|
6
|
+
require "assert/default_view"
|
7
|
+
require "assert/file_line"
|
8
|
+
require "assert/runner"
|
9
9
|
|
10
10
|
class Assert::Config
|
11
11
|
|
@@ -32,9 +32,9 @@ class Assert::Config
|
|
32
32
|
end
|
33
33
|
|
34
34
|
should "default the test dir/helper/suffixes" do
|
35
|
-
assert_equal
|
36
|
-
assert_equal
|
37
|
-
assert_equal [
|
35
|
+
assert_equal "test", subject.test_dir
|
36
|
+
assert_equal "helper.rb", subject.test_helper
|
37
|
+
assert_equal ["_tests.rb", "_test.rb"], subject.test_file_suffixes
|
38
38
|
end
|
39
39
|
|
40
40
|
should "default the procs" do
|
@@ -75,7 +75,7 @@ class Assert::Config
|
|
75
75
|
end
|
76
76
|
|
77
77
|
should "know its single test file line" do
|
78
|
-
exp = Assert::FileLine.parse(File.expand_path(
|
78
|
+
exp = Assert::FileLine.parse(File.expand_path("", Dir.pwd))
|
79
79
|
assert_equal exp, subject.single_test_file_line
|
80
80
|
|
81
81
|
file_line_path = "#{Factory.path}_tests.rb:#{Factory.integer}"
|
@@ -86,7 +86,7 @@ class Assert::Config
|
|
86
86
|
end
|
87
87
|
|
88
88
|
should "know its single test file path" do
|
89
|
-
exp = Assert::FileLine.parse(File.expand_path(
|
89
|
+
exp = Assert::FileLine.parse(File.expand_path("", Dir.pwd)).file
|
90
90
|
assert_equal exp, subject.single_test_file_path
|
91
91
|
|
92
92
|
path = "#{Factory.path}_tests.rb"
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "assert/context/setup_dsl"
|
3
3
|
|
4
4
|
module Assert::Context::SetupDSL
|
5
5
|
|
@@ -91,10 +91,10 @@ module Assert::Context::SetupDSL
|
|
91
91
|
end
|
92
92
|
|
93
93
|
should "run it's parent and it's own blocks in the correct order" do
|
94
|
-
subject.send(
|
94
|
+
subject.send("run_setups", obj = @test_status_class.new)
|
95
95
|
assert_equal "the setup has been run with something", obj.setup_status
|
96
96
|
|
97
|
-
subject.send(
|
97
|
+
subject.send("run_teardowns", obj = @test_status_class.new)
|
98
98
|
assert_equal "with something has been run the teardown", obj.teardown_status
|
99
99
|
end
|
100
100
|
|
@@ -105,7 +105,7 @@ module Assert::Context::SetupDSL
|
|
105
105
|
setup do
|
106
106
|
@parent_class = Factory.modes_off_context_class do
|
107
107
|
around do |block|
|
108
|
-
self.out_status ||=
|
108
|
+
self.out_status ||= ""
|
109
109
|
self.out_status += "p-around start, "
|
110
110
|
block.call
|
111
111
|
self.out_status += "p-around end."
|
@@ -132,8 +132,8 @@ module Assert::Context::SetupDSL
|
|
132
132
|
|
133
133
|
should "run it's parent and it's own blocks in the correct order" do
|
134
134
|
obj = @test_status_class.new
|
135
|
-
subject.send(
|
136
|
-
obj.instance_eval{ self.out_status +=
|
135
|
+
subject.send("run_arounds", obj) do
|
136
|
+
obj.instance_eval{ self.out_status += "TEST, " }
|
137
137
|
end
|
138
138
|
|
139
139
|
exp = "p-around start, c-around1 start, c-around2 start, "\
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "assert/context/subject_dsl"
|
3
3
|
|
4
4
|
module Assert::Context::SubjectDSL
|
5
5
|
|
@@ -12,7 +12,7 @@ module Assert::Context::SubjectDSL
|
|
12
12
|
class DescriptionsTests < UnitTests
|
13
13
|
desc "`descriptions` method"
|
14
14
|
setup do
|
15
|
-
descs = @descs = [
|
15
|
+
descs = @descs = ["something amazing", "it really is"]
|
16
16
|
@context_class = Factory.modes_off_context_class do
|
17
17
|
descs.each{ |text| desc text }
|
18
18
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "assert/context/test_dsl"
|
3
3
|
|
4
4
|
module Assert::Context::TestDSL
|
5
5
|
|
@@ -40,7 +40,7 @@ module Assert::Context::TestDSL
|
|
40
40
|
end
|
41
41
|
|
42
42
|
assert_equal 1, context.class.suite.tests_to_run_count
|
43
|
-
assert_equal
|
43
|
+
assert_equal "TODO", err.message
|
44
44
|
assert_equal 1, err.backtrace.size
|
45
45
|
end
|
46
46
|
|
@@ -52,7 +52,7 @@ module Assert::Context::TestDSL
|
|
52
52
|
end
|
53
53
|
|
54
54
|
assert_equal 1, context.class.suite.tests_to_run_count
|
55
|
-
assert_equal
|
55
|
+
assert_equal "TODO", err.message
|
56
56
|
assert_equal 1, err.backtrace.size
|
57
57
|
end
|
58
58
|
|
@@ -64,7 +64,7 @@ module Assert::Context::TestDSL
|
|
64
64
|
end
|
65
65
|
|
66
66
|
assert_equal 1, context.class.suite.tests_to_run_count
|
67
|
-
assert_equal
|
67
|
+
assert_equal "TODO", err.message
|
68
68
|
assert_equal 1, err.backtrace.size
|
69
69
|
end
|
70
70
|
|
@@ -76,7 +76,7 @@ module Assert::Context::TestDSL
|
|
76
76
|
end
|
77
77
|
|
78
78
|
assert_equal 1, context.class.suite.tests_to_run_count
|
79
|
-
assert_equal
|
79
|
+
assert_equal "TODO", err.message
|
80
80
|
assert_equal 1, err.backtrace.size
|
81
81
|
end
|
82
82
|
|
@@ -88,7 +88,7 @@ module Assert::Context::TestDSL
|
|
88
88
|
end
|
89
89
|
|
90
90
|
assert_equal 1, context.class.suite.tests_to_run_count
|
91
|
-
assert_equal
|
91
|
+
assert_equal "TODO", err.message
|
92
92
|
assert_equal 1, err.backtrace.size
|
93
93
|
end
|
94
94
|
|
@@ -100,7 +100,7 @@ module Assert::Context::TestDSL
|
|
100
100
|
end
|
101
101
|
|
102
102
|
assert_equal 1, context.class.suite.tests_to_run_count
|
103
|
-
assert_equal
|
103
|
+
assert_equal "TODO", err.message
|
104
104
|
assert_equal 1, err.backtrace.size
|
105
105
|
end
|
106
106
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "assert/context_info"
|
3
3
|
|
4
|
-
require
|
4
|
+
require "assert/context"
|
5
5
|
|
6
6
|
class Assert::ContextInfo
|
7
7
|
|
@@ -30,7 +30,7 @@ class Assert::ContextInfo
|
|
30
30
|
end
|
31
31
|
|
32
32
|
should "set its file from caller info on init" do
|
33
|
-
assert_equal @caller.first.gsub(/\:[0-9]+.*$/,
|
33
|
+
assert_equal @caller.first.gsub(/\:[0-9]+.*$/, ""), subject.file
|
34
34
|
end
|
35
35
|
|
36
36
|
should "not have any file info if no caller is given" do
|
@@ -43,8 +43,8 @@ class Assert::ContextInfo
|
|
43
43
|
name = Factory.string
|
44
44
|
|
45
45
|
assert_equal name, subject.test_name(name)
|
46
|
-
assert_equal
|
47
|
-
assert_equal
|
46
|
+
assert_equal "", subject.test_name("")
|
47
|
+
assert_equal "", subject.test_name(nil)
|
48
48
|
|
49
49
|
Assert.stub(subject.klass, :description){ desc }
|
50
50
|
assert_equal "#{desc} #{name}", subject.test_name(name)
|
data/test/unit/context_tests.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "assert/context"
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
4
|
+
require "assert/config"
|
5
|
+
require "assert/result"
|
6
|
+
require "assert/utils"
|
7
7
|
|
8
8
|
class Assert::Context
|
9
9
|
|
@@ -43,7 +43,7 @@ class Assert::Context
|
|
43
43
|
end
|
44
44
|
private
|
45
45
|
|
46
|
-
ASSERT_TEST_PATH_REGEX = /\A#{File.join(ROOT_PATH,
|
46
|
+
ASSERT_TEST_PATH_REGEX = /\A#{File.join(ROOT_PATH, "test", "")}/
|
47
47
|
|
48
48
|
def assert_with_bt_set(exp_with_bt, result)
|
49
49
|
with_backtrace(caller) do
|
@@ -212,7 +212,7 @@ class Assert::Context
|
|
212
212
|
should "return a pass result given a `true` assertion" do
|
213
213
|
result = subject.assert(true, @fail_desc){ @what_failed }
|
214
214
|
assert_kind_of Assert::Result::Pass, result
|
215
|
-
assert_equal
|
215
|
+
assert_equal "", result.message
|
216
216
|
end
|
217
217
|
|
218
218
|
should "return a fail result given a `false` assertion" do
|
@@ -251,7 +251,7 @@ class Assert::Context
|
|
251
251
|
should "return a pass result given a `false` assertion" do
|
252
252
|
result = subject.assert_not(false, @fail_desc)
|
253
253
|
assert_kind_of Assert::Result::Pass, result
|
254
|
-
assert_equal
|
254
|
+
assert_equal "", result.message
|
255
255
|
end
|
256
256
|
|
257
257
|
should "return a fail result given a `true` assertion" do
|
@@ -302,7 +302,7 @@ class Assert::Context
|
|
302
302
|
end
|
303
303
|
|
304
304
|
should "make fails skips and make passes fails" do
|
305
|
-
@context.fail
|
305
|
+
@context.fail "not affected"
|
306
306
|
@context.pass
|
307
307
|
@context.pending(&@block1)
|
308
308
|
|
@@ -342,12 +342,12 @@ class Assert::Context
|
|
342
342
|
class WithBacktraceTests < UnitTests
|
343
343
|
desc "`with_backtrace` method"
|
344
344
|
setup do
|
345
|
-
@from_bt = [
|
346
|
-
@from_block = proc { ignore; fail; pass; skip
|
345
|
+
@from_bt = ["called_from_here", Factory.string]
|
346
|
+
@from_block = proc { ignore; fail; pass; skip "todo"; }
|
347
347
|
end
|
348
348
|
|
349
349
|
should "alter non-error block results' bt with given bt's first line" do
|
350
|
-
@context.fail
|
350
|
+
@context.fail "not affected"
|
351
351
|
begin
|
352
352
|
@context.with_backtrace(@from_bt, &@from_block)
|
353
353
|
rescue Assert::Result::TestSkipped => e
|
@@ -371,15 +371,15 @@ class Assert::Context
|
|
371
371
|
class WithNestedBacktraceTests < UnitTests
|
372
372
|
desc "`with_backtrace` method nested"
|
373
373
|
setup do
|
374
|
-
@from_bt1 = [
|
375
|
-
@from_bt2 = from_bt2 = [
|
374
|
+
@from_bt1 = ["called_from_here 1", Factory.string]
|
375
|
+
@from_bt2 = from_bt2 = ["called_from_here 2", Factory.string]
|
376
376
|
|
377
|
-
from_block2 = proc { ignore; fail; pass; skip
|
377
|
+
from_block2 = proc { ignore; fail; pass; skip "todo"; }
|
378
378
|
@from_block1 = proc { with_backtrace(from_bt2, &from_block2) }
|
379
379
|
end
|
380
380
|
|
381
381
|
should "alter non-error block results' bt with nested wbt accrued first lines" do
|
382
|
-
@context.fail
|
382
|
+
@context.fail "not affected"
|
383
383
|
begin
|
384
384
|
@context.with_backtrace(@from_bt1, &@from_block1)
|
385
385
|
rescue Assert::Result::TestSkipped => e
|
data/test/unit/factory_tests.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "assert/file_line"
|
3
3
|
|
4
4
|
class Assert::FileLine
|
5
5
|
|
@@ -27,19 +27,19 @@ class Assert::FileLine
|
|
27
27
|
should "handle parsing bad data gracefully" do
|
28
28
|
file_line = subject.parse(@file)
|
29
29
|
assert_equal @file, file_line.file
|
30
|
-
assert_equal
|
30
|
+
assert_equal "", file_line.line
|
31
31
|
|
32
32
|
file_line = subject.parse(@line)
|
33
33
|
assert_equal @line, file_line.file
|
34
|
-
assert_equal
|
34
|
+
assert_equal "", file_line.line
|
35
35
|
|
36
|
-
file_line = subject.parse(
|
37
|
-
assert_equal
|
38
|
-
assert_equal
|
36
|
+
file_line = subject.parse("")
|
37
|
+
assert_equal "", file_line.file
|
38
|
+
assert_equal "", file_line.line
|
39
39
|
|
40
40
|
file_line = subject.parse(nil)
|
41
|
-
assert_equal
|
42
|
-
assert_equal
|
41
|
+
assert_equal "", file_line.file
|
42
|
+
assert_equal "", file_line.line
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
@@ -59,11 +59,11 @@ class Assert::FileLine
|
|
59
59
|
|
60
60
|
file_line = Assert::FileLine.new(@file)
|
61
61
|
assert_equal @file, file_line.file
|
62
|
-
assert_equal
|
62
|
+
assert_equal "", file_line.line
|
63
63
|
|
64
64
|
file_line = Assert::FileLine.new
|
65
|
-
assert_equal
|
66
|
-
assert_equal
|
65
|
+
assert_equal "", file_line.file
|
66
|
+
assert_equal "", file_line.line
|
67
67
|
end
|
68
68
|
|
69
69
|
should "know its string representation" do
|