Debugging Ruby Selenium Webdriver RSpec tests on JetBrains IntelliJ on a Java Project

So, you already have a Java project on IntelliJ and want to run and debug ruby selenium tests.

Specify Ruby SDK in IntelliJ for the project.
1. Navigate to File -> Project Structure -> SDKs -> Project.
2. Select SDK, in my case Ruby-2.0.0.
3. Click Apply and OK

Create a Ruby Module (This is specific to my scenario, so your module settings may be different)
1. Navigate to File -> Project Structure -> Modules
2. Remove existing Java module.
3. Create New Module based on Ruby Gem.
4. Select project’s root level as the module, rest of the fields autofill.
5. Remove Ruby Gem facet from module.
6. Click Apply and OK

Create RSpec Configuration
1. Edit Configuration -> Add New Configuration -> Rspec
2. Select spec and SDK.
3. Click Apply and OK
4. Run/debug

Troubleshooting
If you get the Teamcity Formatter error below error in Intellij when executing the RSpec script, try the following.
1. Execute the Create a Ruby Module step
2. Remove the existing RSpec configuration
3. Re-create the RSpec Configuration

/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /usr/bin/rspec spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter
Testing started at 9:47 AM ...
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:867:in `block in setup_load_path_and_require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:867:in `each'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:867:in `setup_load_path_and_require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration_options.rb:25:in `configure'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:21:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'

Process finished with exit code 1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s