shoot 0.0.3 → 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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/shoot/cli.rb +5 -1
- data/lib/shoot/scenario.rb +10 -7
- data/lib/shoot/version.rb +1 -1
- data/shoot.gemspec +3 -2
- data/spec/cli_spec.rb +93 -0
- data/spec/scenario_spec.rb +31 -0
- metadata +26 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f471b23de129e1d36b02ac4f695648e991d260f0
|
4
|
+
data.tar.gz: 75106d08c978cbdb2ddaaacf05f67a27456f94b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6885fdc2f83d8145aed592e9727fa9f0cbb87718171e7505d582572903d00a6b2ba578765e08007409339e670407e2eaa587fb2ed8cc6e18ba52a11215df5d26
|
7
|
+
data.tar.gz: 2f81457e2f77ff7f49b6d436a754291773269d0e0898541e0341d6a9637cd86097b39b73c7cf745f559f6fa924794ae258e77de3971b0cd58ad2c7d384b806e5
|
data/README.md
CHANGED
data/lib/shoot/cli.rb
CHANGED
@@ -20,7 +20,7 @@ module Shoot
|
|
20
20
|
|
21
21
|
desc 'scenario', 'Runs the given scenario on all active platforms or one platform, based on ID'
|
22
22
|
def scenario(file, id = nil, test = 'all')
|
23
|
-
|
23
|
+
require_file(file)
|
24
24
|
klass_name = File.basename(file, '.rb').split('_').map(&:capitalize).join
|
25
25
|
klass = Kernel.const_get(klass_name)
|
26
26
|
|
@@ -50,6 +50,10 @@ module Shoot
|
|
50
50
|
end
|
51
51
|
|
52
52
|
no_commands do
|
53
|
+
def require_file(file)
|
54
|
+
require Dir.pwd + '/' + file
|
55
|
+
end
|
56
|
+
|
53
57
|
def table(browsers)
|
54
58
|
table = browsers.map do |p|
|
55
59
|
to_row(p)
|
data/lib/shoot/scenario.rb
CHANGED
@@ -23,6 +23,16 @@ class Shoot::Scenario
|
|
23
23
|
Capybara.current_driver = platform_name
|
24
24
|
end
|
25
25
|
|
26
|
+
def shoot(method)
|
27
|
+
send(method)
|
28
|
+
Kernel.sleep(1) # Just in case
|
29
|
+
require 'fileutils'
|
30
|
+
FileUtils::mkdir_p '.screenshots'
|
31
|
+
save_screenshot(".screenshots/#{method} #{platform_name}.png")
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
26
36
|
def platform_name
|
27
37
|
@platform_name ||= if @platform['device']
|
28
38
|
@platform['device']
|
@@ -50,11 +60,4 @@ class Shoot::Scenario
|
|
50
60
|
@capabilities[:device] = @platform['device'] if @platform['device']
|
51
61
|
end
|
52
62
|
|
53
|
-
def shoot(method)
|
54
|
-
send(method)
|
55
|
-
sleep(1) # Just in case
|
56
|
-
require 'fileutils'
|
57
|
-
FileUtils::mkdir_p '.screenshots'
|
58
|
-
save_screenshot(".screenshots/#{method} #{platform_name}.png")
|
59
|
-
end
|
60
63
|
end
|
data/lib/shoot/version.rb
CHANGED
data/shoot.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["juan.lulkin@klarna.com"]
|
11
11
|
spec.summary = %q{A helper to take shots on BrowserStack}
|
12
12
|
spec.description = %q{A helper to take shots on BrowserStack. Run the shoot binary for more info.}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "http://joaomilho.github.io/shoot"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -20,10 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2"
|
23
24
|
|
24
25
|
spec.add_dependency "selenium-webdriver", "~> 2.44"
|
25
26
|
spec.add_dependency "capybara", "~> 2.4"
|
26
27
|
spec.add_dependency "thor", "~> 0.19"
|
27
28
|
spec.add_dependency "colorize", "~> 0.7"
|
28
|
-
spec.add_dependency "rest_client"
|
29
|
+
spec.add_dependency "rest_client", "~> 1.7"
|
29
30
|
end
|
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require_relative '../lib/shoot/cli'
|
2
|
+
|
3
|
+
describe 'Shoot::CLI' do
|
4
|
+
subject(:cli) do
|
5
|
+
Shoot::CLI.new
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:mock_json) do
|
9
|
+
[
|
10
|
+
{os: "Foo", os_version: "Foo 1", browser: "Foo browser", device: nil, browser_version: "6.0", id: 0, 'active' => false},
|
11
|
+
{os: "Bar", os_version: "Bar 2", browser: "Bar browser", device: nil, browser_version: "7.0", id: 1, 'active' => true}
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
allow(cli).to receive(:json).and_return(mock_json)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'list' do
|
20
|
+
before do
|
21
|
+
allow(cli).to receive(:json).and_return(mock_json)
|
22
|
+
allow(cli).to receive(:table) {|arg| arg }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'list all' do
|
26
|
+
it 'show the json in a table' do
|
27
|
+
expect(cli.list).to eq(mock_json)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'list with filter' do
|
32
|
+
it 'show the the filtered json in a table' do
|
33
|
+
expect(cli.list("Foo browser")).to eq([mock_json[0]])
|
34
|
+
expect(cli.list("7.0")).to eq([mock_json[1]])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'active' do
|
40
|
+
before do
|
41
|
+
allow(cli).to receive(:table) {|arg| arg }
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'displays the active browsers' do
|
45
|
+
expect(cli.active).to eq([mock_json[1]])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'activate' do
|
50
|
+
before do
|
51
|
+
allow(cli).to receive(:table) {|arg| arg }
|
52
|
+
allow(cli).to receive(:save_json)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'activates the browser' do
|
56
|
+
expect{ cli.activate(0) }.to change{ mock_json[0]['active'] }.from(false).to(true)
|
57
|
+
expect(cli).to have_received(:save_json)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'deactivate' do
|
62
|
+
before do
|
63
|
+
allow(cli).to receive(:table) {|arg| arg }
|
64
|
+
allow(cli).to receive(:save_json)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'deactivates the browser' do
|
68
|
+
expect{ cli.deactivate(1) }.to change{ mock_json[1]['active'] }.from(true).to(false)
|
69
|
+
expect(cli).to have_received(:save_json)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'scenario' do
|
74
|
+
before do
|
75
|
+
class Foo
|
76
|
+
def initialize(config); end
|
77
|
+
def method; end
|
78
|
+
end
|
79
|
+
|
80
|
+
allow_any_instance_of(Foo).to receive(:shoot)
|
81
|
+
expect_any_instance_of(Foo).to receive(:ok)
|
82
|
+
|
83
|
+
allow(cli).to receive(:_active).and_return(["foo"])
|
84
|
+
allow(cli).to receive(:require_file)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'runs scenario' do
|
88
|
+
cli.scenario('foo.rb')
|
89
|
+
expect(cli).to have_received(:require_file)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative '../lib/shoot'
|
2
|
+
require 'capybara'
|
3
|
+
|
4
|
+
describe 'Shoot::Scenario' do
|
5
|
+
|
6
|
+
describe 'shoot' do
|
7
|
+
before do
|
8
|
+
allow(Capybara).to receive(:register_driver).with("browser 5.0 os 22.0")
|
9
|
+
allow(Capybara).to receive(:current_driver=).with("browser 5.0 os 22.0")
|
10
|
+
allow(FileUtils).to receive(:mkdir_p)
|
11
|
+
allow(Kernel).to receive(:sleep)
|
12
|
+
|
13
|
+
@scenario = Shoot::Scenario.new({
|
14
|
+
'browser' => 'browser',
|
15
|
+
'browser_version' => '5.0',
|
16
|
+
'os' => 'os',
|
17
|
+
'os_version' => '22.0'
|
18
|
+
})
|
19
|
+
|
20
|
+
allow(@scenario).to receive(:foo)
|
21
|
+
allow(@scenario).to receive(:save_screenshot)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'shoots' do
|
25
|
+
@scenario.shoot(:foo)
|
26
|
+
expect(@scenario).to have_received(:foo)
|
27
|
+
expect(@scenario).to have_received(:save_screenshot)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
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: 0.0
|
4
|
+
version: 0.1.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-02-
|
11
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: selenium-webdriver
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,16 +112,16 @@ dependencies:
|
|
98
112
|
name: rest_client
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- - "
|
115
|
+
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
117
|
+
version: '1.7'
|
104
118
|
type: :runtime
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- - "
|
122
|
+
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
124
|
+
version: '1.7'
|
111
125
|
description: A helper to take shots on BrowserStack. Run the shoot binary for more
|
112
126
|
info.
|
113
127
|
email:
|
@@ -130,7 +144,9 @@ files:
|
|
130
144
|
- lib/shoot/version.rb
|
131
145
|
- shoot-0.0.2.gem
|
132
146
|
- shoot.gemspec
|
133
|
-
|
147
|
+
- spec/cli_spec.rb
|
148
|
+
- spec/scenario_spec.rb
|
149
|
+
homepage: http://joaomilho.github.io/shoot
|
134
150
|
licenses:
|
135
151
|
- MIT
|
136
152
|
metadata: {}
|
@@ -154,4 +170,6 @@ rubygems_version: 2.2.2
|
|
154
170
|
signing_key:
|
155
171
|
specification_version: 4
|
156
172
|
summary: A helper to take shots on BrowserStack
|
157
|
-
test_files:
|
173
|
+
test_files:
|
174
|
+
- spec/cli_spec.rb
|
175
|
+
- spec/scenario_spec.rb
|