I am working on moving our celerity based integration tests to capybara-webkit.
The documentation provided on git-hub (https://github.com/thoughtbot/capybara-webkit) for capybara-webkit was helpful but i am unable to run my tests, ending up with error for jruby:
NotImplementedError: fork is not available on this platform
org/jruby/RubyKernel.java:1792:in `fork'
Is there a way I can get capybara-webkit work with jruby?
You could try poltergeist which also provides a headless webkit driver for capybara, but does not rely on any native extensions. Instead, it uses PhantomJS to drive the tests. According to the README jruby is supported.
This is a bit of a long shot but have you tried gem 'spoon' in your Gemfile?
I have not been able to get capybara-webkit working with JRuby. I have had success using MRI for my development/TDD cycles and switching to JRuby (using RVM) to make sure everything still runs. When I run my JRuby features (cucumber), I just use selenium for testing javascript. I have a bit of setup code that looks similar to this in features/support/setup.rb:
Before do
if running_in_jruby
Capybara.javascript_driver = :selenium
else
Capybara.javascript_driver = :webkit
end
end
This is specific to cucumber of course, although you should be able to do something similar with rspec. I've found that MRI is quite a bit faster at running my tests due to the faster startup time vs. Java. I'll run my features/specs many times during the development of a feature, and then before I check in I'll switch to JRuby and run the tests just once.
Related
In one of my last projects the tests are breaking after the first fail. Investigating a bit I see this is the expected behaviour when you activate fail fast:
rails test -f
But I am running plane:
rails test
And still the tests are not all executed.
What is making the fail fast to be activate in my project by default? How can I prevent this?
I am pasting my Gemfile.lock here: https://pastebin.com/FD8dEnUE
This is actually a known bug (https://github.com/seattlerb/minitest/issues/730).
A quick and dirty fix is to lock minitest version on your Gemfile:
gem "minitest", "5.10.3"
Since rails 5.0.x is not on maintenance mode anymore (as per https://github.com/rails/rails/pull/32547#issuecomment-380930889) you might need to downgrade minitest version until you are able to upgrade Rails to >= 5.1x
When I run my massive suite of Capybara "system" tests, the automated Chrome window constantly takes focus! It basically means I can't work while the test is running. This is driving me insane. Is there anything I can do? It didn't do this until recently.
Gems:
rails 5.2.0
capybara 3.0.3
selenium-webdriver 3.12.0
chromedriver-helper 1.2.0
You haven't configured your selenium webdriver correctly. From my 5.2 app:
# spec/rails_helper.rb
require 'capybara/rspec'
Capybara.javascript_driver = :selenium_chrome_headless
Other than running in headless mode (or filing an issue with the Chrome developers and hoping they change the behavior in a future version of Chrome) there is nothing you can do
I'm looking for a tool to generate code coverage statistics for my JRuby-backed Rails application. I've looked into things like simplecov, but they don't seem to support JRuby. As far as I can see, none of the 'common' libraries support JRuby. I haven't been able to find any good tools to do this for me.
I am using Rails 3.1.3 with Ruby 1.9.2.
There is a known issue with current JRuby coverage lib: http://jira.codehaus.org/browse/JRUBY-6106.
As the issue status states it is fixed in JRuby 1.7, which is currently in RC stage and will be out very soon.
I'm building a Rails 3 app. I'm trying to learn Cucumber with Capybara.
Do I need JRuby to run Capybara via Cucumber?
I've used Webrat, but many people seem to be using Capybara,
so I'd love to try.
I don't need JavaScript testing right away, but I want to install
Capybara if I need in the end.
I read and read the Capybara documentation, but couldn't understand.
Capybara does not require jRuby or the Selenium-RC drivers.
Simply do the following to setup Cucumber with Capybara.
$ gem install capybara cucumber
$ rails generate cucumber --capybara
I haven't used Capybara myself, but from what I can glean from the readme, it doesn't look like it requires JRuby, depending on the JavaScript driver you use. For instance, if you want to use Culerity, then yes you need JRuby, since it needs to be in your path.
Are you having difficulty installing Capybara?
I am trying to use Cucumber for a Rails project on Windows.
Unfortunately the time it takes to run a scenario is making BDD
impossible.
I understand this is largely due to the time taken by Rails to load up
under windows.
Does anyone have any ideas about how I can speed things up.
e.g Is it possible to call Cucumber inside a Rails console to avoid
the load up delay.
Cheers.
Windows is now supported by Spork! http://wiki.github.com/timcharper/spork/
Spork is a test server than can be invoked via DRb.
On POSIX systems Spork uses Kernel.fork.
On Windows forking is not an option so Spork creates a pool of preloaded processes which
avoids the huge Rails start up time.
At the moment it only works with win32/mingw Ruby because it depends on the win32-process gem.
A big thanks to the Spork Guys for doing such a great job and making cucumber BDD possible on Windows.
Please note that I have only tried Spork with
Windows XP
Rails 2.3.5
Ruby 1.9.1 from rubyinstaller.org
Have you tried running cucumber without db:test:prepare?
What about setting t.fork = true # set to false for performance increase
(both in /lib/tasks/cucumber.rake)
Is this just my machine, or is the console output of Spork running on Windows extremely slow?