shoot 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +70 -0
- data/Rakefile +2 -0
- data/bin/shoot +5 -0
- data/lib/shoot/cli.rb +90 -0
- data/lib/shoot/scenario.rb +58 -0
- data/lib/shoot/version.rb +3 -0
- data/lib/shoot.rb +5 -0
- data/shoot.gemspec +29 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b7f66f4f6cbb2bfc395676753d9caf658eea2a2f
|
4
|
+
data.tar.gz: 30a61b20f76d2a68d9eac98675f145c056fa1b6d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 26b92ed0a68cf7e763bd0850326580eecc22984d230a924cdc98f934896b66c78fa6e7fec5743c33bc21ed5a154321e6aeef50702ed50bdb90ebf127cf4cc94e
|
7
|
+
data.tar.gz: b8b77da37f0600c7ff6eccb5e6d57d16876dced267345dcb83d93ae50ea598c2f9caf3220ccbf8d3280c18d152c45c45a27bbfe856cd70b9ca1644aa1dbd2aa9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright (c) 2015, Juan Lulkin <maiz at lulk in>
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Juan Lulkin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Shoot
|
2
|
+
|
3
|
+
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.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :test do
|
11
|
+
gem 'shoot'
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Shoot installs a binary. To inspect it, just run:
|
22
|
+
|
23
|
+
$ shoot
|
24
|
+
|
25
|
+
The first thing you should do is:
|
26
|
+
|
27
|
+
$ shoot list
|
28
|
+
ID OS # Browser # Device
|
29
|
+
0 OS X Snow Leopard safari 5.1
|
30
|
+
1 OS X Snow Leopard chrome 14.0
|
31
|
+
2 OS X Snow Leopard chrome 16.0
|
32
|
+
...
|
33
|
+
537 ios 7.0 ipad iPad mini Retina
|
34
|
+
538 ios 7.0 iphone iPhone 5S
|
35
|
+
539 ios 7.0 iphone iPhone 5C
|
36
|
+
|
37
|
+
The `list` command basically fetches all browsers available on BrowserStack and caches them locally on `.browsers.json`. You can choose to add this file on yout `.gitignore`.
|
38
|
+
|
39
|
+
Then, you can choose to activate the browsers you wanna use, based on id. Example:
|
40
|
+
|
41
|
+
$ shoot activate 2
|
42
|
+
|
43
|
+
This will activate (given your output is the same as above) chrome 16 on OS X Snow Leopard.
|
44
|
+
|
45
|
+
Now, create a scenario. Here's an example:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
class MyScenario < Shoot::Scenario
|
49
|
+
def login
|
50
|
+
visit "http://url.to.login"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
As you can see, it follows [capybara's](https://github.com/jnicklas/capybara) syntax, so you can visit pages, fill forms, click links and so on...
|
56
|
+
|
57
|
+
Now run:
|
58
|
+
|
59
|
+
$ shoot scenario my_scenario.rb
|
60
|
+
|
61
|
+
This will run all the methods of MyScenario and generate screenshots for all active browsers.
|
62
|
+
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
1. Fork it ( https://github.com/joaomilho/shoot/fork )
|
67
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
68
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
70
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/shoot
ADDED
data/lib/shoot/cli.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'json'
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
module Shoot
|
6
|
+
class CLI < Thor
|
7
|
+
BROWSERS_PATH = '.browsers.json'
|
8
|
+
|
9
|
+
desc 'list', 'List all platforms. Optionally pass a filter (e.g. browserstack list ie)'
|
10
|
+
def list(filter = nil)
|
11
|
+
table json.select { |p| p.inspect =~ /#{filter}/i }
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'active', 'List active platforms.'
|
15
|
+
def active
|
16
|
+
table _active
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'scenario', 'Runs the given scenario on all active platforms or one platform, based on ID'
|
20
|
+
def scenario(file, id = nil, test = 'all')
|
21
|
+
require Dir.pwd + '/' + file
|
22
|
+
klass_name = File.basename(file, '.rb').split('_').map(&:capitalize).join
|
23
|
+
klass = Kernel.const_get(klass_name)
|
24
|
+
|
25
|
+
runners = id ? [json[id.to_i]] : _active
|
26
|
+
runners.each do |config|
|
27
|
+
instance = klass.new(config)
|
28
|
+
klass.instance_methods(false).each do |method|
|
29
|
+
instance.shoot(method)
|
30
|
+
end
|
31
|
+
instance.ok
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'activate', 'Activate one platform, based on ID or interval'
|
36
|
+
def activate(from_id, to_id = from_id)
|
37
|
+
ids = (from_id.to_i..to_id.to_i).to_a
|
38
|
+
ids.each { |id| json[id]['active'] = true }
|
39
|
+
save_json
|
40
|
+
table json[from_id.to_i - 2, ids.size + 4]
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'deactivate', 'Deactivate one platform, based on ID'
|
44
|
+
def deactivate(id)
|
45
|
+
json[id.to_i]['active'] = false
|
46
|
+
save_json
|
47
|
+
table json[id.to_i - 2, 5]
|
48
|
+
end
|
49
|
+
|
50
|
+
no_commands do
|
51
|
+
def table(browsers)
|
52
|
+
table = browsers.map do |p|
|
53
|
+
to_row(p)
|
54
|
+
end.unshift(['ID', 'OS #', 'Browser #', 'Device'])
|
55
|
+
print_table table, truncate: true
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_row(p)
|
59
|
+
[
|
60
|
+
p['id'].to_s.colorize(p['active'] ? :green : :red),
|
61
|
+
"#{p['os']} #{p['os_version']}",
|
62
|
+
"#{p['browser']} #{p['browser_version']}",
|
63
|
+
p['device']
|
64
|
+
]
|
65
|
+
end
|
66
|
+
|
67
|
+
def json
|
68
|
+
File.write(BROWSERS_PATH, JSON.dump(fetch_json_and_prepare)) unless File.exist?(BROWSERS_PATH)
|
69
|
+
@json ||= JSON.parse(File.read(BROWSERS_PATH))
|
70
|
+
end
|
71
|
+
|
72
|
+
def _active
|
73
|
+
@active ||= json.select { |p| p['active'] }
|
74
|
+
end
|
75
|
+
|
76
|
+
def save_json
|
77
|
+
File.write(BROWSERS_PATH, JSON.dump(json))
|
78
|
+
end
|
79
|
+
|
80
|
+
def fetch_json_and_prepare
|
81
|
+
require 'rest_client'
|
82
|
+
JSON.parse(RestClient.get("https://juanlulkin1:NDswkopCqKPmA9wWAQws@www.browserstack.com/automate/browsers.json")).tap do |json|
|
83
|
+
json.each_with_index do |browser, index|
|
84
|
+
browser['id'] = index
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'selenium-webdriver'
|
2
|
+
require 'capybara'
|
3
|
+
|
4
|
+
class Shoot::Scenario
|
5
|
+
URL = sprintf 'http://%s:%s@hub.browserstack.com/wd/hub',
|
6
|
+
ENV['BROWSERSTACK_USER'],
|
7
|
+
ENV['BROWSERSTACK_KEY']
|
8
|
+
|
9
|
+
include Capybara::DSL
|
10
|
+
|
11
|
+
def initialize(platform)
|
12
|
+
@platform = platform
|
13
|
+
config_capabilities
|
14
|
+
|
15
|
+
Capybara.register_driver platform_name do |app|
|
16
|
+
Capybara::Selenium::Driver.new(app,
|
17
|
+
browser: :remote,
|
18
|
+
url: URL,
|
19
|
+
desired_capabilities: @capabilities)
|
20
|
+
end
|
21
|
+
|
22
|
+
puts "Running #{platform_name}"
|
23
|
+
Capybara.current_driver = platform_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def platform_name
|
27
|
+
@platform_name ||= if @platform['device']
|
28
|
+
@platform['device']
|
29
|
+
else
|
30
|
+
name_items = %w(browser browser_version os os_version)
|
31
|
+
@platform.values_at(*name_items).join(' ')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def ok
|
36
|
+
puts 'OK'
|
37
|
+
page.driver.quit
|
38
|
+
end
|
39
|
+
|
40
|
+
def config_capabilities # rubocop:disable AbcSize
|
41
|
+
@capabilities = Selenium::WebDriver::Remote::Capabilities.new
|
42
|
+
@capabilities[:browser] = @platform['browser']
|
43
|
+
@capabilities[:browser_version] = @platform['browser_version']
|
44
|
+
@capabilities[:os] = @platform['os']
|
45
|
+
@capabilities[:os_version] = @platform['os_version']
|
46
|
+
@capabilities['browserstack.debug'] = 'true'
|
47
|
+
@capabilities[:name] = "Digital Goods - #{@platform}"
|
48
|
+
@capabilities[:browserName] = @platform['browser']
|
49
|
+
@capabilities[:platform] = @platform['os']
|
50
|
+
@capabilities[:device] = @platform['device'] if @platform['device']
|
51
|
+
end
|
52
|
+
|
53
|
+
def shoot(method)
|
54
|
+
send(method)
|
55
|
+
sleep(1) # Just in case
|
56
|
+
save_screenshot("shoot/screenshots/#{method} #{platform_name}.png")
|
57
|
+
end
|
58
|
+
end
|
data/lib/shoot.rb
ADDED
data/shoot.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "shoot/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "shoot"
|
8
|
+
spec.version = Shoot::VERSION
|
9
|
+
spec.authors = ["Juan Lulkin"]
|
10
|
+
spec.email = ["juan.lulkin@klarna.com"]
|
11
|
+
spec.summary = %q{A helper to take shots on BrowserStack}
|
12
|
+
spec.description = %q{A helper to take shots on BrowserStack. Run the shoot binary for more info.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_dependency "selenium-webdriver", "~> 2.44"
|
25
|
+
spec.add_dependency "capybara", "~> 2.4"
|
26
|
+
spec.add_dependency "thor", "~> 0.19"
|
27
|
+
spec.add_dependency "colorize", "~> 0.7"
|
28
|
+
spec.add_dependency "rest_client"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shoot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juan Lulkin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: selenium-webdriver
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.44'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.44'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capybara
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.4'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.19'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.19'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: colorize
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.7'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rest_client
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A helper to take shots on BrowserStack. Run the shoot binary for more
|
112
|
+
info.
|
113
|
+
email:
|
114
|
+
- juan.lulkin@klarna.com
|
115
|
+
executables:
|
116
|
+
- shoot
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/shoot
|
127
|
+
- lib/shoot.rb
|
128
|
+
- lib/shoot/cli.rb
|
129
|
+
- lib/shoot/scenario.rb
|
130
|
+
- lib/shoot/version.rb
|
131
|
+
- shoot.gemspec
|
132
|
+
homepage: ''
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.2.2
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: A helper to take shots on BrowserStack
|
156
|
+
test_files: []
|