superbara 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 +5 -5
- data/.ruby-version +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +7 -0
- data/lib/pry_monkey.rb +1 -0
- data/lib/superbara/drivers/chrome_headless.rb +1 -0
- data/lib/superbara/dsl.rb +3 -93
- data/lib/superbara/functions/debug.rb +22 -0
- data/lib/superbara/functions/wait.rb +78 -0
- data/lib/superbara/rspec.rb +34 -0
- data/lib/superbara/version.rb +1 -1
- data/lib/superbara.rb +8 -38
- data/lib/supershell +8 -8
- data/www/another.html +4 -0
- data/www/index.html +3 -0
- metadata +8 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 28e196c5e92b19c49f6987d1d4a30f7f46d78e23b24310289c111b3ecbc5e806
|
|
4
|
+
data.tar.gz: ea552b59aedf49a9da460d3cf04030a4aa1d04e38c4c9129af97793253bec977
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b21f1edbf537f0e98515cd4029d9a8b747381496b0d546f01ebfc39b77ee61b7abfcbe932673429be781c1e61a744f67f635a3d53dbd3bf8b4783eb721ef7f62
|
|
7
|
+
data.tar.gz: '0048d645c0269ad40b7b75dc958a2b033d3f513a8fbbf99a01b12896e66f8b7ce34e1b285e01dfe9227fa86517d8f6aae96f5cc9fc60c9dab913d3dd0a7854a6'
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.5.0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/pry_monkey.rb
CHANGED
|
@@ -2,6 +2,7 @@ Capybara.register_driver :chrome_headless do
|
|
|
2
2
|
options = ::Selenium::WebDriver::Chrome::Options.new
|
|
3
3
|
options.add_argument 'headless'
|
|
4
4
|
options.add_argument 'disable-gpu'
|
|
5
|
+
options.add_argument 'window-size=1680,1024'
|
|
5
6
|
|
|
6
7
|
Capybara::Selenium::Driver.new(nil,
|
|
7
8
|
browser: :chrome,
|
data/lib/superbara/dsl.rb
CHANGED
|
@@ -1,99 +1,9 @@
|
|
|
1
1
|
module Superbara; module DSL
|
|
2
2
|
def wait(seconds, &block)
|
|
3
|
-
|
|
4
|
-
word, color = if status
|
|
5
|
-
["ok", :green]
|
|
6
|
-
else
|
|
7
|
-
["FAIL", :red]
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
puts "#{word.colorize(color)} (took #{(took_delta)}s)"
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
seconds = seconds.to_f
|
|
14
|
-
|
|
15
|
-
print "--> waiting max #{seconds}s "
|
|
16
|
-
started_at = Time.now
|
|
17
|
-
|
|
18
|
-
previous_capybara_default_max_wait_time = Capybara.default_max_wait_time
|
|
19
|
-
block_value = nil
|
|
20
|
-
exception = nil
|
|
21
|
-
timed_out = false
|
|
22
|
-
begin
|
|
23
|
-
Capybara.default_max_wait_time = seconds
|
|
24
|
-
Timeout::timeout (seconds+0.1) do
|
|
25
|
-
block_value = block.call
|
|
26
|
-
end
|
|
27
|
-
rescue Timeout::Error => ex
|
|
28
|
-
timed_out = true
|
|
29
|
-
rescue Exception => ex
|
|
30
|
-
exception = ex
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
took_delta = (Time.now - started_at).floor(2)
|
|
34
|
-
Capybara.default_max_wait_time = previous_capybara_default_max_wait_time
|
|
35
|
-
|
|
36
|
-
if exception || timed_out
|
|
37
|
-
formatted_output false, took_delta
|
|
38
|
-
|
|
39
|
-
additional_started_at = Time.now
|
|
40
|
-
additional_block_value = nil
|
|
41
|
-
additional_exception = nil
|
|
42
|
-
puts " testing if waiting for 2 seconds more would help.."
|
|
43
|
-
begin
|
|
44
|
-
Capybara.default_max_wait_time = 2
|
|
45
|
-
additional_block_value = block.call
|
|
46
|
-
rescue Exception => ex
|
|
47
|
-
additional_exception = ex
|
|
48
|
-
end
|
|
49
|
-
additional_took_delta = (Time.now - additional_started_at).floor(2)
|
|
50
|
-
suggested_wait_value = (seconds + additional_took_delta).floor(2)
|
|
51
|
-
|
|
52
|
-
if additional_exception || additional_block_value.nil?
|
|
53
|
-
puts " ..did not help."
|
|
54
|
-
else
|
|
55
|
-
puts " ..setting wait to >#{suggested_wait_value} would help here?"
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
if exception
|
|
59
|
-
raise exception
|
|
60
|
-
else
|
|
61
|
-
raise "capybara timed out"
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
if block_value == false
|
|
66
|
-
formatted_output false, took_delta
|
|
67
|
-
raise "wait condition was falsy"
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
if block_value == nil
|
|
71
|
-
formatted_output false, took_delta
|
|
72
|
-
raise "wait condition was nil"
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
formatted_output true, took_delta
|
|
76
|
-
return block_value
|
|
3
|
+
Superbara.wait(seconds, &block)
|
|
77
4
|
end
|
|
78
5
|
|
|
79
|
-
def debug(exception_occurred:false)
|
|
80
|
-
|
|
81
|
-
debug_help = """
|
|
82
|
-
c - continue to the next debug breakpoint
|
|
83
|
-
s - step to the next line
|
|
84
|
-
r - retry running
|
|
85
|
-
h - help on commands available
|
|
86
|
-
q - exit to shell"""
|
|
87
|
-
|
|
88
|
-
debug_header_prefix = "== DEBUG "
|
|
89
|
-
debug_header_suffix = "=" * (IO.console.winsize.last - debug_header_prefix.size)
|
|
90
|
-
|
|
91
|
-
puts """
|
|
92
|
-
#{debug_header_prefix}#{debug_header_suffix}
|
|
93
|
-
#{debug_help}
|
|
94
|
-
""".colorize(:light_green)
|
|
95
|
-
|
|
96
|
-
$supress_pry_whereami = true if exception_occurred
|
|
97
|
-
Pry.start(binding.of_caller(1))
|
|
6
|
+
def debug(exception_occurred: false)
|
|
7
|
+
Superbara.debug(exception_occurred: exception_occurred)
|
|
98
8
|
end
|
|
99
9
|
end; end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Superbara
|
|
2
|
+
def self.debug(exception_occurred:false)
|
|
3
|
+
return if ENV['SUPERBARA_FRONTEND'] == "noninteractive"
|
|
4
|
+
debug_help = """
|
|
5
|
+
c - continue to the next debug breakpoint
|
|
6
|
+
s - step to the next line
|
|
7
|
+
r - retry running
|
|
8
|
+
h - help on commands available
|
|
9
|
+
q - exit to shell"""
|
|
10
|
+
|
|
11
|
+
debug_header_prefix = "== DEBUG "
|
|
12
|
+
debug_header_suffix = "=" * (IO.console.winsize.last - debug_header_prefix.size)
|
|
13
|
+
|
|
14
|
+
puts """
|
|
15
|
+
#{debug_header_prefix}#{debug_header_suffix}
|
|
16
|
+
#{debug_help}
|
|
17
|
+
""".colorize(:light_green)
|
|
18
|
+
|
|
19
|
+
$supress_pry_whereami = true if exception_occurred
|
|
20
|
+
Pry.start(binding.of_caller(1))
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
module Superbara
|
|
2
|
+
def self.wait(seconds, &block)
|
|
3
|
+
seconds = seconds.to_f
|
|
4
|
+
|
|
5
|
+
print "--> waiting max #{seconds}s "
|
|
6
|
+
started_at = Time.now
|
|
7
|
+
|
|
8
|
+
previous_capybara_default_max_wait_time = Capybara.default_max_wait_time
|
|
9
|
+
block_value = nil
|
|
10
|
+
exception = nil
|
|
11
|
+
timed_out = false
|
|
12
|
+
begin
|
|
13
|
+
Capybara.default_max_wait_time = seconds
|
|
14
|
+
Timeout::timeout (seconds+0.1) do
|
|
15
|
+
block_value = block.call
|
|
16
|
+
end
|
|
17
|
+
rescue Timeout::Error => ex
|
|
18
|
+
timed_out = true
|
|
19
|
+
rescue Exception => ex
|
|
20
|
+
exception = ex
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
took_delta = (Time.now - started_at).floor(2)
|
|
24
|
+
Capybara.default_max_wait_time = previous_capybara_default_max_wait_time
|
|
25
|
+
|
|
26
|
+
if exception || timed_out
|
|
27
|
+
self.wait_formatted_output false, took_delta
|
|
28
|
+
|
|
29
|
+
additional_started_at = Time.now
|
|
30
|
+
additional_block_value = nil
|
|
31
|
+
additional_exception = nil
|
|
32
|
+
puts " testing if waiting for 2 seconds more would help.."
|
|
33
|
+
begin
|
|
34
|
+
Capybara.default_max_wait_time = 2
|
|
35
|
+
additional_block_value = block.call
|
|
36
|
+
rescue Exception => ex
|
|
37
|
+
additional_exception = ex
|
|
38
|
+
end
|
|
39
|
+
additional_took_delta = (Time.now - additional_started_at).floor(2)
|
|
40
|
+
suggested_wait_value = (seconds + additional_took_delta).floor(2)
|
|
41
|
+
|
|
42
|
+
if additional_exception || additional_block_value.nil?
|
|
43
|
+
puts " ..did not help."
|
|
44
|
+
else
|
|
45
|
+
puts " ..setting wait to >#{suggested_wait_value} would help here?"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
if exception
|
|
49
|
+
raise exception
|
|
50
|
+
else
|
|
51
|
+
raise "capybara timed out"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
if block_value == false
|
|
56
|
+
self.wait_formatted_output false, took_delta
|
|
57
|
+
raise "wait condition was falsy"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if block_value == nil
|
|
61
|
+
self.wait_formatted_output false, took_delta
|
|
62
|
+
raise "wait condition was nil"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
self.wait_formatted_output true, took_delta
|
|
66
|
+
return block_value
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def self.wait_formatted_output(status, took_delta)
|
|
70
|
+
word, color = if status
|
|
71
|
+
["ok", :green]
|
|
72
|
+
else
|
|
73
|
+
["FAIL", :red]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
puts "#{word.colorize(color)} (took #{(took_delta)}s)"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require "superbara"
|
|
2
|
+
require "superbara/dsl"
|
|
3
|
+
require "rspec"
|
|
4
|
+
|
|
5
|
+
RSpec.configure do |config|
|
|
6
|
+
config.include Capybara::DSL
|
|
7
|
+
config.include Superbara::DSL
|
|
8
|
+
|
|
9
|
+
config.fail_fast = true
|
|
10
|
+
|
|
11
|
+
config.before(:each) do |example|
|
|
12
|
+
$superbara_current_file = example.metadata[:example_group][:file_path]
|
|
13
|
+
|
|
14
|
+
puts ""
|
|
15
|
+
class_path = example.example_group_instance.class.to_s.split("::")
|
|
16
|
+
class_path.shift
|
|
17
|
+
class_path.shift
|
|
18
|
+
print class_path.shift
|
|
19
|
+
for c in class_path do
|
|
20
|
+
print "/#{c}"
|
|
21
|
+
end
|
|
22
|
+
puts " #{example.description} - #{example.location}"
|
|
23
|
+
puts "-"*IO.console.winsize.last
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
config.after(:each) do |example|
|
|
27
|
+
if example.exception
|
|
28
|
+
puts ("="*80).colorize(:yellow)
|
|
29
|
+
puts example.exception.message.colorize(:red)
|
|
30
|
+
puts ("="*80).colorize(:yellow)
|
|
31
|
+
debug(exception_occurred: true)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/superbara/version.rb
CHANGED
data/lib/superbara.rb
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
require "io/console"
|
|
2
2
|
require "colorize"
|
|
3
|
-
require "pry_monkey"
|
|
4
3
|
|
|
5
4
|
require "capybara"
|
|
6
5
|
require "capybara/dsl"
|
|
7
6
|
require "selenium-webdriver"
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
require "superbara/dsl"
|
|
11
|
-
require "superbara/helpers"
|
|
12
|
-
require "superbara/drivers/chrome"
|
|
13
|
-
require "superbara/drivers/chrome_headless"
|
|
8
|
+
require_relative "pry_monkey"
|
|
14
9
|
|
|
15
|
-
|
|
10
|
+
require_relative "superbara/version"
|
|
11
|
+
require_relative "superbara/helpers"
|
|
12
|
+
require_relative "superbara/drivers/chrome"
|
|
13
|
+
require_relative "superbara/drivers/chrome_headless"
|
|
14
|
+
|
|
15
|
+
require_relative "superbara/functions/debug.rb"
|
|
16
|
+
require_relative "superbara/functions/wait.rb"
|
|
16
17
|
|
|
17
18
|
trap "SIGINT" do
|
|
18
19
|
puts "
|
|
@@ -31,34 +32,3 @@ end
|
|
|
31
32
|
Capybara.default_driver = :chrome
|
|
32
33
|
Capybara.default_max_wait_time = 1
|
|
33
34
|
|
|
34
|
-
RSpec.configure do |config|
|
|
35
|
-
config.include Capybara::DSL
|
|
36
|
-
config.include Superbara::DSL
|
|
37
|
-
|
|
38
|
-
config.fail_fast = true
|
|
39
|
-
|
|
40
|
-
config.before(:each) do |example|
|
|
41
|
-
$superbara_current_file = example.metadata[:example_group][:file_path]
|
|
42
|
-
|
|
43
|
-
puts ""
|
|
44
|
-
class_path = example.example_group_instance.class.to_s.split("::")
|
|
45
|
-
class_path.shift
|
|
46
|
-
class_path.shift
|
|
47
|
-
print class_path.shift
|
|
48
|
-
for c in class_path do
|
|
49
|
-
print "/#{c}"
|
|
50
|
-
end
|
|
51
|
-
puts " #{example.description} - #{example.location}"
|
|
52
|
-
puts "-"*IO.console.winsize.last
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
config.after(:each) do |example|
|
|
56
|
-
if example.exception
|
|
57
|
-
puts ("="*80).colorize(:yellow)
|
|
58
|
-
puts example.exception.message.colorize(:red)
|
|
59
|
-
puts ("="*80).colorize(:yellow)
|
|
60
|
-
debug(exception_occurred: true)
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
#
|
|
64
|
-
end
|
data/lib/supershell
CHANGED
|
@@ -93,14 +93,14 @@ case $1 in
|
|
|
93
93
|
Error "$target_file already exists"
|
|
94
94
|
fi
|
|
95
95
|
mkdir -p $2
|
|
96
|
-
echo
|
|
97
|
-
|
|
96
|
+
echo '''RSpec.describe \"${test_name}\" do
|
|
97
|
+
it "loads" do
|
|
98
98
|
visit "http://www.example.com"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
more_link = find "a", text: /ore information/
|
|
100
|
+
debug
|
|
101
|
+
more_link.click
|
|
102
|
+
debug
|
|
103
|
+
end
|
|
104
104
|
end''' >> "$target_file"
|
|
105
105
|
|
|
106
106
|
echo " --> created $target_file
|
|
@@ -128,7 +128,7 @@ esac
|
|
|
128
128
|
|
|
129
129
|
while true; do
|
|
130
130
|
set +e
|
|
131
|
-
rspec --require superbara $@
|
|
131
|
+
rspec --require superbara/rspec $@
|
|
132
132
|
rspec_exit_code=$?
|
|
133
133
|
set -e
|
|
134
134
|
|
data/www/another.html
ADDED
data/www/index.html
ADDED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: superbara
|
|
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
|
- Matti Paksula
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-03-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: colorize
|
|
@@ -175,10 +175,15 @@ files:
|
|
|
175
175
|
- lib/superbara/drivers/chrome.rb
|
|
176
176
|
- lib/superbara/drivers/chrome_headless.rb
|
|
177
177
|
- lib/superbara/dsl.rb
|
|
178
|
+
- lib/superbara/functions/debug.rb
|
|
179
|
+
- lib/superbara/functions/wait.rb
|
|
178
180
|
- lib/superbara/helpers.rb
|
|
181
|
+
- lib/superbara/rspec.rb
|
|
179
182
|
- lib/superbara/version.rb
|
|
180
183
|
- lib/supershell
|
|
181
184
|
- superbara.gemspec
|
|
185
|
+
- www/another.html
|
|
186
|
+
- www/index.html
|
|
182
187
|
homepage: https://www.github.com/matti/superbara
|
|
183
188
|
licenses:
|
|
184
189
|
- MIT
|
|
@@ -199,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
199
204
|
version: '0'
|
|
200
205
|
requirements: []
|
|
201
206
|
rubyforge_project:
|
|
202
|
-
rubygems_version: 2.
|
|
207
|
+
rubygems_version: 2.7.3
|
|
203
208
|
signing_key:
|
|
204
209
|
specification_version: 4
|
|
205
210
|
summary: Super Capybara
|