rspec-expectations 2.0.0.beta.4 → 2.0.0.beta.5

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/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.beta.4
1
+ 2.0.0.beta.5
@@ -45,7 +45,7 @@ Feature: customized message
45
45
  end
46
46
 
47
47
  """
48
- When I run "rspec node_spec.rb --format n"
48
+ When I run "rspec node_spec.rb --format documentation"
49
49
  Then I should see "3 examples, 3 failures"
50
50
  And I should not see "to return true, got false"
51
51
  And I should not see "to return false, got true"
@@ -1,12 +1,20 @@
1
- @wip
2
1
  Feature: access running example
3
2
 
4
- Scenario: matcher defined via DSL
3
+ In order to take advantage of services that are available
4
+ in my examples when I'm writing matchers
5
+ As a spec author
6
+ I want to call methods on the running example
7
+
8
+ If the method exists in the context of the example, it gets
9
+ called. If not, a NoMethodError is raised on the Matcher itself
10
+ (not the example).
11
+
12
+ Scenario: call method defined on example from matcher
5
13
  Given a file named "example_spec.rb" with:
6
14
  """
7
15
  Rspec::Matchers.define :bar do
8
16
  match do |_|
9
- running_example.foo == "foo"
17
+ foo == "foo"
10
18
  end
11
19
  end
12
20
 
@@ -22,27 +30,24 @@ Feature: access running example
22
30
  """
23
31
  When I run "rspec example_spec.rb"
24
32
  Then I should see "1 example, 0 failures"
25
-
26
- Scenario: matcher defined via #new
33
+
34
+ Scenario: call method _not_ defined on example from matcher
27
35
  Given a file named "example_spec.rb" with:
28
36
  """
29
- describe "something" do
30
- def bar
31
- Rspec::Matchers::Matcher.new :bar do
32
- match do |_|
33
- running_example.foo == "foo"
34
- end
35
- end
36
- end
37
-
38
- def foo
39
- "foo"
37
+ Rspec::Matchers.define :bar do
38
+ match do |_|
39
+ foo == "foo"
40
40
  end
41
+ end
41
42
 
43
+ describe "something" do
42
44
  it "does something" do
43
45
  "foo".should bar
44
46
  end
45
47
  end
46
48
  """
47
49
  When I run "rspec example_spec.rb"
48
- Then I should see "1 example, 0 failures"
50
+ Then I should see "1 example, 1 failure"
51
+ And I should see "undefined local variable"
52
+ And I should see "Rspec::Matchers::Matcher"
53
+ And I should not see "ExampleGroup"
@@ -34,7 +34,7 @@ Feature: define matcher
34
34
  end
35
35
 
36
36
  """
37
- When I run "rspec matcher_with_default_message_spec.rb --format specdoc"
37
+ When I run "rspec matcher_with_default_message_spec.rb --format documentation"
38
38
  Then the exit status should not be 0
39
39
 
40
40
  And I should see "should be a multiple of 3"
@@ -116,7 +116,7 @@ Feature: define matcher
116
116
  it {should_not be_a_multiple_of(4)}
117
117
  end
118
118
  """
119
- When I run "rspec matcher_overriding_description_spec.rb --format specdoc"
119
+ When I run "rspec matcher_overriding_description_spec.rb --format documentation"
120
120
  Then the exit status should be 0
121
121
  And the stdout should contain "2 examples, 0 failures"
122
122
  And the stdout should contain "should be multiple of 3"
@@ -141,7 +141,7 @@ Feature: define matcher
141
141
  it {should have_7_fingers}
142
142
  end
143
143
  """
144
- When I run "rspec matcher_with_no_args_spec.rb --format specdoc"
144
+ When I run "rspec matcher_with_no_args_spec.rb --format documentation"
145
145
  Then the exit status should be 0
146
146
  And the stdout should contain "1 example, 0 failures"
147
147
  And the stdout should contain "should have 7 fingers"
@@ -161,7 +161,7 @@ Feature: define matcher
161
161
  it {should be_the_sum_of(1,2,3,4)}
162
162
  end
163
163
  """
164
- When I run "rspec matcher_with_multiple_args_spec.rb --format specdoc"
164
+ When I run "rspec matcher_with_multiple_args_spec.rb --format documentation"
165
165
  Then the exit status should be 0
166
166
  And the stdout should contain "1 example, 0 failures"
167
167
  And the stdout should contain "should be the sum of 1, 2, 3, and 4"
@@ -22,6 +22,6 @@ Feature: define matcher
22
22
  it { should be_bigger_than(4).but_smaller_than(6) }
23
23
  end
24
24
  """
25
- When I run "rspec between_spec.rb --format specdoc"
25
+ When I run "rspec between_spec.rb --format documentation"
26
26
  Then I should see "1 example, 0 failures"
27
27
  And I should see "should be bigger than 4"
@@ -4,6 +4,7 @@ module Rspec
4
4
  # See Rspec::Matchers
5
5
  def define(name, &declarations)
6
6
  define_method name do |*expected|
7
+ $matcher_execution_context = self
7
8
  Rspec::Matchers::Matcher.new name, *expected, &declarations
8
9
  end
9
10
  end
@@ -22,11 +22,6 @@ module Rspec
22
22
  end
23
23
  end
24
24
 
25
- def instance_exec(*args, &block)
26
- self.running_example ||= eval("running_example", block.binding) rescue nil
27
- super(*args, &block)
28
- end
29
-
30
25
  #Used internally by objects returns by +should+ and +should_not+.
31
26
  def matches?(actual)
32
27
  @actual = actual
@@ -92,10 +87,15 @@ module Rspec
92
87
  end
93
88
  end
94
89
 
95
- protected
96
- attr_accessor :running_example
97
-
98
90
  private
91
+
92
+ def method_missing(name, *args, &block)
93
+ if $matcher_execution_context.respond_to?(name)
94
+ $matcher_execution_context.send name, *args, &block
95
+ else
96
+ super(name, *args, &block)
97
+ end
98
+ end
99
99
 
100
100
  def making_declared_methods_public # :nodoc:
101
101
  # Our home-grown instance_exec in ruby 1.8.6 results in any methods
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec-expectations}
8
- s.version = "2.0.0.beta.4"
8
+ s.version = "2.0.0.beta.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Chelimsky", "Chad Humphries"]
12
- s.date = %q{2010-03-15}
12
+ s.date = %q{2010-04-04}
13
13
  s.description = %q{rspec expectations (should[_not] and matchers)}
14
14
  s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -109,7 +109,7 @@ Gem::Specification.new do |s|
109
109
  s.homepage = %q{http://github.com/rspec/expectations}
110
110
  s.post_install_message = %q{**************************************************
111
111
 
112
- Thank you for installing rspec-expectations-2.0.0.beta.4
112
+ Thank you for installing rspec-expectations-2.0.0.beta.5
113
113
 
114
114
  This is beta software. If you are looking
115
115
  for a supported production release, please
@@ -121,7 +121,7 @@ Gem::Specification.new do |s|
121
121
  s.require_paths = ["lib"]
122
122
  s.rubyforge_project = %q{rspec}
123
123
  s.rubygems_version = %q{1.3.6}
124
- s.summary = %q{rspec-expectations-2.0.0.beta.4}
124
+ s.summary = %q{rspec-expectations-2.0.0.beta.5}
125
125
  s.test_files = [
126
126
  "spec/rspec/expectations/differs/default_spec.rb",
127
127
  "spec/rspec/expectations/extensions/kernel_spec.rb",
@@ -163,19 +163,19 @@ Gem::Specification.new do |s|
163
163
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
164
164
  s.add_development_dependency(%q<cucumber>, [">= 0.6.2"])
165
165
  s.add_development_dependency(%q<aruba>, [">= 0.1.1"])
166
- s.add_development_dependency(%q<rspec-core>, [">= 2.0.0.beta.4"])
167
- s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.4"])
166
+ s.add_development_dependency(%q<rspec-core>, [">= 2.0.0.beta.5"])
167
+ s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.5"])
168
168
  else
169
169
  s.add_dependency(%q<cucumber>, [">= 0.6.2"])
170
170
  s.add_dependency(%q<aruba>, [">= 0.1.1"])
171
- s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.4"])
172
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.4"])
171
+ s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.5"])
172
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.5"])
173
173
  end
174
174
  else
175
175
  s.add_dependency(%q<cucumber>, [">= 0.6.2"])
176
176
  s.add_dependency(%q<aruba>, [">= 0.1.1"])
177
- s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.4"])
178
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.4"])
177
+ s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.5"])
178
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.5"])
179
179
  end
180
180
  end
181
181
 
@@ -286,37 +286,32 @@ module Rspec
286
286
  end
287
287
 
288
288
  context "defined using the dsl" do
289
- it "can access the running_example" do
289
+ def a_method_in_the_example
290
+ "method defined in the example"
291
+ end
292
+
293
+ it "can access methods in the running_example" do
290
294
  Rspec::Matchers.define(:__access_running_example) do
291
295
  match do |actual|
292
- actual == running_example
296
+ a_method_in_the_example == "method defined in the example"
293
297
  end
294
298
  end
295
299
  running_example.should __access_running_example
296
300
  end
297
- end
298
-
299
- context "defined using #new" do
300
- it "can access the running_example" do
301
- @matcher = Rspec::Matchers::Matcher.new(:something) {}
302
- @matcher.send(:running_example).should eq(running_example)
303
- end
304
- end
305
301
 
306
- context "wrapped in a method" do
307
-
308
- def access_running_example
309
- Matcher.new(:access_running_example) do
302
+ it "raises NoMethodError for methods not in the running_example" do
303
+ Rspec::Matchers.define(:__raise_no_method_error) do
310
304
  match do |actual|
311
- actual == running_example
305
+ a_method_not_in_the_example == "method defined in the example"
312
306
  end
313
307
  end
314
- end
315
-
316
- it "can access the running_example" do
317
- running_example.should access_running_example
308
+
309
+ expect do
310
+ running_example.should __raise_no_method_error
311
+ end.to raise_error(/Rspec::Matchers::Matcher/)
318
312
  end
319
313
  end
314
+
320
315
  end
321
316
  end
322
317
  end
metadata CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
7
7
  - 0
8
8
  - 0
9
9
  - beta
10
- - 4
11
- version: 2.0.0.beta.4
10
+ - 5
11
+ version: 2.0.0.beta.5
12
12
  platform: ruby
13
13
  authors:
14
14
  - David Chelimsky
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-03-15 00:00:00 -05:00
20
+ date: 2010-04-04 00:00:00 -03:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -60,8 +60,8 @@ dependencies:
60
60
  - 0
61
61
  - 0
62
62
  - beta
63
- - 4
64
- version: 2.0.0.beta.4
63
+ - 5
64
+ version: 2.0.0.beta.5
65
65
  type: :development
66
66
  version_requirements: *id003
67
67
  - !ruby/object:Gem::Dependency
@@ -76,8 +76,8 @@ dependencies:
76
76
  - 0
77
77
  - 0
78
78
  - beta
79
- - 4
80
- version: 2.0.0.beta.4
79
+ - 5
80
+ version: 2.0.0.beta.5
81
81
  type: :development
82
82
  version_requirements: *id004
83
83
  description: rspec expectations (should[_not] and matchers)
@@ -185,7 +185,7 @@ licenses: []
185
185
  post_install_message: |
186
186
  **************************************************
187
187
 
188
- Thank you for installing rspec-expectations-2.0.0.beta.4
188
+ Thank you for installing rspec-expectations-2.0.0.beta.5
189
189
 
190
190
  This is beta software. If you are looking
191
191
  for a supported production release, please
@@ -219,7 +219,7 @@ rubyforge_project: rspec
219
219
  rubygems_version: 1.3.6
220
220
  signing_key:
221
221
  specification_version: 3
222
- summary: rspec-expectations-2.0.0.beta.4
222
+ summary: rspec-expectations-2.0.0.beta.5
223
223
  test_files:
224
224
  - spec/rspec/expectations/differs/default_spec.rb
225
225
  - spec/rspec/expectations/extensions/kernel_spec.rb