testingbot 0.1.5 → 0.2.2

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.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/test.yml +26 -0
  3. data/.travis.yml +7 -3
  4. data/LICENSE +1 -1
  5. data/README.md +207 -0
  6. data/bin/testingbot +4 -3
  7. data/lib/testingbot.rb +1 -5
  8. data/lib/testingbot/api.rb +153 -35
  9. data/lib/testingbot/version.rb +1 -1
  10. data/spec/integration/api_spec.rb +38 -18
  11. data/spec/resources/test.apk +1 -0
  12. data/spec/spec_helper.rb +6 -3
  13. metadata +55 -94
  14. data/README.rdoc +0 -237
  15. data/examples/android.rb +0 -14
  16. data/examples/capybara.rb +0 -22
  17. data/examples/capybara_multiple_browsers.rb +0 -38
  18. data/examples/cucumber/README.rdoc +0 -15
  19. data/examples/cucumber/Rakefile +0 -20
  20. data/examples/cucumber/features/support/env.rb +0 -13
  21. data/examples/cucumber/features/youtube.feature +0 -10
  22. data/examples/cucumber/features/youtube_steps.rb +0 -15
  23. data/examples/test_rspec.rb +0 -17
  24. data/examples/test_rspec1.rb +0 -36
  25. data/examples/test_unit.rb +0 -30
  26. data/lib/testingbot/capybara.rb +0 -66
  27. data/lib/testingbot/config.rb +0 -125
  28. data/lib/testingbot/cucumber.rb +0 -35
  29. data/lib/testingbot/hooks.rb +0 -287
  30. data/lib/testingbot/jasmine.rb +0 -29
  31. data/lib/testingbot/jasmine/README.rdoc +0 -16
  32. data/lib/testingbot/jasmine/Rakefile +0 -35
  33. data/lib/testingbot/jasmine/public/javascripts/Player.js +0 -22
  34. data/lib/testingbot/jasmine/public/javascripts/Song.js +0 -7
  35. data/lib/testingbot/jasmine/runner.rb +0 -4
  36. data/lib/testingbot/jasmine/spec/javascripts/PlayerSpec.js +0 -58
  37. data/lib/testingbot/jasmine/spec/javascripts/helpers/SpecHelper.js +0 -9
  38. data/lib/testingbot/jasmine/spec/javascripts/support/jasmine.yml +0 -73
  39. data/lib/testingbot/jasmine/test/Rakefile +0 -9
  40. data/lib/testingbot/jasmine/test/public/javascripts/Player.js +0 -22
  41. data/lib/testingbot/jasmine/test/public/javascripts/Song.js +0 -7
  42. data/lib/testingbot/jasmine/test/spec/javascripts/PlayerSpec.js +0 -58
  43. data/lib/testingbot/jasmine/test/spec/javascripts/helpers/SpecHelper.js +0 -9
  44. data/lib/testingbot/jasmine/test/spec/javascripts/support/jasmine.yml +0 -73
  45. data/lib/testingbot/selenium.rb +0 -127
  46. data/lib/testingbot/tunnel.rb +0 -104
  47. data/spec/integration/selenium1_spec.rb +0 -53
  48. data/spec/integration/selenium2_spec.rb +0 -60
  49. data/spec/integration/tunnel_spec.rb +0 -84
  50. data/spec/unit/api_spec.rb +0 -17
  51. data/spec/unit/config_spec.rb +0 -73
  52. data/spec/unit/tunnel_spec.rb +0 -41
  53. data/testingbot.gemspec +0 -25
  54. data/vendor/Testingbot-Tunnel.jar +0 -0
@@ -1,9 +0,0 @@
1
- beforeEach(function() {
2
- this.addMatchers({
3
- toBePlaying: function(expectedSong) {
4
- var player = this.actual;
5
- return player.currentlyPlayingSong === expectedSong &&
6
- player.isPlaying;
7
- }
8
- });
9
- });
@@ -1,73 +0,0 @@
1
- # src_files
2
- #
3
- # Return an array of filepaths relative to src_dir to include before jasmine specs.
4
- # Default: []
5
- #
6
- # EXAMPLE:
7
- #
8
- # src_files:
9
- # - lib/source1.js
10
- # - lib/source2.js
11
- # - dist/**/*.js
12
- #
13
- src_files:
14
- - public/javascripts/**/*.js
15
-
16
- # stylesheets
17
- #
18
- # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
19
- # Default: []
20
- #
21
- # EXAMPLE:
22
- #
23
- # stylesheets:
24
- # - css/style.css
25
- # - stylesheets/*.css
26
- #
27
- stylesheets:
28
-
29
- # helpers
30
- #
31
- # Return an array of filepaths relative to spec_dir to include before jasmine specs.
32
- # Default: ["helpers/**/*.js"]
33
- #
34
- # EXAMPLE:
35
- #
36
- # helpers:
37
- # - helpers/**/*.js
38
- #
39
- helpers:
40
-
41
- # spec_files
42
- #
43
- # Return an array of filepaths relative to spec_dir to include.
44
- # Default: ["**/*[sS]pec.js"]
45
- #
46
- # EXAMPLE:
47
- #
48
- # spec_files:
49
- # - **/*[sS]pec.js
50
- #
51
- spec_files:
52
-
53
- # src_dir
54
- #
55
- # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
56
- # Default: project root
57
- #
58
- # EXAMPLE:
59
- #
60
- # src_dir: public
61
- #
62
- src_dir:
63
-
64
- # spec_dir
65
- #
66
- # Spec directory path. Your spec_files must be returned relative to this path.
67
- # Default: spec/javascripts
68
- #
69
- # EXAMPLE:
70
- #
71
- # spec_dir: spec/javascripts
72
- #
73
- spec_dir:
@@ -1,9 +0,0 @@
1
-
2
- begin
3
- require 'jasmine'
4
- load 'jasmine/tasks/jasmine.rake'
5
- rescue LoadError
6
- task :jasmine do
7
- abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
8
- end
9
- end
@@ -1,22 +0,0 @@
1
- function Player() {
2
- }
3
- Player.prototype.play = function(song) {
4
- this.currentlyPlayingSong = song;
5
- this.isPlaying = true;
6
- };
7
-
8
- Player.prototype.pause = function() {
9
- this.isPlaying = false;
10
- };
11
-
12
- Player.prototype.resume = function() {
13
- if (this.isPlaying) {
14
- throw new Error("song is already playing");
15
- }
16
-
17
- this.isPlaying = true;
18
- };
19
-
20
- Player.prototype.makeFavorite = function() {
21
- this.currentlyPlayingSong.persistFavoriteStatus(true);
22
- };
@@ -1,7 +0,0 @@
1
- function Song() {
2
- }
3
-
4
- Song.prototype.persistFavoriteStatus = function(value) {
5
- // something complicated
6
- throw new Error("not yet implemented");
7
- };
@@ -1,58 +0,0 @@
1
- describe("Player", function() {
2
- var player;
3
- var song;
4
-
5
- beforeEach(function() {
6
- player = new Player();
7
- song = new Song();
8
- });
9
-
10
- it("should be able to play a Song", function() {
11
- player.play(song);
12
- expect(player.currentlyPlayingSong).toEqual(song);
13
-
14
- //demonstrates use of custom matcher
15
- expect(player).toBePlaying(song);
16
- });
17
-
18
- describe("when song has been paused", function() {
19
- beforeEach(function() {
20
- player.play(song);
21
- player.pause();
22
- });
23
-
24
- it("should indicate that the song is currently paused", function() {
25
- expect(player.isPlaying).toBeFalsy();
26
-
27
- // demonstrates use of 'not' with a custom matcher
28
- expect(player).not.toBePlaying(song);
29
- });
30
-
31
- it("should be possible to resume", function() {
32
- player.resume();
33
- expect(player.isPlaying).toBeTruthy();
34
- expect(player.currentlyPlayingSong).toEqual(song);
35
- });
36
- });
37
-
38
- // demonstrates use of spies to intercept and test method calls
39
- it("tells the current song if the user has made it a favorite", function() {
40
- spyOn(song, 'persistFavoriteStatus');
41
-
42
- player.play(song);
43
- player.makeFavorite();
44
-
45
- expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
46
- });
47
-
48
- //demonstrates use of expected exceptions
49
- describe("#resume", function() {
50
- it("should throw an exception if song is already playing", function() {
51
- player.play(song);
52
-
53
- expect(function() {
54
- player.resume();
55
- }).toThrow("song is already playing");
56
- });
57
- });
58
- });
@@ -1,9 +0,0 @@
1
- beforeEach(function() {
2
- this.addMatchers({
3
- toBePlaying: function(expectedSong) {
4
- var player = this.actual;
5
- return player.currentlyPlayingSong === expectedSong &&
6
- player.isPlaying;
7
- }
8
- });
9
- });
@@ -1,73 +0,0 @@
1
- # src_files
2
- #
3
- # Return an array of filepaths relative to src_dir to include before jasmine specs.
4
- # Default: []
5
- #
6
- # EXAMPLE:
7
- #
8
- # src_files:
9
- # - lib/source1.js
10
- # - lib/source2.js
11
- # - dist/**/*.js
12
- #
13
- src_files:
14
- - public/javascripts/**/*.js
15
-
16
- # stylesheets
17
- #
18
- # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
19
- # Default: []
20
- #
21
- # EXAMPLE:
22
- #
23
- # stylesheets:
24
- # - css/style.css
25
- # - stylesheets/*.css
26
- #
27
- stylesheets:
28
-
29
- # helpers
30
- #
31
- # Return an array of filepaths relative to spec_dir to include before jasmine specs.
32
- # Default: ["helpers/**/*.js"]
33
- #
34
- # EXAMPLE:
35
- #
36
- # helpers:
37
- # - helpers/**/*.js
38
- #
39
- helpers:
40
-
41
- # spec_files
42
- #
43
- # Return an array of filepaths relative to spec_dir to include.
44
- # Default: ["**/*[sS]pec.js"]
45
- #
46
- # EXAMPLE:
47
- #
48
- # spec_files:
49
- # - **/*[sS]pec.js
50
- #
51
- spec_files:
52
-
53
- # src_dir
54
- #
55
- # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
56
- # Default: project root
57
- #
58
- # EXAMPLE:
59
- #
60
- # src_dir: public
61
- #
62
- src_dir:
63
-
64
- # spec_dir
65
- #
66
- # Spec directory path. Your spec_files must be returned relative to this path.
67
- # Default: spec/javascripts
68
- #
69
- # EXAMPLE:
70
- #
71
- # spec_dir: spec/javascripts
72
- #
73
- spec_dir:
@@ -1,127 +0,0 @@
1
- # we create our own Selenium classes here to extend them with user credentials and config
2
-
3
- require 'selenium/client'
4
- require 'selenium/webdriver'
5
- require 'selenium/webdriver/remote/http/persistent'
6
-
7
- module TestingBot
8
-
9
- class SeleniumWebdriver
10
-
11
- attr_reader :config, :driver
12
- attr_accessor :session_id_backup
13
-
14
- def initialize(options = {})
15
- @options = TestingBot::get_config.options
16
- @options = @options.merge(options)
17
-
18
- http_client = ::Selenium::WebDriver::Remote::Http::Persistent.new
19
- if ENV['TESTINGBOT_CLIENT_PROXY']
20
- require 'ostruct'
21
- http_client.proxy = OpenStruct.new(:http => ENV['TESTINGBOT_CLIENT_PROXY'])
22
- end
23
- http_client.timeout = 400
24
- @driver = ::Selenium::WebDriver.for(:remote, :url => "http://#{@options[:client_key]}:#{@options[:client_secret]}@#{@options[:host]}:#{@options[:port]}/wd/hub", :desired_capabilities => @options[:desired_capabilities], :http_client => http_client)
25
- http_client.timeout = 120
26
- end
27
-
28
- def method_missing(meth, *args)
29
- @driver.send(meth, *args)
30
- end
31
-
32
- def session_id
33
- @driver.send(:bridge).session_id
34
- end
35
-
36
- def stop
37
- @session_id_backup = session_id
38
- @driver.quit
39
- end
40
- end
41
- end
42
-
43
- # if selenium RC, add testingbot credentials to request
44
- if defined?(Selenium) && defined?(Selenium::Client) && defined?(Selenium::Client::Protocol)
45
- module Selenium
46
- module Client
47
- module Protocol
48
- # add custom parameters for testingbot.com
49
- def http_request_for_testingbot(verb, args)
50
- raise "Please specify your key and secret in a ~/.testingbot or C:\\.testingbot file" if TestingBot.get_config[:client_key].nil?
51
- data = http_request_for_original(verb, args)
52
- data << "&client_key=#{TestingBot.get_config[:client_key]}&client_secret=#{TestingBot.get_config[:client_secret]}"
53
- end
54
-
55
- begin
56
- alias http_request_for_original http_request_for
57
- alias http_request_for http_request_for_testingbot
58
- rescue
59
- end
60
- end
61
- end
62
- end
63
- end
64
-
65
- if defined?(Selenium) && defined?(Selenium::Client) && defined?(Selenium::Client::Base)
66
- module Selenium
67
- module Client
68
- module Base
69
- DEFAULT_OPTIONS = {
70
- :screenshot => true
71
- }
72
-
73
- alias :close_current_browser_session_old :close_current_browser_session
74
- alias :start_new_browser_session_old :start_new_browser_session
75
- alias :initialize_old :initialize
76
-
77
- attr_accessor :options
78
- attr_accessor :session_id_backup
79
- attr_accessor :extra
80
- attr_accessor :platform
81
- attr_accessor :version
82
-
83
- attr_reader :config
84
-
85
- def initialize(*args)
86
- @config = TestingBot::get_config
87
- @options = @config[:options] || {}
88
-
89
- if args[0].kind_of?(Hash)
90
- options = args[0]
91
- @platform = options[:platform] || "WINDOWS"
92
- @version = options[:version] if options[:version]
93
- end
94
-
95
- @options = DEFAULT_OPTIONS
96
- initialize_old(*args)
97
- @host = options[:host] || @config[:host]
98
- @port = options[:port] || @config[:port]
99
- end
100
-
101
- def close_current_browser_session
102
- @session_id_backup = @session_id
103
- close_current_browser_session_old
104
- end
105
-
106
- def session_id
107
- @session_id || @session_id_backup || ""
108
- end
109
-
110
- def start_new_browser_session(options={})
111
- options = @options.merge options
112
- options[:platform] = @platform
113
- options[:version] = @version unless @version.nil?
114
- start_new_browser_session_old(options)
115
- end
116
-
117
- def extra=(str)
118
- @extra = str
119
- end
120
-
121
- def options=(opts = {})
122
- @options = @options.merge opts
123
- end
124
- end
125
- end
126
- end
127
- end
@@ -1,104 +0,0 @@
1
- module TestingBot
2
- class Tunnel
3
- TIMEOUT_SECONDS = 140
4
-
5
- @@running = false
6
-
7
- attr_reader :options, :config, :process, :available, :connected, :errors
8
-
9
- def initialize(opts = {})
10
- @available = false
11
- @errors = []
12
- @config = TestingBot.get_config
13
- @options = default_options
14
- @options = @options.merge(opts)
15
-
16
- raise ArgumentError, "Please make sure you have put the .testingbot file in the your user directory, or set the environment variables TESTINGBOT_CLIENTKEY AND TESTINGBOT_CLIENTSECRET" if @config[:client_key].nil? || @config[:client_secret].nil?
17
- end
18
-
19
- def start
20
- return if @@running == true
21
-
22
- @@running = true
23
-
24
- @config.require_tunnel
25
- p "Starting the TestingBot Tunnel" if @options[:verbose] == true
26
- @process = IO.popen("exec java -jar #{get_jar_path} #{@options[:client_key] || @config[:client_key]} #{@options[:client_secret] || @config[:client_secret]} #{extra_options} 2>&1")
27
- at_exit do
28
- @@running = false
29
- # make sure we kill the tunnel
30
- Process.kill("INT", @process.pid) if @available == true
31
- end
32
-
33
- Thread.new do
34
- while (line = @process.gets)
35
- if line =~ /^You may start your tests/
36
- @available = true
37
- end
38
-
39
- if line =~ /Exception/ || line =~ /error/
40
- @errors << line
41
- end
42
-
43
- p line if @options[:verbose] == true
44
- end
45
- end
46
-
47
- poll_ready
48
-
49
- p "You are now ready to start your test" if @options[:verbose] == true
50
- end
51
-
52
- def is_connected?
53
- @available
54
- end
55
-
56
- def errors
57
- @errors || []
58
- end
59
-
60
- def stop
61
- raise "Can't stop tunnel, it has not been started yet" if @process.nil?
62
- p "Stopping TestingBot Tunnel" if @options[:verbose] == true
63
-
64
- kill
65
- end
66
-
67
- def kill
68
- @@running = false
69
- @available = false
70
- Process.kill("INT", @process.pid)
71
- Process.wait
72
- end
73
-
74
- def extra_options
75
- extra = @options[:options] || []
76
- extra.join(" ")
77
- end
78
-
79
- private
80
-
81
- def default_options
82
- {
83
- :verbose => true
84
- }
85
- end
86
-
87
- def get_jar_path
88
- file = File.expand_path(File.dirname(__FILE__) + '/../../vendor/Testingbot-Tunnel.jar')
89
- raise RuntimeException, "Could not find TestingBot-Tunnel.jar in vendor directory" unless File.exists?(file)
90
-
91
- file
92
- end
93
-
94
- def poll_ready
95
- seconds = 0
96
- while ((@available == false) && (seconds < TIMEOUT_SECONDS) && @errors.empty?)
97
- sleep 1
98
- seconds = seconds + 1
99
- end
100
-
101
- raise "Could not start Tunnel after #{TIMEOUT_SECONDS} seconds" if !is_connected? && @errors.empty?
102
- end
103
- end
104
- end