What's wrong with requiring cucumber-rails outside of env.rb?

94 views
Skip to first unread message

Mikko Koski

unread,
Feb 15, 2014, 5:49:56 AM2/15/14
to cu...@googlegroups.com
Hi there!

What's wrong with requiring cucumber-rails outside of env.rb?

I have a file features/support/database_cleanup.rb which sets up database cleaning and during the suite execution it changes the database cleaner stragery (Cucumber::Rails::Database.javascript_strategy) depending on the scenario tags (@no-transaction). Everything works ok when I run cucumber but when I run cucumber --dry-run I get the "Cucumber-rails required outside of env.rb." error.

In my Gemfile the cucumber-rails is in group :test and it has the require: false as suggested in issue Github issue #227.

So my question is am I doing something wrong here when I'm requiring cucumber-rails outside of env.rb? If yes, how could I fix the issue? I could of course copy all the code from database_cleanup.rb to env.rb, but I'd rather not. A support file named database_cleanup.rb is imo a perfect place for a piece of code that's handling database cleaning setup.

Here are the file:


Thanks!

Kosmas

unread,
Feb 19, 2014, 6:40:34 AM2/19/14
to cu...@googlegroups.com

Mikko Koski

unread,
Feb 20, 2014, 5:02:24 AM2/20/14
to cu...@googlegroups.com
Thanks a lot! With the help of the first post I manged to solve the issue: The fix was to rename my database_cleanup.rb to env.database_cleanup.rb

As stated in the first post: "In dry run mode cucumber does not load files that match this regular expression: support\/env\..*" Is that an official documented feature? Or is it just a hack that happens to do what I need? In other words, can I trust that this "feature" won't break when update to new cucumber-rails version in the future?

Kosmas

unread,
Feb 21, 2014, 10:04:59 AM2/21/14
to cu...@googlegroups.com


On Thursday, 20 February 2014 11:02:24 UTC+1, Mikko Koski wrote:
On Wednesday, February 19, 2014 1:40:34 PM UTC+2, Kosmas wrote:


On Saturday, 15 February 2014 11:49:56 UTC+1, Mikko Koski wrote:
Hi there!

What's wrong with requiring cucumber-rails outside of env.rb?

I have a file features/support/database_cleanup.rb which sets up database cleaning and during the suite execution it changes the database cleaner stragery (Cucumber::Rails::Database.javascript_strategy) depending on the scenario tags (@no-transaction). Everything works ok when I run cucumber but when I run cucumber --dry-run I get the "Cucumber-rails required outside of env.rb." error.

In my Gemfile the cucumber-rails is in group :test and it has the require: false as suggested in issue Github issue #227.

So my question is am I doing something wrong here when I'm requiring cucumber-rails outside of env.rb? If yes, how could I fix the issue? I could of course copy all the code from database_cleanup.rb to env.rb, but I'd rather not. A support file named database_cleanup.rb is imo a perfect place for a piece of code that's handling database cleaning setup.

Here are the file:


Thanks!

Thanks a lot! With the help of the first post I manged to solve the issue: The fix was to rename my database_cleanup.rb to env.database_cleanup.rb

Good. Great that it solved your problem :-)

As stated in the first post: "In dry run mode cucumber does not load files that match this regular expression: support\/env\..*" Is that an official documented feature? Or is it just a hack that happens to do what I need? In other words, can I trust that this "feature" won't break when update to new cucumber-rails version in the future?

I'm afraid that I am not sure about the answer to your question.
Since I have only recently been involved with the cucumber-rails maintenance I cannot tell you about the previous design decisions.
Probably Matt or Aslak would be able to answer that.
As for the future, as long as I'm involved I'll keep this in mind.

Matt Wynne

unread,
Feb 23, 2014, 6:33:45 AM2/23/14
to cu...@googlegroups.com
On 21 Feb 2014, at 15:04, Kosmas <kos...@gmail.com> wrote:



On Thursday, 20 February 2014 11:02:24 UTC+1, Mikko Koski wrote:
On Wednesday, February 19, 2014 1:40:34 PM UTC+2, Kosmas wrote:


On Saturday, 15 February 2014 11:49:56 UTC+1, Mikko Koski wrote:
Hi there!

What's wrong with requiring cucumber-rails outside of env.rb?

I have a file features/support/database_cleanup.rb which sets up database cleaning and during the suite execution it changes the database cleaner stragery (Cucumber::Rails::Database.javascript_strategy) depending on the scenario tags (@no-transaction). Everything works ok when I run cucumber but when I run cucumber --dry-run I get the "Cucumber-rails required outside of env.rb." error.

In my Gemfile the cucumber-rails is in group :test and it has the require: false as suggested in issue Github issue #227.

So my question is am I doing something wrong here when I'm requiring cucumber-rails outside of env.rb? If yes, how could I fix the issue? I could of course copy all the code from database_cleanup.rb to env.rb, but I'd rather not. A support file named database_cleanup.rb is imo a perfect place for a piece of code that's handling database cleaning setup.

Here are the file:


Thanks!

Thanks a lot! With the help of the first post I manged to solve the issue: The fix was to rename my database_cleanup.rb to env.database_cleanup.rb

Good. Great that it solved your problem :-)

As stated in the first post: "In dry run mode cucumber does not load files that match this regular expression: support\/env\..*" Is that an official documented feature? Or is it just a hack that happens to do what I need? In other words, can I trust that this "feature" won't break when update to new cucumber-rails version in the future?

This is a feature of Cucumber, not Cucumber Rails.

There's a chance this might break at some point in the future - I find the loading mechanisms for Cucumber a bit arcane at times and it's something we may revisit, but you'll be seeing a major version bump and plenty of fanfare if we ever do.

I'm afraid that I am not sure about the answer to your question.
Since I have only recently been involved with the cucumber-rails maintenance I cannot tell you about the previous design decisions.
Probably Matt or Aslak would be able to answer that.
As for the future, as long as I'm involved I'll keep this in mind.

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

cheers,
Matt

--
twitter: @mattwynne
skype: mattwynne
google hangouts: matt....@gmail.com

signature.asc

Mikko Koski

unread,
Feb 24, 2014, 2:20:33 AM2/24/14
to cu...@googlegroups.com


On Sunday, February 23, 2014 1:33:45 PM UTC+2, Matt Wynne wrote:

On 21 Feb 2014, at 15:04, Kosmas <kos...@gmail.com> wrote:



On Thursday, 20 February 2014 11:02:24 UTC+1, Mikko Koski wrote:
On Wednesday, February 19, 2014 1:40:34 PM UTC+2, Kosmas wrote:


On Saturday, 15 February 2014 11:49:56 UTC+1, Mikko Koski wrote:
Hi there!

What's wrong with requiring cucumber-rails outside of env.rb?

I have a file features/support/database_cleanup.rb which sets up database cleaning and during the suite execution it changes the database cleaner stragery (Cucumber::Rails::Database.javascript_strategy) depending on the scenario tags (@no-transaction). Everything works ok when I run cucumber but when I run cucumber --dry-run I get the "Cucumber-rails required outside of env.rb." error.

In my Gemfile the cucumber-rails is in group :test and it has the require: false as suggested in issue Github issue #227.

So my question is am I doing something wrong here when I'm requiring cucumber-rails outside of env.rb? If yes, how could I fix the issue? I could of course copy all the code from database_cleanup.rb to env.rb, but I'd rather not. A support file named database_cleanup.rb is imo a perfect place for a piece of code that's handling database cleaning setup.

Here are the file:


Thanks!

Thanks a lot! With the help of the first post I manged to solve the issue: The fix was to rename my database_cleanup.rb to env.database_cleanup.rb

Good. Great that it solved your problem :-)

As stated in the first post: "In dry run mode cucumber does not load files that match this regular expression: support\/env\..*" Is that an official documented feature? Or is it just a hack that happens to do what I need? In other words, can I trust that this "feature" won't break when update to new cucumber-rails version in the future?

This is a feature of Cucumber, not Cucumber Rails.

There's a chance this might break at some point in the future - I find the loading mechanisms for Cucumber a bit arcane at times and it's something we may revisit, but you'll be seeing a major version bump and plenty of fanfare if we ever do.

Ok, thank you for your answers!

-- 
Mikko 
Reply all
Reply to author
Forward
0 new messages