superbara 0.13.2 → 0.14.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: b7487d2e51d4923646fe45ed10831859d18e2cd5c7e3743105b599f617fcd8e6
4
- data.tar.gz: e6c0e8b466193843cfab3d90eb75274cf75a8136771bf60ee269767c9e319cd6
3
+ metadata.gz: 690e9d764e02ee4728756ef0e24432270fb639c455df4080088dad40a763c05e
4
+ data.tar.gz: acb593b91129cdd4a5fd9de9b34ba542c021a592f0aa67db05f71d5a54316d65
5
5
  SHA512:
6
- metadata.gz: a98d1761785cb40d8dc8419963912f5f5619e54a25ba5e490ef5837f289e235f2f5fee60d4673efe3cb82b18638ca8feea122a6dee0cae893b3b7c944b47b224
7
- data.tar.gz: b00af5fb684e230af3d713c7c85d61d57d075a26c41d7652344515ef591f885f6c1814e4cb7f3ccd4689dae12193ee8a0e4e62e55ba7cc5ebbf5c4b3b5b3bd9b
6
+ metadata.gz: 3912747af73e55766a70dc08d5c0eddf10998bc250d3dbf56d80dd2a7c24b253dfacad86c12c0e0c53ab09739b6493bbe6e25cb58a2f46911c96e838e10932f6
7
+ data.tar.gz: 504b8332fdc6d54acc72388dd2aaeaa104d7f454ab893a87365e44f4543e7b68be648ba9c011ce5ff0647765187502d916b9d966181e32ef559b1a9eb4d4daab
@@ -1,13 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superbara (0.13.2)
4
+ superbara (0.14.0)
5
5
  astrolabe (~> 1.3, >= 1.3.1)
6
6
  binding_of_caller (~> 0.8, >= 0.8.0)
7
7
  capybara (~> 3.1, >= 3.1.0)
8
8
  colorize (~> 0.8, >= 0.8.1)
9
9
  faker (~> 1.8, >= 1.8.7)
10
+ kommando (~> 0.1, >= 0.1.2)
11
+ pry
10
12
  pry-byebug (~> 3.6, >= 3.6.0)
13
+ pry-rescue (~> 1.4, >= 1.4.4)
14
+ pry-stack_explorer
15
+ rspec (~> 3.7, >= 3.7.0)
11
16
  selenium-webdriver (~> 3.12, >= 3.12.0)
12
17
  sinatra (~> 2.0, >= 2.0.1)
13
18
 
@@ -41,12 +46,13 @@ GEM
41
46
  ffi (1.9.25)
42
47
  i18n (1.0.1)
43
48
  concurrent-ruby (~> 1.0)
49
+ interception (0.5)
44
50
  kommando (0.1.2)
45
51
  method_source (0.9.0)
46
52
  mini_mime (1.0.0)
47
53
  mini_portile2 (2.3.0)
48
54
  mustermann (1.0.2)
49
- nokogiri (1.8.2)
55
+ nokogiri (1.8.3)
50
56
  mini_portile2 (~> 2.3.0)
51
57
  parser (2.5.1.0)
52
58
  ast (~> 2.4.0)
@@ -56,13 +62,19 @@ GEM
56
62
  pry-byebug (3.6.0)
57
63
  byebug (~> 10.0)
58
64
  pry (~> 0.10)
65
+ pry-rescue (1.4.5)
66
+ interception (>= 0.5)
67
+ pry
68
+ pry-stack_explorer (0.4.9.2)
69
+ binding_of_caller (>= 0.7)
70
+ pry (>= 0.9.11)
59
71
  public_suffix (3.0.2)
60
72
  rack (2.0.5)
61
73
  rack-protection (2.0.3)
62
74
  rack
63
75
  rack-test (1.0.0)
64
76
  rack (>= 1.0, < 3)
65
- rake (10.5.0)
77
+ rake (12.3.0)
66
78
  rspec (3.7.0)
67
79
  rspec-core (~> 3.7.0)
68
80
  rspec-expectations (~> 3.7.0)
@@ -94,9 +106,7 @@ PLATFORMS
94
106
 
95
107
  DEPENDENCIES
96
108
  bundler (~> 1.15, >= 1.15.0)
97
- kommando (~> 0.1, >= 0.1.2)
98
- rake (~> 10.0, >= 10.0.0)
99
- rspec (~> 3.7, >= 3.7.0)
109
+ rake (~> 12.3, >= 12.3.0)
100
110
  superbara!
101
111
 
102
112
  BUNDLED WITH
@@ -0,0 +1,9 @@
1
+ RSpec.describe "example.com" do
2
+ it "has text Example Domain" do
3
+ visit "example.com"
4
+
5
+ wait do
6
+ has_text? "Example Domain"
7
+ end
8
+ end
9
+ end
@@ -3,18 +3,17 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
3
3
  path = find_xpath(XPath.ancestor_or_self).reverse
4
4
 
5
5
  result = []
6
+ default_ns = path.last[:namespaceURI]
6
7
  while (node = path.shift)
7
8
  parent = path.first
8
9
  selector = node.tag_name
10
+ if node[:namespaceURI] != default_ns
11
+ selector = XPath.child.where((XPath.local_name == selector) & (XPath.namespace_uri == node[:namespaceURI])).to_s
12
+ selector
13
+ end
14
+
9
15
  if parent
10
16
  siblings = parent.find_xpath(selector)
11
-
12
- #MONKEY START https://github.com/teamcapybara/capybara/issues/2048
13
- if selector == "svg" && siblings.size == 0
14
- siblings = parent.find_xpath "//*[local-name() = 'svg']"
15
- end
16
- #MONKEY END
17
-
18
17
  selector += "[#{siblings.index(node) + 1}]" unless siblings.size == 1
19
18
  end
20
19
  result.push selector
@@ -47,6 +47,7 @@ module Superbara
47
47
  def self.visual?
48
48
  return true if @@visual
49
49
  return true if ENV["SUPERBARA_VISUAL"]
50
+ return false
50
51
  end
51
52
 
52
53
  def self.visual_disabled(&block)
@@ -68,6 +69,16 @@ module Superbara
68
69
  value
69
70
  end
70
71
 
72
+ def self.visual_enabled(&block)
73
+ visual_was_disabled = true unless Superbara.visual?
74
+
75
+ Superbara.visual_enable! if visual_was_disabled
76
+ value = block.call
77
+ Superbara.visual_disable! if visual_was_disabled
78
+
79
+ value
80
+ end
81
+
71
82
  def self.visual_enable!
72
83
  @@visual = true
73
84
  end
@@ -127,6 +138,12 @@ module Superbara
127
138
  path
128
139
  end
129
140
 
141
+ def self.robot_path
142
+ path = File.join(File.expand_path('~'), ".superbara", "robot")
143
+ path << ".exe" if Superbara.platform == "win32"
144
+ path
145
+ end
146
+
130
147
  def self.platform
131
148
  require 'rbconfig'
132
149
  cfg = RbConfig::CONFIG
@@ -29,7 +29,7 @@ module Superbara; module CLI
29
29
  exit 0
30
30
  when "web", "shell"
31
31
  #
32
- when "init"
32
+ when "init", "init:robot"
33
33
  project_name = ARGV[1]
34
34
  unless project_name
35
35
  puts "project name missing"
@@ -41,7 +41,9 @@ module Superbara; module CLI
41
41
  exit 1
42
42
  end
43
43
 
44
- contents = """visit 'example.com'
44
+ contents, file_name, start_cmd = case main_command
45
+ when "init"
46
+ ["""visit 'example.com'
45
47
 
46
48
  wait 3 do
47
49
  has_text? 'Example Domain'
@@ -49,14 +51,46 @@ end
49
51
 
50
52
  click 'a'
51
53
  scroll 50
52
- """
54
+ """, "main.rb", "start"]
55
+ when "init:robot"
56
+ ["""*** Settings ***
57
+ Library SeleniumLibrary
58
+
59
+ *** Test Cases ***
60
+ Google Robot Framework and Get Results
61
+ Open Browser To https://www.google.com
62
+ Google For Robot Framework
63
+ Result Should Contain Generic test automation
64
+
65
+ Visit example.com
66
+ Open Browser To https://www.example.com
67
+ Result Should Contain Example Domain
68
+
69
+
70
+ *** Keywords ***
71
+ Open Browser To
72
+ [arguments] ${url}
73
+ Open Browser ${url} browser=chrome
74
+ Maximize Browser Window
75
+
76
+ Google For
77
+ [arguments] ${search_term}
78
+ Input Text lst-ib ${search_term}
79
+ Press Key lst-ib \\\\13
80
+
81
+ Result Should Contain
82
+ [arguments] ${content}
83
+ Wait Until Page Contains ${content} 10 s
84
+ """, "main.robot", "start:robot"]
85
+ end
86
+
53
87
  Dir.mkdir project_name
54
- File.write File.join(project_name, "main.rb"), contents
88
+ File.write File.join(project_name, file_name), contents
55
89
 
56
- puts "Created directory #{project_name} with main.rb"
90
+ puts "Created directory #{project_name} with #{file_name}"
57
91
  puts "Start testing with:"
58
92
  puts ""
59
- puts " superbara start #{project_name}"
93
+ puts " superbara #{start_cmd} #{project_name}"
60
94
  exit 0
61
95
  else
62
96
  unless ARGV[1]
@@ -87,6 +121,13 @@ scroll 50
87
121
  FileUtils.mkdir_p target_path
88
122
  FileUtils.cp from, target
89
123
 
124
+ if Superbara.platform == "mac64"
125
+ robot_from = File.join Superbara.path, "vendor", "robot", Superbara.platform, "robot"
126
+ robot_target = File.join target_path, "robot"
127
+ File.unlink robot_target if File.exist? robot_target
128
+ FileUtils.cp robot_from, robot_target
129
+ end
130
+
90
131
  case main_command
91
132
  when "start", "run"
92
133
  project_path_or_file_expanded = File.expand_path(ARGV[1])
@@ -115,6 +156,64 @@ scroll 50
115
156
 
116
157
  loop do
117
158
  case main_command
159
+ when "start:robot"
160
+ require "kommando"
161
+
162
+ chromedriver_dirname = File.dirname(Superbara.chromedriver_path)
163
+ ENV["PATH"] = ENV["PATH"].split(":").push(chromedriver_dirname).join(":")
164
+ puts "#{Superbara.robot_path} -l NONE -r NONE #{Superbara.project_path}/#{project_entrypoint}"
165
+
166
+ k = Kommando.new "#{Superbara.robot_path} -l NONE -r NONE #{ARGV[1]}", {
167
+ output: true
168
+ }
169
+ k.run
170
+ puts ""
171
+ puts "-- [ [r]estart or [q]uit --"
172
+ input = $stdin.gets.chomp.downcase
173
+ case input
174
+ when "q"
175
+ exit 0
176
+ end
177
+ when "start:rspec"
178
+
179
+
180
+ require "rspec"
181
+ require "pry-rescue"
182
+
183
+ RSpec.configure do |config|
184
+ config.include Capybara::DSL
185
+ config.include Superbara::DSL
186
+
187
+ config.fail_fast = true
188
+
189
+ config.before(:each) do |example|
190
+ puts ""
191
+ puts " #{example.description} - #{example.location}"
192
+ puts "-"*IO.console.winsize.last
193
+ end
194
+
195
+
196
+ config.after(:each) do |example|
197
+ if example.exception
198
+ puts ("="*80).colorize(:yellow)
199
+ puts example.exception.message.colorize(:red)
200
+ puts ("="*80).colorize(:yellow)
201
+
202
+ Pry.commands.disabled_command "continue", "can not continue in this context"
203
+ Superbara.visual_enabled do
204
+ Pry::rescued(example.exception)
205
+ end
206
+ else
207
+ Pry.start
208
+ end
209
+ end
210
+ end
211
+
212
+ Pry::rescue do
213
+ RSpec::Core::Runner.run([ARGV[1]], $stderr, $stdout)
214
+ end
215
+
216
+ RSpec.reset
118
217
  when "web"
119
218
  webapp = Superbara::Web.new port: (ENV['SUPERBARA_WEB_PORT'] || 4567)
120
219
  webapp.run!
@@ -1,3 +1,3 @@
1
1
  module Superbara
2
- VERSION = "0.13.2"
2
+ VERSION = "0.14.0"
3
3
  end
@@ -24,6 +24,9 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_dependency 'colorize', '~> 0.8', '>= 0.8.1'
27
+ spec.add_dependency 'pry'
28
+ spec.add_dependency 'pry-stack_explorer'
29
+
27
30
  spec.add_dependency 'pry-byebug', '~> 3.6', '>= 3.6.0'
28
31
  spec.add_dependency 'binding_of_caller', '~> 0.8', '>=0.8.0'
29
32
  spec.add_dependency 'capybara', '~> 3.1', '>= 3.1.0'
@@ -31,9 +34,10 @@ Gem::Specification.new do |spec|
31
34
  spec.add_dependency 'faker', '~> 1.8', '>= 1.8.7'
32
35
  spec.add_dependency 'sinatra', '~> 2.0', '>= 2.0.1'
33
36
  spec.add_dependency 'astrolabe', '~> 1.3', '>= 1.3.1'
37
+ spec.add_dependency 'rspec', '~> 3.7', '>= 3.7.0'
38
+ spec.add_dependency 'pry-rescue', '~> 1.4', '>= 1.4.4'
39
+ spec.add_dependency 'kommando', '~> 0.1', '>= 0.1.2'
34
40
 
35
41
  spec.add_development_dependency 'bundler', '~> 1.15', '>= 1.15.0'
36
- spec.add_development_dependency 'rake', '~> 10.0', '>= 10.0.0'
37
- spec.add_development_dependency 'rspec', '~> 3.7', '>= 3.7.0'
38
- spec.add_development_dependency 'kommando', '~> 0.1', '>= 0.1.2'
42
+ spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.0'
39
43
  end
@@ -1,8 +1,9 @@
1
1
  run "vars"
2
2
  run "webapp", {}, once: true
3
3
 
4
- visit "#{$test_host}:4567"
4
+ loop do
5
+ visit "#{$test_host}:4567"
6
+ sleep 0.1
5
7
 
6
- wait do
7
- has_text? "Superbara"
8
+ break if has_text? "Superbara"
8
9
  end
@@ -1 +1,2 @@
1
+ a_local = 1
1
2
  asdf
Binary file
@@ -0,0 +1,21 @@
1
+ <html xmlns="http://www.w3.org/1999/xhtml">
2
+
3
+ <head>
4
+ <title>Namespace</title>
5
+ </head>
6
+
7
+ <body id="body">
8
+ <div>
9
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid slice" style="width:100%; height:100%; position:absolute; top:0; left:0; z-index:-1;">
10
+ <linearGradient id="gradient">
11
+ <stop class="begin" offset="0%" />
12
+ <stop class="end" offset="100%" />
13
+ </linearGradient>
14
+ <rect x="0" y="0" width="100" height="100" style="fill:url(#gradient)" />
15
+ <rect x="150" y="150" width="25" height="25" style="fill:url(#gradient)" />
16
+ <circle cx="50" cy="50" r="30" style="fill:url(#gradient)" />
17
+ </svg>
18
+ <div>
19
+ </body>
20
+
21
+ </html>
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.13.2
4
+ version: 0.14.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: 2018-06-13 00:00:00.000000000 Z
11
+ date: 2018-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -30,6 +30,34 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 0.8.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: pry
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: pry-stack_explorer
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
33
61
  - !ruby/object:Gem::Dependency
34
62
  name: pry-byebug
35
63
  requirement: !ruby/object:Gem::Requirement
@@ -171,85 +199,105 @@ dependencies:
171
199
  - !ruby/object:Gem::Version
172
200
  version: 1.3.1
173
201
  - !ruby/object:Gem::Dependency
174
- name: bundler
202
+ name: rspec
175
203
  requirement: !ruby/object:Gem::Requirement
176
204
  requirements:
177
205
  - - "~>"
178
206
  - !ruby/object:Gem::Version
179
- version: '1.15'
207
+ version: '3.7'
180
208
  - - ">="
181
209
  - !ruby/object:Gem::Version
182
- version: 1.15.0
183
- type: :development
210
+ version: 3.7.0
211
+ type: :runtime
184
212
  prerelease: false
185
213
  version_requirements: !ruby/object:Gem::Requirement
186
214
  requirements:
187
215
  - - "~>"
188
216
  - !ruby/object:Gem::Version
189
- version: '1.15'
217
+ version: '3.7'
190
218
  - - ">="
191
219
  - !ruby/object:Gem::Version
192
- version: 1.15.0
220
+ version: 3.7.0
193
221
  - !ruby/object:Gem::Dependency
194
- name: rake
222
+ name: pry-rescue
195
223
  requirement: !ruby/object:Gem::Requirement
196
224
  requirements:
197
225
  - - "~>"
198
226
  - !ruby/object:Gem::Version
199
- version: '10.0'
227
+ version: '1.4'
200
228
  - - ">="
201
229
  - !ruby/object:Gem::Version
202
- version: 10.0.0
203
- type: :development
230
+ version: 1.4.4
231
+ type: :runtime
204
232
  prerelease: false
205
233
  version_requirements: !ruby/object:Gem::Requirement
206
234
  requirements:
207
235
  - - "~>"
208
236
  - !ruby/object:Gem::Version
209
- version: '10.0'
237
+ version: '1.4'
210
238
  - - ">="
211
239
  - !ruby/object:Gem::Version
212
- version: 10.0.0
240
+ version: 1.4.4
213
241
  - !ruby/object:Gem::Dependency
214
- name: rspec
242
+ name: kommando
215
243
  requirement: !ruby/object:Gem::Requirement
216
244
  requirements:
217
245
  - - "~>"
218
246
  - !ruby/object:Gem::Version
219
- version: '3.7'
247
+ version: '0.1'
220
248
  - - ">="
221
249
  - !ruby/object:Gem::Version
222
- version: 3.7.0
250
+ version: 0.1.2
251
+ type: :runtime
252
+ prerelease: false
253
+ version_requirements: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '0.1'
258
+ - - ">="
259
+ - !ruby/object:Gem::Version
260
+ version: 0.1.2
261
+ - !ruby/object:Gem::Dependency
262
+ name: bundler
263
+ requirement: !ruby/object:Gem::Requirement
264
+ requirements:
265
+ - - "~>"
266
+ - !ruby/object:Gem::Version
267
+ version: '1.15'
268
+ - - ">="
269
+ - !ruby/object:Gem::Version
270
+ version: 1.15.0
223
271
  type: :development
224
272
  prerelease: false
225
273
  version_requirements: !ruby/object:Gem::Requirement
226
274
  requirements:
227
275
  - - "~>"
228
276
  - !ruby/object:Gem::Version
229
- version: '3.7'
277
+ version: '1.15'
230
278
  - - ">="
231
279
  - !ruby/object:Gem::Version
232
- version: 3.7.0
280
+ version: 1.15.0
233
281
  - !ruby/object:Gem::Dependency
234
- name: kommando
282
+ name: rake
235
283
  requirement: !ruby/object:Gem::Requirement
236
284
  requirements:
237
285
  - - "~>"
238
286
  - !ruby/object:Gem::Version
239
- version: '0.1'
287
+ version: '12.3'
240
288
  - - ">="
241
289
  - !ruby/object:Gem::Version
242
- version: 0.1.2
290
+ version: 12.3.0
243
291
  type: :development
244
292
  prerelease: false
245
293
  version_requirements: !ruby/object:Gem::Requirement
246
294
  requirements:
247
295
  - - "~>"
248
296
  - !ruby/object:Gem::Version
249
- version: '0.1'
297
+ version: '12.3'
250
298
  - - ">="
251
299
  - !ruby/object:Gem::Version
252
- version: 0.1.2
300
+ version: 12.3.0
253
301
  description: Better way to build Capybara tests
254
302
  email:
255
303
  - matti.paksula@iki.fi
@@ -338,6 +386,7 @@ files:
338
386
  - examples/login-and-logout/using-params/main.rb
339
387
  - examples/sites/pharos.sh/main.rb
340
388
  - examples/sites/vr.fi/helsinki-tampere/main.rb
389
+ - examples/spec/minimal_spec.rb
341
390
  - exe/superbara
342
391
  - lib/capybara_monkey.rb
343
392
  - lib/pry_monkey.rb
@@ -358,7 +407,6 @@ files:
358
407
  - lib/superbara/pcm.rb
359
408
  - lib/superbara/pcom.rb
360
409
  - lib/superbara/pom.rb
361
- - lib/superbara/rspec.rb
362
410
  - lib/superbara/version.rb
363
411
  - lib/superbara/web.rb
364
412
  - superbara.gemspec
@@ -401,10 +449,12 @@ files:
401
449
  - vendor/chromedriver/mac64/chromedriver
402
450
  - vendor/chromedriver/win32/.gitkeep
403
451
  - vendor/chromedriver/win32/chromedriver.exe
452
+ - vendor/robot/mac64/robot
404
453
  - web/public/1.html
405
454
  - web/public/2.html
406
455
  - web/public/3.html
407
456
  - web/public/another.html
457
+ - web/public/capybara_svg_test.html
408
458
  - web/public/highcharts.html
409
459
  - web/public/index.html
410
460
  - web/views/layout.erb
@@ -1,35 +0,0 @@
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
- #TODO
13
- #$superbara_current_file = example.metadata[:example_group][:file_path]
14
-
15
- puts ""
16
- class_path = example.example_group_instance.class.to_s.split("::")
17
- class_path.shift
18
- class_path.shift
19
- print class_path.shift
20
- for c in class_path do
21
- print "/#{c}"
22
- end
23
- puts " #{example.description} - #{example.location}"
24
- puts "-"*IO.console.winsize.last
25
- end
26
-
27
- config.after(:each) do |example|
28
- if example.exception
29
- puts ("="*80).colorize(:yellow)
30
- puts example.exception.message.colorize(:red)
31
- puts ("="*80).colorize(:yellow)
32
- debug(exception_occurred: true)
33
- end
34
- end
35
- end