brass 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby CHANGED
@@ -41,7 +41,7 @@ revision: 0
41
41
  created: '2012-01-24'
42
42
  summary: Bare-Metal Ruby Assertion System Standard
43
43
  title: BRASS
44
- version: 1.2.0
44
+ version: 1.2.1
45
45
  name: brass
46
46
  description: ! 'BRASS stands for Bare-Metal Ruby Assertion System Standard. It is
47
47
  a very basic
@@ -50,4 +50,4 @@ description: ! 'BRASS stands for Bare-Metal Ruby Assertion System Standard. It i
50
50
 
51
51
  to make use so they can all work together harmoniously.'
52
52
  organization: Rubyworks
53
- date: '2012-01-25'
53
+ date: '2012-02-09'
@@ -1,5 +1,16 @@
1
1
  = HISTORY
2
2
 
3
+ == 1.2.1 | 2012-02-09
4
+
5
+ This release adds framework adapters for MiniTest and TestUnit, which allows
6
+ those frameworks to recognize BRASS assertions as "failures" rather than
7
+ as "errors".
8
+
9
+ Changes:
10
+
11
+ * Add framework adapters for MiniTest and TestUnit.
12
+
13
+
3
14
  == 1.2.0 | 2012-01-26
4
15
 
5
16
  The default error is `RuntimeError` rather than `StandardError` to
@@ -7,15 +7,30 @@ class Exception
7
7
 
8
8
  # Set the the exception's assertion flag.
9
9
  def set_assertion(boolean)
10
- @assertion = boolean # ? true : false
10
+ @assertion = boolean # ? true : false
11
11
  end
12
12
 
13
13
  # Set message.
14
14
  # (not strictly needed here, but can be useful anyway).
15
+ #
16
+ # @todo Does the message have to be a string?
15
17
  def set_message(msg)
16
18
  @mesg = msg.to_str
17
19
  end
18
20
 
21
+ # TODO: Consider assertion parameters for future vresion.
22
+ ##
23
+ #def parameters
24
+ # @parameters
25
+ #end
26
+ #
27
+ ## Set exception parameters. These are used to store specific information
28
+ ## relavent to a particular exception or assertion. Unlike the message,
29
+ ## which is a String, this is a Hash.
30
+ #def set_parameters(parameters)
31
+ # @parameters = parameters.to_hash
32
+ #end
33
+
19
34
  end
20
35
 
21
36
  module Kernel
@@ -78,7 +93,7 @@ module Kernel
78
93
  error_class = raise_arguments.shift
79
94
  error_class.new(*raise_arguments)
80
95
  else
81
- error_class = RuntimeError
96
+ error_class = $! || RuntimeError
82
97
  error_class.new(*raise_arguments)
83
98
  end
84
99
 
@@ -0,0 +1,26 @@
1
+ module MiniTest #:nodoc:
2
+ class Unit #:nodoc:
3
+ # To teach MiniTest to recognize the expanded concept of assertions
4
+ # we add in an extra capture clause to the it's #puke method.
5
+ def puke c, m, x
6
+ case x
7
+ when MiniTest::Skip
8
+ @skips = @skips + 1
9
+ x = "Skipped:\n#{m}(#{c}) [#{location x}]:\n#{x.message}\n"
10
+ when MiniTest::Assertion
11
+ @failures = @failures + 1
12
+ x = "Failure:\n#{m}(#{c}) [#{location x}]:\n#{x.message}\n"
13
+ when x.respond_to?(:assertion?) && x.assertion?
14
+ @failures = @failures + 1
15
+ x = "Failure:\n#{m}(#{c}) [#{location x}]:\n#{x.message}\n"
16
+ else
17
+ @errors = @errors + 1
18
+ b = MiniTest::filter_backtrace(x.backtrace).join("\n ")
19
+ x = "Error:\n#{m}(#{c}):\n#{x.class}: #{x.message}\n #{b}\n"
20
+ end
21
+ @report << x
22
+ x[0, 1]
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,36 @@
1
+ module Test #:nodoc:
2
+ module Unit #:nodoc:
3
+
4
+ module BrassAssertionHandler
5
+ class << self
6
+ def included(base)
7
+ base.exception_handler(:handle_brass_assertion_failed_error)
8
+ end
9
+ end
10
+
11
+ private
12
+ def handle_brass_assertion_failed_error(exception)
13
+ return false unless exception.assertion?
14
+ problem_occurred
15
+ #parameters = exception.parameters # TODO: assertion parameters
16
+ add_brass_failure exception.message, exception.backtrace,
17
+ #:expected => exception.expected,
18
+ #:actual => exception.actual,
19
+ #:inspected_expected => exception.inspected_expected,
20
+ #:inspected_actual => exception.inspected_actual,
21
+ :user_message => exception.message #exception.user_message
22
+ true
23
+ end
24
+
25
+ def add_brass_failure(message, backtrace, options={})
26
+ failure = Failure.new(name, filter_backtrace(backtrace), message, options)
27
+ current_result.add_failure(failure)
28
+ end
29
+ end
30
+
31
+ class TestCase #:nodoc:
32
+ include BrassAssertionHandler
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,42 @@
1
+ module Test #:nodoc:
2
+ module Unit #:nodoc:
3
+ class TestCase #:nodoc:
4
+ # Runs the individual test method represented by this
5
+ # instance of the fixture, collecting statistics, failures
6
+ # and errors in result.
7
+ def run(result)
8
+ yield(STARTED, name)
9
+ @_result = result
10
+ begin
11
+ setup
12
+ __send__(@method_name)
13
+ rescue AssertionFailedError => e
14
+ add_failure(e.message, e.backtrace)
15
+ rescue Exception => e
16
+ if e.respond_to?(:assertion?) && e.assertion?
17
+ add_failure(e.message, e.backtrace)
18
+ else
19
+ raise if PASSTHROUGH_EXCEPTIONS.include? $!.class
20
+ add_error($!)
21
+ end
22
+ ensure
23
+ begin
24
+ teardown
25
+ rescue AssertionFailedError => e
26
+ add_failure(e.message, e.backtrace)
27
+ rescue Exception => e
28
+ if e.respond_to?(:assertion?) && e.assertion?
29
+ add_failure(e.message, e.backtrace)
30
+ else
31
+ raise if PASSTHROUGH_EXCEPTIONS.include? $!.class
32
+ add_error($!)
33
+ end
34
+ end
35
+ end
36
+ result.add_run
37
+ yield(FINISHED, name)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
@@ -16,7 +16,7 @@ module Kernel
16
16
  rescue error_class
17
17
  assert(true)
18
18
  rescue Exception => err
19
- assert(false, error_class, "#{error_class} expected but #{err} was thrown")
19
+ assert(false, error_class, "#{error_class} expected but #{err.class} was thrown")
20
20
  end
21
21
  end
22
22
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brass
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-25 00:00:00.000000000 Z
12
+ date: 2012-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: detroit
16
- requirement: &16988520 !ruby/object:Gem::Requirement
16
+ requirement: &16492980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *16988520
24
+ version_requirements: *16492980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: lemon
27
- requirement: &16987480 !ruby/object:Gem::Requirement
27
+ requirement: &16492280 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *16987480
35
+ version_requirements: *16492280
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rubytest
38
- requirement: &16986520 !ruby/object:Gem::Requirement
38
+ requirement: &16491100 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *16986520
46
+ version_requirements: *16491100
47
47
  description: ! 'BRASS stands for Bare-Metal Ruby Assertion System Standard. It is
48
48
  a very basic
49
49
 
@@ -61,6 +61,9 @@ extra_rdoc_files:
61
61
  files:
62
62
  - .ruby
63
63
  - .yardopts
64
+ - lib/brass/adapters/minitest.rb
65
+ - lib/brass/adapters/testunit.rb
66
+ - lib/brass/adapters/testunit1.rb
64
67
  - lib/brass/expect.rb
65
68
  - lib/brass.rb
66
69
  - test/case_brass.rb
@@ -88,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
91
  version: '0'
89
92
  requirements: []
90
93
  rubyforge_project:
91
- rubygems_version: 1.8.10
94
+ rubygems_version: 1.8.11
92
95
  signing_key:
93
96
  specification_version: 3
94
97
  summary: Bare-Metal Ruby Assertion System Standard