Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:FeeFighters/samurai-js

  • Loading branch information...
commit 23f91d3959d8dccfcc8215cd8c552f127411c67f 2 parents b432ab5 + 8b95876
@tisho tisho authored
View
55 0.1/integration_tests/browser_tests.rb
@@ -0,0 +1,55 @@
+require 'rubygems'
+require "test/unit"
+require 'selenium-webdriver'
+require 'capybara'
+require 'capybara/dsl'
+require 'active_support/core_ext/string/inflections'
+require 'support/samurai_js_tests'
+
+
+tests = [
+ {:browser => :chrome, :version => nil, :platform => :VISTA },
+ {:browser => :chrome, :version => nil, :platform => :XP },
+ {:browser => :chrome, :version => nil, :platform => :LINUX },
+ {:browser => :firefox, :version => '9', :platform => :XP },
+ {:browser => :firefox, :version => '9', :platform => :VISTA },
+ {:browser => :firefox, :version => '9', :platform => :LINUX },
+ {:browser => :firefox, :version => '8', :platform => :XP },
+ {:browser => :firefox, :version => '7', :platform => :XP },
+ {:browser => :internet_explorer, :version => '9', :platform => :VISTA },
+ {:browser => :internet_explorer, :version => '8', :platform => :XP },
+ {:browser => :internet_explorer, :version => '7', :platform => :XP },
+]
+
+revision = `git rev-parse HEAD`
+
+tests.each do |specs|
+
+ name = "#{specs[:browser].to_s.camelcase}#{specs[:version]}#{specs[:platform].to_s.downcase.camelcase}"
+ klass_name = "#{name}Test".classify
+ klass = Object.const_set(klass_name, Class.new(Test::Unit::TestCase))
+
+ klass.class_eval <<-__RUBY__
+ include Capybara::DSL
+
+ def setup
+ @caps = Selenium::WebDriver::Remote::Capabilities.send("#{specs[:browser]}")
+ @caps.platform = :#{specs[:platform]}
+ @caps[:name] = "Samurai.js Integration Test - #{specs[:browser].to_s.titleize} #{specs[:version]}, #{specs[:platform]}"
+ @caps[:tags] = [ "#{revision}", "#{specs[:browser]}", "#{specs[:platform]}", "#{name}" ]
+
+ Capybara.run_server = false
+ Capybara.register_driver :#{name} do |app|
+ Capybara::Selenium::Driver.new(app, {
+ :browser => :remote,
+ :url => "http://#{ENV['SAUCE_USERNAME']}:#{ENV['SAUCE_ACCESS_KEY']}@ondemand.saucelabs.com:80/wd/hub",
+ :desired_capabilities => @caps,
+ })
+ end
+ Capybara.current_driver = :#{name}
+ end
+
+ include SamuraiJsTests
+ __RUBY__
+
+end
View
44 0.1/integration_tests/support/samurai_js_tests.rb
@@ -0,0 +1,44 @@
+module SamuraiJsTests
+
+ def test_sauce
+ Capybara.app_host = "http://examples.samurai.feefighters.com/sinatra/samurai_js"
+
+ visit '/payment_form'
+ assert_equal true, page.has_content?('Enter your payment information:')
+
+ # First submit it empty
+ click_button 'Submit Payment'
+ assert_not_nil find('.error-summary').text =~ /The card number was blank/
+
+ # Then fill out a successful tx
+ fill_in('First name', :with => 'John')
+ fill_in('Last name', :with => 'Doe')
+ fill_in('Address 1', :with => '1000 1st Av')
+ fill_in('City', :with => 'Chicago')
+ fill_in('State', :with => 'IL')
+ fill_in('Zip', :with => '10101')
+ fill_in('Card number', :with => '4111111111111111')
+ fill_in('CVV', :with => '111')
+ select('05', :from => 'credit_card_expiry_month')
+ select('2015', :from => 'credit_card_expiry_year')
+
+ click_button 'Resubmit Payment'
+ assert_equal true, page.has_content?('Your purchase has been completed')
+ end
+
+ def teardown
+ Capybara.reset_sessions!
+ Capybara.current_session.driver.quit
+ Capybara.use_default_driver
+ end
+
+ private
+
+ def select_option(select_elem, value)
+ select_elem.click
+ select_elem.find_elements( :tag_name => "option" ).find do |option|
+ option.text == value
+ end.click
+ end
+
+end
View
3  Gemfile
@@ -5,4 +5,7 @@ group :test do
gem 'sprockets'
gem 'therubyracer'
gem 'jasmine-headless-webkit', :git=>'git://github.com/jkrall/jasmine-headless-webkit.git'
+ gem 'selenium-webdriver'
+ gem 'activesupport'
+ gem 'capybara'
end
View
30 Gemfile.lock
@@ -11,19 +11,44 @@ GIT
GEM
remote: http://rubygems.org/
specs:
+ activesupport (3.2.1)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ capybara (1.1.2)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ childprocess (0.3.0)
+ ffi (~> 1.0.6)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.3)
execjs (1.2.9)
multi_json (~> 1.0)
+ ffi (1.0.11)
hike (1.2.1)
+ i18n (0.6.0)
jasmine-core (1.2.0.rc1)
+ json_pure (1.6.5)
libv8 (3.3.10.2)
+ mime-types (1.17.2)
multi_json (1.0.3)
+ nokogiri (1.5.0)
rack (1.3.5)
+ rack-test (0.6.1)
+ rack (>= 1.0)
rainbow (1.1.2)
rake (0.9.2)
+ rubyzip (0.9.5)
+ selenium-webdriver (2.13.0)
+ childprocess (>= 0.2.1)
+ ffi (~> 1.0.9)
+ json_pure
+ rubyzip
sprockets (2.0.0)
hike (~> 1.2)
rack (~> 1.0)
@@ -31,12 +56,17 @@ GEM
therubyracer (0.9.4)
libv8 (~> 3.3.10)
tilt (1.3.3)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
+ activesupport
+ capybara
jasmine-headless-webkit!
rake
+ selenium-webdriver
sprockets
therubyracer
View
9 Rakefile
@@ -1,3 +1,5 @@
+require 'rake/testtask'
+
namespace :samurai_js do
task :setup do
rm_rf "api"
@@ -47,5 +49,12 @@ namespace :samurai_js do
rm_rf "0.1/tests/results.xml"
system "cd api/0.1/tests && jasmine-headless-webkit -j jasmine.yml --report results.xml"
end
+
+ Rake::TestTask.new(:integration => :compile) do |t|
+ t.libs << 'api/0.1/integration_tests'
+ t.test_files = FileList['api/0.1/integration_tests/*.rb']
+ t.verbose = true
+ end
+ Rake::Task['samurai_js:integration'].comment = "Run the integration tests on SauceLabs"
end
Please sign in to comment.
Something went wrong with that request. Please try again.