minitest-chain 0.5.1 → 0.5.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.
Files changed (3) hide show
  1. data/lib/minitest-chain.rb +17 -1
  2. data/test/test_chain.rb +24 -0
  3. metadata +11 -4
@@ -53,6 +53,21 @@ module MiniTest::Chain
53
53
  RUBY
54
54
  end
55
55
 
56
+ # Blocks:
57
+ [
58
+ [:raises, :raises],
59
+ [:throws, :throws],
60
+ [:silent, :silent],
61
+ [:output, :output],
62
+ ].each do |name, assertion|
63
+ class_eval <<-RUBY, __FILE__, __LINE__+1
64
+ def #{name}(*args)
65
+ scope.assert_#{assertion}(*args, &subject)
66
+ self
67
+ end
68
+ RUBY
69
+ end
70
+
56
71
  alias is_not not_is
57
72
  remove_method :not_is
58
73
  end
@@ -62,7 +77,8 @@ module MiniTest::Chain
62
77
  AssertionChain.new(self, obj)
63
78
  end
64
79
 
65
- def expect(obj)
80
+ def expect(obj = nil, &blk)
81
+ obj ||= blk
66
82
  AssertionChain.new(self, obj)
67
83
  end
68
84
  end
@@ -128,5 +128,29 @@ class TestChain < MiniTest::Unit::TestCase
128
128
  assert_refutes { expect(1).nil }
129
129
  assert_refutes { expect(nil).not_nil }
130
130
  end
131
+
132
+ def test_raises
133
+ expect { raise TypeError }.raises(TypeError)
134
+
135
+ assert_refutes { expect { }.raises(TypeError) }
136
+ end
137
+
138
+ def test_throws
139
+ expect { throw :foo }.throws(:foo)
140
+
141
+ assert_refutes { expect { }.throws(:foo) }
142
+ assert_refutes { expect { throw :bar }.throws(:foo) }
143
+ end
144
+
145
+ def test_silent
146
+ expect { }.silent
147
+
148
+ assert_refutes { expect { puts 'hello' }.silent }
149
+ end
150
+
151
+ def test_output
152
+ expect { puts 'hello' }.output("hello\n")
153
+ expect { $stderr.puts 'hello' }.output("", "hello\n")
154
+ end
131
155
  end
132
156
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-chain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,30 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-25 00:00:00.000000000 Z
12
+ date: 2013-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>'
20
20
  - !ruby/object:Gem::Version
21
21
  version: '4.0'
22
+ - - <
23
+ - !ruby/object:Gem::Version
24
+ version: '6'
22
25
  type: :runtime
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  none: false
26
29
  requirements:
27
- - - ~>
30
+ - - ! '>'
28
31
  - !ruby/object:Gem::Version
29
32
  version: '4.0'
33
+ - - <
34
+ - !ruby/object:Gem::Version
35
+ version: '6'
30
36
  description: Chainable assertions for MiniTest
31
37
  email: judofyr@gmail.com
32
38
  executables: []
@@ -63,3 +69,4 @@ summary: Chainable assertions for MiniTest
63
69
  test_files:
64
70
  - test/helper.rb
65
71
  - test/test_chain.rb
72
+ has_rdoc: