Skip to content

Commit

Permalink
Just pushing to github
Browse files Browse the repository at this point in the history
  • Loading branch information
isa committed Jun 18, 2012
0 parents commit 183fb3c
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
*.lock
*.log

1 change: 1 addition & 0 deletions .rvmrc
@@ -0,0 +1 @@
rvm --create use ruby-1.8.7@test-base
1 change: 1 addition & 0 deletions .rvmrc_jruby
@@ -0,0 +1 @@
rvm --create use jruby-1.6.7.2@test-base
8 changes: 8 additions & 0 deletions Gemfile
@@ -0,0 +1,8 @@
source 'http://rubygems.org'
source 'http://gems.github.com'

gem 'cucumber'
gem 'rspec'
gem 'headless'
gem 'capybara'
gem 'capybara-webkit'
41 changes: 41 additions & 0 deletions readme.md
@@ -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
10 changes: 10 additions & 0 deletions test/features/calculator.feature
@@ -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
12 changes: 12 additions & 0 deletions test/features/step_definitions/calculator_steps.rb
@@ -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
27 changes: 27 additions & 0 deletions test/features/support/env.rb
@@ -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)

0 comments on commit 183fb3c

Please sign in to comment.