integration-diff 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +42 -3
- data/lib/integration_diff/dummy_runner.rb +3 -0
- data/lib/integration_diff/runner.rb +13 -1
- data/lib/integration_diff/uploaders/concurrent.rb +5 -2
- data/lib/integration_diff/uploaders/sequential.rb +11 -5
- data/lib/integration_diff/utils.rb +5 -2
- data/lib/integration_diff/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: 631209ac6e776d921e664db5fed095e6178b761b
|
4
|
+
data.tar.gz: 25ae1b328f8c0f77a88ec995e34223f4af6b90e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89b9abd69d75548df40336e7f5db4ae9d30eabf0c49792b34695f3803e287e7fc5dc5cfcff197bfcb524920ce13f7c37b7356be5bb6a8de393c3180b71f5c65b
|
7
|
+
data.tar.gz: 00836038fc50f5d024a5ffcc9dee2bebfefdd5a2a3e1b334527af5e42c94d281e3d135d0d57a2026a204c32ea46bb87f109fb1739468451d07b0853ab3ef521c
|
data/Readme.md
CHANGED
@@ -60,20 +60,59 @@ end
|
|
60
60
|
|
61
61
|
### Usage
|
62
62
|
|
63
|
-
In your specs, simply use `idiff` helper
|
64
|
-
|
65
|
-
|
63
|
+
In your specs, simply use `idiff` helper which has bunch of config utilities.
|
64
|
+
|
65
|
+
First, you should specify environment details under which screenshots are
|
66
|
+
taken. There are 6 parameters which can be configured.
|
67
|
+
|
68
|
+
Parameter|Explanation
|
69
|
+
---------|-----------
|
70
|
+
browser | which browser is used to take screenshots. default: 'firefox'
|
71
|
+
| supported: firefox, chrome, safari, ie, opera
|
72
|
+
device | which device is used to take screenshots. default: 'desktop'
|
73
|
+
| supported: desktop, laptop, tablet, phone
|
74
|
+
os | which os is used to take screenshots. default: 'linux'
|
75
|
+
| supported: android, ios, windows, osx, linux
|
76
|
+
browser_version | (optional) version of browser used, for eg: '46' for firefox
|
77
|
+
device_name | (optional) name of device, for eg: 'MacBook Air'
|
78
|
+
os_version | (optional) version of os used, for eg: '10.11'
|
79
|
+
|
80
|
+
|
81
|
+
They can be configured using `idiff` helper while running specs. For eg:
|
82
|
+
|
83
|
+
```rb
|
84
|
+
idiff.browser = 'firefox'
|
85
|
+
idiff.device = 'laptop'
|
86
|
+
idiff.os = 'osx'
|
87
|
+
idiff.browser_version = '46'
|
88
|
+
idiff.device_name = 'MBA'
|
89
|
+
idiff.os_version = '10.11.5'
|
90
|
+
```
|
91
|
+
|
92
|
+
Also, `idiff` can used to take screenshots also. Make sure that you pass
|
93
|
+
unique identifier to screenshots that you take. unique identifier helps
|
94
|
+
in differentiating this screenshot taken from other screenshots for a
|
95
|
+
given set of `browser`, `device`, and `os`.
|
66
96
|
|
67
97
|
|
68
98
|
```rb
|
69
99
|
describe "Landing page" do
|
70
100
|
it "has a big banner" do
|
71
101
|
visit root_path
|
102
|
+
|
103
|
+
idiff.browser = 'chrome'
|
72
104
|
idiff.screenshot("unique-identifier")
|
73
105
|
end
|
74
106
|
end
|
75
107
|
```
|
76
108
|
|
109
|
+
Since there is flexibility to specify `browser`, `device`, and `os` while
|
110
|
+
running specs dynamically (unlike specifying `project_name`), you can run
|
111
|
+
all your specs in a loop by changing `browser`, `device` and `os` by
|
112
|
+
changing selenium driver, or changing viewport etc. Flexibility for your
|
113
|
+
service!
|
114
|
+
|
115
|
+
|
77
116
|
### Concurrency
|
78
117
|
|
79
118
|
By default, when all the screenshots are collected, and before suite ends, this
|
@@ -13,6 +13,9 @@ module IntegrationDiff
|
|
13
13
|
IntegrationDiff.javascript_driver)
|
14
14
|
end
|
15
15
|
|
16
|
+
attr_accessor :browser, :device, :os
|
17
|
+
attr_accessor :browser_version, :device_name, :os_version
|
18
|
+
|
16
19
|
def initialize(project_name, javascript_driver)
|
17
20
|
@project_name = project_name
|
18
21
|
@javascript_driver = javascript_driver
|
@@ -20,6 +23,10 @@ module IntegrationDiff
|
|
20
23
|
dir = IntegrationDiff::Utils.images_dir
|
21
24
|
Dir.mkdir('tmp') unless Dir.exist?('tmp')
|
22
25
|
Dir.mkdir(dir) unless Dir.exist?(dir)
|
26
|
+
|
27
|
+
self.browser = 'firefox'
|
28
|
+
self.device = 'desktop'
|
29
|
+
self.os = 'linux'
|
23
30
|
end
|
24
31
|
|
25
32
|
# TODO: Improve error handling here for network timeouts
|
@@ -42,9 +49,14 @@ module IntegrationDiff
|
|
42
49
|
end
|
43
50
|
|
44
51
|
def screenshot(identifier)
|
52
|
+
raise 'no browser information provided' if browser.nil?
|
53
|
+
raise 'no device information provided' if device.nil?
|
54
|
+
raise 'no os information provided' if os.nil?
|
55
|
+
|
45
56
|
screenshot_name = IntegrationDiff::Utils.image_file(identifier)
|
46
57
|
page.save_screenshot(screenshot_name, full: true)
|
47
|
-
@uploader.enqueue(identifier
|
58
|
+
@uploader.enqueue(identifier, browser, device, os, browser_version,
|
59
|
+
device_name, os_version)
|
48
60
|
end
|
49
61
|
|
50
62
|
private
|
@@ -11,11 +11,14 @@ module IntegrationDiff
|
|
11
11
|
@screenshots_taken = 0
|
12
12
|
end
|
13
13
|
|
14
|
-
def enqueue(identifier
|
14
|
+
def enqueue(identifier, browser, device, os, browser_version,
|
15
|
+
device_name, os_version)
|
15
16
|
@screenshots_taken += 1
|
16
17
|
|
17
18
|
@pool.post do
|
18
|
-
IntegrationDiff::Utils
|
19
|
+
IntegrationDiff::Utils
|
20
|
+
.upload_image(@run_id, identifier, browser, device, os,
|
21
|
+
browser_version, device_name, os_version)
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
@@ -5,16 +5,22 @@ module IntegrationDiff
|
|
5
5
|
class Sequential
|
6
6
|
def initialize(run_id)
|
7
7
|
@run_id = run_id
|
8
|
-
@
|
8
|
+
@identifiers_with_env = []
|
9
9
|
end
|
10
10
|
|
11
|
-
def enqueue(identifier
|
12
|
-
|
11
|
+
def enqueue(identifier, browser, device, os, browser_version,
|
12
|
+
device_name, os_version)
|
13
|
+
@identifiers_with_env << [identifier, browser, device, os,
|
14
|
+
browser_version, device_name,
|
15
|
+
os_version]
|
13
16
|
end
|
14
17
|
|
15
18
|
def wrapup
|
16
|
-
@
|
17
|
-
|
19
|
+
@identifiers_with_env
|
20
|
+
.each do |identifier, browser, device, os, browser_version, device_name, os_version|
|
21
|
+
IntegrationDiff::Utils
|
22
|
+
.upload_image(@run_id, identifier, browser, device, os,
|
23
|
+
browser_version, device_name, os_version)
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
@@ -15,11 +15,14 @@ module IntegrationDiff
|
|
15
15
|
'tmp/idiff_images'.freeze
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.upload_image(run_id, identifier
|
18
|
+
def self.upload_image(run_id, identifier, browser, device, os, browser_version,
|
19
|
+
device_name, os_version)
|
19
20
|
IntegrationDiff.logger.fatal "uploading #{identifier}"
|
20
21
|
image_io = Faraday::UploadIO.new(image_file(identifier), 'image/png')
|
21
22
|
connection.post("/api/v1/runs/#{run_id}/run_images",
|
22
|
-
identifier: identifier, image: image_io
|
23
|
+
identifier: identifier, image: image_io, browser: browser,
|
24
|
+
device: device, os: os, browser_version: browser_version,
|
25
|
+
device_name: device_name, os_version: os_version)
|
23
26
|
end
|
24
27
|
|
25
28
|
def self.image_file(identifier)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: integration-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|