assert 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,7 +49,7 @@ module Assert::Result
49
49
  end
50
50
 
51
51
  def trace
52
- self.backtrace.filtered.first.to_s
52
+ (self.backtrace.filtered.first || self.test.context_info.called_from).to_s
53
53
  end
54
54
 
55
55
  def ==(other)
@@ -107,11 +107,6 @@ module Assert::Result
107
107
  "Fail"
108
108
  end
109
109
 
110
- # override of the base, show the test's context info called_from
111
- def trace
112
- self.test.context_info.called_from || super
113
- end
114
-
115
110
  end
116
111
 
117
112
  # raised by the 'skip' context helper to break test execution
@@ -135,11 +130,6 @@ module Assert::Result
135
130
  "Skip"
136
131
  end
137
132
 
138
- # override of the base, show the test's context info called_from
139
- def trace
140
- self.test.context_info.called_from || super
141
- end
142
-
143
133
  end
144
134
 
145
135
  class Error < Base
@@ -191,42 +181,17 @@ module Assert::Result
191
181
  def to_s; self.join("\n"); end
192
182
 
193
183
  def filtered
194
- new_bt = []
195
-
196
- self.each do |line|
197
- break if filter_out?(line)
198
- new_bt << line
199
- end
200
-
201
- new_bt = self.reject { |line| filter_out?(line) } if new_bt.empty?
202
- new_bt = self.dup if new_bt.empty?
203
-
204
- self.class.new(new_bt)
184
+ self.class.new(self.reject { |line| filter_out?(line) })
205
185
  end
206
186
 
207
187
  protected
208
188
 
209
- # filter a line out if it's an assert lib line
210
-
189
+ # filter a line out if it's an assert lib/bin line
211
190
  def filter_out?(line)
212
- # from minitest (for reference)...
213
- # file = File.expand_path __FILE__
214
- # if RUBY_VERSION =~ /^1\.9/ then # bt's expanded, but __FILE__ isn't :(
215
- # File.expand_path __FILE__
216
- # elsif __FILE__ =~ /^[^\.]/ then # assume both relative
217
- # require 'pathname'
218
- # pwd = Pathname.new Dir.pwd
219
- # pn = Pathname.new File.expand_path(__FILE__)
220
- # relpath = pn.relative_path_from(pwd) rescue pn
221
- # pn = File.join ".", relpath unless pn.relative?
222
- # pn.to_s
223
- # else # assume both are expanded
224
- # __FILE__
225
- # end
226
-
227
191
  # './lib' in project dir, or '/usr/local/blahblah' if installed
228
192
  assert_lib_path = File.expand_path('../..', __FILE__)
229
- line.rindex(assert_lib_path, 0)
193
+ assert_bin_regex = /bin\/assert\:/
194
+ line.rindex(assert_lib_path, 0) || line =~ assert_bin_regex
230
195
  end
231
196
  end
232
197
 
@@ -1,3 +1,3 @@
1
1
  module Assert
2
- VERSION = "2.1.1"
2
+ VERSION = "2.1.2"
3
3
  end
@@ -98,7 +98,7 @@ class Assert::Context
98
98
 
99
99
  should "create a fail result and set its backtrace" do
100
100
  assert_kind_of Assert::Result::Fail, subject
101
- assert_equal Factory.context_info_called_from, subject.trace
101
+ assert_equal subject.backtrace.filtered.first, subject.trace
102
102
  assert_kind_of Array, subject.backtrace
103
103
  end
104
104
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 1
10
- version: 2.1.1
9
+ - 2
10
+ version: 2.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-04-30 00:00:00 Z
19
+ date: 2013-05-02 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: ansi