> --
> You received this message because you are subscribed to the Google Groups "Cukes" group.
> To post to this group, send email to cu...@googlegroups.com.
> To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
cheers,
Matt
To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
Ruby doesn't provide a way to ask the runtime: "has this file been
required before?", so Cucumber can't be intelligent about this.
If you want explicit loading and not automatic loading, just put your
files outside the features folder.
Aslak
I have attached a case which demonstrates my problem. Basically, I define one World mixin in mixin1.rb and another in mixin2.rb. In order to require them from env.rb I add the support directory to $LOAD_PATH. Basically, requiring them works, but they are loaded for the second time later by Cucumber.I'm guessing that Ruby/Cucumber don't understand that the files have already been loaded due to their being referred to by different pathnames (by env.rb and Cucumber). Maybe Cucumber needs to be more intelligent and avoid reloading files?
ThanksArve
<features.zip>
On 8 Sep 2010, at 12:42, Arve Knudsen wrote:I have attached a case which demonstrates my problem. Basically, I define one World mixin in mixin1.rb and another in mixin2.rb. In order to require them from env.rb I add the support directory to $LOAD_PATH. Basically, requiring them works, but they are loaded for the second time later by Cucumber.I'm guessing that Ruby/Cucumber don't understand that the files have already been loaded due to their being referred to by different pathnames (by env.rb and Cucumber). Maybe Cucumber needs to be more intelligent and avoid reloading files?
ThanksArveAre you using File.expand_path? If so, doesn't ruby know to not include them a second time when Cucumber calls Kernel#require ?
Actually, I think ruby 1.9 does expand_path on everything before
loading, and therefore has better caching than 1.8 (I might be wrong).
But all the smarts are inside Kernel.require - as I mentioned in my
other reply, ruby code can't know whether Kernel.require will actually
load a file or not.
Aslak
> On Wed, Sep 8, 2010 at 3:35 PM, Matt Wynne <ma...@mattwynne.net> wrote:
>>
>> On 8 Sep 2010, at 12:42, Arve Knudsen wrote:
>>
>> I have attached a case which demonstrates my problem. Basically, I define
>> one World mixin in mixin1.rb and another in mixin2.rb. In order to require
>> them from env.rb I add the support directory to $LOAD_PATH. Basically,
>> requiring them works, but they are loaded for the second time later by
>> Cucumber.
>> I'm guessing that Ruby/Cucumber don't understand that the files have already
>> been loaded due to their being referred to by different pathnames (by env.rb
>> and Cucumber). Maybe Cucumber needs to be more intelligent and avoid
>> reloading files?
>>
>> Thanks
>> Arve
>>
>> Are you using File.expand_path? If so, doesn't ruby know to not include them
>> a second time when Cucumber calls Kernel#require ?
>>
>
> Actually, I think ruby 1.9 does expand_path on everything before
> loading, and therefore has better caching than 1.8 (I might be wrong).
> But all the smarts are inside Kernel.require - as I mentioned in my
> other reply, ruby code can't know whether Kernel.require will actually
> load a file or not.
But the ruby code should be able to assume the file won't be loaded twice, as long as you give Kernel#require an expanded path, right?
Arve, maybe you're adding an un-necesary slash in there? Or maybe Cucumber isn't expanding paths properly?
Arve, if you run cucumber with -v you'll see it dump out all the files it loads. Try that, along with a puts statement in your env.rb to show the path being required by your code.
On 8 Sep 2010, at 14:43, aslak hellesoy wrote:
> On Wed, Sep 8, 2010 at 3:35 PM, Matt Wynne <ma...@mattwynne.net> wrote:
>>
>> On 8 Sep 2010, at 12:42, Arve Knudsen wrote:
>>
>> I have attached a case which demonstrates my problem. Basically, I define
>> one World mixin in mixin1.rb and another in mixin2.rb. In order to require
>> them from env.rb I add the support directory to $LOAD_PATH. Basically,
>> requiring them works, but they are loaded for the second time later by
>> Cucumber.
>> I'm guessing that Ruby/Cucumber don't understand that the files have already
>> been loaded due to their being referred to by different pathnames (by env.rb
>> and Cucumber). Maybe Cucumber needs to be more intelligent and avoid
>> reloading files?
>>
>> Thanks
>> Arve
>>
>> Are you using File.expand_path? If so, doesn't ruby know to not include them
>> a second time when Cucumber calls Kernel#require ?
>>
>
> Actually, I think ruby 1.9 does expand_path on everything before
> loading, and therefore has better caching than 1.8 (I might be wrong).
> But all the smarts are inside Kernel.require - as I mentioned in my
> other reply, ruby code can't know whether Kernel.require will actually
> load a file or not.
Arve, maybe you're adding an un-necesary slash in there? Or maybe Cucumber isn't expanding paths properly?
Arve, if you run cucumber with -v you'll see it dump out all the files it loads. Try that, along with a puts statement in your env.rb to show the path being required by your code.
1.9 will, but 1.8 won't.
Okay, so there really isn't anything Cucumber can do here, unless we added a 'don't auto-load' command-line switch, which seems like a bit of an edge case.
Arve it sounds like your workaround is either to require the files fully, without modifying $LOAD_PATH, or to start using Ruby 1.9. Are you happy with that?
Did you miss my suggestion further up in this thread? Just put those
files outside features and require them explicitly. Then they won't
get autoloaded by Cucumber.
Aslak