assert 2.0.0.rc.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/Gemfile +1 -1
  2. data/{LICENSE → LICENSE.txt} +0 -0
  3. data/Rakefile +1 -3
  4. data/assert.gemspec +15 -15
  5. data/lib/assert.rb +1 -2
  6. data/lib/assert/assert_runner.rb +2 -1
  7. data/lib/assert/assertions.rb +153 -189
  8. data/lib/assert/version.rb +1 -1
  9. data/test/helper.rb +74 -51
  10. data/test/{fixtures → support}/inherited_stuff.rb +0 -0
  11. data/test/{test → system}/running_tests.rb +16 -43
  12. data/test/{assert_test.rb → unit/assert_tests.rb} +0 -0
  13. data/test/unit/assertions/assert_block_tests.rb +57 -0
  14. data/test/unit/assertions/assert_empty_tests.rb +58 -0
  15. data/test/unit/assertions/assert_equal_tests.rb +59 -0
  16. data/test/unit/assertions/assert_file_exists_tests.rb +59 -0
  17. data/test/unit/assertions/assert_includes_tests.rb +61 -0
  18. data/test/unit/assertions/assert_instance_of_tests.rb +61 -0
  19. data/test/unit/assertions/assert_kind_of_tests.rb +60 -0
  20. data/test/unit/assertions/assert_match_tests.rb +59 -0
  21. data/test/unit/assertions/assert_nil_tests.rb +59 -0
  22. data/test/unit/assertions/assert_raises_tests.rb +73 -0
  23. data/test/unit/assertions/assert_respond_to_tests.rb +63 -0
  24. data/test/unit/assertions/assert_same_tests.rb +65 -0
  25. data/test/unit/assertions_tests.rb +65 -0
  26. data/test/unit/context/basic_singleton_tests.rb +86 -0
  27. data/test/unit/context/setup_teardown_singleton_tests.rb +105 -0
  28. data/test/unit/context/test_should_singleton_tests.rb +134 -0
  29. data/test/{context_test.rb → unit/context_tests.rb} +53 -131
  30. data/test/{macro_test.rb → unit/macro_tests.rb} +15 -11
  31. data/test/{result_test.rb → unit/result_tests.rb} +27 -26
  32. data/test/{runner_test.rb → unit/runner_tests.rb} +1 -2
  33. data/test/{suite_test.rb → unit/suite_tests.rb} +63 -95
  34. data/test/{test_test.rb → unit/test_tests.rb} +45 -77
  35. data/test/{view/base_tests.rb → unit/view_tests.rb} +0 -1
  36. metadata +63 -104
  37. data/CHANGELOG.md +0 -33
  38. data/test/assertions/assert_block_test.rb +0 -39
  39. data/test/assertions/assert_empty_test.rb +0 -43
  40. data/test/assertions/assert_equal_test.rb +0 -43
  41. data/test/assertions/assert_file_exists_test.rb +0 -43
  42. data/test/assertions/assert_includes_test.rb +0 -44
  43. data/test/assertions/assert_instance_of_test.rb +0 -43
  44. data/test/assertions/assert_kind_of_test.rb +0 -43
  45. data/test/assertions/assert_match_test.rb +0 -43
  46. data/test/assertions/assert_nil_test.rb +0 -43
  47. data/test/assertions/assert_not_block_test.rb +0 -39
  48. data/test/assertions/assert_not_empty_test.rb +0 -43
  49. data/test/assertions/assert_not_equal_test.rb +0 -43
  50. data/test/assertions/assert_not_file_exists_test.rb +0 -43
  51. data/test/assertions/assert_not_included_test.rb +0 -44
  52. data/test/assertions/assert_not_instance_of_test.rb +0 -43
  53. data/test/assertions/assert_not_kind_of_test.rb +0 -43
  54. data/test/assertions/assert_not_match_test.rb +0 -43
  55. data/test/assertions/assert_not_nil_test.rb +0 -43
  56. data/test/assertions/assert_not_respond_to_test.rb +0 -43
  57. data/test/assertions/assert_not_same_test.rb +0 -45
  58. data/test/assertions/assert_nothing_raised_test.rb +0 -46
  59. data/test/assertions/assert_raises_test.rb +0 -49
  60. data/test/assertions/assert_respond_to_test.rb +0 -43
  61. data/test/assertions/assert_same_test.rb +0 -45
  62. data/test/assertions_test.rb +0 -60
  63. data/test/context/class_methods_test.rb +0 -531
  64. data/test/fixtures/sample_context.rb +0 -13
  65. data/test/fixtures/test_root/one_test.rb +0 -0
  66. data/test/fixtures/test_root/parent/area_one/area_test.rb +0 -0
  67. data/test/fixtures/test_root/shallow/deeply/nested_test.rb +0 -0
  68. data/test/fixtures/test_root/shallow/nested_test.rb +0 -0
  69. data/test/fixtures/test_root/shallow_test.rb +0 -0
  70. data/test/fixtures/test_root/two_test.rb +0 -0
  71. data/test/suite/context_info_test.rb +0 -42
@@ -1,43 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertInstanceOfTest < Assert::Context
4
- desc "the assert_instance_of helper run in a test"
5
- setup do
6
- fail_desc = @fail_desc = "assert instance of fail desc"
7
- fail_args = @fail_args = [ Array, "object", fail_desc ]
8
- @test = Factory.test do
9
- assert_instance_of(String, "object") # pass
10
- assert_instance_of(*fail_args) # fail
11
- end
12
- @test.run
13
- end
14
- subject{ @test }
15
-
16
- should "have 2 total results" do
17
- assert_equal 2, subject.result_count
18
- end
19
- should "have 1 pass result" do
20
- assert_equal 1, subject.result_count(:pass)
21
- end
22
- should "have 1 fail result" do
23
- assert_equal 1, subject.result_count(:fail)
24
- end
25
-
26
- class FailMessageTest < AssertInstanceOfTest
27
- desc "with a failed result"
28
- setup do
29
- @expected = [
30
- @fail_args[2],
31
- "Expected #{@fail_args[1].inspect} to be an instance of #{@fail_args[0]}, not #{@fail_args[1].class}."
32
- ].join("\n")
33
- @fail_message = @test.fail_results.first.message
34
- end
35
- subject{ @fail_message }
36
-
37
- should "have a fail message with an explanation of what failed and my fail description" do
38
- assert_equal @expected, subject
39
- end
40
-
41
- end
42
-
43
- end
@@ -1,43 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertKindOfTest < Assert::Context
4
- desc "the assert_kind_of helper run in a test"
5
- setup do
6
- fail_desc = @fail_desc = "assert kind of fail desc"
7
- fail_args = @fail_args = [ Array, "object", fail_desc ]
8
- @test = Factory.test do
9
- assert_kind_of(String, "object") # pass
10
- assert_kind_of(*fail_args) # fail
11
- end
12
- @test.run
13
- end
14
- subject{ @test }
15
-
16
- should "have 2 total results" do
17
- assert_equal 2, subject.result_count
18
- end
19
- should "have 1 pass result" do
20
- assert_equal 1, subject.result_count(:pass)
21
- end
22
- should "have 1 fail result" do
23
- assert_equal 1, subject.result_count(:fail)
24
- end
25
-
26
- class FailMessageTest < AssertKindOfTest
27
- desc "with a failed result"
28
- setup do
29
- @expected = [
30
- @fail_args[2],
31
- "Expected #{@fail_args[1].inspect} to be a kind of #{@fail_args[0]}, not #{@fail_args[1].class}."
32
- ].join("\n")
33
- @fail_message = @test.fail_results.first.message
34
- end
35
- subject{ @fail_message }
36
-
37
- should "have a fail message with an explanation of what failed and my fail description" do
38
- assert_equal @expected, subject
39
- end
40
-
41
- end
42
-
43
- end
@@ -1,43 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertMatchTest < Assert::Context
4
- desc "the assert_match helper run in a test"
5
- setup do
6
- fail_desc = @fail_desc = "assert match fail desc"
7
- fail_args = @fail_args = [ "not", "a string", fail_desc ]
8
- @test = Factory.test do
9
- assert_match(/a/, "a string") # pass
10
- assert_match(*fail_args) # fail
11
- end
12
- @test.run
13
- end
14
- subject{ @test }
15
-
16
- should "have 2 total results" do
17
- assert_equal 2, subject.result_count
18
- end
19
- should "have 1 pass result" do
20
- assert_equal 1, subject.result_count(:pass)
21
- end
22
- should "have 1 fail result" do
23
- assert_equal 1, subject.result_count(:fail)
24
- end
25
-
26
- class FailMessageTest < AssertMatchTest
27
- desc "with a failed result"
28
- setup do
29
- @expected = [
30
- @fail_args[2],
31
- "Expected #{@fail_args[1].inspect} to match #{@fail_args[0].inspect}.",
32
- ].join("\n")
33
- @fail_message = @test.fail_results.first.message
34
- end
35
- subject{ @fail_message }
36
-
37
- should "have a fail message with an explanation of what failed and my fail description" do
38
- assert_equal @expected, subject
39
- end
40
-
41
- end
42
-
43
- end
@@ -1,43 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertNilTest < Assert::Context
4
- desc "the assert_nil helper run in a test"
5
- setup do
6
- fail_desc = @fail_desc = "assert nil empty fail desc"
7
- fail_args = @fail_args = [ 1, fail_desc ]
8
- @test = Factory.test do
9
- assert_nil(nil) # pass
10
- assert_nil(*fail_args) # fail
11
- end
12
- @test.run
13
- end
14
- subject{ @test }
15
-
16
- should "have 2 total results" do
17
- assert_equal 2, subject.result_count
18
- end
19
- should "have 1 pass result" do
20
- assert_equal 1, subject.result_count(:pass)
21
- end
22
- should "have 1 fail result" do
23
- assert_equal 1, subject.result_count(:fail)
24
- end
25
-
26
- class FailMessageTest < AssertNilTest
27
- desc "with a failed result"
28
- setup do
29
- @expected = [
30
- @fail_args[1],
31
- "Expected nil, not #{@fail_args[0].inspect}.",
32
- ].join("\n")
33
- @fail_message = @test.fail_results.first.message
34
- end
35
- subject{ @fail_message }
36
-
37
- should "have a fail message with an explanation of what failed and my fail description" do
38
- assert_equal @expected, subject
39
- end
40
-
41
- end
42
-
43
- end
@@ -1,39 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertNotBlockTest < Assert::Context
4
- desc "the assert_not_block helper run in a test"
5
- setup do
6
- fail_desc = @fail_desc = "assert not block fail desc"
7
- @test = Factory.test do
8
- assert_not_block(fail_desc){ true }
9
- assert_not_block{ false }
10
- end
11
- @test.run
12
- end
13
- subject{ @test }
14
-
15
- should "have 2 total results" do
16
- assert_equal 2, subject.result_count
17
- end
18
- should "have 1 pass result" do
19
- assert_equal 1, subject.result_count(:pass)
20
- end
21
- should "have 1 fail result" do
22
- assert_equal 1, subject.result_count(:fail)
23
- end
24
-
25
- class FailMessageTest < AssertNotBlockTest
26
- desc "with a failed result"
27
- setup do
28
- @expected = [@fail_desc, "Expected block to return false value."].join("\n")
29
- @fail_message = @test.fail_results.first.message
30
- end
31
- subject{ @fail_message }
32
-
33
- should "have a fail message with an explanation of what failed and my fail description" do
34
- assert_equal @expected, subject
35
- end
36
-
37
- end
38
-
39
- end
@@ -1,43 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertNotEmptyTest < Assert::Context
4
- desc "the assert_not_empty helper run in a test"
5
- setup do
6
- fail_desc = @fail_desc = "assert not empty fail desc"
7
- fail_args = @fail_args = [ [], fail_desc ]
8
- @test = Factory.test do
9
- assert_not_empty([ 1 ]) # pass
10
- assert_not_empty(*fail_args) # fail
11
- end
12
- @test.run
13
- end
14
- subject{ @test }
15
-
16
- should "have 2 total results" do
17
- assert_equal 2, subject.result_count
18
- end
19
- should "have 1 pass result" do
20
- assert_equal 1, subject.result_count(:pass)
21
- end
22
- should "have 1 fail result" do
23
- assert_equal 1, subject.result_count(:fail)
24
- end
25
-
26
- class FailMessageTest < AssertNotEmptyTest
27
- desc "with a failed result"
28
- setup do
29
- @expected = [
30
- @fail_args[1],
31
- "Expected #{@fail_args[0].inspect} to not be empty.",
32
- ].join("\n")
33
- @fail_message = @test.fail_results.first.message
34
- end
35
- subject{ @fail_message }
36
-
37
- should "have a fail message with an explanation of what failed and my fail description" do
38
- assert_equal @expected, subject
39
- end
40
-
41
- end
42
-
43
- end
@@ -1,43 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertNotEqualTest < Assert::Context
4
- desc "the assert_not_equal helper run in a test"
5
- setup do
6
- fail_desc = @fail_desc = "assert not equal fail desc"
7
- fail_args = @fail_args = [ 1, 1, fail_desc ]
8
- @test = Factory.test do
9
- assert_not_equal(*fail_args) # fail
10
- assert_not_equal(1, 2) # pass
11
- end
12
- @test.run
13
- end
14
- subject{ @test }
15
-
16
- should "have 2 total results" do
17
- assert_equal 2, subject.result_count
18
- end
19
- should "have 1 pass result" do
20
- assert_equal 1, subject.result_count(:pass)
21
- end
22
- should "have 1 fail result" do
23
- assert_equal 1, subject.result_count(:fail)
24
- end
25
-
26
- class FailMessageTest < AssertNotEqualTest
27
- desc "with a failed result"
28
- setup do
29
- @expected = [
30
- @fail_args[2],
31
- "#{@fail_args[0]} not expected to be equal to #{@fail_args[1]}.",
32
- ].join("\n")
33
- @fail_message = @test.fail_results.first.message
34
- end
35
- subject{ @fail_message }
36
-
37
- should "have a fail message with an explanation of what failed and my fail description" do
38
- assert_equal @expected, subject
39
- end
40
-
41
- end
42
-
43
- end
@@ -1,43 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertNotFileExistsTests < Assert::Context
4
- desc "the assert_not_file_exists helper run in a test"
5
- setup do
6
- fail_desc = @fail_desc = "assert not file exists empty fail desc"
7
- fail_args = @fail_args = [ __FILE__, fail_desc ]
8
- @test = Factory.test do
9
- assert_not_file_exists('/a/path/to/some/file/that/no/exists') # pass
10
- assert_not_file_exists(*fail_args) # fail
11
- end
12
- @test.run
13
- end
14
- subject{ @test }
15
-
16
- should "have 2 total results" do
17
- assert_equal 2, subject.result_count
18
- end
19
- should "have 1 pass result" do
20
- assert_equal 1, subject.result_count(:pass)
21
- end
22
- should "have 1 fail result" do
23
- assert_equal 1, subject.result_count(:fail)
24
- end
25
-
26
- class FailMessageTest < AssertNotFileExistsTests
27
- desc "with a failed result"
28
- setup do
29
- @expected = [
30
- @fail_args[1],
31
- "Expected #{@fail_args[0].inspect} to not exist."
32
- ].join("\n")
33
- @fail_message = @test.fail_results.first.message
34
- end
35
- subject{ @fail_message }
36
-
37
- should "have a fail message with an explanation of what failed and my fail description" do
38
- assert_equal @expected, subject
39
- end
40
-
41
- end
42
-
43
- end
@@ -1,44 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertNotIncluded < Assert::Context
4
- desc "the assert_not_included helper run in a test"
5
- setup do
6
-
7
- fail_desc = @fail_desc = "assert not included fail desc"
8
- fail_args = @fail_args = [ 1, [ 1 ], fail_desc ]
9
- @test = Factory.test do
10
- assert_not_included(2, [ 1 ]) # pass
11
- assert_not_included(*fail_args) # fail
12
- end
13
- @test.run
14
- end
15
- subject{ @test }
16
-
17
- should "have 2 total results" do
18
- assert_equal 2, subject.result_count
19
- end
20
- should "have 1 pass result" do
21
- assert_equal 1, subject.result_count(:pass)
22
- end
23
- should "have 1 fail result" do
24
- assert_equal 1, subject.result_count(:fail)
25
- end
26
-
27
- class FailMessageTest < AssertNotIncluded
28
- desc "with a failed result"
29
- setup do
30
- @expected = [
31
- @fail_args[2],
32
- "Expected #{@fail_args[1].inspect} to not include #{@fail_args[0].inspect}.",
33
- ].join("\n")
34
- @fail_message = @test.fail_results.first.message
35
- end
36
- subject{ @fail_message }
37
-
38
- should "have a fail message with an explanation of what failed and my fail description" do
39
- assert_equal @expected, subject
40
- end
41
-
42
- end
43
-
44
- end
@@ -1,43 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertNotInstanceOfTest < Assert::Context
4
- desc "the assert_not_instance_of helper run in a test"
5
- setup do
6
- fail_desc = @fail_desc = "assert not instance of fail desc"
7
- fail_args = @fail_args = [ String, "object", fail_desc ]
8
- @test = Factory.test do
9
- assert_not_instance_of(*fail_args) # fail
10
- assert_not_instance_of(Array, "object") # pass
11
- end
12
- @test.run
13
- end
14
- subject{ @test }
15
-
16
- should "have 2 total results" do
17
- assert_equal 2, subject.result_count
18
- end
19
- should "have 1 pass result" do
20
- assert_equal 1, subject.result_count(:pass)
21
- end
22
- should "have 1 fail result" do
23
- assert_equal 1, subject.result_count(:fail)
24
- end
25
-
26
- class FailMessageTest < AssertNotInstanceOfTest
27
- desc "with a failed result"
28
- setup do
29
- @expected = [
30
- @fail_args[2],
31
- "#{@fail_args[1].inspect} was not expected to be an instance of #{@fail_args[0]}.",
32
- ].join("\n")
33
- @fail_message = @test.fail_results.first.message
34
- end
35
- subject{ @fail_message }
36
-
37
- should "have a fail message with an explanation of what failed and my fail description" do
38
- assert_equal @expected, subject
39
- end
40
-
41
- end
42
-
43
- end
@@ -1,43 +0,0 @@
1
- require 'assert'
2
-
3
- class Assert::Assertions::AssertNotKindOfTest < Assert::Context
4
- desc "the assert_not_kind_of helper run in a test"
5
- setup do
6
- fail_desc = @fail_desc = "assert not kind of fail desc"
7
- fail_args = @fail_args = [ String, "object", fail_desc ]
8
- @test = Factory.test do
9
- assert_not_kind_of(*fail_args) # fail
10
- assert_not_kind_of(Array, "object") # pass
11
- end
12
- @test.run
13
- end
14
- subject{ @test }
15
-
16
- should "have 2 total results" do
17
- assert_equal 2, subject.result_count
18
- end
19
- should "have 1 pass result" do
20
- assert_equal 1, subject.result_count(:pass)
21
- end
22
- should "have 1 fail result" do
23
- assert_equal 1, subject.result_count(:fail)
24
- end
25
-
26
- class FailMessageTest < AssertNotKindOfTest
27
- desc "with a failed result"
28
- setup do
29
- @expected = [
30
- @fail_args[2],
31
- "#{@fail_args[1].inspect} was not expected to be a kind of #{@fail_args[0]}.",
32
- ].join("\n")
33
- @fail_message = @test.fail_results.first.message
34
- end
35
- subject{ @fail_message }
36
-
37
- should "have a fail message with an explanation of what failed and my fail description" do
38
- assert_equal @expected, subject
39
- end
40
-
41
- end
42
-
43
- end