Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Just pushing to github

  • Loading branch information...
commit 183fb3cf4f32583d8339611f7dbaf98004e9e638 0 parents
@isa isa authored
3  .gitignore
@@ -0,0 +1,3 @@
+*.lock
+*.log
+
1  .rvmrc
@@ -0,0 +1 @@
+rvm --create use ruby-1.8.7@test-base
1  .rvmrc_jruby
@@ -0,0 +1 @@
+rvm --create use jruby-1.6.7.2@test-base
8 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 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 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 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 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)
+
Please sign in to comment.
Something went wrong with that request. Please try again.