assert 2.0.0.rc.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/{LICENSE → LICENSE.txt} +0 -0
- data/Rakefile +1 -3
- data/assert.gemspec +15 -15
- data/lib/assert.rb +1 -2
- data/lib/assert/assert_runner.rb +2 -1
- data/lib/assert/assertions.rb +153 -189
- data/lib/assert/version.rb +1 -1
- data/test/helper.rb +74 -51
- data/test/{fixtures → support}/inherited_stuff.rb +0 -0
- data/test/{test → system}/running_tests.rb +16 -43
- data/test/{assert_test.rb → unit/assert_tests.rb} +0 -0
- data/test/unit/assertions/assert_block_tests.rb +57 -0
- data/test/unit/assertions/assert_empty_tests.rb +58 -0
- data/test/unit/assertions/assert_equal_tests.rb +59 -0
- data/test/unit/assertions/assert_file_exists_tests.rb +59 -0
- data/test/unit/assertions/assert_includes_tests.rb +61 -0
- data/test/unit/assertions/assert_instance_of_tests.rb +61 -0
- data/test/unit/assertions/assert_kind_of_tests.rb +60 -0
- data/test/unit/assertions/assert_match_tests.rb +59 -0
- data/test/unit/assertions/assert_nil_tests.rb +59 -0
- data/test/unit/assertions/assert_raises_tests.rb +73 -0
- data/test/unit/assertions/assert_respond_to_tests.rb +63 -0
- data/test/unit/assertions/assert_same_tests.rb +65 -0
- data/test/unit/assertions_tests.rb +65 -0
- data/test/unit/context/basic_singleton_tests.rb +86 -0
- data/test/unit/context/setup_teardown_singleton_tests.rb +105 -0
- data/test/unit/context/test_should_singleton_tests.rb +134 -0
- data/test/{context_test.rb → unit/context_tests.rb} +53 -131
- data/test/{macro_test.rb → unit/macro_tests.rb} +15 -11
- data/test/{result_test.rb → unit/result_tests.rb} +27 -26
- data/test/{runner_test.rb → unit/runner_tests.rb} +1 -2
- data/test/{suite_test.rb → unit/suite_tests.rb} +63 -95
- data/test/{test_test.rb → unit/test_tests.rb} +45 -77
- data/test/{view/base_tests.rb → unit/view_tests.rb} +0 -1
- metadata +63 -104
- data/CHANGELOG.md +0 -33
- data/test/assertions/assert_block_test.rb +0 -39
- data/test/assertions/assert_empty_test.rb +0 -43
- data/test/assertions/assert_equal_test.rb +0 -43
- data/test/assertions/assert_file_exists_test.rb +0 -43
- data/test/assertions/assert_includes_test.rb +0 -44
- data/test/assertions/assert_instance_of_test.rb +0 -43
- data/test/assertions/assert_kind_of_test.rb +0 -43
- data/test/assertions/assert_match_test.rb +0 -43
- data/test/assertions/assert_nil_test.rb +0 -43
- data/test/assertions/assert_not_block_test.rb +0 -39
- data/test/assertions/assert_not_empty_test.rb +0 -43
- data/test/assertions/assert_not_equal_test.rb +0 -43
- data/test/assertions/assert_not_file_exists_test.rb +0 -43
- data/test/assertions/assert_not_included_test.rb +0 -44
- data/test/assertions/assert_not_instance_of_test.rb +0 -43
- data/test/assertions/assert_not_kind_of_test.rb +0 -43
- data/test/assertions/assert_not_match_test.rb +0 -43
- data/test/assertions/assert_not_nil_test.rb +0 -43
- data/test/assertions/assert_not_respond_to_test.rb +0 -43
- data/test/assertions/assert_not_same_test.rb +0 -45
- data/test/assertions/assert_nothing_raised_test.rb +0 -46
- data/test/assertions/assert_raises_test.rb +0 -49
- data/test/assertions/assert_respond_to_test.rb +0 -43
- data/test/assertions/assert_same_test.rb +0 -45
- data/test/assertions_test.rb +0 -60
- data/test/context/class_methods_test.rb +0 -531
- data/test/fixtures/sample_context.rb +0 -13
- data/test/fixtures/test_root/one_test.rb +0 -0
- data/test/fixtures/test_root/parent/area_one/area_test.rb +0 -0
- data/test/fixtures/test_root/shallow/deeply/nested_test.rb +0 -0
- data/test/fixtures/test_root/shallow/nested_test.rb +0 -0
- data/test/fixtures/test_root/shallow_test.rb +0 -0
- data/test/fixtures/test_root/two_test.rb +0 -0
- data/test/suite/context_info_test.rb +0 -42
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/assertions'
|
3
|
+
|
4
|
+
module Assert::Assertions
|
5
|
+
|
6
|
+
class AssertFileExistsTests < Assert::Context
|
7
|
+
desc "the assert_file_exists helper"
|
8
|
+
setup do
|
9
|
+
desc = @desc = "assert file exists empty fail desc"
|
10
|
+
args = @args = [ '/a/path/to/some/file/that/no/exists', desc ]
|
11
|
+
@test = Factory.test do
|
12
|
+
assert_file_exists(__FILE__) # pass
|
13
|
+
assert_file_exists(*args) # fail
|
14
|
+
end
|
15
|
+
@test.run
|
16
|
+
end
|
17
|
+
subject{ @test }
|
18
|
+
|
19
|
+
should "produce results as expected" do
|
20
|
+
assert_equal 2, subject.result_count
|
21
|
+
assert_equal 1, subject.result_count(:pass)
|
22
|
+
assert_equal 1, subject.result_count(:fail)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "have a fail message with custom and generic explanations" do
|
26
|
+
exp = "#{@args[1]}\nExpected #{@args[0].inspect} to exist."
|
27
|
+
assert_equal exp, subject.fail_results.first.message
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class AssertNotFileExistsTests < Assert::Context
|
33
|
+
desc "the assert_not_file_exists helper"
|
34
|
+
setup do
|
35
|
+
desc = @desc = "assert not file exists empty fail desc"
|
36
|
+
args = @args = [ __FILE__, desc ]
|
37
|
+
@test = Factory.test do
|
38
|
+
assert_not_file_exists('/a/path/to/some/file/that/no/exists') # pass
|
39
|
+
assert_not_file_exists(*args) # fail
|
40
|
+
end
|
41
|
+
@test.run
|
42
|
+
end
|
43
|
+
subject{ @test }
|
44
|
+
|
45
|
+
should "produce results as expected" do
|
46
|
+
assert_equal 2, subject.result_count
|
47
|
+
assert_equal 1, subject.result_count(:pass)
|
48
|
+
assert_equal 1, subject.result_count(:fail)
|
49
|
+
end
|
50
|
+
|
51
|
+
should "have a fail message with custom and generic explanations" do
|
52
|
+
exp = "#{@args[1]}\nExpected #{@args[0].inspect} to not exist."
|
53
|
+
assert_equal exp, subject.fail_results.first.message
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/assertions'
|
3
|
+
|
4
|
+
module Assert::Assertions
|
5
|
+
|
6
|
+
class AssertIncludesTests < Assert::Context
|
7
|
+
desc "the assert_includes helper"
|
8
|
+
setup do
|
9
|
+
desc = @desc = "assert includes fail desc"
|
10
|
+
args = @args = [ 2, [ 1 ], desc ]
|
11
|
+
@test = Factory.test do
|
12
|
+
assert_includes(1, [ 1 ]) # pass
|
13
|
+
assert_includes(*args) # fail
|
14
|
+
end
|
15
|
+
@test.run
|
16
|
+
end
|
17
|
+
subject{ @test }
|
18
|
+
|
19
|
+
should "produce results as expected" do
|
20
|
+
assert_equal 2, subject.result_count
|
21
|
+
assert_equal 1, subject.result_count(:pass)
|
22
|
+
assert_equal 1, subject.result_count(:fail)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "have a fail message with custom and generic explanations" do
|
26
|
+
exp = "#{@args[2]}\n"\
|
27
|
+
"Expected #{@args[1].inspect} to include #{@args[0].inspect}."
|
28
|
+
assert_equal exp, subject.fail_results.first.message
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
class AssertNotIncluded < Assert::Context
|
34
|
+
desc "the assert_not_included helper"
|
35
|
+
setup do
|
36
|
+
desc = @desc = "assert not included fail desc"
|
37
|
+
args = @args = [ 1, [ 1 ], desc ]
|
38
|
+
@test = Factory.test do
|
39
|
+
assert_not_included(2, [ 1 ]) # pass
|
40
|
+
assert_not_included(*args) # fail
|
41
|
+
end
|
42
|
+
@test.run
|
43
|
+
end
|
44
|
+
subject{ @test }
|
45
|
+
|
46
|
+
should "produce results as expected" do
|
47
|
+
assert_equal 2, subject.result_count
|
48
|
+
assert_equal 1, subject.result_count(:pass)
|
49
|
+
assert_equal 1, subject.result_count(:fail)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "have a fail message with custom and generic explanations" do
|
53
|
+
exp = "#{@args[2]}\n"\
|
54
|
+
"Expected #{@args[1].inspect} to not include #{@args[0].inspect}."
|
55
|
+
assert_equal exp, subject.fail_results.first.message
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/assertions'
|
3
|
+
|
4
|
+
module Assert::Assertions
|
5
|
+
|
6
|
+
class AssertInstanceOfTests < Assert::Context
|
7
|
+
desc "the assert_instance_of helper"
|
8
|
+
setup do
|
9
|
+
desc = @desc = "assert instance of fail desc"
|
10
|
+
args = @args = [ Array, "object", desc ]
|
11
|
+
@test = Factory.test do
|
12
|
+
assert_instance_of(String, "object") # pass
|
13
|
+
assert_instance_of(*args) # fail
|
14
|
+
end
|
15
|
+
@test.run
|
16
|
+
end
|
17
|
+
subject{ @test }
|
18
|
+
|
19
|
+
should "produce results as expected" do
|
20
|
+
assert_equal 2, subject.result_count
|
21
|
+
assert_equal 1, subject.result_count(:pass)
|
22
|
+
assert_equal 1, subject.result_count(:fail)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "have a fail message with custom and generic explanations" do
|
26
|
+
exp = "#{@args[2]}\nExpected #{@args[1].inspect} (#{@args[1].class}) to"\
|
27
|
+
" be an instance of #{@args[0]}."
|
28
|
+
assert_equal exp, subject.fail_results.first.message
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
class AssertNotInstanceOfTests < Assert::Context
|
34
|
+
desc "the assert_not_instance_of helper"
|
35
|
+
setup do
|
36
|
+
desc = @desc = "assert not instance of fail desc"
|
37
|
+
args = @args = [ String, "object", desc ]
|
38
|
+
@test = Factory.test do
|
39
|
+
assert_not_instance_of(*args) # fail
|
40
|
+
assert_not_instance_of(Array, "object") # pass
|
41
|
+
end
|
42
|
+
@test.run
|
43
|
+
end
|
44
|
+
subject{ @test }
|
45
|
+
|
46
|
+
should "produce results as expected" do
|
47
|
+
assert_equal 2, subject.result_count
|
48
|
+
assert_equal 1, subject.result_count(:pass)
|
49
|
+
assert_equal 1, subject.result_count(:fail)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "have a fail message with custom and generic explanations" do
|
53
|
+
exp = "#{@args[2]}\n#{@args[1].inspect} not expected to"\
|
54
|
+
" be an instance of #{@args[0]}."
|
55
|
+
assert_equal exp, subject.fail_results.first.message
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/assertions'
|
3
|
+
|
4
|
+
module Assert::Assertions
|
5
|
+
|
6
|
+
class AssertKindOfTests < Assert::Context
|
7
|
+
desc "the assert_kind_of helper"
|
8
|
+
setup do
|
9
|
+
desc = @desc = "assert kind of fail desc"
|
10
|
+
args = @args = [ Array, "object", desc ]
|
11
|
+
@test = Factory.test do
|
12
|
+
assert_kind_of(String, "object") # pass
|
13
|
+
assert_kind_of(*args) # fail
|
14
|
+
end
|
15
|
+
@test.run
|
16
|
+
end
|
17
|
+
subject{ @test }
|
18
|
+
|
19
|
+
should "produce results as expected" do
|
20
|
+
assert_equal 2, subject.result_count
|
21
|
+
assert_equal 1, subject.result_count(:pass)
|
22
|
+
assert_equal 1, subject.result_count(:fail)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "have a fail message with custom and generic explanations" do
|
26
|
+
exp = "#{@args[2]}\nExpected #{@args[1].inspect} (#{@args[1].class}) to"\
|
27
|
+
" be a kind of #{@args[0]}."
|
28
|
+
assert_equal exp, subject.fail_results.first.message
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
class AssertNotKindOfTests < Assert::Context
|
34
|
+
desc "the assert_not_kind_of helper"
|
35
|
+
setup do
|
36
|
+
desc = @desc = "assert not kind of fail desc"
|
37
|
+
args = @args = [ String, "object", desc ]
|
38
|
+
@test = Factory.test do
|
39
|
+
assert_not_kind_of(*args) # fail
|
40
|
+
assert_not_kind_of(Array, "object") # pass
|
41
|
+
end
|
42
|
+
@test.run
|
43
|
+
end
|
44
|
+
subject{ @test }
|
45
|
+
|
46
|
+
should "produce results as expected" do
|
47
|
+
assert_equal 2, subject.result_count
|
48
|
+
assert_equal 1, subject.result_count(:pass)
|
49
|
+
assert_equal 1, subject.result_count(:fail)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "have a fail message with custom and generic explanations" do
|
53
|
+
exp = "#{@args[2]}\n#{@args[1].inspect} not expected to be a kind of #{@args[0]}."
|
54
|
+
assert_equal exp, subject.fail_results.first.message
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/assertions'
|
3
|
+
|
4
|
+
module Assert::Assertions
|
5
|
+
|
6
|
+
class AssertMatchTests < Assert::Context
|
7
|
+
desc "the assert_match helper"
|
8
|
+
setup do
|
9
|
+
desc = @desc = "assert match fail desc"
|
10
|
+
args = @args = [ "not", "a string", desc ]
|
11
|
+
@test = Factory.test do
|
12
|
+
assert_match(/a/, "a string") # pass
|
13
|
+
assert_match(*args) # fail
|
14
|
+
end
|
15
|
+
@test.run
|
16
|
+
end
|
17
|
+
subject{ @test }
|
18
|
+
|
19
|
+
should "produce results as expected" do
|
20
|
+
assert_equal 2, subject.result_count
|
21
|
+
assert_equal 1, subject.result_count(:pass)
|
22
|
+
assert_equal 1, subject.result_count(:fail)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "have a fail message with custom and generic explanations" do
|
26
|
+
exp = "#{@args[2]}\nExpected #{@args[1].inspect} to match #{@args[0].inspect}."
|
27
|
+
assert_equal exp, subject.fail_results.first.message
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class AssertNotMatchTests < Assert::Context
|
33
|
+
desc "the assert_not_match helper"
|
34
|
+
setup do
|
35
|
+
desc = @desc = "assert not match fail desc"
|
36
|
+
args = @args = [ /a/, "a string", desc ]
|
37
|
+
@test = Factory.test do
|
38
|
+
assert_not_match(*args) # fail
|
39
|
+
assert_not_match("not", "a string") # pass
|
40
|
+
end
|
41
|
+
@test.run
|
42
|
+
end
|
43
|
+
subject{ @test }
|
44
|
+
|
45
|
+
should "produce results as expected" do
|
46
|
+
assert_equal 2, subject.result_count
|
47
|
+
assert_equal 1, subject.result_count(:pass)
|
48
|
+
assert_equal 1, subject.result_count(:fail)
|
49
|
+
end
|
50
|
+
|
51
|
+
should "have a fail message with custom and generic explanations" do
|
52
|
+
exp = "#{@args[2]}\n#{@args[1].inspect} not expected to match #{@args[0].inspect}."
|
53
|
+
assert_equal exp, subject.fail_results.first.message
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/assertions'
|
3
|
+
|
4
|
+
module Assert::Assertions
|
5
|
+
|
6
|
+
class AssertNilTests < Assert::Context
|
7
|
+
desc "the assert_nil helper"
|
8
|
+
setup do
|
9
|
+
desc = @desc = "assert nil empty fail desc"
|
10
|
+
args = @args = [ 1, desc ]
|
11
|
+
@test = Factory.test do
|
12
|
+
assert_nil(nil) # pass
|
13
|
+
assert_nil(*args) # fail
|
14
|
+
end
|
15
|
+
@test.run
|
16
|
+
end
|
17
|
+
subject{ @test }
|
18
|
+
|
19
|
+
should "produce results as expected" do
|
20
|
+
assert_equal 2, subject.result_count
|
21
|
+
assert_equal 1, subject.result_count(:pass)
|
22
|
+
assert_equal 1, subject.result_count(:fail)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "have a fail message with custom and generic explanations" do
|
26
|
+
exp = "#{@args[1]}\nExpected nil, not #{@args[0].inspect}."
|
27
|
+
assert_equal exp, subject.fail_results.first.message
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class AssertNotNilTests < Assert::Context
|
33
|
+
desc "the assert_not_nil helper"
|
34
|
+
setup do
|
35
|
+
desc = @desc = "assert not nil empty fail desc"
|
36
|
+
args = @args = [ nil, desc ]
|
37
|
+
@test = Factory.test do
|
38
|
+
assert_not_nil(1) # pass
|
39
|
+
assert_not_nil(*args) # fail
|
40
|
+
end
|
41
|
+
@test.run
|
42
|
+
end
|
43
|
+
subject{ @test }
|
44
|
+
|
45
|
+
should "produce results as expected" do
|
46
|
+
assert_equal 2, subject.result_count
|
47
|
+
assert_equal 1, subject.result_count(:pass)
|
48
|
+
assert_equal 1, subject.result_count(:fail)
|
49
|
+
end
|
50
|
+
|
51
|
+
should "have a fail message with custom and generic explanations" do
|
52
|
+
exp = "#{@args[1]}\nExpected #{@args[0].inspect} to not be nil."
|
53
|
+
assert_equal exp, subject.fail_results.first.message
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/assertions'
|
3
|
+
|
4
|
+
module Assert::Assertions
|
5
|
+
|
6
|
+
class AssertRaisesTests < Assert::Context
|
7
|
+
desc "the assert_raises helper"
|
8
|
+
setup do
|
9
|
+
d = @d = "assert raises fail desc"
|
10
|
+
@test = Factory.test do
|
11
|
+
assert_raises(StandardError, RuntimeError){ raise(StandardError) } # pass
|
12
|
+
assert_raises(StandardError, RuntimeError, d){ raise(Exception) } # fail
|
13
|
+
assert_raises(RuntimeError, d){ raise(StandardError) } # fail
|
14
|
+
assert_raises(RuntimeError, d){ true } # fail
|
15
|
+
assert_raises(d){ true } # fail
|
16
|
+
end
|
17
|
+
@test.run
|
18
|
+
end
|
19
|
+
subject{ @test }
|
20
|
+
|
21
|
+
should "produce results as expected" do
|
22
|
+
assert_equal 5, subject.result_count
|
23
|
+
assert_equal 1, subject.result_count(:pass)
|
24
|
+
assert_equal 4, subject.result_count(:fail)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "have a fail message with custom and generic explanations" do
|
28
|
+
exp = [
|
29
|
+
"#{@d}\nStandardError or RuntimeError exception expected, not:",
|
30
|
+
"#{@d}\nRuntimeError exception expected, not:",
|
31
|
+
"#{@d}\nRuntimeError exception expected but nothing raised.",
|
32
|
+
"#{@d}\nAn exception expected but nothing raised."
|
33
|
+
]
|
34
|
+
messages = @test.fail_results.map(&:message)
|
35
|
+
messages.each_with_index{ |msg, n| assert_match /^#{exp[n]}/, msg }
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
class AssertNothingRaisedTests < Assert::Context
|
41
|
+
desc "the assert_nothing_raised helper"
|
42
|
+
setup do
|
43
|
+
d = @d = "assert nothing raised fail desc"
|
44
|
+
@test = Factory.test do
|
45
|
+
anr = :assert_nothing_raised
|
46
|
+
self.send(anr, StandardError, RuntimeError, d){ raise(StandardError) } # fail
|
47
|
+
self.send(anr, RuntimeError){ raise(StandardError) } # pass
|
48
|
+
self.send(anr, d){ raise(RuntimeError) } # fail
|
49
|
+
self.send(anr){ true } # pass
|
50
|
+
end
|
51
|
+
@test.run
|
52
|
+
end
|
53
|
+
subject{ @test }
|
54
|
+
|
55
|
+
should "produce results as expected" do
|
56
|
+
assert_equal 4, subject.result_count
|
57
|
+
assert_equal 2, subject.result_count(:pass)
|
58
|
+
assert_equal 2, subject.result_count(:fail)
|
59
|
+
end
|
60
|
+
|
61
|
+
should "have a fail message with custom and generic explanations" do
|
62
|
+
exp = [
|
63
|
+
"#{@d}\nStandardError or RuntimeError exception not expected, but raised:",
|
64
|
+
"#{@d}\nAn exception not expected, but raised:"
|
65
|
+
]
|
66
|
+
messages = @test.fail_results.map(&:message)
|
67
|
+
messages.each_with_index{ |msg, n| assert_match /^#{exp[n]}/, msg }
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/assertions'
|
3
|
+
|
4
|
+
module Assert::Assertions
|
5
|
+
|
6
|
+
class AssertRespondToTest < Assert::Context
|
7
|
+
desc "the assert_respond_to helper"
|
8
|
+
setup do
|
9
|
+
desc = @desc = "assert respond to fail desc"
|
10
|
+
args = @args = [ :abs, "1", desc ]
|
11
|
+
@test = Factory.test do
|
12
|
+
assert_respond_to(:abs, 1) # pass
|
13
|
+
assert_respond_to(*args) # fail
|
14
|
+
end
|
15
|
+
@test.run
|
16
|
+
end
|
17
|
+
subject{ @test }
|
18
|
+
|
19
|
+
should "produce results as expected" do
|
20
|
+
assert_equal 2, subject.result_count
|
21
|
+
assert_equal 1, subject.result_count(:pass)
|
22
|
+
assert_equal 1, subject.result_count(:fail)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "have a fail message with custom and generic explanations" do
|
26
|
+
exp = "#{@args[2]}\n"\
|
27
|
+
"Expected #{@args[1].inspect} (#{@args[1].class})"\
|
28
|
+
" to respond to `#{@args[0]}`."
|
29
|
+
assert_equal exp, subject.fail_results.first.message
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
class AssertNotRespondToTests < Assert::Context
|
35
|
+
desc "the assert_not_respond_to helper"
|
36
|
+
setup do
|
37
|
+
desc = @desc = "assert not respond to fail desc"
|
38
|
+
args = @args = [ :abs, 1, desc ]
|
39
|
+
@test = Factory.test do
|
40
|
+
assert_not_respond_to(*args) # fail
|
41
|
+
assert_not_respond_to(:abs, "1") # pass
|
42
|
+
end
|
43
|
+
@test.run
|
44
|
+
end
|
45
|
+
subject{ @test }
|
46
|
+
|
47
|
+
should "produce results as expected" do
|
48
|
+
assert_equal 2, subject.result_count
|
49
|
+
assert_equal 1, subject.result_count(:pass)
|
50
|
+
assert_equal 1, subject.result_count(:fail)
|
51
|
+
end
|
52
|
+
|
53
|
+
should "have a fail message with custom and generic explanations" do
|
54
|
+
exp = "#{@args[2]}\n"\
|
55
|
+
"#{@args[1].inspect} (#{@args[1].class})"\
|
56
|
+
" not expected to respond to `#{@args[0]}`."
|
57
|
+
assert_equal exp, subject.fail_results.first.message
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|