kintama 0.1.13 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 89d410c25c98282d6a3f2e566a49bad89748fb19
4
- data.tar.gz: 73b36955b5f69912da853293ec30c5661fcaa03b
2
+ SHA256:
3
+ metadata.gz: '0585d375e075683687b7a47da3323ace4468f9a9f61c4fdb2c8931144a879d55'
4
+ data.tar.gz: 63325f6c21c46bec7432996421fe43ac54316a5b96c12d0c89851dd2f9fd88ea
5
5
  SHA512:
6
- metadata.gz: e6f06b7b88c56ea57f0bd65fe5c260daa6cbe54fad79f078e5105fd9c2e6db63070b25487bb1217a88486c07880d2d31b7d59daaf98c8ac3e0b6265cd99be3f2
7
- data.tar.gz: ca6e19d9b7649cd34467838bfe2a33a5930774c71514e0e551121e9a550f58e5f9f45fc59a81f2472fa95b460f2e0e69764ff0956a642e84d56cf9fcc88bb6e1
6
+ metadata.gz: d90b1a3eb60ff446e2ebeea8e9e251384750db13dde88986aa86164da6595bbbac6ccff9dec4ad44f36d915a86e84bce64dd9fc0075ee478462236b39a828396
7
+ data.tar.gz: 317f355a6141242af6c6d5efb388b8bfa8fbc9ab14a5d56f02e1413485470901b970ae4565645adf0d7c8604bff956edc63163d6e68e78c4c33cc6c090e96aea
data/README.md CHANGED
@@ -30,7 +30,7 @@ Probably the closest thing I've seen is [baretest][]. If you look around the cod
30
30
 
31
31
  Another alternative test framework is [riot][], which claims to be fast, but also appears to constrain the way that tests are written by avoiding instance variables in setups, for example.
32
32
 
33
- [Testy][] is interesting - it looks like its output is YAML!. [Tryouts][] is thinking outside the box, using comment examples.
33
+ [Testy][] is interesting - it looks like its output is YAML! [Tryouts][] is thinking outside the box, using comment examples.
34
34
 
35
35
  [Zebra][] addresses the apparent duplication of the test name and the test body, but does it by introducing an [RSpec][]-esque method on every object. Wild. Also, it's an extension of [Test::Unit][], so that's strike two for me, personally.
36
36
 
@@ -21,7 +21,7 @@ module Kintama
21
21
  end
22
22
 
23
23
  def default_context
24
- reset unless @default_context
24
+ reset unless instance_variable_defined?(:@default_context) && @default_context
25
25
  @default_context
26
26
  end
27
27
 
@@ -77,12 +77,12 @@ module Kintama
77
77
  end
78
78
 
79
79
  def options
80
- unless @options
81
- @options = OpenStruct.new(
80
+ @options ||= begin
81
+ options = OpenStruct.new(
82
82
  :reporter => Kintama::Reporter.default,
83
83
  :runner => Kintama::Runner.default
84
84
  )
85
- opts = OptionParser.new do |opts|
85
+ cmd_options = OptionParser.new do |opts|
86
86
  opts.banner = "Usage: ruby <test_file> [options]"
87
87
 
88
88
  opts.separator ""
@@ -101,16 +101,16 @@ module Kintama
101
101
  exit
102
102
  end
103
103
  end
104
- opts.parse!(ARGV)
104
+ cmd_options.parse!(ARGV)
105
+ options
105
106
  end
106
- @options
107
107
  end
108
108
 
109
109
  # Adds the hook to automatically run all known tests using #run when
110
110
  # ruby exits; this is most useful when running a test file from the command
111
111
  # line or from within an editor
112
112
  def add_exit_hook
113
- return if @__added_exit_hook
113
+ return if instance_variable_defined?(:@__added_exit_hook)
114
114
  at_exit { exit(options.runner.with(Kintama.default_context).run(options.reporter) ? 0 : 1) }
115
115
  @__added_exit_hook = true
116
116
  end
@@ -50,7 +50,7 @@ module Kintama
50
50
  module ClassMethods
51
51
 
52
52
  def find_definition_1_8
53
- line = caller.find { |line| line =~ /^[^:]+:(\d+)$/ }
53
+ line = caller.find { |l| l =~ /^[^:]+:(\d+)$/ }
54
54
  if line
55
55
  parts = line.split(":")
56
56
  parts[1] = parts[1].to_i
@@ -64,8 +64,8 @@ module Kintama
64
64
 
65
65
  def find_definition_rbx(&block)
66
66
  if block
67
- m = block.block.code
68
- [m.file, m.first_line]
67
+ block_environment = block.block
68
+ [block_environment.file, block_environment.line]
69
69
  end
70
70
  end
71
71
 
@@ -150,7 +150,11 @@ module Kintama
150
150
  def let(name, &block)
151
151
  define_method(name) do
152
152
  memo = "@__#{name}"
153
- instance_variable_get(memo) || instance_variable_set(memo, instance_eval(&block))
153
+ if instance_variable_defined?(memo)
154
+ instance_variable_get(memo)
155
+ else
156
+ instance_variable_set(memo, instance_eval(&block))
157
+ end
154
158
  end
155
159
  end
156
160
 
@@ -1,17 +1,6 @@
1
1
  require 'kintama'
2
2
  require 'mocha/api'
3
3
 
4
- Kintama.include Mocha::API
5
- Kintama.teardown do
6
- begin
7
- mocha_verify
8
- rescue Mocha::ExpectationError => e
9
- raise e
10
- ensure
11
- mocha_teardown
12
- end
13
- end
14
-
15
4
  module Kintama::Mocha
16
5
  module Expect
17
6
  def expect(name, &block)
@@ -21,5 +10,25 @@ module Kintama::Mocha
21
10
  end
22
11
  end
23
12
  end
13
+
14
+ def self.setup
15
+ Kintama.include Mocha::API
16
+ Kintama.include Mocha::Hooks
17
+ Kintama.extend(Kintama::Mocha::Expect)
18
+
19
+ Kintama.setup do
20
+ mocha_setup
21
+ end
22
+ Kintama.teardown do
23
+ begin
24
+ mocha_verify
25
+ rescue Mocha::ExpectationError => e
26
+ raise e
27
+ ensure
28
+ mocha_teardown
29
+ end
30
+ end
31
+ end
24
32
  end
25
- Kintama.extend(Kintama::Mocha::Expect)
33
+
34
+ Kintama::Mocha.setup
@@ -2,7 +2,8 @@ module Kintama
2
2
  class Reporter
3
3
 
4
4
  def self.default
5
- Verbose.new(colour=$stdin.tty?)
5
+ colour = $stdin.tty?
6
+ Verbose.new(colour)
6
7
  end
7
8
 
8
9
  def self.called(name)
@@ -65,7 +66,7 @@ module Kintama
65
66
  end
66
67
 
67
68
  def character_status_of(test)
68
- character = if test.pending?
69
+ if test.pending?
69
70
  'P'
70
71
  elsif test.passed?
71
72
  '.'
@@ -139,20 +140,20 @@ module Kintama
139
140
  end
140
141
  end
141
142
 
142
- def color(text, color_code)
143
- "#{color_code}#{text}\e[0m"
143
+ def colour(text, colour_code)
144
+ "#{colour_code}#{text}\e[0m"
144
145
  end
145
146
 
146
147
  def green(text)
147
- color(text, "\e[32m")
148
+ colour(text, "\e[32m")
148
149
  end
149
150
 
150
151
  def red(text)
151
- color(text, "\e[31m")
152
+ colour(text, "\e[31m")
152
153
  end
153
154
 
154
155
  def yellow(text)
155
- color(text, "\e[33m")
156
+ colour(text, "\e[33m")
156
157
  end
157
158
  end
158
159
 
@@ -22,7 +22,7 @@ module Kintama
22
22
 
23
23
  # Returns the full name of this context, taking any parent contexts into account
24
24
  def full_name
25
- if @name
25
+ if instance_variable_defined?(:@name) && @name
26
26
  [parent ? parent.full_name : nil, @name].compact.join(" ")
27
27
  else
28
28
  nil
@@ -34,4 +34,4 @@ module Kintama
34
34
  end
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -58,15 +58,15 @@ module Kintama
58
58
  runnable = @runnables.map { |r| r.runnable_on_line(@line) }.compact.first
59
59
  if runnable
60
60
  if runnable.is_a_test?
61
- heirarchy = []
61
+ hierarchy = []
62
62
  parent = runnable.parent.parent
63
63
  until parent == Kintama.default_context do
64
- heirarchy.unshift parent
64
+ hierarchy.unshift parent
65
65
  parent = parent.parent
66
66
  end
67
- heirarchy.each { |context| reporter.context_started(context) }
67
+ hierarchy.each { |context| reporter.context_started(context) }
68
68
  runnable.parent.run_tests([runnable], false, reporter)
69
- heirarchy.reverse.each { |context| reporter.context_finished(context) }
69
+ hierarchy.reverse.each { |context| reporter.context_finished(context) }
70
70
  [runnable.parent]
71
71
  else
72
72
  runnable.run(reporter)
@@ -74,7 +74,7 @@ module Kintama
74
74
  end
75
75
  else
76
76
  puts "Nothing runnable found on line #{@line}"
77
- exit -1
77
+ exit(-1)
78
78
  end
79
79
  end
80
80
  end
@@ -9,7 +9,7 @@ module Kintama
9
9
  attr_accessor :block
10
10
 
11
11
  def pending?
12
- @block.nil?
12
+ !instance_variable_defined?(:@block) || @block.nil?
13
13
  end
14
14
 
15
15
  def run
@@ -65,4 +65,4 @@ module Kintama
65
65
  @failure.backtrace.select { |line| File.expand_path(line).index(base_dir).nil? }.map { |l| " "*4 + File.expand_path(l) }.join("\n")
66
66
  end
67
67
  end
68
- end
68
+ end
@@ -1,45 +1,22 @@
1
1
  require 'test_helper'
2
2
 
3
- class AutomaticRunningTest < Minitest::Test
3
+ class AutomaticRunningTest < KintamaIntegrationTest
4
4
 
5
5
  def test_should_be_able_to_run_kintama_tests_automatically_when_file_is_loaded
6
- assert_passes write_test %{
6
+ test_with_content(%{
7
7
  context "given a thing" do
8
8
  should "work" do
9
9
  assert true
10
10
  end
11
- end}
12
- assert_fails write_test %{
11
+ end
12
+ }).run.should_have_passing_exit_status
13
+
14
+ test_with_content(%{
13
15
  context "given a thing" do
14
16
  should "not work" do
15
17
  flunk
16
18
  end
17
- end}
18
- end
19
-
20
- private
21
-
22
- def write_test(string)
23
- f = File.open("/tmp/kintama_tmp_test.rb", "w") do |f|
24
- f.puts %|$LOAD_PATH.unshift "#{File.expand_path("../../lib", __FILE__)}"; require "kintama"|
25
- f.puts string
26
- end
27
- "/tmp/kintama_tmp_test.rb"
28
- end
29
-
30
- def run_kintama_test(path)
31
- prev = ENV["KINTAMA_EXPLICITLY_DONT_RUN"]
32
- ENV["KINTAMA_EXPLICITLY_DONT_RUN"] = nil
33
- output = `ruby #{path}`
34
- ENV["KINTAMA_EXPLICITLY_DONT_RUN"] = prev
35
- $?
36
- end
37
-
38
- def assert_passes(path)
39
- assert_equal 0, run_kintama_test(path).exitstatus
40
- end
41
-
42
- def assert_fails(path)
43
- assert_equal 1, run_kintama_test(path).exitstatus
19
+ end
20
+ }).run.should_have_failing_exit_status
44
21
  end
45
22
  end
@@ -1,8 +1,8 @@
1
1
  require "test_helper"
2
2
 
3
- class LineBasedRunningTest < Minitest::Test
3
+ class LineBasedRunningTest < KintamaIntegrationTest
4
4
  def test_should_be_able_to_run_the_test_by_giving_the_line_number_the_test_is_defined_on
5
- test_file = %{
5
+ test = test_with_content(%{
6
6
  context "given a thing" do
7
7
  should "run this test" do
8
8
  assert true
@@ -10,16 +10,20 @@ class LineBasedRunningTest < Minitest::Test
10
10
  should "not run this test" do
11
11
  flunk
12
12
  end
13
- end}
14
- assert_match /^#{passing("should run this test")}\n\n1 tests/, run_kintama_test(test_file, "--line 3")
15
- assert_match /^1 tests, 0 failures/, run_kintama_test(test_file, "--line 3")
16
-
17
- assert_match /^#{failing("should not run this test")}\n\n1 tests/, run_kintama_test(test_file, "--line 6")
18
- assert_match /^1 tests, 1 failures/, run_kintama_test(test_file, "--line 6")
13
+ end
14
+ })
15
+ test.run('--line 3') do
16
+ assert_output(/^#{passing("should run this test")}\n\n1 tests/)
17
+ assert_output(/^1 tests, 0 failures/)
18
+ end
19
+ test.run('--line 6') do
20
+ assert_output(/^#{failing("should not run this test")}\n\n1 tests/)
21
+ assert_output(/^1 tests, 1 failures/)
22
+ end
19
23
  end
20
24
 
21
25
  def test_should_be_able_to_run_the_test_by_giving_the_line_number_within_the_test_definition
22
- test_file = %{
26
+ test = test_with_content(%{
23
27
  context "given a thing" do
24
28
  should "run this test" do
25
29
  assert true
@@ -27,13 +31,18 @@ class LineBasedRunningTest < Minitest::Test
27
31
  should "not run this test" do
28
32
  flunk
29
33
  end
30
- end}
31
- assert_match /^#{passing("should run this test")}\n\n1 tests/, run_kintama_test(test_file, "--line 4")
32
- assert_match /^#{failing("should not run this test")}\n\n1 tests/, run_kintama_test(test_file, "--line 7")
34
+ end
35
+ })
36
+ test.run('--line 4') do
37
+ assert_output(/^#{passing("should run this test")}\n\n1 tests/)
38
+ end
39
+ test.run('--line 7') do
40
+ assert_output(/^#{failing("should not run this test")}\n\n1 tests/)
41
+ end
33
42
  end
34
43
 
35
44
  def test_should_be_able_to_run_all_tests_within_a_context_when_line_falls_on_a_context
36
- test_file = %{
45
+ test_with_content(%{
37
46
  context "given a thing" do
38
47
  should "not run this test" do
39
48
  flunk
@@ -44,12 +53,14 @@ class LineBasedRunningTest < Minitest::Test
44
53
  should "run this test too" do
45
54
  end
46
55
  end
47
- end}
48
- assert_match /#{passing("should run this test")}\n#{passing("should run this test too")}\n\n2 tests/, run_kintama_test(test_file, "--line 6")
56
+ end
57
+ }).run('--line 6') do
58
+ assert_output(/#{passing("should run this test")}\n#{passing("should run this test too")}\n\n2 tests/)
59
+ end
49
60
  end
50
61
 
51
62
  def test_should_be_able_to_run_a_test_defined_in_a_second_top_level_context
52
- test_file = %{
63
+ test_with_content(%{
53
64
  context "given a thing" do
54
65
  should "not run this test" do
55
66
  flunk
@@ -58,86 +69,61 @@ class LineBasedRunningTest < Minitest::Test
58
69
  context "and another thing" do
59
70
  should "run this test" do
60
71
  end
61
- end}
62
- assert_match /#{passing("should run this test")}\n\n1 tests/, run_kintama_test(test_file, "--line 8")
72
+ end
73
+ }).run('--line 8') do
74
+ assert_output(/#{passing("should run this test")}\n\n1 tests/)
75
+ end
63
76
  end
64
77
 
65
78
  def test_should_print_out_the_full_nested_test_name
66
- test_file = %{
79
+ test_with_content(%{
67
80
  context "given a test" do
68
81
  context "that is nested deeply" do
69
82
  should "print the full nesting name" do
70
83
  end
71
84
  end
72
- end}
73
- assert_match /given a test\n that is nested deeply\n/, run_kintama_test(test_file, "--line 5")
85
+ end
86
+ }).run('--line 5') do
87
+ assert_output(/given a test\n that is nested deeply\n/)
88
+ end
74
89
  end
75
90
 
76
91
  def test_should_not_show_pending_tests_in_the_same_context_as_pending_when_not_targeted
77
- test_file = %{
92
+ test_with_content(%{
78
93
  context "given a context with a pending test" do
79
94
  should "only show the run test" do
80
95
  end
81
96
  should "ignore the pending test"
82
- end}
83
- assert_no_match /1 pending/, run_kintama_test(test_file, "--line 3")
97
+ end
98
+ }).run('--line 3') do
99
+ refute_output(/1 pending/)
100
+ end
84
101
  end
85
102
 
86
103
  def test_should_be_able_to_target_a_top_level_context
87
104
  end
88
105
 
89
- def test_should_not_show_pending_tests_in_the_same_context_as_pending_when_not_targeted
90
- test_file = %{
106
+ def test_should_run_all_tests_when_context_is_on_target_line
107
+ test_with_content(%{
91
108
  context "given a context with a pending test" do
92
109
  should "run this" do
93
110
  end
94
111
  should "run this too" do
95
112
  end
96
- end}
97
- assert_match /2 tests/, run_kintama_test(test_file, "--line 2")
113
+ end
114
+ }).run('--line 2') do
115
+ assert_output(/2 tests/)
116
+ end
98
117
  end
99
118
 
100
119
  def test_should_report_if_nothing_runnable_can_be_found_for_that_line
101
- test_file = %{
120
+ test_with_content(%{
102
121
  context "given a short context" do
103
122
  should "not run this" do
104
123
  end
105
- end}
106
- assert_match /Nothing runnable found on line 1/, run_kintama_test(test_file, "--line 1")
107
- end
108
-
109
- private
110
-
111
- def write_test(string, path)
112
- f = File.open(path, "w") do |f|
113
- f.puts %|$LOAD_PATH.unshift "#{File.expand_path("../../lib", __FILE__)}"; require "kintama"|
114
- f.puts string.strip
115
- end
116
- end
117
-
118
- def run_kintama_test(test_content, options)
119
- path = "/tmp/kintama_tmp_test.rb"
120
- write_test(test_content.strip, path)
121
- prev = ENV["KINTAMA_EXPLICITLY_DONT_RUN"]
122
- ENV["KINTAMA_EXPLICITLY_DONT_RUN"] = nil
123
- output = `ruby #{path} #{options}`
124
- ENV["KINTAMA_EXPLICITLY_DONT_RUN"] = prev
125
- output
126
- end
127
-
128
- def passing(test_name)
129
- if $stdin.tty?
130
- /\e\[32m\s*#{test_name}\e\[0m/
131
- else
132
- /\s*#{test_name}: ./
133
- end
134
- end
135
-
136
- def failing(test_name)
137
- if $stdin.tty?
138
- /\e\[31m\s*#{test_name}\e\[0m/
139
- else
140
- /\s*#{test_name}: F/
124
+ end
125
+ }).run('--line 1') do
126
+ assert_output(/Nothing runnable found on line 1/)
141
127
  end
142
128
  end
143
129
  end
@@ -112,7 +112,8 @@ class VerboseReporterTest < KintamaIntegrationTest
112
112
  end
113
113
 
114
114
  def test_should_print_out_test_names_in_colour_if_colour_is_set
115
- use_reporter Kintama::Reporter::Verbose.new(colour=true)
115
+ use_colour = true
116
+ use_reporter Kintama::Reporter::Verbose.new(use_colour)
116
117
 
117
118
  context "given tests reported in colour" do
118
119
  should "show failures in red" do
@@ -6,7 +6,7 @@ ENV["KINTAMA_EXPLICITLY_DONT_RUN"] = "true"
6
6
  require 'kintama'
7
7
 
8
8
  require 'stringio'
9
- require 'mocha/setup'
9
+ require 'mocha/minitest'
10
10
 
11
11
  class Minitest::Test
12
12
  def setup
@@ -47,7 +47,7 @@ end
47
47
  class KintamaIntegrationTest < Minitest::Test
48
48
  class << self
49
49
  def reporter_class
50
- @reporter_class || Kintama::Reporter::Verbose
50
+ @reporter_class ||= Kintama::Reporter::Verbose
51
51
  end
52
52
 
53
53
  def report_with(reporter_class)
@@ -77,7 +77,8 @@ class KintamaIntegrationTest < Minitest::Test
77
77
  @test_unit_test = test_unit_test
78
78
  @context = context
79
79
  @result = nil
80
- @reporter = @test_unit_test.reporter || test_unit_test.class.reporter_class.new(colour=false)
80
+ use_colour = false
81
+ @reporter = @test_unit_test.reporter || test_unit_test.class.reporter_class.new(use_colour)
81
82
  @output = capture_stdout do
82
83
  @result = Kintama::Runner.default.with(context).run(@reporter)
83
84
  end.read
@@ -124,4 +125,69 @@ class KintamaIntegrationTest < Minitest::Test
124
125
  string.gsub("\n#{initial_indent}", "\n").gsub(/^\n/, '').gsub(/\s+$/, '')
125
126
  end
126
127
  end
128
+
129
+ def test_with_content(content)
130
+ IntegrationTestRunner.new(self, content)
131
+ end
132
+
133
+ class IntegrationTestRunner
134
+ def initialize(test_unit_test, test_body)
135
+ @test_unit_test = test_unit_test
136
+ @test_body = test_body
137
+ end
138
+
139
+ def run(options = nil, &block)
140
+ path = write_test(@test_body)
141
+ prev = ENV["KINTAMA_EXPLICITLY_DONT_RUN"]
142
+ ENV["KINTAMA_EXPLICITLY_DONT_RUN"] = nil
143
+ @output = `ruby #{path} #{options}`
144
+ ENV["KINTAMA_EXPLICITLY_DONT_RUN"] = prev
145
+ @exit_status = $?
146
+ instance_eval(&block) if block_given?
147
+ self
148
+ end
149
+
150
+ def should_have_passing_exit_status
151
+ @test_unit_test.assert_equal 0, @exit_status.exitstatus
152
+ end
153
+
154
+ def should_have_failing_exit_status
155
+ @test_unit_test.assert_equal 1, @exit_status.exitstatus
156
+ end
157
+
158
+ private
159
+
160
+ def assert_output(match)
161
+ @test_unit_test.assert_match(match, @output)
162
+ end
163
+
164
+ def refute_output(match)
165
+ @test_unit_test.refute_match(match, @output)
166
+ end
167
+
168
+ def passing(test_name)
169
+ if $stdin.tty?
170
+ /\e\[32m\s*#{test_name}\e\[0m/
171
+ else
172
+ /\s*#{test_name}: ./
173
+ end
174
+ end
175
+
176
+ def failing(test_name)
177
+ if $stdin.tty?
178
+ /\e\[31m\s*#{test_name}\e\[0m/
179
+ else
180
+ /\s*#{test_name}: F/
181
+ end
182
+ end
183
+
184
+ def write_test(string)
185
+ path = "/tmp/kintama_tmp_test.rb"
186
+ File.open(path, "w") do |f|
187
+ f.puts %|$LOAD_PATH.unshift "#{File.expand_path("../../lib", __FILE__)}"; require "kintama"|
188
+ f.puts string.strip
189
+ end
190
+ path
191
+ end
192
+ end
127
193
  end
@@ -40,7 +40,7 @@ class AssertionsTest < Minitest::Test
40
40
  end
41
41
 
42
42
  def test_should_provide_assert_kind_of
43
- assert_passed { @test.assert_kind_of Fixnum, 1 }
43
+ assert_passed { @test.assert_kind_of Integer, 1 }
44
44
  assert_passed { @test.assert_kind_of Object, 1 }
45
45
  assert_passed { @test.assert_kind_of String, "hello" }
46
46
  assert_failed("pa!") { @test.assert_kind_of String, 1, "pa!" }
@@ -61,13 +61,13 @@ class AssertionsTest < Minitest::Test
61
61
  end
62
62
 
63
63
  def test_should_provide_assert_match
64
- assert_passed { @test.assert_match /jam/, "bluejam" }
65
- assert_failed(%|expected "blah" to match /mm/|) { @test.assert_match /mm/, "blah" }
64
+ assert_passed { @test.assert_match(/jam/, "bluejam") }
65
+ assert_failed(%|expected "blah" to match /mm/|) { @test.assert_match(/mm/, "blah") }
66
66
  end
67
67
 
68
68
  def test_should_provide_assert_no_match
69
- assert_passed { @test.assert_no_match /jam/, "bluejay" }
70
- assert_failed(%|expected "blah" not to match /ah/|) { @test.assert_no_match /ah/, "blah" }
69
+ assert_passed { @test.assert_no_match(/jam/, "bluejay") }
70
+ assert_failed(%|expected "blah" not to match /ah/|) { @test.assert_no_match(/ah/, "blah") }
71
71
  end
72
72
 
73
73
  def test_should_provide_assert_same_elements_to_compare_arrays
@@ -93,7 +93,7 @@ class AssertionsTest < Minitest::Test
93
93
  end
94
94
  end
95
95
  assert_passed do
96
- @test.assert_output /oba/ do
96
+ @test.assert_output(/oba/) do
97
97
  puts 'foobar'
98
98
  end
99
99
  end
@@ -111,7 +111,7 @@ class AssertionsTest < Minitest::Test
111
111
  end
112
112
  end
113
113
  assert_passed do
114
- @test.assert_not_output /oba/ do
114
+ @test.assert_not_output(/oba/) do
115
115
  puts 'whambam'
116
116
  end
117
117
  end
@@ -3,6 +3,7 @@ require 'test_helper'
3
3
  class TeardownTest < KintamaIntegrationTest
4
4
 
5
5
  def setup
6
+ super
6
7
  @order = sequence('teardown order')
7
8
  end
8
9
  attr_reader :order
@@ -3,6 +3,7 @@ require "test_helper"
3
3
  class StartAndFinishTest < KintamaIntegrationTest
4
4
 
5
5
  def setup
6
+ super
6
7
  @order = sequence('order')
7
8
  end
8
9
  attr_reader :order
@@ -1,15 +1,14 @@
1
1
  require 'test_helper'
2
+ require 'kintama/mocha'
2
3
 
3
4
  class ExpectationsAndMockingTest < KintamaIntegrationTest
4
5
 
5
6
  def setup
6
- # In order to use the Mocha integration in Kintama, you need to
7
- # require 'kintama/mocha'.
8
- #
9
- # We require it in the setup here to ensure that the behaviour is
10
- # available for every test that runs in this test case, because Kintama
11
- # is thoroughly reset after each test by default.
12
- require 'kintama/mocha'
7
+ super
8
+ # This is normally called automatically when requiring 'kintama/mocha'
9
+ # but in these tests we totally reset Kintama, and so we need to
10
+ # ensure that the mocha integration is loaded properly.
11
+ Kintama::Mocha.setup
13
12
  end
14
13
 
15
14
  def test_should_allow_setting_of_expectations_in_tests
@@ -43,7 +42,7 @@ class ExpectationsAndMockingTest < KintamaIntegrationTest
43
42
  should_fail.
44
43
  with_failure(%{
45
44
  unsatisfied expectations:
46
- - expected exactly once, not yet invoked: #<Mock:thing>.blah
45
+ - expected exactly once, invoked never: #<Mock:thing>.blah
47
46
  })
48
47
  end
49
48
 
@@ -87,17 +87,26 @@ class LetAndSubjectTest < KintamaIntegrationTest
87
87
  end
88
88
 
89
89
  def test_subject_should_work_just_like_lets
90
+ $object_id_in_test_one = nil
91
+ $object_id_in_test_two = nil
92
+
90
93
  context "Defining a `subject` attribute in a context" do
91
94
  subject do
92
95
  Object.new
93
96
  end
94
97
 
95
98
  should "return one instance in one test" do
96
- $object_id = subject.object_id
99
+ $object_id_in_test_one = subject.object_id
100
+ if $object_id_in_test_two # this test might run first
101
+ assert_not_equal $object_id_in_test_one, $object_id_in_test_two, "object ids should be different between tests"
102
+ end
97
103
  end
98
104
 
99
105
  should "return a different instance in a different test" do
100
- assert $object_id && $object_id != subject.object_id
106
+ $object_id_in_test_two = subject.object_id
107
+ if $object_id_in_test_one # or this test might run first
108
+ assert_not_equal $object_id_in_test_one, $object_id_in_test_two, "object ids should be different between tests"
109
+ end
101
110
  end
102
111
  end.
103
112
  should_run_tests(2).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kintama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Adam
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-18 00:00:00.000000000 Z
11
+ date: 2020-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mocha
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: 1.11.2
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.0
26
+ version: 1.11.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description:
55
+ description:
56
56
  email: james@lazyatom.com
57
57
  executables: []
58
58
  extensions: []
@@ -94,7 +94,7 @@ files:
94
94
  homepage: http://github.com/lazyatom
95
95
  licenses: []
96
96
  metadata: {}
97
- post_install_message:
97
+ post_install_message:
98
98
  rdoc_options:
99
99
  - "--main"
100
100
  - README.md
@@ -111,9 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.4.5
116
- signing_key:
114
+ rubygems_version: 3.0.3
115
+ signing_key:
117
116
  specification_version: 4
118
117
  summary: It's for writing tests.
119
118
  test_files: []