kintama 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/lib/kintama.rb +19 -5
  3. data/lib/kintama/assertions.rb +4 -0
  4. data/lib/kintama/context.rb +58 -47
  5. data/lib/kintama/mocha.rb +13 -0
  6. data/lib/kintama/no_conflict.rb +2 -0
  7. data/lib/kintama/reporter.rb +3 -3
  8. data/test/{automatic_running_test.rb → integration/automatic_running_test.rb} +5 -5
  9. data/test/{line_based_running_test.rb → integration/line_based_running_test.rb} +13 -13
  10. data/test/reporters/base_reporter_test.rb +31 -101
  11. data/test/reporters/inline_reporter_test.rb +23 -35
  12. data/test/reporters/verbose_reporter_test.rb +77 -76
  13. data/test/test_helper.rb +92 -0
  14. data/test/{assertions_test.rb → unit/assertions_test.rb} +8 -0
  15. data/test/unit/context_test.rb +15 -0
  16. data/test/unit/runner_test.rb +87 -0
  17. data/test/{test_and_subcontext_access_test.rb → unit/test_and_subcontext_access_test.rb} +5 -32
  18. data/test/usage/01_basic_usage_test.rb +131 -0
  19. data/test/usage/02_setup_test.rb +98 -0
  20. data/test/usage/03_teardown_test.rb +120 -0
  21. data/test/usage/04_pending_tests_test.rb +16 -0
  22. data/test/usage/05_aliases_test.rb +73 -0
  23. data/test/usage/06_defining_methods_in_tests_test.rb +202 -0
  24. data/test/usage/07_exceptions_test.rb +42 -0
  25. data/test/usage/08_start_and_finish_test.rb +252 -0
  26. data/test/usage/09_expectations_and_mocking_test.rb +86 -0
  27. data/test/usage/10_let_and_subject_test.rb +125 -0
  28. data/test/usage/11_matcher_test.rb +148 -0
  29. data/test/usage/12_action_test.rb +118 -0
  30. metadata +36 -42
  31. data/test/aliases_test.rb +0 -26
  32. data/test/exceptions_test.rb +0 -40
  33. data/test/kintama_test.rb +0 -114
  34. data/test/matcher_test.rb +0 -80
  35. data/test/method_behaviour_test.rb +0 -176
  36. data/test/pending_test_and_context.rb +0 -20
  37. data/test/setup_test.rb +0 -107
  38. data/test/start_and_finish_test.rb +0 -94
  39. data/test/teardown_test.rb +0 -106
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PendingTest < Test::Unit::TestCase
4
-
5
- def test_should_pass_any_pending_tests
6
- c = context "Given a context" do
7
- test "that is not implemented"
8
- end
9
- c.run
10
- assert c.passed?
11
- end
12
-
13
- def test_should_ignore_empty_contexts
14
- c = context "Given an empty context" do
15
- context "should ignore this"
16
- end
17
- c.run
18
- assert c.passed?
19
- end
20
- end
@@ -1,107 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SetupTest < Test::Unit::TestCase
4
-
5
- def test_should_allow_setup_to_provide_instance_variables
6
- x = context "Given something" do
7
- setup do
8
- @name = "james"
9
- end
10
- should "work" do
11
- assert_equal "james", @name
12
- end
13
- end
14
- x.run
15
- assert x.passed?
16
- end
17
-
18
- def test_should_run_setup_before_every_test
19
- x = context "Given something" do
20
- setup do
21
- @name = "james"
22
- end
23
- should "work" do
24
- @name += " is awesome"
25
- assert_equal "james is awesome", @name
26
- end
27
- should "also work" do
28
- @name += " is the best"
29
- assert_equal "james is the best", @name
30
- end
31
- end
32
- x.run
33
- assert x.passed?, x.failures.join(", ")
34
- end
35
-
36
- def test_should_allow_call_all_setup_methods_when_running_tests_in_a_nested_context
37
- x = context "Given something" do
38
- setup do
39
- @name = "james"
40
- end
41
- context "and another thing" do
42
- setup do
43
- @name += " is amazing"
44
- end
45
- should "work" do
46
- assert_equal "james is amazing", @name
47
- end
48
- end
49
- end
50
- x.run
51
- assert x.passed?
52
- end
53
-
54
- def test_should_only_run_necessary_setups_where_tests_at_different_nestings_exist
55
- x = context "Given something" do
56
- setup do
57
- @name = "james"
58
- end
59
- context "and another thing" do
60
- setup do
61
- @name += " is amazing"
62
- end
63
- should "work" do
64
- assert_equal "james is amazing", @name
65
- end
66
- end
67
- should "work" do
68
- assert_equal "james", @name
69
- end
70
- end
71
- x.run
72
- assert x.passed?
73
- end
74
-
75
- def test_should_run_setup_defined_on_kintama_itself_before_other_setups
76
- Kintama.setup do
77
- @thing = 'well then'
78
- end
79
- c = context "Given a context" do
80
- setup do
81
- assert_equal 'well then', @thing
82
- @thing = 'now then'
83
- end
84
- should "have run the setup defined in the default behaviour" do
85
- assert_equal 'now then', @thing
86
- end
87
- end
88
- c.run
89
- assert c.passed?, "@thing was not defined!"
90
- end
91
-
92
- def test_should_allow_multiple_setups_to_be_registered
93
- Kintama.setup do
94
- @thing = 1
95
- end
96
- Kintama.setup do
97
- @thing += 1
98
- end
99
- c = context "Given multiple setups" do
100
- should "run them all" do
101
- assert_equal 2, @thing
102
- end
103
- end
104
- c.run
105
- assert c.passed?, "both setups didn't run - #{c.failures.inspect}"
106
- end
107
- end
@@ -1,94 +0,0 @@
1
- require "test_helper"
2
-
3
- class StartAndFinishTest < Test::Unit::TestCase
4
-
5
- def test_should_call_any_on_start_block_when_running_a_context
6
- $ran = 0
7
- c = context "A context with a startup block" do
8
- on_start { $ran += 1 }
9
- should "have run the on_start block" do
10
- end
11
- end
12
- c.run
13
- assert_equal 1, $ran
14
- end
15
-
16
- def test_should_only_call_on_start_block_once_when_running_a_context
17
- $ran = 0
18
- c = context "A context with a startup block" do
19
- on_start { $ran += 1 }
20
- should "have run the on_start block" do
21
- end
22
- should "not run that block again" do
23
- end
24
- end
25
- c.run
26
- assert_equal 1, $ran
27
- end
28
-
29
- def test_should_only_call_on_start_block_before_any_test
30
- $ran = 0
31
- c = context "A context with a startup block" do
32
- on_start { $ran += 1 }
33
- should "have run the on_start block" do
34
- assert_equal 1, $ran
35
- end
36
- should "not run that block again" do
37
- assert_equal 1, $ran
38
- end
39
- end
40
- c.run
41
- assert c.passed?
42
- end
43
-
44
- def test_should_call_any_on_finish_block_when_running_a_context
45
- $ran = 0
46
- c = context "A context with a startup block" do
47
- should "have run the on_start block" do
48
- end
49
- on_finish { $ran += 1 }
50
- end
51
- c.run
52
- assert_equal 1, $ran
53
- end
54
-
55
- def test_should_only_call_on_finish_block_once_when_running_a_context
56
- $ran = 0
57
- c = context "A context with a startup block" do
58
- should "have run the on_start block" do
59
- end
60
- should "not run that block again" do
61
- end
62
- on_finish { $ran += 1 }
63
- end
64
- c.run
65
- assert_equal 1, $ran
66
- end
67
-
68
- def test_should_only_call_on_finish_block_after_all_tests
69
- $ran = 0
70
- c = context "A context with a startup block" do
71
- should "have run the on_start block" do
72
- assert_equal 0, $ran
73
- end
74
- should "not run that block again" do
75
- assert_equal 0, $ran
76
- end
77
- on_finish { $ran += 1 }
78
- end
79
- c.run
80
- assert c.passed?
81
- end
82
-
83
- def test_should_be_able_to_use_rspec_like_aliases
84
- $ran = 0
85
- c = context "A context with a startup block" do
86
- before_all { $ran += 1 }
87
- should "have run the on_start block" do
88
- end
89
- after_all { $ran += 1 }
90
- end
91
- c.run
92
- assert_equal 2, $ran
93
- end
94
- end
@@ -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