pludoni_rspec 0.1.0 → 0.2.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/Gemfile.lock +75 -0
- data/README.md +8 -0
- data/lib/pludoni_rspec.rb +9 -0
- data/lib/pludoni_rspec/capybara.rb +6 -43
- data/lib/pludoni_rspec/shared_context.rb +31 -0
- data/lib/pludoni_rspec/system_test_chrome_helper.rb +40 -0
- data/lib/pludoni_rspec/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f064dd6d3cf6747fccd078d7be705168e3f2c7ed
|
4
|
+
data.tar.gz: b0126a8924628bd52a44426d47479f3999ff8006
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e0d2358c1af571b6090fdd51b314b6c22109f41bc9d9c05b6cec71c0e54a354e9b620309c08faefe2c5e569b3f1364298c0609bd05881a7b4479c3391688e4f
|
7
|
+
data.tar.gz: d7027fe06dfd6ec85454c45fc86df53c70a8b4a0311c61841fa05c5f54ed8060659ffcea7e00a4bb445915e47a237251fe6c718d9d000072f9383bc4dee472fb
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pludoni_rspec (0.2.0)
|
5
|
+
capybara (>= 3.0.0)
|
6
|
+
chromedriver-helper (>= 1.2.0)
|
7
|
+
headless (>= 2.3.1)
|
8
|
+
pry-rails
|
9
|
+
puma
|
10
|
+
selenium-webdriver (>= 3.12.0)
|
11
|
+
simplecov (>= 0.16.1)
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
addressable (2.5.2)
|
17
|
+
public_suffix (>= 2.0.2, < 4.0)
|
18
|
+
archive-zip (0.11.0)
|
19
|
+
io-like (~> 0.3.0)
|
20
|
+
capybara (3.2.1)
|
21
|
+
addressable
|
22
|
+
mini_mime (>= 0.1.3)
|
23
|
+
nokogiri (~> 1.8)
|
24
|
+
rack (>= 1.6.0)
|
25
|
+
rack-test (>= 0.6.3)
|
26
|
+
xpath (~> 3.1)
|
27
|
+
childprocess (0.9.0)
|
28
|
+
ffi (~> 1.0, >= 1.0.11)
|
29
|
+
chromedriver-helper (1.2.0)
|
30
|
+
archive-zip (~> 0.10)
|
31
|
+
nokogiri (~> 1.8)
|
32
|
+
coderay (1.1.2)
|
33
|
+
docile (1.3.1)
|
34
|
+
ffi (1.9.25)
|
35
|
+
headless (2.3.1)
|
36
|
+
io-like (0.3.0)
|
37
|
+
json (2.1.0)
|
38
|
+
method_source (0.9.0)
|
39
|
+
mini_mime (1.0.0)
|
40
|
+
mini_portile2 (2.3.0)
|
41
|
+
nokogiri (1.8.2)
|
42
|
+
mini_portile2 (~> 2.3.0)
|
43
|
+
pry (0.11.3)
|
44
|
+
coderay (~> 1.1.0)
|
45
|
+
method_source (~> 0.9.0)
|
46
|
+
pry-rails (0.3.6)
|
47
|
+
pry (>= 0.10.4)
|
48
|
+
public_suffix (3.0.2)
|
49
|
+
puma (3.11.4)
|
50
|
+
rack (2.0.5)
|
51
|
+
rack-test (1.0.0)
|
52
|
+
rack (>= 1.0, < 3)
|
53
|
+
rake (10.5.0)
|
54
|
+
rubyzip (1.2.1)
|
55
|
+
selenium-webdriver (3.12.0)
|
56
|
+
childprocess (~> 0.5)
|
57
|
+
rubyzip (~> 1.2)
|
58
|
+
simplecov (0.16.1)
|
59
|
+
docile (~> 1.1)
|
60
|
+
json (>= 1.8, < 3)
|
61
|
+
simplecov-html (~> 0.10.0)
|
62
|
+
simplecov-html (0.10.2)
|
63
|
+
xpath (3.1.0)
|
64
|
+
nokogiri (~> 1.8)
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
ruby
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
bundler (~> 1.16)
|
71
|
+
pludoni_rspec!
|
72
|
+
rake (~> 10.0)
|
73
|
+
|
74
|
+
BUNDLED WITH
|
75
|
+
1.16.0
|
data/README.md
CHANGED
@@ -37,3 +37,11 @@ What's done:
|
|
37
37
|
* nf -> rspec --next-failure
|
38
38
|
* of -> rspec --only-failures
|
39
39
|
|
40
|
+
* Shared Contexts that can be included on demand:
|
41
|
+
* include_context 'mails' - For working with ActionMailer::Base.deliveries
|
42
|
+
* mails_with(to: '') - Filter mails sent to a user
|
43
|
+
* last_mail == ActionMailer::Base.deliveries.last
|
44
|
+
* mails == ActionMailer::Base.deliveries
|
45
|
+
* extract_link_from(last_mail, link: 0) - gets you the link (without protocol + host) of the first link in the last mail with a html body
|
46
|
+
* include_context 'active_job_inline'
|
47
|
+
* all ActiveJobs will be run immediately in this group
|
data/lib/pludoni_rspec.rb
CHANGED
@@ -2,6 +2,14 @@ require "pludoni_rspec/version"
|
|
2
2
|
|
3
3
|
# rubocop:disable Rails/FilePath
|
4
4
|
module PludoniRspec
|
5
|
+
class Config
|
6
|
+
class << self
|
7
|
+
attr_accessor :chrome_driver_version
|
8
|
+
attr_accessor :chrome_window_size
|
9
|
+
end
|
10
|
+
self.chrome_driver_version = "2.36"
|
11
|
+
self.chrome_window_size = '1600,1200'
|
12
|
+
end
|
5
13
|
def self.run
|
6
14
|
ENV["RAILS_ENV"] ||= 'test'
|
7
15
|
coverage!
|
@@ -12,6 +20,7 @@ module PludoniRspec
|
|
12
20
|
require 'pludoni_rspec/spec_helper'
|
13
21
|
require 'pludoni_rspec/capybara'
|
14
22
|
require 'pludoni_rspec/freeze_time'
|
23
|
+
require 'pludoni_rspec/shared_context'
|
15
24
|
if defined?(VCR)
|
16
25
|
require 'pludoni_rspec/vcr'
|
17
26
|
end
|
@@ -4,46 +4,7 @@ require "selenium-webdriver"
|
|
4
4
|
require "headless"
|
5
5
|
require "selenium/webdriver"
|
6
6
|
require "puma"
|
7
|
-
|
8
|
-
module SystemTestChromeHelper
|
9
|
-
def console_logs
|
10
|
-
page.driver.browser.manage.logs.get(:browser)
|
11
|
-
end
|
12
|
-
|
13
|
-
def drop_in_dropzone(file_path)
|
14
|
-
# Generate a fake input selector
|
15
|
-
page.execute_script <<-JS
|
16
|
-
fakeFileInput = window.$('<input/>').attr(
|
17
|
-
{id: 'fakeFileInput', type:'file'}
|
18
|
-
).appendTo('body');
|
19
|
-
JS
|
20
|
-
# Attach the file to the fake input selector
|
21
|
-
attach_file("fakeFileInput", file_path)
|
22
|
-
# Add the file to a fileList array
|
23
|
-
page.execute_script("var fileList = [fakeFileInput.get(0).files[0]]")
|
24
|
-
# Trigger the fake drop event
|
25
|
-
page.execute_script <<-JS
|
26
|
-
var e = jQuery.Event('drop', { dataTransfer : { files : [fakeFileInput.get(0).files[0]] } });
|
27
|
-
$('.uploader-action')[0].dropzone.listeners[0].events.drop(e);
|
28
|
-
JS
|
29
|
-
end
|
30
|
-
|
31
|
-
def screenshot(path = '1')
|
32
|
-
page.save_screenshot(Rails.root.join("public/screenshots/#{1.png}.png"))
|
33
|
-
end
|
34
|
-
|
35
|
-
# skip any confirm: "Really delete?"
|
36
|
-
def skip_confirm(page)
|
37
|
-
page.evaluate_script('window.confirm = function() { return true; }')
|
38
|
-
end
|
39
|
-
|
40
|
-
def in_browser(name)
|
41
|
-
old_session = Capybara.session_name
|
42
|
-
Capybara.session_name = name
|
43
|
-
yield
|
44
|
-
Capybara.session_name = old_session
|
45
|
-
end
|
46
|
-
end
|
7
|
+
require 'pludoni_rspec/system_test_chrome_helper'
|
47
8
|
|
48
9
|
Capybara.register_driver :chrome do |app|
|
49
10
|
Capybara::Selenium::Driver.new(app, browser: :chrome, timeout: 300)
|
@@ -52,7 +13,7 @@ end
|
|
52
13
|
Capybara.register_driver :headless_chrome do |app|
|
53
14
|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
54
15
|
'chromeOptions' => {
|
55
|
-
args:
|
16
|
+
args: ['headless', 'disable-gpu', "window-size=#{PludoniRspec::Config.chrome_window_size}", 'no-sandbox']
|
56
17
|
}
|
57
18
|
)
|
58
19
|
|
@@ -81,10 +42,12 @@ RSpec.configure do |c|
|
|
81
42
|
end
|
82
43
|
end
|
83
44
|
|
45
|
+
Chromedriver.set_version(PludoniRspec::Config.chrome_driver_version)
|
46
|
+
|
84
47
|
Capybara.javascript_driver = :headless_chrome
|
85
48
|
|
86
49
|
RSpec.configure do |config|
|
87
|
-
config.include SystemTestChromeHelper, type: :feature
|
88
|
-
config.include SystemTestChromeHelper, type: :system
|
50
|
+
config.include PludoniRspec::SystemTestChromeHelper, type: :feature
|
51
|
+
config.include PludoniRspec::SystemTestChromeHelper, type: :system
|
89
52
|
end
|
90
53
|
Capybara.default_max_wait_time = 60
|
@@ -0,0 +1,31 @@
|
|
1
|
+
if defined?(ActiveJob)
|
2
|
+
RSpec.shared_context "active_job_inline" do
|
3
|
+
include ActiveJob::TestHelper
|
4
|
+
around(:each) do |ex|
|
5
|
+
perform_enqueued_jobs do
|
6
|
+
ex.run
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
if defined?(ActionMailer::Base)
|
13
|
+
RSpec.shared_context "mails" do
|
14
|
+
def mails_with(to: nil)
|
15
|
+
ActionMailer::Base.deliveries.select { |i| i.to.to_s[to] }
|
16
|
+
end
|
17
|
+
|
18
|
+
def last_mail
|
19
|
+
ActionMailer::Base.deliveries.last
|
20
|
+
end
|
21
|
+
|
22
|
+
def mails
|
23
|
+
ActionMailer::Base.deliveries
|
24
|
+
end
|
25
|
+
|
26
|
+
def extract_link_from(mail, link: 0)
|
27
|
+
link = Nokogiri.parse(mail.html_part.decoded.to_s).search('a')[link]['href']
|
28
|
+
URI.parse(link).tap { |i| i.host = nil; i.scheme = nil }.to_s
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module PludoniRspec::SystemTestChromeHelper
|
2
|
+
def console_logs
|
3
|
+
page.driver.browser.manage.logs.get(:browser)
|
4
|
+
end
|
5
|
+
|
6
|
+
def drop_in_dropzone(file_path)
|
7
|
+
# Generate a fake input selector
|
8
|
+
page.execute_script <<-JS
|
9
|
+
fakeFileInput = window.$('<input/>').attr(
|
10
|
+
{id: 'fakeFileInput', type:'file'}
|
11
|
+
).appendTo('body');
|
12
|
+
JS
|
13
|
+
# Attach the file to the fake input selector
|
14
|
+
attach_file("fakeFileInput", file_path)
|
15
|
+
# Add the file to a fileList array
|
16
|
+
page.execute_script("var fileList = [fakeFileInput.get(0).files[0]]")
|
17
|
+
# Trigger the fake drop event
|
18
|
+
page.execute_script <<-JS
|
19
|
+
var e = jQuery.Event('drop', { dataTransfer : { files : [fakeFileInput.get(0).files[0]] } });
|
20
|
+
$('.uploader-action')[0].dropzone.listeners[0].events.drop(e);
|
21
|
+
JS
|
22
|
+
end
|
23
|
+
|
24
|
+
def screenshot(path = '1')
|
25
|
+
page.save_screenshot(Rails.root.join("public/screenshots/#{1.png}.png"))
|
26
|
+
end
|
27
|
+
|
28
|
+
# skip any confirm: "Really delete?"
|
29
|
+
def skip_confirm(page)
|
30
|
+
page.evaluate_script('window.confirm = function() { return true; }')
|
31
|
+
end
|
32
|
+
|
33
|
+
def in_browser(name)
|
34
|
+
old_session = Capybara.session_name
|
35
|
+
Capybara.session_name = name
|
36
|
+
yield
|
37
|
+
Capybara.session_name = old_session
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pludoni_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Wienert
|
@@ -147,6 +147,7 @@ extra_rdoc_files: []
|
|
147
147
|
files:
|
148
148
|
- ".gitignore"
|
149
149
|
- Gemfile
|
150
|
+
- Gemfile.lock
|
150
151
|
- LICENSE.txt
|
151
152
|
- README.md
|
152
153
|
- Rakefile
|
@@ -157,7 +158,9 @@ files:
|
|
157
158
|
- lib/pludoni_rspec.rb
|
158
159
|
- lib/pludoni_rspec/capybara.rb
|
159
160
|
- lib/pludoni_rspec/freeze_time.rb
|
161
|
+
- lib/pludoni_rspec/shared_context.rb
|
160
162
|
- lib/pludoni_rspec/spec_helper.rb
|
163
|
+
- lib/pludoni_rspec/system_test_chrome_helper.rb
|
161
164
|
- lib/pludoni_rspec/vcr.rb
|
162
165
|
- lib/pludoni_rspec/version.rb
|
163
166
|
- pludoni_rspec.gemspec
|