You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given that I have RSpec 1.3.0 and 2.0.0.beta.17 installed
And this code is in rspec_example.rb:
require 'rubygems'
if ENV['RSPEC_VERSION'] == '2'
require 'rspec'
elsif ENV['RSPEC_VERSION'] == '1'
require 'spec'
require 'spec/autorun'
end
describe Array do
subject { [1, 'a'] }
its(:last) { should == 'a' }
describe '.first' do
def subject; super.first; end
its(:next) { should == 2 }
end
end
When I run it with RSPEC_VERSION=1 ruby rspec_example.rb
Then I see:
..
Finished in 0.002495 seconds
2 examples, 0 failures
When I run it with RSPEC_VERSION=2 ruby rspec_example.rb
Then I see:
.F
Finished in 0.00171 seconds
2 examples, 1 failure
1) Array .first next
Failure/Error: Unable to find matching line from backtrace
undefined method `next' for [1, "a"]:Array
# rspec_example.rb:16:in `subject'
# rspec_example.rb:18
# rspec_example.rb:10
Yes, this is a super contrived example. If you're interested in a real world example, see these specs.
This may not have been documented behavior of rspec 1.x, but it intuitively made sense to me--I understood subject { [1, 'a'] } to create a helper method called subject that returns the given array, and the nested example is a subclass, so I could override subject and super to the original definition.
I know I can use its('first.next') { should == 2 } now in rspec 2, but this seems like a backwards incompatibility with rspec 1.3 that should be either fixed or documented.
The text was updated successfully, but these errors were encountered:
Don't be too impressed. Or rather, don't set future expectations too high :) I'm just trying to get rspec-2 ready for a production release right now, so this and the book get primary focus these days.
timcharper
pushed a commit
to timcharper/rspec-core
that referenced
this issue
Aug 19, 2011
Given that I have RSpec 1.3.0 and 2.0.0.beta.17 installed
And this code is in rspec_example.rb:
When I run it with
RSPEC_VERSION=1 ruby rspec_example.rb
Then I see:
When I run it with
RSPEC_VERSION=2 ruby rspec_example.rb
Then I see:
Yes, this is a super contrived example. If you're interested in a real world example, see these specs.
This may not have been documented behavior of rspec 1.x, but it intuitively made sense to me--I understood
subject { [1, 'a'] }
to create a helper method calledsubject
that returns the given array, and the nested example is a subclass, so I could override subject and super to the original definition.I know I can use
its('first.next') { should == 2 }
now in rspec 2, but this seems like a backwards incompatibility with rspec 1.3 that should be either fixed or documented.The text was updated successfully, but these errors were encountered: