baretest 0.1.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/LICENSE.txt +52 -0
  2. data/MANIFEST.txt +50 -31
  3. data/README.rdoc +260 -0
  4. data/bin/baretest +82 -24
  5. data/doc/baretest.rdoc +98 -0
  6. data/doc/mocking_stubbing_test_doubles.rdoc +5 -0
  7. data/doc/quickref.rdoc +261 -0
  8. data/doc/writing_tests.rdoc +148 -0
  9. data/examples/test.rake +58 -30
  10. data/examples/tests/irb_mode/failures.rb +26 -0
  11. data/examples/tests/mock_developer/test/helper/mocks.rb +0 -0
  12. data/examples/tests/mock_developer/test/setup.rb +57 -0
  13. data/examples/tests/mock_developer/test/suite/mock_demo.rb +19 -0
  14. data/examples/tests/overview/test.rb +89 -0
  15. data/examples/tests/variations/variations_01.rb +14 -0
  16. data/examples/tests/variations/variations_02.rb +19 -0
  17. data/examples/tests/variations/variations_03.rb +19 -0
  18. data/lib/baretest/assertion/context.rb +20 -0
  19. data/lib/baretest/assertion/failure.rb +22 -0
  20. data/lib/baretest/assertion/skip.rb +21 -0
  21. data/lib/{test → baretest}/assertion/support.rb +174 -39
  22. data/lib/baretest/assertion.rb +182 -0
  23. data/lib/baretest/irb_mode.rb +263 -0
  24. data/lib/{test/assertion/failure.rb → baretest/layout.rb} +6 -5
  25. data/lib/baretest/mocha.rb +18 -0
  26. data/lib/baretest/run/cli.rb +104 -0
  27. data/lib/{test → baretest}/run/errors.rb +12 -7
  28. data/lib/{test → baretest}/run/minimal.rb +8 -3
  29. data/lib/baretest/run/profile.rb +151 -0
  30. data/lib/{test → baretest}/run/spec.rb +10 -4
  31. data/lib/baretest/run/tap.rb +44 -0
  32. data/lib/baretest/run/xml.rb +80 -0
  33. data/lib/{test → baretest}/run.rb +31 -18
  34. data/lib/baretest/setup.rb +15 -0
  35. data/lib/baretest/skipped/assertion.rb +20 -0
  36. data/lib/baretest/skipped/suite.rb +49 -0
  37. data/lib/baretest/skipped.rb +15 -0
  38. data/lib/baretest/suite.rb +234 -0
  39. data/lib/baretest/utilities.rb +43 -0
  40. data/lib/{test → baretest}/version.rb +12 -3
  41. data/lib/baretest.rb +112 -0
  42. data/test/external/bootstraptest.rb +1 -1
  43. data/test/setup.rb +1 -1
  44. data/test/{lib/test → suite/lib/baretest}/assertion/support.rb +78 -24
  45. data/test/suite/lib/baretest/assertion.rb +192 -0
  46. data/test/{lib/test → suite/lib/baretest}/irb_mode.rb +0 -0
  47. data/test/{lib/test → suite/lib/baretest}/run/cli.rb +0 -0
  48. data/test/{lib/test → suite/lib/baretest}/run/errors.rb +0 -0
  49. data/test/{lib/test → suite/lib/baretest}/run/interactive.rb +0 -0
  50. data/test/{lib/test → suite/lib/baretest}/run/spec.rb +0 -0
  51. data/test/{lib/test → suite/lib/baretest}/run/tap.rb +0 -0
  52. data/test/{lib/test → suite/lib/baretest}/run/xml.rb +0 -0
  53. data/test/{lib/test → suite/lib/baretest}/run.rb +63 -61
  54. data/test/{lib/test → suite/lib/baretest}/suite.rb +77 -54
  55. data/test/{lib/test.rb → suite/lib/baretest.rb} +37 -37
  56. metadata +61 -40
  57. data/README.markdown +0 -229
  58. data/examples/test.rb +0 -93
  59. data/lib/test/assertion.rb +0 -117
  60. data/lib/test/debug.rb +0 -34
  61. data/lib/test/irb_mode.rb +0 -104
  62. data/lib/test/run/cli.rb +0 -79
  63. data/lib/test/run/interactive.rb +0 -60
  64. data/lib/test/run/tap.rb +0 -32
  65. data/lib/test/run/xml.rb +0 -56
  66. data/lib/test/suite.rb +0 -95
  67. data/lib/test.rb +0 -118
  68. data/test/lib/test/assertion.rb +0 -142
  69. data/test/lib/test/debug.rb +0 -63
@@ -1,142 +0,0 @@
1
- #--
2
- # Copyright 2009 by Stefan Rusterholz.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
-
8
-
9
- Test.define "Test" do
10
- suite "Assertion" do
11
- suite "::new" do
12
- assert "Should return a ::Test::Assertion instance" do
13
- ::Test::Assertion.new(nil, "description") { nil }.class ==
14
- ::Test::Assertion
15
- end
16
-
17
- assert "Should expect exactly 2 arguments" do
18
- raises(ArgumentError) { ::Test::Assertion.new() } &&
19
- raises(ArgumentError) { ::Test::Assertion.new(nil) } &&
20
- raises(ArgumentError) { ::Test::Assertion.new(nil, "foo", "bar") }
21
- end
22
- end
23
-
24
- suite "#status" do
25
- assert "A new Assertion should have a status of nil" do
26
- ::Test::Assertion.new(nil, "description") {}.status.nil?
27
- end
28
-
29
- assert "Executing an assertion with a block that returns true should be :success" do
30
- assertion_success = ::Test::Assertion.new(nil, "description") { true }
31
- assertion_success.execute
32
- assertion_success.status == :success
33
- end
34
-
35
- assert "Executing an assertion with a block that returns false should be :failure" do
36
- assertion_success = ::Test::Assertion.new(nil, "description") { false }
37
- assertion_success.execute
38
- assertion_success.status == :failure
39
- end
40
-
41
- assert "Executing an assertion with a block that raises should be :error" do
42
- assertion_success = ::Test::Assertion.new(nil, "description") { raise }
43
- assertion_success.execute
44
- assertion_success.status == :error
45
- end
46
-
47
- assert "Executing an assertion without a block should be :pending" do
48
- assertion_success = ::Test::Assertion.new(nil, "description")
49
- assertion_success.execute
50
-
51
- same :expected => :pending, :actual => assertion_success.status
52
- end
53
- end
54
-
55
- suite "#exception" do
56
- assert "An assertion that doesn't raise should have nil as exception" do
57
- assertion_success = ::Test::Assertion.new(nil, "description") { true }
58
- assertion_success.execute
59
- same :expected => nil, :actual => assertion_success.exception
60
- end
61
- end
62
-
63
- suite "#description" do
64
- assert "An assertion should have a description" do
65
- description = "The assertion description"
66
- assertion = ::Test::Assertion.new(nil, description) { true }
67
- same :expected => description, :actual => assertion.description
68
- end
69
- end
70
-
71
- suite "#suite" do
72
- assert "An assertion can belong to a suite" do
73
- suite = ::Test::Suite.new
74
- assertion = ::Test::Assertion.new(suite, "") { true }
75
- same :expected => suite, :actual => assertion.suite
76
- end
77
- end
78
-
79
- suite "#block" do
80
- assert "An assertion can have a block" do
81
- block = proc { true }
82
- assertion = ::Test::Assertion.new(nil, "", &block)
83
- same :expected => block, :actual => assertion.block
84
- end
85
- end
86
-
87
- suite "#setup" do
88
- assert "Should run all enclosing suite's setup blocks, outermost first" do
89
- executed = []
90
- block1 = proc { executed << :block1 }
91
- block2 = proc { executed << :block2 }
92
- suite1 = ::Test::Suite.new("block1") do setup(&block1) end
93
- suite2 = ::Test::Suite.new("suite2", suite1) do setup(&block2) end
94
- assertion = ::Test::Assertion.new(suite2, "assertion")
95
-
96
- raises_nothing do assertion.setup end &&
97
- equal([:block1, :block2], executed)
98
- end
99
- end
100
-
101
- suite "#teardown" do
102
- assert "Should run all enclosing suite's teardown blocks, innermost first" do
103
- executed = []
104
- block1 = proc { executed << :block1 }
105
- block2 = proc { executed << :block2 }
106
- suite1 = ::Test::Suite.new("block1") do teardown(&block1) end
107
- suite2 = ::Test::Suite.new("suite2", suite1) do teardown(&block2) end
108
- assertion = ::Test::Assertion.new(suite2, "assertion")
109
-
110
- raises_nothing do assertion.teardown end &&
111
- equal([:block2, :block1], executed)
112
- end
113
- end
114
-
115
- suite "#execute" do
116
- assert "Execute will run the assertion's block" do
117
- this = self # needed because touch is called in the block of another assertion, so otherwise it'd be local to that assertion
118
- assertion = ::Test::Assertion.new(nil, "") { this.touch(:execute) }
119
- assertion.execute
120
- touched(:execute)
121
- end
122
- end
123
-
124
- suite "#clean_copy" do
125
- assert "Should return an instance of Test::Assertion" do
126
- kind_of(::Test::Assertion, ::Test::Assertion.new("", nil).clean_copy)
127
- end
128
-
129
- assert "Should have the same description, suite and block" do
130
- description = "description"
131
- suite = ::Test::Suite.new
132
- block = proc { true }
133
- assertion1 = ::Test::Assertion.new(description, suite, &block)
134
- assertion2 = assertion1.clean_copy
135
-
136
- same(assertion1.description, assertion2.description, "description") &&
137
- same(assertion1.suite, assertion2.suite, "suite") &&
138
- same(assertion1.block, assertion2.block, "block")
139
- end
140
- end
141
- end
142
- end
@@ -1,63 +0,0 @@
1
- #--
2
- # Copyright 2009 by Stefan Rusterholz.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
-
8
-
9
- Test.define "Test with test/debug", :requires => 'test/debug' do
10
- suite "Assertion with test/debug", :requires => 'test/debug' do
11
- suite "#to_s" do
12
- assert "Assertion should have a to_s which contains the classname and the description" do
13
- description = "the description"
14
- assertion = Test::Assertion.new(nil, description)
15
- print_string = assertion.to_s
16
-
17
- print_string.include?(assertion.class.name) &&
18
- print_string.include?(description)
19
- end
20
- end
21
-
22
- suite "#inspect" do
23
- assert "Assertion should have an inspect which contains the classname, the shifted object-id in zero-padded hex, the suite's inspect and the description's inspect" do
24
- suite = Test::Suite.new
25
- description = "the description"
26
- assertion = Test::Assertion.new(suite, description)
27
- def suite.inspect; "<inspect of suite>"; end
28
-
29
- inspect_string = assertion.inspect
30
-
31
- inspect_string.include?(assertion.class.name) &&
32
- inspect_string.include?("%08x" % (assertion.object_id >> 1)) &&
33
- inspect_string.include?(suite.inspect) &&
34
- inspect_string.include?(description.inspect)
35
- end
36
- end
37
- end
38
-
39
- suite "Suite with test/debug", :requires => 'test/debug' do
40
- suite "#to_s" do
41
- assert "Suite should have a to_s which contains the classname and the description" do
42
- description = "the description"
43
- suite = Test::Suite.new(description)
44
- print_string = suite.to_s
45
-
46
- print_string.include?(suite.class.name) &&
47
- print_string.include?(description)
48
- end
49
- end
50
-
51
- suite "#inspect" do
52
- assert "Suite should have an inspect which contains the classname, the shifted object-id in zero-padded hex and the description's inspect" do
53
- description = "the description"
54
- suite = Test::Suite.new(description)
55
- inspect_string = suite.inspect
56
-
57
- inspect_string.include?(suite.class.name) &&
58
- inspect_string.include?("%08x" % (suite.object_id >> 1)) &&
59
- inspect_string.include?(description.inspect)
60
- end
61
- end
62
- end
63
- end