forked from isa/test-base-xruby
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 183fb3c
Showing
8 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.lock | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rvm --create use ruby-1.8.7@test-base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rvm --create use jruby-1.6.7.2@test-base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
source 'http://rubygems.org' | ||
source 'http://gems.github.com' | ||
|
||
gem 'cucumber' | ||
gem 'rspec' | ||
gem 'headless' | ||
gem 'capybara' | ||
gem 'capybara-webkit' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## Test Setup | ||
|
||
Basic test base setup with cucumber, capybara, selenium, capybara-webkit, headless and rspec. | ||
|
||
First thing to do is installing ruby or jruby. You can do this by: | ||
|
||
rvm install ruby-1.8.7 | ||
rvm install jruby-1.6.7.2 | ||
|
||
I setup two different rvmrc files, so you can pick either of them. By default it is ruby. | ||
|
||
Another thing you should install prior to use this base is: | ||
|
||
brew install qt chromedriver | ||
|
||
### Ruby | ||
|
||
Well, after getting into the directory, all you need to do is just installing the gems: | ||
|
||
bundle install | ||
|
||
And then create your tests by following the example and run them as below: | ||
|
||
bundle exec cucumber test/features | ||
|
||
### JRuby | ||
|
||
Same goes here: | ||
|
||
jruby -S bundle install | ||
|
||
and execute your tests with: | ||
|
||
jruby -S bundle exec cucumber test/features | ||
|
||
### WebKit Headless Testing | ||
|
||
Normally, base is setup to use selenium out-of-the-box. However, if you would like to do the headless testing, make sure you are changing the `env.rb` file under `test/features/support` folder as following: | ||
|
||
Capybara.default_driver = :webkit | ||
Capybara.javascript_driver = :webkit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Feature: Addition | ||
In order to avoid silly mistakes | ||
As a math idiot | ||
I want to be told the sum of two numbers | ||
|
||
@javascript | ||
Scenario: Add two numbers | ||
Given I go to the Google | ||
When I enter 50 + 70 into the search box | ||
Then the result should be 120 on the screen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Given /^I go to the Google$/ do | ||
visit '/ncr' | ||
end | ||
|
||
When /^I enter (\d+) \+ (\d+) into the search box$/ do |number1, number2| | ||
term = "#{number1} + #{number2}" | ||
fill_in 'q', :with => term | ||
end | ||
|
||
Then /^the result should be (\d+) on the screen$/ do |result| | ||
page.should have_content result | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'rubygems' | ||
require 'capybara' | ||
require 'capybara-webkit' | ||
require 'capybara/dsl' | ||
require 'capybara/rspec' | ||
|
||
Capybara.run_server = false | ||
Capybara.app_host = 'http://www.google.com' | ||
# Capybara.default_driver = :selenium | ||
Capybara.default_driver = :webkit | ||
Capybara.javascript_driver = :webkit | ||
Capybara.default_selector = :css | ||
# Capybara.default_selector = :xpath | ||
Capybara.default_wait_time = 2 #default wait time for ajax | ||
Capybara.ignore_hidden_elements = false #ignore hidden elements when testing, make helpful when you hide or show elements using javascript | ||
|
||
|
||
module Helpers | ||
def without_resynchronize | ||
page.driver.options[:resynchronize] = false | ||
yield | ||
page.driver.options[:resynchronize] = true | ||
end | ||
end | ||
|
||
World(Capybara::DSL, Helpers) | ||
|