test-rig 0.0.1 → 0.0.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.
@@ -14,7 +14,7 @@ If necessary, install "Gemcutter":http://gemcutter.org.
14
14
  Install test-rig
15
15
  <pre><code>sudo gem install test-rig</code></pre>
16
16
 
17
- Add @require 'testrig'@ to test_helper.rb, and @include TestRig@ into @Test::Unit:TestCase@.
17
+ Add @require 'test_rig'@ to test_helper.rb, and @include TestRig@ into @Test::Unit:TestCase@.
18
18
  If you only want dynamic assertions or smarter messages, @include TestRig::DynamicAssertions@
19
19
  or @include TestRig::SmarterMessage@ instead of @TestRig@.
20
20
 
@@ -80,6 +80,11 @@ In Test::Unit: <code>assert_not_equal "joe", @foo.user</code>
80
80
 
81
81
  With Dynamic assertions: <code>assert_not_user "joe", @foo</code>
82
82
 
83
+ h4. Everything else
84
+
85
+ <code>assert @foo.user.include?('j')</code>
86
+ <code>assert_not @foo.user.include?('z')</code>
87
+
83
88
  h2. Smarter Message
84
89
 
85
90
  My bane: "false did not equal true" -- What you really want to know is what
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -2,9 +2,14 @@ require 'active_support'
2
2
 
3
3
  module TestRig
4
4
  module SmarterMessage
5
+ mattr_writer :backtrace_regex
5
6
  mattr_accessor :context_lines
6
7
  @@context_lines = 2
7
8
 
9
+ def self.backtrace_regex
10
+ @@backtrace_regex ||= /_test\.rb/
11
+ end
12
+
8
13
  def self.included(klass)
9
14
  klass.class_eval do
10
15
  alias_method_chain :assert_block, :smarter_message
@@ -31,7 +36,10 @@ module TestRig
31
36
  end
32
37
 
33
38
  def relevant_traces(backtrace)
34
- backtrace.select { |trace| trace =~ /_test\.rb/}.reject{|trace| trace =~ /#{File.basename(__FILE__)}/}
39
+ backtrace.select do |trace|
40
+ trace =~ TestRig::SmarterMessage.backtrace_regex &&
41
+ trace !~ /#{File.basename(__FILE__)}/
42
+ end
35
43
  end
36
44
 
37
45
  def first_relevant_trace(backtrace)
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{test-rig}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jacob Rothstein"]
12
- s.date = %q{2009-11-30}
12
+ s.date = %q{2009-12-02}
13
13
  s.description = %q{TestRig supplies dynamic assertions and contextual failure messages}
14
14
  s.email = %q{github@jacobrothstein.com}
15
15
  s.extra_rdoc_files = [
@@ -52,3 +52,4 @@ Gem::Specification.new do |s|
52
52
  else
53
53
  end
54
54
  end
55
+
@@ -32,6 +32,19 @@ class SmarterMessageTest < Test::Unit::TestCase
32
32
  assert_match /-->.+assert false/, context_output[context]
33
33
  TestRig::SmarterMessage.context_lines = 2
34
34
  end
35
+
36
+ test 'backtrace scrubbing' do
37
+ TestRig::SmarterMessage.backtrace_regex = /test_helper/
38
+ e = assert_test_failure { assert false }
39
+ assert_equal 1, e.backtrace.size
40
+
41
+ TestRig::SmarterMessage.backtrace_regex = /assert_test_failure/
42
+ e = assert_test_failure { assert false }
43
+ assert_equal 1, e.backtrace.size
44
+
45
+ TestRig::SmarterMessage.backtrace_regex = nil
46
+ assert_equal /_test\.rb/, TestRig::SmarterMessage.backtrace_regex
47
+ end
35
48
  end
36
49
 
37
50
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-rig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Rothstein
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-30 00:00:00 -08:00
12
+ date: 2009-12-02 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15