superbara 0.0.3 → 0.1.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
- SHA1:
3
- metadata.gz: 31bf4f944af7a7c66680d65077be24f2dd81a9e7
4
- data.tar.gz: d5e3e90814aa07c4f94443dd7a4ec82a90278df0
2
+ SHA256:
3
+ metadata.gz: 28e196c5e92b19c49f6987d1d4a30f7f46d78e23b24310289c111b3ecbc5e806
4
+ data.tar.gz: ea552b59aedf49a9da460d3cf04030a4aa1d04e38c4c9129af97793253bec977
5
5
  SHA512:
6
- metadata.gz: d556ace7d673ae98274840380498eb5d86557623019843649a8d86a008033bd1daf049a1321418ec1820d215a3cb3e650c42c5a902135cc2e2a22bea38671b0f
7
- data.tar.gz: c06c15c12969ca0dd5d54a826c2889246a1196619817379def6b26d33261087956369e63fbec66b22123766a175eab76d25b4ffe3190b9a449aed7c34db953f6
6
+ metadata.gz: b21f1edbf537f0e98515cd4029d9a8b747381496b0d546f01ebfc39b77ee61b7abfcbe932673429be781c1e61a744f67f635a3d53dbd3bf8b4783eb721ef7f62
7
+ data.tar.gz: '0048d645c0269ad40b7b75dc958a2b033d3f513a8fbbf99a01b12896e66f8b7ce34e1b285e01dfe9227fa86517d8f6aae96f5cc9fc60c9dab913d3dd0a7854a6'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.2
1
+ 2.5.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superbara (0.0.3)
4
+ superbara (0.1.0)
5
5
  binding_of_caller (= 0.7.2)
6
6
  capybara (= 2.16.0)
7
7
  chromedriver-helper (= 1.1.0)
@@ -94,4 +94,4 @@ DEPENDENCIES
94
94
  superbara!
95
95
 
96
96
  BUNDLED WITH
97
- 1.16.0
97
+ 1.16.1
data/README.md CHANGED
@@ -13,3 +13,10 @@ superbara start example
13
13
 
14
14
  https://github.com/SeleniumHQ/selenium/blob/master/rb/CHANGES
15
15
  https://github.com/teamcapybara/capybara/blob/master/History.md
16
+
17
+
18
+ ## Releasing
19
+
20
+ ```
21
+ $ rake release
22
+ ```
data/lib/pry_monkey.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "pry-byebug"
2
2
  require "binding_of_caller"
3
+
3
4
  class Pry
4
5
  class Command::Whereami < Pry::ClassCommand
5
6
  alias_method :process_orig, :process
@@ -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
- def formatted_output(status, took_delta)
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
- return if ENV['SUPERBARA_FRONTEND'] == "noninteractive"
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
@@ -1,3 +1,3 @@
1
1
  module Superbara
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
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
- require "superbara/version"
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
- require "rspec"
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 "RSpec.describe \"${test_name}\" do" > $target_file
97
- echo ''' it "loads" do
96
+ echo '''RSpec.describe \"${test_name}\" do
97
+ it "loads" do
98
98
  visit "http://www.example.com"
99
- more_link = find "a", text: /ore information/
100
- debug
101
- more_link.click
102
- debug
103
- end
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
@@ -0,0 +1,4 @@
1
+ <h1>Another page</h1>
2
+ <hr>
3
+
4
+ <a href="index.html">Index</a>
data/www/index.html ADDED
@@ -0,0 +1,3 @@
1
+ <h1>Superbara</h1>
2
+ <hr>
3
+ <a href="another.html">Another page</a>
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.3
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: 2017-11-14 00:00:00.000000000 Z
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.6.14
207
+ rubygems_version: 2.7.3
203
208
  signing_key:
204
209
  specification_version: 4
205
210
  summary: Super Capybara