so_many_devices 0.1.0 → 1.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/.gitignore +1 -0
- data/.semaphore/main-deploy.yml +19 -0
- data/.semaphore/semaphore.yml +31 -0
- data/CHANGELOG.md +13 -0
- data/README.md +66 -8
- data/Rakefile +1 -1
- data/lib/so_many_devices/downloads_helper.rb +45 -0
- data/lib/so_many_devices/version.rb +1 -1
- data/lib/so_many_devices.rb +19 -8
- data/so_many_devices.gemspec +16 -13
- metadata +40 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2083f8748f8786c8ec499d5f9a67b6d97d5fc5080c3c7bfb82ee2217bb9ae515
|
4
|
+
data.tar.gz: '09eb90cbaac0a1ae8d4f2c4dac0dc5e96306bd03bea6d2f6dd8b24fc0b475f7f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef4f46954c438c4be338b370918fed154e2f9dde3d51e765d40ec5ed489c63c827af69f3eb3c432f003deb028dcd58b117ba57fc7d9754599d10e2dbc3e4622b
|
7
|
+
data.tar.gz: 2b2509f8b113fea58f28010997f90f58d7d73f365e49b45db826a3dc0a80e5261b04fd1ee5729410cf0c9532ee9ae4d3ab4f04f1e7af80a57e999b7e53950e23
|
data/.gitignore
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
version: v1.0
|
2
|
+
name: main-deploy
|
3
|
+
agent:
|
4
|
+
machine:
|
5
|
+
type: e1-standard-2
|
6
|
+
os_image: ubuntu1804
|
7
|
+
|
8
|
+
blocks:
|
9
|
+
- name: main-deploy
|
10
|
+
task:
|
11
|
+
secrets:
|
12
|
+
- name: rubygems-deploy
|
13
|
+
jobs:
|
14
|
+
- name: main-deploy
|
15
|
+
commands:
|
16
|
+
- checkout --use-cache
|
17
|
+
- gem build so_many_devices
|
18
|
+
- chmod 0600 ~/.gem/credentials
|
19
|
+
- gem push so_many_devices-*.gem
|
@@ -0,0 +1,31 @@
|
|
1
|
+
version: "v1.0"
|
2
|
+
name: so_many_devices
|
3
|
+
agent:
|
4
|
+
machine:
|
5
|
+
type: e1-standard-2
|
6
|
+
os_image: ubuntu1804
|
7
|
+
auto_cancel:
|
8
|
+
running:
|
9
|
+
when: "true"
|
10
|
+
|
11
|
+
blocks:
|
12
|
+
- name: tests
|
13
|
+
execution_time_limit:
|
14
|
+
minutes: 10
|
15
|
+
dependencies: []
|
16
|
+
task:
|
17
|
+
env_vars:
|
18
|
+
- name: RAILS_ENV
|
19
|
+
value: test
|
20
|
+
jobs:
|
21
|
+
- name: tests
|
22
|
+
commands:
|
23
|
+
- checkout --use-cache
|
24
|
+
- cache restore
|
25
|
+
- bundle install -j 4 --path vendor/bundle
|
26
|
+
- cache store
|
27
|
+
- bundle exec standardrb
|
28
|
+
- bundle exec rspec
|
29
|
+
promotions:
|
30
|
+
- name: main
|
31
|
+
pipeline_file: main-deploy.yml
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
## [0.3.0] - 2023-01-25
|
2
|
+
|
3
|
+
- Added two new methods `first_download` and `last_download`.
|
4
|
+
- Added more instructions to the README for Chrome with downloads options, in particular to clean up folders.
|
5
|
+
- Added an example to read a downloaded file
|
6
|
+
|
7
|
+
## [0.2.0] - 2020-06-18
|
8
|
+
|
9
|
+
- Add chrome with downloads capabilities to the list of already so many devices
|
10
|
+
|
11
|
+
## [0.1.0] - 2020-03-02
|
12
|
+
|
13
|
+
- Initial release
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# So Many Devices! 🕺
|
2
2
|
|
3
|
+
[](https://renuo.semaphoreci.com/projects/so_many_devices)
|
4
|
+
|
3
5
|
This gem provides a list of Capybara Selenium configurations that you can use.
|
4
6
|
Probably useful to run your system tests on different devices.
|
5
7
|
|
@@ -29,7 +31,7 @@ In your `rails_helper.rb` you can configure your preferred device for tests:
|
|
29
31
|
|
30
32
|
```ruby
|
31
33
|
config.before(:each, type: :system, js: true) do
|
32
|
-
|
34
|
+
driven_by :iphone_6_7_8
|
33
35
|
end
|
34
36
|
```
|
35
37
|
|
@@ -37,7 +39,7 @@ You can always use the headless version of each device by appending `_headless`
|
|
37
39
|
|
38
40
|
```ruby
|
39
41
|
config.before(:each, type: :system, js: true) do
|
40
|
-
|
42
|
+
driven_by :iphone_6_7_8_headless
|
41
43
|
end
|
42
44
|
```
|
43
45
|
|
@@ -45,7 +47,7 @@ We use it to run our system tests on so many devices! Here is our standard confi
|
|
45
47
|
|
46
48
|
```ruby
|
47
49
|
config.before(:each, type: :system, js: true) do
|
48
|
-
|
50
|
+
driven_by ENV['SELENIUM_DRIVER'].to_sym
|
49
51
|
end
|
50
52
|
```
|
51
53
|
|
@@ -60,7 +62,63 @@ of course, your tests need to run on so many devices!
|
|
60
62
|
|
61
63
|
## Available devices
|
62
64
|
|
63
|
-
Check [the YML file containing all the devices](./lib/so_many_devices
|
65
|
+
Check [the YML file containing all the devices](./lib/so_many_devices.yml). So many!
|
66
|
+
|
67
|
+
## Chrome with downloads capabilities
|
68
|
+
|
69
|
+
We provide also an instance of Chrome already configured with
|
70
|
+
Downloads capabilities and a `SoManyDevices::DownloadsHelper` that you can use in your project.
|
71
|
+
|
72
|
+
Use the following:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
config.before(:each, type: :system, js: true) do
|
76
|
+
driven_by :selenium_chrome_with_download_headless # or non-headless version
|
77
|
+
end
|
78
|
+
|
79
|
+
config.after(:each, type: :system, js: true) do
|
80
|
+
clear_downloads
|
81
|
+
end
|
82
|
+
|
83
|
+
config.include SoManyDevices::DownloadsHelper, type: :system
|
84
|
+
```
|
85
|
+
|
86
|
+
and in your test (just an example...):
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
it 'can download a file', :js do
|
90
|
+
visit funny_page_path
|
91
|
+
click_link 'Download PDF'
|
92
|
+
wait_for_download
|
93
|
+
expect(downloads.length).to eq(1)
|
94
|
+
expect(last_download).to match(/.*\.pdf/)
|
95
|
+
last_pdf = File.read(last_download)
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
If you prefer to use this driver only on selected tests, you can use the following:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
config.before(:each, type: :system, js: true, with_downloads: true) do
|
103
|
+
driven_by :selenium_chrome_with_download_headless
|
104
|
+
end
|
105
|
+
|
106
|
+
config.after(:each, type: :system, js: true, with_downloads: true) do
|
107
|
+
clear_downloads
|
108
|
+
end
|
109
|
+
|
110
|
+
config.include SoManyDevices::DownloadsHelper, type: :system
|
111
|
+
```
|
112
|
+
|
113
|
+
and in your test (just an example...):
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
it 'can download a file', :js, :with_downloads do
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
The call to `clear_downloads` makes sure that all the downloads are removed from the downloads folder.
|
121
|
+
All downloads are performed in the `tmp/downloads` folder of your project.
|
64
122
|
|
65
123
|
## Development
|
66
124
|
|
@@ -73,8 +131,8 @@ which will create a git tag for the version, push git commits and tags, and push
|
|
73
131
|
|
74
132
|
## Contributing
|
75
133
|
|
76
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/renuo/so_many_devices
|
77
|
-
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/renuo/so_many_devices/blob/
|
134
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/renuo/so_many_devices>.
|
135
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/renuo/so_many_devices/blob/main/CODE_OF_CONDUCT.md).
|
78
136
|
|
79
137
|
Do you think our devices are not that many? 😡
|
80
138
|
|
@@ -86,9 +144,9 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
86
144
|
|
87
145
|
## Code of Conduct
|
88
146
|
|
89
|
-
Everyone interacting in the SoManyDevices project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/renuo/so_many_devices/blob/
|
147
|
+
Everyone interacting in the SoManyDevices project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/renuo/so_many_devices/blob/main/CODE_OF_CONDUCT.md).
|
90
148
|
|
91
149
|
|
92
150
|
## Special Thanks
|
93
151
|
|
94
|
-
[](https://www.renuo.ch)
|
data/Rakefile
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
module SoManyDevices
|
2
|
+
module DownloadsHelper
|
3
|
+
TIMEOUT = 10
|
4
|
+
PATH = "#{Dir.pwd}/tmp/downloads"
|
5
|
+
|
6
|
+
def downloads
|
7
|
+
Dir["#{PATH}/*"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def download
|
11
|
+
downloads.first
|
12
|
+
end
|
13
|
+
|
14
|
+
def first_download
|
15
|
+
downloads.first
|
16
|
+
end
|
17
|
+
|
18
|
+
def last_download
|
19
|
+
downloads.last
|
20
|
+
end
|
21
|
+
|
22
|
+
def download_content
|
23
|
+
wait_for_download
|
24
|
+
File.read(download)
|
25
|
+
end
|
26
|
+
|
27
|
+
def wait_for_download
|
28
|
+
Timeout.timeout(TIMEOUT) do
|
29
|
+
sleep 0.1 until downloaded?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def downloaded?
|
34
|
+
!downloading? && downloads.any?
|
35
|
+
end
|
36
|
+
|
37
|
+
def downloading?
|
38
|
+
downloads.grep(/\.crdownload$/).any?
|
39
|
+
end
|
40
|
+
|
41
|
+
def clear_downloads
|
42
|
+
FileUtils.rm_f(downloads)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/so_many_devices.rb
CHANGED
@@ -1,23 +1,34 @@
|
|
1
1
|
require "so_many_devices/version"
|
2
|
+
require "so_many_devices/downloads_helper"
|
3
|
+
require "yaml"
|
4
|
+
require "capybara"
|
2
5
|
|
3
6
|
module SoManyDevices
|
4
|
-
class Error < StandardError;
|
5
|
-
end
|
7
|
+
class Error < StandardError; end
|
6
8
|
|
7
|
-
devices = YAML
|
9
|
+
devices = YAML.load_file(File.join(__dir__, "so_many_devices.yml"))
|
8
10
|
|
9
11
|
devices.each do |device_name, options|
|
10
|
-
standard_args = [
|
11
|
-
headless_args = [
|
12
|
-
headless_args <<
|
12
|
+
standard_args = ["--disable-site-isolation-trials"]
|
13
|
+
headless_args = ["--headless", "--disable-site-isolation-trials"]
|
14
|
+
headless_args << "--disable-gpu" if Gem.win_platform?
|
13
15
|
|
14
|
-
[[device_name
|
16
|
+
[[device_name, standard_args], ["#{device_name}_headless", headless_args]].each do |device_name, args|
|
15
17
|
Capybara.register_driver device_name.to_sym do |app|
|
16
18
|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
17
|
-
|
19
|
+
"goog:chromeOptions" => {args: args, mobileEmulation: options}
|
18
20
|
)
|
19
21
|
Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
|
20
22
|
end
|
21
23
|
end
|
24
|
+
|
25
|
+
[[:selenium_chrome_with_download, standard_args], [:selenium_chrome_with_download_headless, headless_args]].each do |device_name, args|
|
26
|
+
Capybara.register_driver device_name do |app|
|
27
|
+
browser_options = ::Selenium::WebDriver::Chrome::Options.new(args: args)
|
28
|
+
browser_options.add_preference(:download, prompt_for_download: false, default_directory: SoManyDevices::DownloadsHelper::PATH.to_s)
|
29
|
+
browser_options.add_preference(:browser, set_download_behavior: {behavior: "allow"})
|
30
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
31
|
+
end
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
data/so_many_devices.gemspec
CHANGED
@@ -1,27 +1,30 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "lib/so_many_devices/version"
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name
|
5
|
-
spec.version
|
6
|
-
spec.authors
|
7
|
-
spec.email
|
4
|
+
spec.name = "so_many_devices"
|
5
|
+
spec.version = SoManyDevices::VERSION
|
6
|
+
spec.authors = ["Alessandro Rodi"]
|
7
|
+
spec.email = ["coorasse@gmail.com"]
|
8
8
|
|
9
|
-
spec.summary
|
10
|
-
spec.description
|
11
|
-
spec.homepage
|
12
|
-
spec.license
|
9
|
+
spec.summary = "A list of configurations for so many devices!"
|
10
|
+
spec.description = "This incomplete but very satisfying list of devices, will help you run your app on so many devices!"
|
11
|
+
spec.homepage = "https://github.com/renuo/so_many_devices"
|
12
|
+
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
16
|
spec.metadata["source_code_uri"] = "https://github.com/renuo/so_many_devices"
|
17
|
-
spec.metadata["changelog_uri"] = "https://github.com/renuo/so_many_devices/CHANGELOG.md"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/renuo/so_many_devices/blob/main/CHANGELOG.md"
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
-
spec.files
|
21
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
22
22
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
23
|
end
|
24
|
-
spec.bindir
|
25
|
-
spec.executables
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_dependency "capybara", ">= 3.0"
|
29
|
+
spec.add_development_dependency "standard"
|
27
30
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: so_many_devices
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Rodi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2023-01-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capybara
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: standard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
description: This incomplete but very satisfying list of devices, will help you run
|
14
42
|
your app on so many devices!
|
15
43
|
email:
|
@@ -20,7 +48,10 @@ extra_rdoc_files: []
|
|
20
48
|
files:
|
21
49
|
- ".gitignore"
|
22
50
|
- ".rspec"
|
51
|
+
- ".semaphore/main-deploy.yml"
|
52
|
+
- ".semaphore/semaphore.yml"
|
23
53
|
- ".travis.yml"
|
54
|
+
- CHANGELOG.md
|
24
55
|
- CODE_OF_CONDUCT.md
|
25
56
|
- Gemfile
|
26
57
|
- LICENSE.txt
|
@@ -30,6 +61,7 @@ files:
|
|
30
61
|
- bin/setup
|
31
62
|
- lib/so_many_devices.rb
|
32
63
|
- lib/so_many_devices.yml
|
64
|
+
- lib/so_many_devices/downloads_helper.rb
|
33
65
|
- lib/so_many_devices/version.rb
|
34
66
|
- logo/renuo.png
|
35
67
|
- so_many_devices.gemspec
|
@@ -39,8 +71,8 @@ licenses:
|
|
39
71
|
metadata:
|
40
72
|
homepage_uri: https://github.com/renuo/so_many_devices
|
41
73
|
source_code_uri: https://github.com/renuo/so_many_devices
|
42
|
-
changelog_uri: https://github.com/renuo/so_many_devices/CHANGELOG.md
|
43
|
-
post_install_message:
|
74
|
+
changelog_uri: https://github.com/renuo/so_many_devices/blob/main/CHANGELOG.md
|
75
|
+
post_install_message:
|
44
76
|
rdoc_options: []
|
45
77
|
require_paths:
|
46
78
|
- lib
|
@@ -55,8 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
87
|
- !ruby/object:Gem::Version
|
56
88
|
version: '0'
|
57
89
|
requirements: []
|
58
|
-
rubygems_version: 3.
|
59
|
-
signing_key:
|
90
|
+
rubygems_version: 3.3.10
|
91
|
+
signing_key:
|
60
92
|
specification_version: 4
|
61
93
|
summary: A list of configurations for so many devices!
|
62
94
|
test_files: []
|