so_many_devices 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4563bbece97b6bd3ec50f380fc87a52098e4fc70b80bfe6c894e3e3fe1d7d22
4
- data.tar.gz: ffcfe67293875045e902364d374786ee67bdcaa1b00125dbb52146785bfdfca3
3
+ metadata.gz: 0c89db46b332aab888e79736d583df4b7897354fa0d5eb7d400ed9518e3ea5c9
4
+ data.tar.gz: dd7d100ca70832f4cd6fdba1ba3c090893a08de58c7a259b08ac3636ff4bf7ab
5
5
  SHA512:
6
- metadata.gz: 9d3ab569ad319c3ed04f50d614041bc40500e7116145be28df9ad49565c28fd3a34bafc6d3f88f09e12a26d1f7a44656279863bd757f7f44480d04c49a81de2d
7
- data.tar.gz: e77cb90c14a71bcf687ed62895601ce862daeaac9b17f236973b0f69c08c989a7d268d979fc5de25fe9e41c49ae76d9b759a6f50e58c3290afa556918cc1ec45
6
+ metadata.gz: f819f293cf1f3548930378db087c0329a1d93136e29ae62213a970217622e65be0bc56fe73bf075786fea0dfdea6a9e376a5ee0c4e08cb67b8d8e0cce33c1318
7
+ data.tar.gz: d4ade32037dbda8691bcf4a60d93d3088cc5337994dfa1c1d63589aaa4263689e1b2d693864a93db198c55458ac3b447d3265726ad4c33bc9c8c47f96d9144cc
@@ -0,0 +1,19 @@
1
+ version: v1.0
2
+ name: master-deploy
3
+ agent:
4
+ machine:
5
+ type: e1-standard-2
6
+ os_image: ubuntu1804
7
+
8
+ blocks:
9
+ - name: master-deploy
10
+ task:
11
+ secrets:
12
+ - name: rubygems-deploy
13
+ jobs:
14
+ - name: master-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,32 @@
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
+ secrets:
18
+ - name: so_many_devices
19
+ env_vars:
20
+ - name: RAILS_ENV
21
+ value: test
22
+ jobs:
23
+ - name: tests
24
+ commands:
25
+ - checkout --use-cache
26
+ - cache restore
27
+ - bundle install -j 4 --path vendor/bundle
28
+ - cache store
29
+ - bundle exec rspec
30
+ promotions:
31
+ - name: master
32
+ pipeline_file: master-deploy.yml
@@ -0,0 +1,56 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ so_many_devices (0.2.0)
5
+ capybara (>= 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ capybara (3.32.1)
13
+ addressable
14
+ mini_mime (>= 0.1.3)
15
+ nokogiri (~> 1.8)
16
+ rack (>= 1.6.0)
17
+ rack-test (>= 0.6.3)
18
+ regexp_parser (~> 1.5)
19
+ xpath (~> 3.2)
20
+ diff-lcs (1.3)
21
+ mini_mime (1.0.2)
22
+ mini_portile2 (2.4.0)
23
+ nokogiri (1.10.9)
24
+ mini_portile2 (~> 2.4.0)
25
+ public_suffix (4.0.4)
26
+ rack (2.2.2)
27
+ rack-test (1.1.0)
28
+ rack (>= 1.0, < 3)
29
+ rake (12.3.3)
30
+ regexp_parser (1.7.0)
31
+ rspec (3.9.0)
32
+ rspec-core (~> 3.9.0)
33
+ rspec-expectations (~> 3.9.0)
34
+ rspec-mocks (~> 3.9.0)
35
+ rspec-core (3.9.2)
36
+ rspec-support (~> 3.9.3)
37
+ rspec-expectations (3.9.2)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.9.0)
40
+ rspec-mocks (3.9.1)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.9.0)
43
+ rspec-support (3.9.3)
44
+ xpath (3.2.0)
45
+ nokogiri (~> 1.8)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ rake (~> 12.0)
52
+ rspec (~> 3.0)
53
+ so_many_devices!
54
+
55
+ BUNDLED WITH
56
+ 2.1.4
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # So Many Devices! 🕺
2
2
 
3
+ [![status](https://renuo.semaphoreci.com/badges/so_many_devices.svg)](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
- driven_by :iphone_6_7_8
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
- driven_by :iphone_6_7_8_headless
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
- driven_by ENV['SELENIUM_DRIVER'].to_sym
50
+ driven_by ENV['SELENIUM_DRIVER'].to_sym
49
51
  end
50
52
  ```
51
53
 
@@ -60,7 +62,35 @@ 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/so_many_devices.yml). So many!
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.include SoManyDevices::DownloadsHelper, type: :system
80
+ ```
81
+
82
+ and in your test (just an example...):
83
+
84
+ ```ruby
85
+ it 'can download a file', :js do
86
+ visit funny_page_path
87
+ click_link 'Download PDF'
88
+ wait_for_download
89
+ expect(downloads.length).to eq(1)
90
+ expect(download).to match(/.*\.pdf/)
91
+ end
92
+ ```
93
+
64
94
 
65
95
  ## Development
66
96
 
@@ -73,7 +103,7 @@ which will create a git tag for the version, push git commits and tags, and push
73
103
 
74
104
  ## Contributing
75
105
 
76
- Bug reports and pull requests are welcome on GitHub at https://github.com/renuo/so_many_devices.
106
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/renuo/so_many_devices>.
77
107
  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/master/CODE_OF_CONDUCT.md).
78
108
 
79
109
  Do you think our devices are not that many? 😡
@@ -91,4 +121,4 @@ Everyone interacting in the SoManyDevices project's codebases, issue trackers, c
91
121
 
92
122
  ## Special Thanks
93
123
 
94
- [![Renuo AG](/logo/renuo.png)](https://renuo.ch)
124
+ [![Renuo AG](./logo/renuo.png)](https://www.renuo.ch)
@@ -1,8 +1,10 @@
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
9
  devices = YAML::load_file(File.join(__dir__, 'so_many_devices.yml'))
8
10
 
@@ -11,7 +13,7 @@ module SoManyDevices
11
13
  headless_args = ['--headless', '--disable-site-isolation-trials']
12
14
  headless_args << '--disable-gpu' if Gem.win_platform?
13
15
 
14
- [[device_name.to_sym, standard_args], ["#{device_name}_headless".to_sym, headless_args]].each do |device_name, args|
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 }
@@ -19,5 +21,14 @@ module SoManyDevices
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
@@ -0,0 +1,37 @@
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 download_content
15
+ wait_for_download
16
+ File.read(download)
17
+ end
18
+
19
+ def wait_for_download
20
+ Timeout.timeout(TIMEOUT) do
21
+ sleep 0.1 until downloaded?
22
+ end
23
+ end
24
+
25
+ def downloaded?
26
+ !downloading? && downloads.any?
27
+ end
28
+
29
+ def downloading?
30
+ downloads.grep(/\.crdownload$/).any?
31
+ end
32
+
33
+ def clear_downloads
34
+ FileUtils.rm_f(downloads)
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module SoManyDevices
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -24,4 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.bindir = "exe"
25
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'
27
29
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: so_many_devices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Rodi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-02 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2020-06-18 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'
13
27
  description: This incomplete but very satisfying list of devices, will help you run
14
28
  your app on so many devices!
15
29
  email:
@@ -20,9 +34,12 @@ extra_rdoc_files: []
20
34
  files:
21
35
  - ".gitignore"
22
36
  - ".rspec"
37
+ - ".semaphore/master-deploy.yml"
38
+ - ".semaphore/semaphore.yml"
23
39
  - ".travis.yml"
24
40
  - CODE_OF_CONDUCT.md
25
41
  - Gemfile
42
+ - Gemfile.lock
26
43
  - LICENSE.txt
27
44
  - README.md
28
45
  - Rakefile
@@ -30,6 +47,7 @@ files:
30
47
  - bin/setup
31
48
  - lib/so_many_devices.rb
32
49
  - lib/so_many_devices.yml
50
+ - lib/so_many_devices/downloads_helper.rb
33
51
  - lib/so_many_devices/version.rb
34
52
  - logo/renuo.png
35
53
  - so_many_devices.gemspec
@@ -55,7 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
73
  - !ruby/object:Gem::Version
56
74
  version: '0'
57
75
  requirements: []
58
- rubygems_version: 3.0.1
76
+ rubyforge_project:
77
+ rubygems_version: 2.7.6.2
59
78
  signing_key:
60
79
  specification_version: 4
61
80
  summary: A list of configurations for so many devices!