kintama 0.1.9 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +2 -2
  3. data/lib/kintama.rb +26 -12
  4. data/lib/kintama/assertions.rb +40 -1
  5. data/lib/kintama/context.rb +65 -50
  6. data/lib/kintama/mocha.rb +32 -10
  7. data/lib/kintama/no_conflict.rb +2 -0
  8. data/lib/kintama/reporter.rb +11 -10
  9. data/lib/kintama/runnable.rb +2 -2
  10. data/lib/kintama/runner.rb +5 -5
  11. data/lib/kintama/test.rb +2 -2
  12. data/test/integration/automatic_running_test.rb +22 -0
  13. data/test/integration/line_based_running_test.rb +129 -0
  14. data/test/reporters/base_reporter_test.rb +31 -101
  15. data/test/reporters/inline_reporter_test.rb +23 -35
  16. data/test/reporters/verbose_reporter_test.rb +78 -76
  17. data/test/test_helper.rb +159 -2
  18. data/test/{assertions_test.rb → unit/assertions_test.rb} +54 -5
  19. data/test/unit/context_test.rb +15 -0
  20. data/test/unit/runner_test.rb +87 -0
  21. data/test/{test_and_subcontext_access_test.rb → unit/test_and_subcontext_access_test.rb} +6 -33
  22. data/test/usage/01_basic_usage_test.rb +131 -0
  23. data/test/usage/02_setup_test.rb +98 -0
  24. data/test/usage/03_teardown_test.rb +121 -0
  25. data/test/usage/04_pending_tests_test.rb +16 -0
  26. data/test/usage/05_aliases_test.rb +73 -0
  27. data/test/usage/06_defining_methods_in_tests_test.rb +202 -0
  28. data/test/usage/07_exceptions_test.rb +42 -0
  29. data/test/usage/08_start_and_finish_test.rb +261 -0
  30. data/test/usage/09_expectations_and_mocking_test.rb +85 -0
  31. data/test/usage/10_let_and_subject_test.rb +134 -0
  32. data/test/usage/11_matcher_test.rb +148 -0
  33. data/test/usage/12_action_test.rb +118 -0
  34. metadata +55 -48
  35. data/test/aliases_test.rb +0 -26
  36. data/test/automatic_running_test.rb +0 -45
  37. data/test/exceptions_test.rb +0 -40
  38. data/test/kintama_test.rb +0 -114
  39. data/test/line_based_running_test.rb +0 -143
  40. data/test/matcher_test.rb +0 -80
  41. data/test/method_behaviour_test.rb +0 -176
  42. data/test/pending_test_and_context.rb +0 -20
  43. data/test/setup_test.rb +0 -107
  44. data/test/start_and_finish_test.rb +0 -94
  45. data/test/teardown_test.rb +0 -106
@@ -1,106 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TeardownTest < Test::Unit::TestCase
4
-
5
- def test_should_run_teardown_after_the_test_finishes
6
- $called = false
7
- x = context "Given a teardown" do
8
- teardown do
9
- raise "Argh" unless @result == 123
10
- $called = true
11
- end
12
- should "run teardown after this test" do
13
- @result = 123
14
- end
15
- end
16
- x.run
17
- assert x.passed?
18
- assert $called
19
- end
20
-
21
- def test_should_run_all_teardowns_in_proximity_of_nesting_order_after_a_nested_test_finishes
22
- $called = false
23
- x = context "Given a teardown" do
24
- teardown do
25
- raise "Argh" unless @result == 123
26
- $called = true
27
- end
28
- context "with a subcontext with another teardown" do
29
- teardown do
30
- raise "Oh no" unless @result == 456
31
- @result = 123
32
- end
33
- should "run teardown after this test" do
34
- @result = 456
35
- end
36
- end
37
- end
38
- x.run
39
- assert x.passed?
40
- assert $called
41
- end
42
-
43
- def test_should_run_teardown_defined_on_kintama_itself_after_other_teardowns
44
- ran = false
45
- Kintama.teardown do
46
- ran = true
47
- assert_equal 'blah', @thing
48
- end
49
- c = context "Given a context" do
50
- should "have run the setup defined in the default behaviour" do
51
- # nothing
52
- end
53
- teardown do
54
- @thing = 'blah'
55
- end
56
- end
57
- c.run
58
- assert c.passed?, "@thing was not redefined!"
59
- assert ran
60
- end
61
-
62
- def test_should_allow_multiple_teardowns_to_be_registered
63
- Kintama.teardown do
64
- $ran = 1
65
- end
66
- Kintama.teardown do
67
- $ran += 1
68
- end
69
- c = context "Given multiple setups" do
70
- should "run them all" do
71
- assert true
72
- end
73
- end
74
- c.run
75
- assert_equal 2, $ran, "both teardowns didn't run"
76
- end
77
-
78
- def test_should_run_teardowns_even_after_exceptions
79
- ran = false
80
- c = context "Given a test that fails" do
81
- should "still run teardown" do
82
- raise "argh"
83
- end
84
- teardown do
85
- ran = true
86
- end
87
- end
88
- c.run
89
- assert !c.passed?
90
- assert ran
91
- end
92
-
93
- def test_should_not_mask_exceptions_in_tests_with_ones_in_teardown
94
- c = context "Given a test that fails" do
95
- should "report this error" do
96
- raise "this"
97
- end
98
- teardown do
99
- raise "that"
100
- end
101
- end
102
- c.run
103
- assert !c.passed?
104
- assert_equal "this", c.failures.first.failure.to_s
105
- end
106
- end