[rspec-devel] [ rspec-Patches-12817 ] Cannot include same shared behaviour when required with absolute paths.

noreply at rubyforge.org noreply at rubyforge.org
Sat Aug 4 09:29:07 EDT 2007


Patches item #12817, was opened at 2007-08-04 13:10
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=12817&group_id=797

Category: None
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 3
Submitted By: Ian Leitch (idl)
>Assigned to: David Chelimsky (dchelimsky)
Summary: Cannot include same shared behaviour when required with absolute paths.

Initial Comment:
When trying to require a file containing a shared behavior with an absolute path different from the first require, RSpec raises an ArgumentError.

Due to the fact that we run 'rake spec' from the base of our Rails apps, all require statements in our specs are prefixed with File.dirname(__FILE__), e.g.:

require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/../email_template_view_helper'

Here email_template_view_helper contains a shared helper, yet when included by different specs IN DIFFERENT DIRECTORIES, the ArgumentError is raised.

The attached patch fixes this issue.



----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-08-04 13:29

Message:
Nice - I did modify it a bit because this patch would cause behaviours from different files with the same names to NOT raise an error (which we'd actually want):

/path/to/my/spec.rb
/path/to/another/spec.rb

I added an example expecting an error in that situation and it failed. Using File.expand_path instead of File.basename got it to pass along with the other examples.

Applied to r2240.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=12817&group_id=797


More information about the rspec-devel mailing list