[Ruby on Rails] Wants to load Rails-3 project models in cucumber for database transactions

74 views
Skip to first unread message

jitendra....@gmail.com

unread,
Mar 24, 2013, 2:44:08 PM3/24/13
to cu...@googlegroups.com
My project is in Rails 3.  I am using latest version of cucumber gem for writing cukes to test my app which is hosted on QA env (i.e external url). And for that I have feature , feature/support/env.rb and feature/step_definition directory in my project root directory. I am using cucumber for outline my scenarios with other gems like capybara or rest-client for implementing steps.

It works fine till I don't want to do database transaction. Even for database transaction I can connect to database and execute my SQL query.  But I want to do it Rails way, so that I can reuse my existing models defined in my rails project for database transaction; And for that I need to load Rails environment when my cukes start executing test cases.

I don't want to use cucumber-rails gem because it clean my QA env database. Because I also want to use same QA env for manual testing some time so I don't want it to clean up my data on the database. My test cases are written in such as way that it won't be affected by existing data in the database.

So, Is there any way to load my project Rails environment when I execute bundle execute cucumber ....?

Perry Smith

unread,
Mar 24, 2013, 11:01:26 PM3/24/13
to cu...@googlegroups.com
I thought cucumber-rails did not directly clean the database.  It calls database_cleaner if it is installed.  If it is not installed, then it will not use it.

Also, IIRC you can set database_cleaner to use the null method

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
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 https://groups.google.com/d/forum/cukes?hl=en
---
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.
 
 

jitendra....@gmail.com

unread,
Mar 25, 2013, 5:02:56 AM3/25/13
to cu...@googlegroups.com
Actually , the project is also using rspec gem for unit testing and that requires database_cleaner gem. So, I can't remove database_cleaner.
So I have set the database_cleaner strategy to nill.

Thanks! its worked.
Message has been deleted

jitendra....@gmail.com

unread,
Mar 25, 2013, 5:14:16 AM3/25/13
to cu...@googlegroups.com
Now after successful execution of cucumber test cases I getting below error. But if any test case failed then I don't get this error. This irritating. I am not using any where test-unit in env.rb ... Is this a bug in  cucumber-rails-1.3.1/lib/cucumber/rails/world.rb:13:in `initialize':  ?

1 scenario (1 passed)
1 step (1 passed)
0m5.522s
/home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/cucumber-rails-1.3.1/lib/cucumber/rails/world.rb:13:in `initialize': wrong number of arguments (1 for 0) (ArgumentError)
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/testsuitecreator.rb:38:in `new'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/testsuitecreator.rb:38:in `append_test'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/testsuitecreator.rb:32:in `create'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/testcase.rb:139:in `suite'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/collector.rb:60:in `block in add_test_case'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/collector.rb:59:in `each'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/collector.rb:59:in `add_test_case'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/collector.rb:35:in `block in add_test_cases'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/collector.rb:34:in `each'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/collector.rb:34:in `add_test_cases'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/collector/descendant.rb:13:in `collect'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/autorunner.rb:84:in `block in <class:AutoRunner>'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/autorunner.rb:400:in `[]'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/autorunner.rb:400:in `run'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit/autorunner.rb:59:in `run'
    from /home/jitendra/.rvm/gems/ruby-1.9.3-p327@myproj/gems/test-unit-2.5.4/lib/test/unit.rb:502:in `block (2 levels) in <top (required)>'

Matt Wynne

unread,
Mar 25, 2013, 6:59:29 AM3/25/13
to cu...@googlegroups.com
On 25 Mar 2013, at 09:14, jitendra....@gmail.com wrote:

Now after successful execution of cucumber test cases I getting below error. But if any test case failed then I don't get this error. This irritating. I am not using any where test-unit in env.rb ... Is this a bug in  cucumber-rails-1.3.1/lib/cucumber/rails/world.rb:13:in `initialize':  ?

I think maybe you've got this bug:


Try adding this line somewhere in your features/support directory:

Test::Unit::AutoRunner.need_auto_run = false

jitendra....@gmail.com

unread,
Mar 25, 2013, 1:49:36 PM3/25/13
to cu...@googlegroups.com
Thanks Matt!!! You are correct its cucumber 404 issue. I used the resolution and it worked.
Reply all
Reply to author
Forward
0 new messages