mcmire-protest 0.3.1 → 0.3.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.
@@ -1,5 +1,5 @@
1
1
  module Protest
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
 
4
4
  # Exception raised when an assertion fails. See TestCase#assert
5
5
  class AssertionFailed < StandardError; end
@@ -183,7 +183,7 @@ module Protest
183
183
  # by passing it as an argument.
184
184
  def assert(condition, message="Expected condition to be satisfied")
185
185
  @report.add_assertion
186
- raise AssertionFailed, message unless condition
186
+ raise AssertionFailed, (Proc === message ? message.call : message) unless condition
187
187
  end
188
188
 
189
189
  # Provided for Test::Unit compatibility, this lets you include
@@ -202,6 +202,10 @@ module Protest
202
202
  def name
203
203
  @name
204
204
  end
205
+
206
+ def context_description
207
+ self.class.description
208
+ end
205
209
 
206
210
  private
207
211
 
@@ -252,6 +256,10 @@ module Protest
252
256
  def run(report)
253
257
  @test.send("do_global_#{@type}")
254
258
  end
259
+
260
+ def context_description
261
+ @test.description
262
+ end
255
263
  end
256
264
  end
257
265
  end
@@ -71,10 +71,11 @@ module Protest
71
71
  pad_indexes = failures_and_errors.size.to_s.size
72
72
  failures_and_errors.each_with_index do |error, index|
73
73
  colorize_as = ErroredTest === error ? :errored : :failed
74
- puts " #{pad(index+1, pad_indexes)}) #{test_type(error)} in `#{error.test.class.description} #{error.test_name}' (on line #{error.line} of `#{error.file}')", colorize_as
74
+ puts " #{pad(index+1, pad_indexes)}) #{test_type(error)} in `#{error.test.context_description} #{error.test_name}' (on line #{error.line} of `#{error.file}')", colorize_as
75
75
  # If error message has line breaks, indent the message
76
76
  prefix = "with"
77
- unless error.error.is_a?(Protest::AssertionFailed) || error.error.is_a?(::Test::Unit::AssertionFailedError)
77
+ unless error.error.is_a?(Protest::AssertionFailed) ||
78
+ ((RUBY_VERSION =~ /^1\.9/) ? error.error.is_a?(MiniTest::Assertion) : error.error.is_a?(::Test::Unit::AssertionFailedError))
78
79
  prefix << " #{error.error.class}"
79
80
  end
80
81
  if error.error_message =~ /\n/
@@ -113,9 +114,10 @@ module Protest
113
114
  # and in Ruby 1.8, String#each is equivalent to String#each_line
114
115
  # so effectively it's equivalent to .split("\n") but keeping the \n's
115
116
  strings = [strings] unless Array === strings
116
- strings.map do |str|
117
+ out = strings.map do |str|
117
118
  str.to_s.split("\n").map {|s| indent_with * size + s }.join("\n")
118
119
  end
120
+ out.size == 1 ? out[0] : out
119
121
  end
120
122
 
121
123
  def pad(str, amount)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "mcmire-protest"
3
- s.version = "0.3.1"
4
- s.date = "2010-01-10"
3
+ s.version = "0.3.2"
4
+ s.date = "2010-01-14"
5
5
 
6
6
  s.description = "Protest is a tiny, simple, and easy-to-extend test framework"
7
7
  s.summary = s.description
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcmire-protest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Nicol\xC3\xA1s Sanguinetti"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-10 00:00:00 -06:00
12
+ date: 2010-01-14 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15