protest 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -117,13 +117,17 @@ Or you can call the +pending+ method from inside your test.
117
117
 
118
118
  == Custom assertions
119
119
 
120
- By default Protest bundles all the assertions defined in Test::Unit (it
121
- literally requires them), so check its documentation for all the goodness.
120
+ Previous versions of Protest used to bundle all the assertions defined in
121
+ Test::Unit, but that has changed and now Protest includes just three basic
122
+ assertion methods:
122
123
 
123
- If you want to add assertions, just define methods that rely on +assert+ or
124
- +assert_block+. The former takes a boolean and an optional error message as
125
- arguments, while the latter takes an optional error message as an argument and
126
- a block. The assertions is considered to fail if the block evaluates to neither
124
+ - assert
125
+ - assert_equal
126
+ - assert_raise
127
+
128
+ If you want to add assertions, just define methods that rely on +assert+.
129
+ This method takes a boolean and an optional error message as arguments, and
130
+ the assertion is considered to fail if the boolean evaluates to neither
127
131
  +false+ nor +nil+.
128
132
 
129
133
  For example:
@@ -1,5 +1,5 @@
1
1
  module Protest
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
 
4
4
  # Exception raised when an assertion fails. See TestCase#assert
5
5
  class AssertionFailed < StandardError; end
@@ -25,12 +25,6 @@ module Protest
25
25
  # your tests by declaring nested contexts inside the class. See
26
26
  # TestCase.context.
27
27
  class TestCase
28
- begin
29
- require "test/unit/assertions"
30
- include Test::Unit::Assertions
31
- rescue LoadError
32
- end
33
-
34
28
  # Run all tests in this context. Takes a Runner instance in order to
35
29
  # provide output.
36
30
  def self.run(runner)
@@ -182,10 +176,23 @@ module Protest
182
176
  raise AssertionFailed, message unless condition
183
177
  end
184
178
 
185
- # Provided for Test::Unit compatibility, this lets you include
186
- # Test::Unit::Assertions and everything works seamlessly.
187
- def assert_block(message="Expected condition to be satisified") #:nodoc:
188
- assert(yield, message)
179
+ # Passes if expected == actual. You can override the default
180
+ # failure message by passing it as an argument.
181
+ def assert_equal(expected, actual, message=nil)
182
+ assert expected == actual, message || "#{expected.inspect} expected but was #{actual.inspect}"
183
+ end
184
+
185
+ # Passes if the code block raises the specified exception. If no
186
+ # exception is specified, passes if any exception is raised,
187
+ # otherwise it fails. You can override the default failure message
188
+ # by passing it as an argument.
189
+ def assert_raise(exception_class=Exception, message=nil)
190
+ begin
191
+ yield
192
+ rescue exception_class => e
193
+ ensure
194
+ assert e, message || "Expected #{exception_class.name} to be raised"
195
+ end
189
196
  end
190
197
 
191
198
  # Make the test be ignored as pending. You can override the default message
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "protest"
4
- s.version = "0.4.0"
5
- s.date = "2010-09-01"
4
+ s.version = "0.4.1"
5
+ s.date = "2010-09-13"
6
6
 
7
7
  s.description = "Protest is a tiny, simple, and easy-to-extend test framework"
8
8
  s.summary = s.description
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 4
9
- - 0
10
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - "Nicol\xC3\xA1s Sanguinetti"
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-09-01 00:00:00 -03:00
18
+ date: 2010-09-13 00:00:00 -03:00
20
19
  default_executable:
21
20
  dependencies: []
22
21
 
@@ -65,7 +64,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
64
  requirements:
66
65
  - - ">="
67
66
  - !ruby/object:Gem::Version
68
- hash: 3
69
67
  segments:
70
68
  - 0
71
69
  version: "0"
@@ -74,7 +72,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
72
  requirements:
75
73
  - - ">="
76
74
  - !ruby/object:Gem::Version
77
- hash: 3
78
75
  segments:
79
76
  - 0
80
77
  version: "0"