testingbot 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ before_script: echo "travis:rocks" > ~/.testingbot
5
+ script: bundle exec rspec -P "spec/unit/*.rb"
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source "http://rubygems.org"
2
-
2
+ gem 'rspec'
3
+ gem 'cucumber'
4
+ gem 'capybara'
3
5
  # Specify your gem's dependencies in testingbot.gemspec
4
6
  gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 TestingBot
1
+ Copyright (c) 2012 TestingBot
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.rdoc CHANGED
@@ -1,3 +1,5 @@
1
+ {<img src="https://secure.travis-ci.org/testingbot/testingbot_ruby.png" />}[http://travis-ci.org/testingbot/testingbot_ruby]
2
+
1
3
  = TestingBot
2
4
 
3
5
  Testingbot.com is a website where you can use our cloud based Selenium grid. Test your web applications in various environments/browsers/devices.
@@ -11,7 +13,7 @@ You can install our testingbot ruby-gem by running "gem install testingbot" on y
11
13
  == Setup
12
14
 
13
15
  After you installed the gem you need to run a one part setup.
14
- Type testingbot in your commandline and fill in the API key and API secret you obtained on http://www.testingbot.com
16
+ Type testingbot in your commandline and fill in the API key and API secret you obtained on http://testingbot.com
15
17
  $ testingbot
16
18
 
17
19
  == Usage
@@ -26,17 +28,11 @@ You can find an example in our examples folder, try something like this:
26
28
 
27
29
  def setup
28
30
  @browser = Selenium::Client::Driver.new \
29
- :host => "hub.testingbot.com",
30
- :port => 4444,
31
31
  :browser => "firefox",
32
32
  :url => "http://www.google.com",
33
33
  :platform => "WINDOWS",
34
34
  :version => 10,
35
35
  :timeout_in_second => 90
36
-
37
- browser.options = {
38
- :screenshot => true
39
- }
40
36
 
41
37
  browser.start_new_browser_session
42
38
  end
@@ -58,18 +54,22 @@ This example uses RSpec 2. You can run it with rspec test_rspec.rb
58
54
  require "selenium/client"
59
55
  require 'rspec'
60
56
  require 'testingbot'
57
+ require 'testingbot/tunnel'
61
58
 
62
- describe "Test", :type => :selenium do
59
+ # rspec 2
60
+ describe "People", :type => :selenium do
63
61
  attr_reader :selenium_driver
64
62
  before(:all) do
65
- @selenium_driver = Selenium::Client::Driver.new \
66
- :host => "hub.testingbot.com",
67
- :port => 4444,
68
- :browser => "firefox",
69
- :url => "http://www.google.com",
70
- :timeout_in_second => 90,
71
- :platform => "WINDOWS",
72
- :version => "10"
63
+ # uncomment if you want to use our Tunnel
64
+ # tunnel = TestingBot::Tunnel.new
65
+ # tunnel.start
66
+
67
+ @selenium_driver = Selenium::Client::Driver.new \
68
+ :browser => "firefox",
69
+ :url => "http://www.google.com",
70
+ :timeout_in_second => 60,
71
+ :platform => "WINDOWS",
72
+ :version => "10"
73
73
  end
74
74
 
75
75
  before(:each) do
@@ -101,10 +101,8 @@ This example uses RSpec 1. You can run it with spec test_rspec1.rb
101
101
  attr_reader :selenium_driver
102
102
  alias :page :selenium_driver
103
103
 
104
- before(:all) do
104
+ before(:all) do
105
105
  @selenium_driver = Selenium::Client::Driver.new \
106
- :host => "hub.testingbot.com",
107
- :port => 4444,
108
106
  :browser => "firefox",
109
107
  :url => "http://www.google.com",
110
108
  :timeout_in_second => 90,
@@ -113,7 +111,7 @@ This example uses RSpec 1. You can run it with spec test_rspec1.rb
113
111
  end
114
112
 
115
113
  before(:each) do
116
- selenium_driver.start_new_browser_session
114
+ @selenium_driver.start_new_browser_session
117
115
  end
118
116
 
119
117
  append_after(:each) do
@@ -131,29 +129,18 @@ This example uses RSpec 2 together with capybara and Selenium webdriver. You can
131
129
 
132
130
  require 'rspec'
133
131
  require 'capybara/rspec'
134
- require 'selenium/webdriver'
135
132
  require 'testingbot'
133
+ require 'testingbot/capybara'
136
134
 
137
- RSpec.configure do |config|
138
- caps = Selenium::WebDriver::Remote::Capabilities.firefox
139
- caps.version = "8"
140
- caps.platform = :WINDOWS
141
-
142
- Capybara.default_driver = :testingbot
143
- Capybara.register_driver :testingbot do |app|
144
- client = Selenium::WebDriver::Remote::Http::Default.new
145
- client.timeout = 120
146
- Capybara::Selenium::Driver.new(app,
147
- :browser => :remote,
148
- :url => "http://key:secret@hub.testingbot.com:4444/wd/hub",
149
- :http_client => client,
150
- :desired_capabilities => caps)
151
- end
135
+ TestingBot::config do |config|
136
+ config[:desired_capabilities] = { :browserName => "firefox", :version => 9, :platform => "WINDOWS" }
137
+ # config.require_tunnel # uncomment if you want to use our Tunnel
152
138
  end
153
139
 
154
- describe "Test", :type => :request do
140
+ describe "People", :type => :request do
155
141
  before :all do
156
- Capybara.app_host = "http://testingbot.com"
142
+ Capybara.current_driver = :testingbot
143
+ Capybara.app_host = "http://testingbot.com"
157
144
  end
158
145
 
159
146
  it 'has a homepage with the word Selenium' do
@@ -162,15 +149,75 @@ This example uses RSpec 2 together with capybara and Selenium webdriver. You can
162
149
  end
163
150
  end
164
151
 
152
+ === Example RSpec 2, Capybara and Rails
153
+ In this example we will need rspec-rails and Capybara, a rack server will be started by Capybara to run your localhost tests.
154
+ Add the example below in spec/integration/home_spec.rb
155
+ ----------------------------------------------------------
156
+ spec_helper.rb:
157
+
158
+ require 'capybara/rspec'
159
+ require 'capybara/rails'
160
+ require 'testingbot'
161
+ require 'testingbot/capybara'
162
+
163
+ ----------------------------------------------------------
164
+ spec/integration/home_spec.rb:
165
+
166
+ require 'spec_helper'
167
+
168
+ TestingBot::config do |config|
169
+ config[:desired_capabilities] = { :browserName => "firefox", :version => 9, :platform => "WINDOWS", :localhost => "YES" }
170
+ config.require_tunnel
171
+ end
172
+
173
+ describe 'home page' do
174
+ before :all do
175
+ Capybara.server_port = 3011
176
+ Capybara.current_driver = :testingbot
177
+ Capybara.app_host = "http://127.0.0.1:3011"
178
+ end
179
+
180
+ it "shows the home page", :type => :request do
181
+ visit '/'
182
+ page.should have_content('Selenium')
183
+ end
184
+ end
185
+
186
+ === Example RSpec 2 run on multiple browsers
187
+ Use the :multibrowser => true statement to indicate you want to test on multiple browsers.
188
+
189
+ require 'rubygems'
190
+ require "selenium/client"
191
+ require 'rspec'
192
+ require 'testingbot'
193
+ require 'testingbot/tunnel'
194
+
195
+ TestingBot::config do |config|
196
+ config[:desired_capabilities] = [{ :browserName => "firefox", :version => 9, :platform => "WINDOWS" }, { :browserName => "firefox", :version => 11, :platform => "WINDOWS" }]
197
+ end
198
+
199
+ describe "Google", :type => :selenium, :multibrowser => true do
200
+ it "can find the right title" do
201
+ page.navigate.to "http://www.google.com"
202
+ page.title.should eql("Google")
203
+ end
204
+ end
205
+
165
206
  == Capybara and Cucumber
166
- The examples directory contains an example of testing with Capybara and Cucumber
207
+ The examples directory contains an example of testing with Capybara and Cucumber.
208
+ The Rakefile in examples/cucumber contains a cucumber task which will run the same Cucumber story on multiple browsers.
209
+
167
210
  More info available on http://testingbot.com/support/getting-started/cucumber.html
168
211
 
212
+ == Test this gem
213
+ The tests for this gem are located in the spec folder, you can run them with this Rake task:
214
+ rake spec
215
+
169
216
  == Extra options
170
- You can specify extra options like enabling/disabling the screenrecording or screenshot feature. (browser.options)
217
+ You can specify extra options like enabling/disabling the screenrecording or screenshot feature.
218
+ For WebDriver use the config[:desired_capabilities] to specify extra options.
171
219
 
172
- There's also an option to pass along extra data with your test, which will be visible on testingbot.com.
173
- For example a build number, or other custom data. (browser.extra = "")
220
+ For RC tests use the start_new_browser_session(options) options hash.
174
221
 
175
222
  == More information
176
223
 
data/Rakefile CHANGED
@@ -1 +1,16 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+
5
+ task :spec do
6
+ begin
7
+ require 'rspec/core/rake_task'
8
+ desc "Run the specs under spec/"
9
+ RSpec::Core::RakeTask.new do |t|
10
+ t.fail_on_error = false
11
+ t.pattern = FileList['spec/**/*_spec.rb'].exclude(/tunnel/)
12
+ end
13
+ rescue NameError, LoadError => e
14
+ puts e
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/testingbot/config.rb')
4
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/testingbot/selenium.rb')
5
+
6
+ TestingBot::config do |config|
7
+ config[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.android
8
+ end
9
+
10
+ driver = TestingBot::SeleniumWebdriver.new
11
+
12
+ driver.navigate.to "http://testingbot.com/"
13
+ puts driver.title
14
+ driver.quit
data/examples/capybara.rb CHANGED
@@ -1,32 +1,22 @@
1
1
  require 'rspec'
2
2
  require 'capybara/rspec'
3
- require 'selenium/webdriver'
4
3
  require 'testingbot'
4
+ require 'testingbot/capybara'
5
5
 
6
- RSpec.configure do |config|
7
- caps = Selenium::WebDriver::Remote::Capabilities.firefox
8
- caps.version = "8"
9
- caps.platform = :WINDOWS
10
-
11
- Capybara.default_driver = :testingbot
12
- Capybara.register_driver :testingbot do |app|
13
- client = Selenium::WebDriver::Remote::Http::Default.new
14
- client.timeout = 120
15
- Capybara::Selenium::Driver.new(app,
16
- :browser => :remote,
17
- :url => "http://key:secret@hub.testingbot.com:4444/wd/hub",
18
- :http_client => client,
19
- :desired_capabilities => caps)
20
- end
6
+ TestingBot::config do |config|
7
+ config[:desired_capabilities] = { :browserName => "firefox", :version => 9, :platform => "WINDOWS" }
8
+ config[:options] = { :screenshot => false, :extra => "Some extra data" }
9
+ #config.require_tunnel
21
10
  end
22
11
 
23
12
  describe "People", :type => :request do
24
13
  before :all do
14
+ Capybara.current_driver = :testingbot
25
15
  Capybara.app_host = "http://testingbot.com"
26
16
  end
27
17
 
28
- it 'has a homepage with the word Selenium' do
29
- visit '/'
30
- page.should have_content('Selenium')
31
- end
18
+ it 'has a homepage with the word Selenium' do
19
+ visit '/'
20
+ page.should have_content('Selenium')
21
+ end
32
22
  end
@@ -0,0 +1,38 @@
1
+ require 'rspec'
2
+ require 'capybara/rspec'
3
+ require 'testingbot'
4
+ require 'testingbot/capybara'
5
+
6
+ browsers = [{ :browserName => "firefox", :version => 9, :platform => "WINDOWS" }, { :browserName => "firefox", :version => 10, :platform => "WINDOWS" }]
7
+
8
+ browsers.each do |browser|
9
+
10
+ shared_examples "an example test on #{browser[:browserName]} #{browser[:version]}" do |actions|
11
+ describe "Demo", :type => :request do
12
+ before :all do
13
+ TestingBot::config do |config|
14
+ config[:desired_capabilities] = browser
15
+ end
16
+ Capybara.run_server = false
17
+ Capybara.current_driver = :testingbot
18
+ Capybara.app_host = "http://testingbot.com"
19
+ end
20
+
21
+ after :all do
22
+ TestingBot.reset_config!
23
+ Capybara.current_driver = :testingbot
24
+ page.driver.browser.quit
25
+ page.driver.instance_variable_set(:@browser, nil)
26
+ end
27
+
28
+ it 'has a homepage with the word Selenium' do
29
+ visit '/'
30
+ page.should have_content('Selenium')
31
+ end
32
+ end
33
+ end
34
+
35
+ describe "Sample", :type => :request do
36
+ it_behaves_like "an example test on #{browser[:browserName]} #{browser[:version]}"
37
+ end
38
+ end
@@ -0,0 +1,15 @@
1
+ Testing with Cucumber, Selenium and Capybara
2
+
3
+ == Usage
4
+
5
+ This example contains a basic Cucumber story which will run on TestingBot.
6
+ Included you will find a Rakefile which contains a cucumber task.
7
+ If you run this Rake task you can run the same Cucumber story on multiple browsers.
8
+
9
+ rake cucumber
10
+
11
+ You can specify the browser list inside the Rakefile.
12
+
13
+ === More information
14
+
15
+ More info at http://testingbot.com/support/getting-started/ruby.html
@@ -0,0 +1,20 @@
1
+ require "rubygems"
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'cucumber/rake/task'
5
+ require 'selenium/rake/tasks'
6
+
7
+ task :cucumber do
8
+ browsers = [{ :browserName => "firefox", :version => 9, :platform => "WINDOWS" }, { :browserName => "firefox", :version => 10, :platform => "WINDOWS" }]
9
+
10
+ browsers.each do |browser|
11
+ ENV['SELENIUM_BROWSERNAME'] = browser[:browserName]
12
+ ENV['SELENIUM_BROWSERVERSION'] = browser[:version].to_s
13
+ ENV['SELENIUM_BROWSERPLATFORM'] = browser[:platform]
14
+ Rake::Task[:run_cucumber].execute(browser)
15
+ end
16
+ end
17
+
18
+ Cucumber::Rake::Task.new(:run_cucumber) do |t|
19
+ t.cucumber_opts = ["features"]
20
+ end
@@ -4,35 +4,10 @@ require 'rspec'
4
4
  require 'selenium/webdriver'
5
5
  require 'testingbot/cucumber'
6
6
 
7
- if ENV['TESTINGBOT_BROWSER']
8
- caps = {}
9
- caps[:browser] = ENV['TESTINGBOT_BROWSER']
10
- caps[:version] = ENV['TESTINGBOT_BROWSERVERSION'] || ""
11
- caps[:platform] = ENV['TESTINGBOT_BROWSEROS'] || :WINDOWS
12
-
13
- Capybara.default_driver = :testingbot
14
- Capybara.register_driver :testingbot do |app|
15
- client = Selenium::WebDriver::Remote::Http::Default.new
16
- client.timeout = 120
17
- Capybara::Selenium::Driver.new(app,
18
- :browser => :remote,
19
- :url => "http://251ca561ab0f7557bb34c3ee3dbde285:3fc22e44f086fa036d8b01eadf66740b@hub.testingbot.com:4444/wd/hub",
20
- :http_client => client,
21
- :desired_capabilities => caps)
22
- end
23
- else
24
- caps = Selenium::WebDriver::Remote::Capabilities.firefox
25
- caps.version = "10"
26
- caps.platform = :WINDOWS
27
-
28
- Capybara.default_driver = :testingbot
29
- Capybara.register_driver :testingbot do |app|
30
- client = Selenium::WebDriver::Remote::Http::Default.new
31
- client.timeout = 120
32
- Capybara::Selenium::Driver.new(app,
33
- :browser => :remote,
34
- :url => "http://251ca561ab0f7557bb34c3ee3dbde285:3fc22e44f086fa036d8b01eadf66740b@hub.testingbot.com:4444/wd/hub",
35
- :http_client => client,
36
- :desired_capabilities => caps)
7
+ unless ENV['SELENIUM_BROWSERNAME'].nil?
8
+ TestingBot::config do |config|
9
+ config[:desired_capabilities] = { :browserName => ENV['SELENIUM_BROWSERNAME'], :version => ENV['SELENIUM_BROWSERVERSION'], :platform => ENV['SELENIUM_BROWSERPLATFORM'] }
37
10
  end
38
11
  end
12
+
13
+ Capybara.default_driver = :testingbot
@@ -1,3 +1,4 @@
1
+ @selenium
1
2
  Feature: YouTube has a search function.
2
3
 
3
4
  Background:
@@ -2,38 +2,16 @@ require 'rubygems'
2
2
  require "selenium/client"
3
3
  require 'rspec'
4
4
  require 'testingbot'
5
- #require 'testingbot/tunnel'
5
+ require 'testingbot/tunnel'
6
6
 
7
- # rspec 2
8
- describe "People", :type => :selenium do
9
- attr_reader :selenium_driver
10
- before(:all) do
11
- #TestingBot::Tunnel.start_tunnel("selenium@tunnel.testingbot.com", 2052)
7
+ TestingBot::config do |config|
8
+ config[:desired_capabilities] = [{ :browserName => "firefox", :version => 9, :platform => "WINDOWS" }, { :browserName => "firefox", :version => 11, :platform => "WINDOWS" }]
9
+ end
12
10
 
13
- @selenium_driver = Selenium::Client::Driver.new \
14
- :host => "hub.testingbot.com",
15
- :port => 4444,
16
- :browser => "firefox",
17
- :url => "http://www.google.com",
18
- :timeout_in_second => 60,
19
- :platform => "WINDOWS",
20
- :version => "10"
21
- end
22
-
23
- before(:each) do
24
- @selenium_driver.start_new_browser_session
25
- end
26
-
27
- after(:each) do
28
- @selenium_driver.close_current_browser_session
29
- end
30
-
11
+ # rspec 2
12
+ describe "People", :type => :selenium, :multibrowser => true do
31
13
  it "can find the right title" do
32
- @selenium_driver.open "/"
33
- @selenium_driver.title.should eql("Google")
14
+ page.navigate.to "http://www.google.com"
15
+ page.title.should eql("Google")
34
16
  end
35
-
36
- # after(:all) do
37
- # TestingBot::Tunnel.stop_tunnel
38
- # end
39
17
  end