assert 0.7.0 → 0.7.1

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.
data/CHANGELOG.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  == Assert Changes
2
2
 
3
- === v0.7.0
3
+ === v0.7.x
4
4
  * tests know context info (klass, called_from, file) (#62)
5
5
  * suites track tests ungrouped
6
6
  * fixed issue where method macros display incorrect fail traces
@@ -17,5 +17,5 @@
17
17
  * overhaul to how the rake tasks are generated and handled (#69)
18
18
  * added name attr to Result model (#61)
19
19
 
20
- === v0.6.0
20
+ === v0.6.x
21
21
  * everything prior to changelog tracking...
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assert (0.7.0)
4
+ assert (0.7.1)
5
5
  assert-view (~> 0.4)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  ansi (1.3.0)
11
- assert-view (0.4.0)
11
+ assert-view (0.4.1)
12
12
  ansi (~> 1.3)
13
13
  undies (~> 1.1)
14
14
  rake (0.9.2)
@@ -18,7 +18,6 @@ module Assert
18
18
  # capture any context info, build a test obj, and add it to the suite
19
19
  def self.method_added(method_name)
20
20
  if method_name.to_s =~ Suite::TEST_METHOD_REGEX
21
- called_from = caller.first
22
21
  klass_method_name = "#{self}##{method_name}"
23
22
 
24
23
  if Assert.suite.test_methods.include?(klass_method_name)
@@ -28,7 +27,7 @@ module Assert
28
27
  Assert.suite.test_methods << klass_method_name
29
28
  end
30
29
 
31
- ci = Suite::ContextInfo.new(self, called_from)
30
+ ci = Suite::ContextInfo.new(self, nil, caller.first)
32
31
  Assert.suite.tests << Test.new(method_name.to_s, ci, method_name)
33
32
  end
34
33
  end
@@ -113,8 +112,7 @@ module Assert
113
112
  end
114
113
  end
115
114
 
116
- def test(desc_or_macro, called_from=nil, &block)
117
- called_from ||= caller.first
115
+ def test(desc_or_macro, called_from=nil, first_caller=nil, &block)
118
116
  if desc_or_macro.kind_of?(Macro)
119
117
  instance_eval(&desc_or_macro)
120
118
  else
@@ -123,27 +121,25 @@ module Assert
123
121
  # if no block given, create a test that just skips
124
122
  method_block = block_given? ? block : (Proc.new { skip })
125
123
 
126
- ci = Suite::ContextInfo.new(self, called_from)
124
+ ci = Suite::ContextInfo.new(self, called_from, first_caller || caller.first)
127
125
  Assert.suite.tests << Test.new(method_name, ci, &method_block)
128
126
  end
129
127
  end
130
128
 
131
- def test_eventually(desc_or_macro, called_from=nil, &block)
132
- called_from ||= caller.first
133
- test(desc_or_macro, called_from)
129
+ def test_eventually(desc_or_macro, called_from=nil, first_caller=nil, &block)
130
+ test(desc_or_macro, called_from, first_caller || caller.first)
134
131
  end
135
132
  alias_method :test_skip, :test_eventually
136
133
 
137
- def should(desc_or_macro, called_from=nil, &block)
138
- called_from ||= caller.first
134
+ def should(desc_or_macro, called_from=nil, first_caller=nil, &block)
139
135
  if !desc_or_macro.kind_of?(Macro)
140
136
  desc_or_macro = "should #{desc_or_macro}"
141
137
  end
142
- test(desc_or_macro, called_from, &block)
138
+ test(desc_or_macro, called_from, first_caller || caller.first, &block)
143
139
  end
144
140
 
145
- def should_eventually(desc_or_macro, called_from=nil, &block)
146
- should(desc_or_macro, called_from)
141
+ def should_eventually(desc_or_macro, called_from=nil, first_caller=nil, &block)
142
+ should(desc_or_macro, called_from, first_caller || caller.first)
147
143
  end
148
144
  alias_method :should_skip, :should_eventually
149
145
 
data/lib/assert/result.rb CHANGED
@@ -165,7 +165,7 @@ module Assert::Result
165
165
 
166
166
  # override of the base, show the test's context info called_from
167
167
  def trace
168
- self.test.context_info.called_from
168
+ self.test.context_info.called_from || super
169
169
  end
170
170
 
171
171
  end
data/lib/assert/suite.rb CHANGED
@@ -5,13 +5,14 @@ module Assert
5
5
 
6
6
  class ContextInfo
7
7
 
8
- attr_reader :klass, :called_from, :file
8
+ attr_reader :called_from, :first_caller, :klass, :file
9
9
 
10
- def initialize(klass, called_from=nil)
11
- @klass = klass
10
+ def initialize(klass, called_from=nil, first_caller=nil)
11
+ @first_caller = first_caller
12
12
  @called_from = called_from
13
- @file = if called_from
14
- called_from.gsub(/\:[0-9]+.*$/, '')
13
+ @klass = klass
14
+ @file = if (@called_from || @first_caller)
15
+ (@called_from || @first_caller).gsub(/\:[0-9]+.*$/, '')
15
16
  end
16
17
  end
17
18
 
@@ -1,3 +1,3 @@
1
1
  module Assert
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
data/test/helper.rb CHANGED
@@ -17,7 +17,7 @@ TEST_ASSERT_SUITE = Assert::Suite.new
17
17
  class TestContext < Assert::Context
18
18
  def self.method_added(meth)
19
19
  if meth.to_s =~ Assert::Suite::TEST_METHOD_REGEX
20
- ci = Assert::Suite::ContextInfo.new(self, Assert.suite.current_caller_info)
20
+ ci = Assert::Suite::ContextInfo.new(self, Factory.context_info_called_from)
21
21
  TEST_ASSERT_SUITE.tests << Assert::Test.new(meth.to_s, ci, meth)
22
22
  end
23
23
  end
@@ -7,18 +7,18 @@ class Assert::Suite::ContextInfo
7
7
  setup do
8
8
  @caller = caller
9
9
  @klass = Assert::Context
10
- @info = Assert::Suite::ContextInfo.new(@klass, @caller.first)
10
+ @info = Assert::Suite::ContextInfo.new(@klass, nil, @caller.first)
11
11
  end
12
12
  subject { @info }
13
13
 
14
- should have_readers :klass, :called_from, :file
14
+ should have_readers :called_from, :first_caller, :klass, :file
15
15
 
16
16
  should "set its klass on init" do
17
17
  assert_equal @klass, subject.klass
18
18
  end
19
19
 
20
20
  should "set its called_from to the first caller on init" do
21
- assert_equal @caller.first, subject.called_from
21
+ assert_equal @caller.first, subject.first_caller
22
22
  end
23
23
 
24
24
  should "set its file from caller info on init" do
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: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 0
10
- version: 0.7.0
9
+ - 1
10
+ version: 0.7.1
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: 2011-10-11 00:00:00 Z
19
+ date: 2011-10-13 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  type: :development