shoot 2.1.0 → 3.0.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.
- checksums.yaml +4 -4
- data/README.md +12 -16
- data/lib/shoot/cli.rb +4 -32
- data/lib/shoot/scenario.rb +36 -15
- data/lib/shoot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ca9a9451cff2cc399deb61e11c3fd1f18bff01a
|
4
|
+
data.tar.gz: 4d3aabcee015d1579598430f3d4c3f6834d61d31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56fe978d7c64ce752396bc1c09dcccc5deab326568c1eccc7f9cee00036e7200a75cd07ac48c227d7c172e0e7f36e1e6bc7049d389636bf40644857aa421173f
|
7
|
+
data.tar.gz: 679738bbf228d54c4b788b9b2618cc7ecc185ebe5ffc788c8eeb7071d60448649fa34f0c72031a98cc6b0062abf3d12f52d72738811da568d92df1cbf72e7284
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
# Shoot
|
5
5
|
|
6
|
-
Shoot is a helper library to take screenshots using BrowserStack. If you don't need a full integration test coupled with screenshots, it's a simpler choice.
|
6
|
+
Shoot is a helper library to take screenshots using [BrowserStack](https://www.browserstack.com/). If you don't need a full integration test coupled with screenshots, it's a simpler choice.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -39,14 +39,12 @@ The first thing you should do is:
|
|
39
39
|
538 ios 7.0 iphone iPhone 5S
|
40
40
|
539 ios 7.0 iphone iPhone 5C
|
41
41
|
|
42
|
-
The `list` command basically fetches all browsers available on BrowserStack and caches them locally on `.screenshots/.browsers.json`. You can choose to add this folder on your `.gitignore`, since shoot will save all images there as well.
|
42
|
+
The `list` command basically fetches all browsers available on [BrowserStack](https://www.browserstack.com/) and caches them locally on `.screenshots/.browsers.json`. You can choose to add this folder on your `.gitignore`, since shoot will save all images there as well.
|
43
43
|
|
44
44
|
Then, you can choose to activate the browsers you wanna use, based on id. Example:
|
45
45
|
|
46
46
|
$ shoot activate 2
|
47
47
|
|
48
|
-
This will activate (given your output is the same as above) chrome 16 on OS X Snow Leopard.
|
49
|
-
|
50
48
|
Now, create a scenario. Here's an example:
|
51
49
|
|
52
50
|
```ruby
|
@@ -87,7 +85,7 @@ end
|
|
87
85
|
```
|
88
86
|
|
89
87
|
|
90
|
-
If you wanna just test your scenarios, without paying
|
88
|
+
If you wanna just test your scenarios, without paying [BrowserStack](https://www.browserstack.com/) and wasting time with remote connections:
|
91
89
|
|
92
90
|
$ shoot test my_scenario.rb
|
93
91
|
|
@@ -95,14 +93,12 @@ Or you can run a whole folder, like:
|
|
95
93
|
|
96
94
|
$ shoot test my_scenarios/
|
97
95
|
|
98
|
-
The `test` command will run locally using phantomjs (
|
96
|
+
The `test` command will run locally using [phantomjs](http://phantomjs.org/) ([poltergeist](https://github.com/teampoltergeist/poltergeist)).
|
99
97
|
|
100
98
|
You can choose to deactivate the browsers you don't wanna use, based on id as well. Example:
|
101
99
|
|
102
100
|
$ shoot deactivate 2
|
103
101
|
|
104
|
-
This will deactivate (given your output is the same as above) chrome 16 on OS X Snow Leopard.
|
105
|
-
|
106
102
|
If you want to deactivate all the active browsers at once you can run:
|
107
103
|
|
108
104
|
$ shoot deactivate_all
|
@@ -145,9 +141,9 @@ You got the idea.
|
|
145
141
|
shoot update # Update browser list (WARNING: will override active browsers)
|
146
142
|
shoot version, --version, -v # Shoot version
|
147
143
|
|
148
|
-
### Using ngrok
|
144
|
+
### Using [ngrok](https://ngrok.com/)
|
149
145
|
|
150
|
-
In order to access your local development environment on BrowserStack you need to forward it somehow to the external
|
146
|
+
In order to access your local development environment on [BrowserStack](https://www.browserstack.com/) you need to forward it somehow to the external world (a.k.a. the internet). [BrowserStack](https://www.browserstack.com/) has it's own forwarder, but [ngrok](https://ngrok.com/) is better. If you wanna use it:
|
151
147
|
|
152
148
|
1. Install it from [https://ngrok.com/download](https://ngrok.com/download)
|
153
149
|
|
@@ -157,25 +153,25 @@ In order to access your local development environment on BrowserStack you need t
|
|
157
153
|
|
158
154
|
``` ruby
|
159
155
|
def my_test
|
160
|
-
my_server = Shoot::Ngrok(12345)
|
156
|
+
my_server = Shoot::Ngrok.new(12345)
|
161
157
|
visit my_server.url
|
162
158
|
end
|
163
159
|
```
|
164
160
|
|
165
|
-
Where `12345` is the port of your local server. The default is `3000`, since I believe you're probably using Rails.
|
161
|
+
Where `12345` is the port of your local server. The default is `3000`, since I believe you're probably using [Rails](http://rubyonrails.org/).
|
166
162
|
|
167
|
-
#### What if I'm using pow?
|
163
|
+
#### What if I'm using [pow](http://pow.cx)?
|
168
164
|
|
169
|
-
If you're using pow, skip step 3 above and do it like this instead:
|
165
|
+
If you're using [pow](http://pow.cx), skip step 3 above and do it like this instead:
|
170
166
|
|
171
167
|
``` ruby
|
172
168
|
def my_test
|
173
|
-
my_server = Shoot::NgrokPow(:my_server_folder)
|
169
|
+
my_server = Shoot::NgrokPow.new(:my_server_folder)
|
174
170
|
visit my_server.url
|
175
171
|
end
|
176
172
|
```
|
177
173
|
|
178
|
-
NgrokPow will create another symlink of your server folder with a unique name and forward it correctly to ngrok. This symlink will be properly removed at the end of the execution of shoot.
|
174
|
+
NgrokPow will create another symlink of your server folder with a unique name and forward it correctly to [ngrok](https://ngrok.com/). This symlink will be properly removed at the end of the execution of shoot.
|
179
175
|
|
180
176
|
## Contributing
|
181
177
|
|
data/lib/shoot/cli.rb
CHANGED
@@ -9,41 +9,12 @@ module Shoot
|
|
9
9
|
require 'fileutils'
|
10
10
|
FileUtils::mkdir_p '.screenshots'
|
11
11
|
map %w[--version -v] => :version
|
12
|
-
map %w[--interactive -i] => :interactive
|
13
12
|
|
14
13
|
desc 'version, --version, -v', 'Shoot version'
|
15
14
|
def version
|
16
15
|
puts Shoot::VERSION
|
17
16
|
end
|
18
17
|
|
19
|
-
INTERACTIVE_COMMANDS = {
|
20
|
-
active: ->(_) { active },
|
21
|
-
activate: ->(params){ activate(*params.split(" ")) },
|
22
|
-
deactivate: ->(params){ deactivate(*params.split(" ")) },
|
23
|
-
deactivate_all: ->(_) { deactivate_all },
|
24
|
-
list: ->(params){ list(params) },
|
25
|
-
open: ->(_) { open },
|
26
|
-
test: ->(params){ test(params) },
|
27
|
-
scenario: ->(params){ scenario(params) },
|
28
|
-
update: ->(_) { update },
|
29
|
-
exit: ->(_) { @exit = true }
|
30
|
-
}
|
31
|
-
|
32
|
-
desc 'interactive, --interactive, -i', 'Interactive mode'
|
33
|
-
def interactive
|
34
|
-
@exit = false
|
35
|
-
while ! @exit
|
36
|
-
choose do |menu|
|
37
|
-
menu.layout = :menu_only
|
38
|
-
menu.shell = true
|
39
|
-
|
40
|
-
INTERACTIVE_COMMANDS.each do |command_name, command_action|
|
41
|
-
menu.choice(command_name, desc(command_name)){|_, details| command_action.call(details) }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
18
|
desc 'open', 'Opens all screenshots taken'
|
48
19
|
def open
|
49
20
|
`open #{Dir.glob(".screenshots/**/*.png").join(" ")}`
|
@@ -59,12 +30,13 @@ module Shoot
|
|
59
30
|
table Browser.active
|
60
31
|
end
|
61
32
|
|
62
|
-
desc 'scenario PATH', 'Runs the given scenario or all files in a directory on all active platforms'
|
63
|
-
def scenario(path)
|
33
|
+
desc 'scenario PATH', 'Runs the given scenario or all files in a directory on all active or specified platforms'
|
34
|
+
def scenario(path, *browser_ids)
|
64
35
|
scenarios = File.directory?(path) ? Dir.glob("#{path}/*.rb") : [path]
|
65
36
|
|
37
|
+
browsers = browser_ids.empty? ? Browser.active : Browser.select_by_ids(browser_ids)
|
66
38
|
elapsed_time do
|
67
|
-
|
39
|
+
browsers.each do |browser|
|
68
40
|
scenarios.each do |scenario|
|
69
41
|
run scenario, browser
|
70
42
|
end
|
data/lib/shoot/scenario.rb
CHANGED
@@ -3,12 +3,17 @@ require 'capybara'
|
|
3
3
|
require 'timeout'
|
4
4
|
|
5
5
|
class Shoot::Scenario
|
6
|
-
URL = sprintf 'http://%s:%s@hub.browserstack.com/wd/hub',
|
7
|
-
ENV['BROWSERSTACK_USER'],
|
8
|
-
ENV['BROWSERSTACK_KEY']
|
9
6
|
|
10
7
|
include Capybara::DSL
|
11
8
|
|
9
|
+
def self.url
|
10
|
+
raise "I guess you forgot your browserstack credetials. Take a look at the docs." unless ENV['BROWSERSTACK_USER'] and ENV['BROWSERSTACK_KEY']
|
11
|
+
|
12
|
+
@@url ||= sprintf 'http://%s:%s@hub.browserstack.com/wd/hub',
|
13
|
+
ENV['BROWSERSTACK_USER'],
|
14
|
+
ENV['BROWSERSTACK_KEY']
|
15
|
+
end
|
16
|
+
|
12
17
|
def initialize(platform=nil)
|
13
18
|
if platform
|
14
19
|
@platform = platform
|
@@ -17,12 +22,21 @@ class Shoot::Scenario
|
|
17
22
|
Capybara.register_driver platform_name do |app|
|
18
23
|
Capybara::Selenium::Driver.new(app,
|
19
24
|
browser: :remote,
|
20
|
-
url:
|
25
|
+
url: Shoot::Scenario.url,
|
21
26
|
desired_capabilities: @capabilities)
|
22
27
|
end
|
23
28
|
else
|
24
29
|
require 'capybara/poltergeist'
|
25
30
|
|
31
|
+
options = {
|
32
|
+
:js_errors => false,
|
33
|
+
:phantomjs_options => ["--web-security=false"]
|
34
|
+
}
|
35
|
+
|
36
|
+
Capybara.register_driver :poltergeist do |app|
|
37
|
+
Capybara::Poltergeist::Driver.new(app, options)
|
38
|
+
end
|
39
|
+
|
26
40
|
Capybara.run_server = false
|
27
41
|
@platform_name = :poltergeist
|
28
42
|
end
|
@@ -30,16 +44,6 @@ class Shoot::Scenario
|
|
30
44
|
Capybara.current_driver = platform_name
|
31
45
|
end
|
32
46
|
|
33
|
-
def find *args
|
34
|
-
Timeout.timeout(10) do
|
35
|
-
begin
|
36
|
-
super *args
|
37
|
-
rescue
|
38
|
-
retry
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
47
|
def run(method)
|
44
48
|
@current_method = method
|
45
49
|
send(method)
|
@@ -68,6 +72,22 @@ class Shoot::Scenario
|
|
68
72
|
end
|
69
73
|
end
|
70
74
|
|
75
|
+
protected
|
76
|
+
|
77
|
+
# In Selenium the enter key is :return
|
78
|
+
# and on poltergeits it is :Enter
|
79
|
+
def enter_key
|
80
|
+
remote? ? :return : :Enter
|
81
|
+
end
|
82
|
+
|
83
|
+
def remote?
|
84
|
+
@platform_name != :poltergeist
|
85
|
+
end
|
86
|
+
|
87
|
+
def send_enter(selector)
|
88
|
+
find(selector).native.send_key(enter_key)
|
89
|
+
end
|
90
|
+
|
71
91
|
private
|
72
92
|
|
73
93
|
def directory
|
@@ -80,7 +100,7 @@ class Shoot::Scenario
|
|
80
100
|
end
|
81
101
|
|
82
102
|
def shoot(label)
|
83
|
-
save_screenshot("#{directory}/#{label}.png")
|
103
|
+
save_screenshot("#{directory}/#{label}.png", full: true)
|
84
104
|
rescue => e
|
85
105
|
File.write("#{directory}/#{label}.error.txt", %(#{e.inspect}\n\n#{e.backtrace.join("\n")}))
|
86
106
|
end
|
@@ -97,6 +117,7 @@ class Shoot::Scenario
|
|
97
117
|
@capabilities[:platform] = @platform.os
|
98
118
|
@capabilities[:device] = @platform.device if @platform.device
|
99
119
|
@capabilities[:emulator] = @platform.emulator
|
120
|
+
@capabilities[:rotatable] = true
|
100
121
|
end
|
101
122
|
|
102
123
|
end
|
data/lib/shoot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Lulkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|