kintama 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a59c25b77b6889c784049956601ab4ba2000c31
4
- data.tar.gz: 8aefa27d4b0581ea3799f3c4faba2ae861a7cc5c
3
+ metadata.gz: 89d410c25c98282d6a3f2e566a49bad89748fb19
4
+ data.tar.gz: 73b36955b5f69912da853293ec30c5661fcaa03b
5
5
  SHA512:
6
- metadata.gz: b4fd4b530520996ccc0a1014cc9146d2ea0a934e6d024d009e37fc0c9efb61271033463b87b890111d1e2d5aac38641fa2e76e197d79ffad196e68a53d37f9bd
7
- data.tar.gz: 8c5c445a35e8243820690ba4fc2ee1944144ae779562c7b8d7d4305341c61e6e679a9b1a8841c65248dba1d50bc173450837507ae13957682211e23922c7258b
6
+ metadata.gz: e6f06b7b88c56ea57f0bd65fe5c260daa6cbe54fad79f078e5105fd9c2e6db63070b25487bb1217a88486c07880d2d31b7d59daaf98c8ac3e0b6265cd99be3f2
7
+ data.tar.gz: ca6e19d9b7649cd34467838bfe2a33a5930774c71514e0e551121e9a550f58e5f9f45fc59a81f2472fa95b460f2e0e69764ff0956a642e84d56cf9fcc88bb6e1
data/README.md CHANGED
@@ -66,7 +66,7 @@ These will all be very familiar to most people who are already users of [shoulda
66
66
  end
67
67
  end
68
68
 
69
- Simple, right? Note that we don't need an outer subclass of `Test::Unit::TestCase`; it's nice to lose that noise, but otherwise so far so same-old-same-old. That's kind-of the point. Anyway, here's what you get when you run this:
69
+ Simple, right? Note that we don't need an outer subclass of `Minitest::Test` or `Test::Unit::TestCase`; it's nice to lose that noise, but otherwise so far so same-old-same-old. That's kind-of the point. Anyway, here's what you get when you run this:
70
70
 
71
71
  A thing
72
72
  should act like a thing: F
@@ -1,4 +1,5 @@
1
1
  require "set"
2
+ require "stringio"
2
3
 
3
4
  module Kintama
4
5
  module Assertions
@@ -30,6 +31,10 @@ module Kintama
30
31
  assert (string =~ regexp), message
31
32
  end
32
33
 
34
+ def assert_no_match(regexp, string, message="expected #{string.inspect} not to match #{regexp.inspect}")
35
+ assert !(string =~ regexp), message
36
+ end
37
+
33
38
  def assert_kind_of(klass, thing, message="should be a kind of #{klass}")
34
39
  assert thing.is_a?(klass), message
35
40
  end
@@ -66,5 +71,35 @@ module Kintama
66
71
  ensure
67
72
  raise Kintama::TestFailure, message unless raised
68
73
  end
74
+
75
+ def assert_output(expected, message="Expected output to match #{expected.inspect}", &block)
76
+ output = capture_output(&block).read.strip
77
+ if expected.is_a?(Regexp)
78
+ assert_match expected, output, message
79
+ else
80
+ assert_equal expected, output, message
81
+ end
82
+ end
83
+
84
+ def assert_not_output(not_expected, message="Expected output not to match #{not_expected.inspect}", &block)
85
+ output = capture_output(&block).read.strip
86
+ if not_expected.is_a?(Regexp)
87
+ assert_no_match not_expected, output, message
88
+ else
89
+ assert_not_equal not_expected, output, message
90
+ end
91
+ end
92
+
93
+ private
94
+
95
+ def capture_output(&block)
96
+ out = StringIO.new
97
+ $stdout = out
98
+ yield
99
+ out.rewind
100
+ return out
101
+ ensure
102
+ $stdout = STDOUT
103
+ end
69
104
  end
70
- end
105
+ end
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class AutomaticRunningTest < Test::Unit::TestCase
3
+ class AutomaticRunningTest < Minitest::Test
4
4
 
5
5
  def test_should_be_able_to_run_kintama_tests_automatically_when_file_is_loaded
6
6
  assert_passes write_test %{
@@ -1,6 +1,6 @@
1
1
  require "test_helper"
2
2
 
3
- class LineBasedRunningTest < Test::Unit::TestCase
3
+ class LineBasedRunningTest < Minitest::Test
4
4
  def test_should_be_able_to_run_the_test_by_giving_the_line_number_the_test_is_defined_on
5
5
  test_file = %{
6
6
  context "given a thing" do
data/test/test_helper.rb CHANGED
@@ -1,7 +1,6 @@
1
-
2
1
  $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
3
- require 'test/unit'
4
2
  require 'bundler/setup'
3
+ require 'minitest/autorun'
5
4
 
6
5
  ENV["KINTAMA_EXPLICITLY_DONT_RUN"] = "true"
7
6
  require 'kintama'
@@ -9,7 +8,7 @@ require 'kintama'
9
8
  require 'stringio'
10
9
  require 'mocha/setup'
11
10
 
12
- class Test::Unit::TestCase
11
+ class Minitest::Test
13
12
  def setup
14
13
  Kintama.reset
15
14
  end
@@ -45,7 +44,7 @@ class Test::Unit::TestCase
45
44
  end
46
45
  end
47
46
 
48
- class KintamaIntegrationTest < Test::Unit::TestCase
47
+ class KintamaIntegrationTest < Minitest::Test
49
48
  class << self
50
49
  def reporter_class
51
50
  @reporter_class || Kintama::Reporter::Verbose
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class AssertionsTest < Test::Unit::TestCase
3
+ class AssertionsTest < Minitest::Test
4
4
 
5
5
  class PseudoTest
6
6
  include Kintama::Assertions
@@ -65,6 +65,11 @@ class AssertionsTest < Test::Unit::TestCase
65
65
  assert_failed(%|expected "blah" to match /mm/|) { @test.assert_match /mm/, "blah" }
66
66
  end
67
67
 
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" }
71
+ end
72
+
68
73
  def test_should_provide_assert_same_elements_to_compare_arrays
69
74
  assert_passed { @test.assert_same_elements [1,2,3], [1,2,3] }
70
75
  assert_passed { @test.assert_same_elements [1,2,3], [3,1,2] }
@@ -81,6 +86,42 @@ class AssertionsTest < Test::Unit::TestCase
81
86
  end
82
87
  end
83
88
 
89
+ def test_should_provide_assert_output
90
+ assert_passed do
91
+ @test.assert_output 'foobar' do
92
+ puts 'foobar'
93
+ end
94
+ end
95
+ assert_passed do
96
+ @test.assert_output /oba/ do
97
+ puts 'foobar'
98
+ end
99
+ end
100
+ assert_failed('Expected output to match "foobar"') do
101
+ @test.assert_output 'foobar' do
102
+ puts 'whambam'
103
+ end
104
+ end
105
+ end
106
+
107
+ def test_should_provide_assert_not_output
108
+ assert_passed do
109
+ @test.assert_not_output 'foobar' do
110
+ puts 'whambam'
111
+ end
112
+ end
113
+ assert_passed do
114
+ @test.assert_not_output /oba/ do
115
+ puts 'whambam'
116
+ end
117
+ end
118
+ assert_failed('Expected output not to match "foobar"') do
119
+ @test.assert_not_output 'foobar' do
120
+ puts 'foobar'
121
+ end
122
+ end
123
+ end
124
+
84
125
  private
85
126
 
86
127
  def assert_passed
@@ -95,4 +136,4 @@ class AssertionsTest < Test::Unit::TestCase
95
136
  assert_equal message, e.message, "assertion failure message didn't match"
96
137
  end
97
138
  end
98
- end
139
+ end
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class ContextTest < Test::Unit::TestCase
3
+ class ContextTest < Minitest::Test
4
4
  def test_should_clear_previous_failure_when_running_test_again
5
5
  $thing = 456
6
6
  x = context "Given something" do
@@ -1,6 +1,6 @@
1
1
  require "test_helper"
2
2
 
3
- class RunnerTest < Test::Unit::TestCase
3
+ class RunnerTest < Minitest::Test
4
4
  def setup
5
5
  @reporter = Kintama::Reporter::Verbose.new(colour=false)
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class TestAndSubcontextAccessTest < Test::Unit::TestCase
3
+ class TestAndSubcontextAccessTest < Minitest::Test
4
4
 
5
5
  def test_should_stash_all_defined_contexts_so_they_can_be_accessed_later
6
6
  c1 = context "Given some context" do
@@ -212,7 +212,7 @@ class StartAndFinishTest < KintamaIntegrationTest
212
212
  spy = test_spy
213
213
 
214
214
  spy.expects(:before_all_tests).once.in_sequence(order)
215
- spy.expects(:in_test).in_sequence(order)
215
+ spy.expects(:in_test).twice.in_sequence(order)
216
216
 
217
217
  Kintama.reset
218
218
  Kintama.on_start do
@@ -223,13 +223,17 @@ class StartAndFinishTest < KintamaIntegrationTest
223
223
  should "have run the `before_all_tests` block before a test" do
224
224
  spy.in_test
225
225
  end
226
+
227
+ should "only run `before_all_tests` once" do
228
+ spy.in_test
229
+ end
226
230
  end
227
231
  end
228
232
 
229
233
  def test_should_be_able_to_run_things_after_all_tests_have_run
230
234
  spy = test_spy
231
235
 
232
- spy.expects(:in_test).in_sequence(order)
236
+ spy.expects(:in_test).twice.in_sequence(order)
233
237
  spy.expects(:after_all_tests).once.in_sequence(order)
234
238
 
235
239
  Kintama.reset
@@ -241,6 +245,10 @@ class StartAndFinishTest < KintamaIntegrationTest
241
245
  should "have run the `before_all_tests` block before a test" do
242
246
  spy.in_test
243
247
  end
248
+
249
+ should "only run `after_all_tests` once all tests have finished" do
250
+ spy.in_test
251
+ end
244
252
  end
245
253
  end
246
254
 
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.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Adam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-03-18 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: 0.13.0
19
+ version: 1.1.0
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: 0.13.0
26
+ version: 1.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description:
42
56
  email: james@lazyatom.com
43
57
  executables: []
@@ -98,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
112
  version: '0'
99
113
  requirements: []
100
114
  rubyforge_project:
101
- rubygems_version: 2.2.2
115
+ rubygems_version: 2.4.5
102
116
  signing_key:
103
117
  specification_version: 4
104
118
  summary: It's for writing tests.