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
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kintama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
5
- prerelease:
4
+ version: 0.1.12
6
5
  platform: ruby
7
6
  authors:
8
7
  - James Adam
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-18 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: mocha
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.13.0
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.13.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description:
@@ -51,61 +46,60 @@ extra_rdoc_files:
51
46
  - README.md
52
47
  files:
53
48
  - README.md
54
- - test/aliases_test.rb
55
- - test/assertions_test.rb
56
- - test/automatic_running_test.rb
57
- - test/exceptions_test.rb
58
- - test/kintama_test.rb
59
- - test/line_based_running_test.rb
60
- - test/matcher_test.rb
61
- - test/method_behaviour_test.rb
62
- - test/pending_test_and_context.rb
63
- - test/reporters/base_reporter_test.rb
64
- - test/reporters/inline_reporter_test.rb
65
- - test/reporters/verbose_reporter_test.rb
66
- - test/setup_test.rb
67
- - test/start_and_finish_test.rb
68
- - test/teardown_test.rb
69
- - test/test_and_subcontext_access_test.rb
70
- - test/test_helper.rb
49
+ - lib/kintama.rb
71
50
  - lib/kintama/assertions.rb
72
51
  - lib/kintama/context.rb
73
52
  - lib/kintama/mocha.rb
53
+ - lib/kintama/no_conflict.rb
74
54
  - lib/kintama/reporter.rb
75
55
  - lib/kintama/runnable.rb
76
56
  - lib/kintama/runner.rb
77
57
  - lib/kintama/test.rb
78
- - lib/kintama.rb
58
+ - test/integration/automatic_running_test.rb
59
+ - test/integration/line_based_running_test.rb
60
+ - test/reporters/base_reporter_test.rb
61
+ - test/reporters/inline_reporter_test.rb
62
+ - test/reporters/verbose_reporter_test.rb
63
+ - test/test_helper.rb
64
+ - test/unit/assertions_test.rb
65
+ - test/unit/context_test.rb
66
+ - test/unit/runner_test.rb
67
+ - test/unit/test_and_subcontext_access_test.rb
68
+ - test/usage/01_basic_usage_test.rb
69
+ - test/usage/02_setup_test.rb
70
+ - test/usage/03_teardown_test.rb
71
+ - test/usage/04_pending_tests_test.rb
72
+ - test/usage/05_aliases_test.rb
73
+ - test/usage/06_defining_methods_in_tests_test.rb
74
+ - test/usage/07_exceptions_test.rb
75
+ - test/usage/08_start_and_finish_test.rb
76
+ - test/usage/09_expectations_and_mocking_test.rb
77
+ - test/usage/10_let_and_subject_test.rb
78
+ - test/usage/11_matcher_test.rb
79
+ - test/usage/12_action_test.rb
79
80
  homepage: http://github.com/lazyatom
80
81
  licenses: []
82
+ metadata: {}
81
83
  post_install_message:
82
84
  rdoc_options:
83
- - --main
85
+ - "--main"
84
86
  - README.md
85
87
  require_paths:
86
88
  - lib
87
89
  required_ruby_version: !ruby/object:Gem::Requirement
88
- none: false
89
90
  requirements:
90
- - - ! '>='
91
+ - - ">="
91
92
  - !ruby/object:Gem::Version
92
93
  version: '0'
93
- segments:
94
- - 0
95
- hash: -2321837181279822201
96
94
  required_rubygems_version: !ruby/object:Gem::Requirement
97
- none: false
98
95
  requirements:
99
- - - ! '>='
96
+ - - ">="
100
97
  - !ruby/object:Gem::Version
101
98
  version: '0'
102
- segments:
103
- - 0
104
- hash: -2321837181279822201
105
99
  requirements: []
106
100
  rubyforge_project:
107
- rubygems_version: 1.8.23
101
+ rubygems_version: 2.2.2
108
102
  signing_key:
109
- specification_version: 3
103
+ specification_version: 4
110
104
  summary: It's for writing tests.
111
105
  test_files: []
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AliasesTest < Test::Unit::TestCase
4
-
5
- def test_should_provide_given_and_it_aliases_for_context_and_should
6
- x = context "In a world without hope" do
7
- given "a massive gun" do
8
- it "should work out well in the end" do
9
- assert true
10
- end
11
- end
12
- end
13
- x.run
14
- assert x.passed?
15
- end
16
-
17
- def test_should_provide_testcase_alias_for_context
18
- x = testcase "In a world without hope" do
19
- should "work out well in the end" do
20
- assert true
21
- end
22
- end
23
- x.run
24
- assert x.passed?
25
- end
26
- end
@@ -1,40 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ExceptionsTest < Test::Unit::TestCase
4
-
5
- def test_should_capture_exceptions_in_tests_as_failing_tests
6
- x = context "Given a test" do
7
- should "that raises an exception" do
8
- raise "aaargh"
9
- end
10
- end
11
- x.run
12
- assert !x.passed?
13
- end
14
-
15
- def test_should_capture_exceptions_in_setups_as_failing_tests
16
- x = context "Given a test with setup that fails" do
17
- setup do
18
- raise "aargh"
19
- end
20
- should "that would otherwise pass" do
21
- assert true
22
- end
23
- end
24
- x.run
25
- assert !x.passed?
26
- end
27
-
28
- def test_should_capture_exceptions_in_teardowns_as_failing_tests
29
- x = context "Given a test with teardown that fails" do
30
- teardown do
31
- raise "aargh"
32
- end
33
- should "that would otherwise pass" do
34
- assert true
35
- end
36
- end
37
- x.run
38
- assert !x.passed?
39
- end
40
- end
@@ -1,114 +0,0 @@
1
- require 'test_helper'
2
-
3
- class KintamaTest < Test::Unit::TestCase
4
-
5
- def test_should_pass_when_all_tests_pass
6
- x = context "Given something" do
7
- should "work" do
8
- assert true
9
- end
10
- end
11
- x.run
12
- assert x.passed?
13
- end
14
-
15
- def test_should_fail_when_all_tests_fail
16
- x = context "Given something" do
17
- should "work" do
18
- flunk
19
- end
20
- end
21
- x.run
22
- assert !x.passed?
23
- end
24
-
25
- def test_should_fail_when_any_tests_fail
26
- x = context "Given something" do
27
- should "work" do
28
- flunk
29
- end
30
- should "also work" do
31
- assert true
32
- end
33
- end
34
- x.run
35
- assert !x.passed?
36
- end
37
-
38
- def test_should_fail_when_any_assertion_within_a_test_fails
39
- x = context "Given something" do
40
- should "ultimately not work" do
41
- flunk
42
- assert true
43
- end
44
- end
45
- x.run
46
- assert !x.passed?
47
- end
48
-
49
- def test_should_not_run_any_code_beyond_a_failing_assertion
50
- x = context "Given something" do
51
- should "ultimately not work" do
52
- flunk
53
- raise "should not get here!"
54
- end
55
- end
56
- x.run
57
- assert !x.passed?
58
- end
59
-
60
- def test_should_allow_nesting_of_contexts
61
- x = context "Given something" do
62
- context "and another thing" do
63
- should "work" do
64
- flunk
65
- end
66
- end
67
- end
68
- x.run
69
- assert !x.passed?
70
- end
71
-
72
- def test_should_allow_multiple_subcontexts
73
- x = context "Given something" do
74
- context "and another thing" do
75
- should "work" do
76
- flunk
77
- end
78
- end
79
- context "and another different thing" do
80
- should "work" do
81
- assert true
82
- end
83
- end
84
- end
85
- x.run
86
- assert !x.passed?
87
- end
88
-
89
- def test_should_allow_deep_nesting_of_subcontexts
90
- x = context "Given something" do
91
- context "and another thing" do
92
- context "and one more thing" do
93
- should "work" do
94
- flunk
95
- end
96
- end
97
- end
98
- end
99
- x.run
100
- assert !x.passed?
101
- end
102
-
103
- def test_should_clear_previous_failure_when_running_test_again
104
- $thing = 456
105
- x = context "Given something" do
106
- should "work" do
107
- assert_equal 123, $thing
108
- end
109
- end
110
- assert_equal false, x.run
111
- $thing = 123
112
- assert_equal true, x.run
113
- end
114
- end
@@ -1,80 +0,0 @@
1
- require "test_helper"
2
-
3
- class MatcherTest < Test::Unit::TestCase
4
-
5
- class EqualMatcher
6
- def initialize(expected)
7
- @expected = expected
8
- end
9
-
10
- def matches?(provided_value)
11
- @actual = provided_value
12
- @actual == @expected
13
- end
14
-
15
- def failure_message
16
- "Expected #{@expected}, but got #{@actual}"
17
- end
18
-
19
- def negative_failure_message
20
- "Didn't expect #{@expected}, but got it anyway"
21
- end
22
-
23
- def description
24
- "be equal to #{@expected.inspect}"
25
- end
26
- end
27
-
28
- def test_should_allow_use_of_matchers_within_contexts
29
- c = context "x" do
30
- subject { 123 }
31
- should EqualMatcher.new(456)
32
- end
33
- c.run
34
- assert !c.passed?
35
- assert_match /^Expected 456, but got 123/, c.failures.first.failure_message
36
- end
37
-
38
- def test_should_use_a_single_instance_of_the_subject_within_a_test
39
- c = context "x" do
40
- subject { Array.new }
41
- should "allow me to poke around with subject like it was a variable" do
42
- subject << 1
43
- assert_equal [1], subject
44
- end
45
- should "now be empty again" do
46
- assert subject.empty?
47
- end
48
- end
49
- c.run
50
- assert c.passed?
51
- end
52
-
53
- def test_should_allow_negation_of_matchers
54
- c = context "x" do
55
- subject { 123 }
56
- should_not EqualMatcher.new(123)
57
- end
58
- c.run
59
- assert !c.passed?
60
- assert_match /^Didn't expect 123, but got it anyway/, c.failures.first.failure_message
61
- end
62
-
63
- module MatcherExtension
64
- def be_equal_to(expected)
65
- EqualMatcher.new(expected)
66
- end
67
- end
68
-
69
- def test_should_allow_definition_of_matchers_in_contexts
70
- Kintama.extend(MatcherExtension)
71
- c = context "x" do
72
- subject { 'abc' }
73
- should be_equal_to('abc')
74
- should_not be_equal_to('def')
75
- end
76
- c.run
77
- assert c.passed?
78
- assert_equal ["should be equal to \"abc\"", "should not be equal to \"def\""], c.tests.map { |t| t.name }
79
- end
80
- end
@@ -1,176 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MethodBehaviourTest < Test::Unit::TestCase
4
-
5
- def test_should_allow_methods_defined_in_the_context_to_be_called_in_tests
6
- x = context "Given I ran a method" do
7
- should "set something" do
8
- assert self.respond_to?(:do_something)
9
- assert_equal 123, do_something
10
- end
11
- def do_something
12
- 123
13
- end
14
- end
15
- x.run
16
- assert x.passed?
17
- end
18
-
19
- def test_should_allow_methods_defined_in_the_context_to_be_called_in_tests_in_subcontexts
20
- x = context "Given I ran a method" do
21
- context "in a subcontext" do
22
- should "set something" do
23
- assert self.respond_to?(:do_something)
24
- assert_equal 234, do_something
25
- end
26
- end
27
- def do_something
28
- 234
29
- end
30
- end
31
- x.run
32
- assert x.passed?
33
- end
34
-
35
- module MyStuff
36
- def do_something
37
- 456
38
- end
39
- end
40
-
41
- def test_should_be_able_to_call_methods_from_included_modules_in_tests
42
- x = context "Given I include a module" do
43
- include MyStuff
44
- should "allow calling methods from that module" do
45
- assert_equal 456, do_something
46
- end
47
- end
48
- x.run
49
- assert x.passed?
50
- end
51
-
52
- def test_should_not_allow_methods_from_one_context_to_bleed_into_another
53
- context "Given I define a method in one context" do
54
- def do_another_thing
55
- end
56
- end
57
- x = context "And I define another context" do
58
- it "should not be possible to call that method" do
59
- assert !self.respond_to?(:do_another_thing)
60
- assert_raises("should not be able to call this") { do_another_thing }
61
- end
62
- end
63
- x.run
64
- assert x.passed?
65
- end
66
-
67
- module MoreMyStuff
68
- def get_thing
69
- @thing
70
- end
71
- end
72
-
73
- def test_should_allow_defined_methods_to_refer_to_instance_variables_defined_in_setup_when_included_via_modules
74
- c = context "Given I define an instance variable in my setup" do
75
- include MoreMyStuff
76
- setup do
77
- @thing = 123
78
- end
79
- should "be able to call a method that refers to that variable in a test" do
80
- assert_equal 123, get_thing
81
- end
82
- end
83
- c.run
84
- assert c.passed?, "Thing was not defined!"
85
- end
86
-
87
- module DefaultBehaviour
88
- def something
89
- 'abc'
90
- end
91
- end
92
-
93
- def test_should_allow_including_default_behaviour_in_all_contexts
94
- Kintama.include DefaultBehaviour
95
- c = context "Given a context" do
96
- should "be able to call a method from the globally shared behaviour" do
97
- assert_equal 'abc', something
98
- end
99
- end
100
- c.run
101
- assert c.passed?, "something was not defined!"
102
- end
103
-
104
- def test_should_be_able_to_compose_shoulds_into_methods
105
- $ran = false
106
- x = context "Given a context" do
107
- def self.should_create_a_should_from_a_method
108
- should "have created this test" do
109
- $ran = true
110
- assert true
111
- end
112
- end
113
-
114
- should_create_a_should_from_a_method
115
- end
116
- x.run
117
- assert x.passed?
118
- assert $ran
119
-
120
- assert_not_nil x.should_have_created_this_test
121
- end
122
-
123
- def test_should_be_able_to_call_methods_in_subcontexts_that_create_tests
124
- x = context "Given a subcontext" do
125
- def self.with_a_method
126
- should "create this test in the subcontext" do
127
- flunk
128
- end
129
- end
130
- context "which calls a method defined at the top level" do
131
- with_a_method
132
- end
133
- end
134
- x.run
135
- subcontext = x.subcontexts.first
136
- assert_equal ["should create this test in the subcontext"], subcontext.tests.map { |t| t.name }
137
- end
138
-
139
- module TestCreatingBehaviour
140
- def with_a_method
141
- should "create this test in the subcontext" do
142
- flunk
143
- end
144
- end
145
- end
146
-
147
- def test_should_be_able_to_call_methods_in_subcontexts_that_create_tests_when_defined_in_modules
148
- x = context "Given a subcontext" do
149
- extend TestCreatingBehaviour
150
-
151
- context "which calls a method defined at the top level" do
152
- with_a_method
153
- end
154
- end
155
- x.run
156
- subcontext = x.subcontexts.first
157
- assert_equal ["should create this test in the subcontext"], subcontext.tests.map { |t| t.name }
158
- end
159
-
160
- module NewKintamaBehaviour
161
- def define_a_test
162
- should "define a test" do
163
- flunk
164
- end
165
- end
166
- end
167
-
168
- def test_should_be_able_to_add_behaviour_to_kintama
169
- Kintama.extend NewKintamaBehaviour
170
- x = context "A context" do
171
- define_a_test
172
- end
173
- x.run
174
- assert !x.passed?
175
- end
176
- end