superbara 0.9.1 → 0.10.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: b9f3a8603cefb2c738a232b7b59fc8f12420bb4290cf7e1ae19833fd1b0b392c
4
- data.tar.gz: c04c50f6b234649f9361bba1129fd8a0d2c42c355fb69b00da48c3a093de58cf
3
+ metadata.gz: 27a8bbaf155457a0bb1dcb511c4e4081b6c8631d4caf71c29dc4a4cb37a7ee60
4
+ data.tar.gz: 93338098098c6d467b293367234c1f8690c5ecb1517004c83460edfff9c93faa
5
5
  SHA512:
6
- metadata.gz: 8aaf995a69d5c8c26e0702f6763999d9d79bad6031b3f362b1223bf33b9aeac5deeedabc8f0c44f20582f87053b856b929c46d04558e2a10755da0fa96e147f6
7
- data.tar.gz: 7c6934809be18de784b8f6fff38c50aa9d282229a7d979a574120dedbe991b619ff27a8f53050ccfc5b80b90e3e89e25bb878e45dcd15a780ec80f096972deb0
6
+ metadata.gz: e5ae25605b3be93f76251dae87287e1c7010f22959a5b944f0bbb8c505e70c3e2f9b03b946452fa6d7b96bda296841f3813343ff73e734c9b9ed8e687a18db56
7
+ data.tar.gz: d8a4b309d2087703461700df621dc197464405aa2530f98e111c0581f6f2d302b5200c82de17454403004aeb13ded29f70df8e44c55d7f24464b9b3b6dc860c1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superbara (0.9.1)
4
+ superbara (0.10.0)
5
5
  binding_of_caller (~> 0.8, >= 0.8.0)
6
6
  capybara (~> 3.1, >= 3.1.0)
7
7
  colorize (~> 0.8, >= 0.8.1)
@@ -52,7 +52,7 @@ GEM
52
52
  pry (~> 0.10)
53
53
  public_suffix (3.0.2)
54
54
  rack (2.0.5)
55
- rack-protection (2.0.1)
55
+ rack-protection (2.0.2)
56
56
  rack
57
57
  rack-test (1.0.0)
58
58
  rack (>= 1.0, < 3)
@@ -74,10 +74,10 @@ GEM
74
74
  selenium-webdriver (3.12.0)
75
75
  childprocess (~> 0.5)
76
76
  rubyzip (~> 1.2)
77
- sinatra (2.0.1)
77
+ sinatra (2.0.2)
78
78
  mustermann (~> 1.0)
79
79
  rack (~> 2.0)
80
- rack-protection (= 2.0.1)
80
+ rack-protection (= 2.0.2)
81
81
  tilt (~> 2.0)
82
82
  tilt (2.0.8)
83
83
  xpath (3.1.0)
@@ -0,0 +1,19 @@
1
+ click_link 'Form Authentication'
2
+
3
+ # wait 3 seconds for field 'username' to appear
4
+ username_field = wait 3 do
5
+ find_field 'username'
6
+ end
7
+
8
+ # username comes from: run "helpers/login" username: "tomsmith"
9
+ username_field.type username
10
+
11
+ # we assume that because username was found, then password will be found without waiting
12
+ # also we use parenthesis around to be able to call .type on the returned element
13
+ find_field('password').type password
14
+
15
+ click_button 'Login'
16
+
17
+ wait 3 do
18
+ has_text? 'Welcome to the Secure Area'
19
+ end
@@ -0,0 +1,5 @@
1
+ click_link 'Logout'
2
+
3
+ wait 3 do
4
+ has_text? 'You logged out'
5
+ end
@@ -0,0 +1,13 @@
1
+ visit 'the-internet.herokuapp.com'
2
+
3
+ # by default waits 5 seconds
4
+ wait do
5
+ has_text? 'Welcome to the-internet'
6
+ end
7
+
8
+ run 'helpers/login', username: 'tomsmith', password: 'SuperSecretPassword!'
9
+
10
+ # do nothing for 2 seconds
11
+ sleep 2
12
+
13
+ run 'helpers/logout'
data/lib/superbara.rb CHANGED
@@ -24,6 +24,16 @@ module Superbara
24
24
  @@project_path = Dir.pwd
25
25
  @@config = Superbara::Config.new
26
26
  @@errored_runs = []
27
+ @@main = nil
28
+
29
+ def self.main=(main)
30
+ @@main=main
31
+ end
32
+
33
+ def self.main
34
+ @@main
35
+ end
36
+
27
37
 
28
38
  def self.start!
29
39
  @@started_at = Time.now
@@ -212,6 +222,8 @@ if (window.document.body) {
212
222
  end
213
223
  end
214
224
 
225
+ Superbara.main = self
226
+
215
227
  require_relative "superbara/version"
216
228
  require_relative "superbara/helpers"
217
229
  require_relative "superbara/chrome"
@@ -241,3 +253,4 @@ else
241
253
  end
242
254
 
243
255
  Capybara.default_max_wait_time = 0.1
256
+
@@ -14,12 +14,22 @@ sleep 0.0001
14
14
  """
15
15
  end
16
16
 
17
- def __superbara_load(path)
17
+ def __superbara_load(path, params={})
18
+ params.each_pair do |k,v|
19
+ Superbara.main.define_singleton_method k.to_sym do
20
+ v
21
+ end
22
+ end
23
+
18
24
  begin
19
25
  load path, true
20
26
  rescue Superbara::Errors::NotDesiredTagError
21
27
  Superbara.output " ..skipped due to tag not found"
22
28
  end
29
+
30
+ params.each_pair do |k,v|
31
+ Superbara.main.instance_eval "undef #{k.to_sym}"
32
+ end
23
33
  end
24
34
 
25
35
  def __superbara_eval(str)
data/lib/superbara/dsl.rb CHANGED
@@ -87,7 +87,7 @@ return Array.from(
87
87
  end
88
88
 
89
89
  @@once_runs = []
90
- def run(what, once: false, &block)
90
+ def run(what, once: false, **params, &block)
91
91
  if once
92
92
  if @@once_runs.include? what
93
93
  if block
@@ -118,7 +118,7 @@ return Array.from(
118
118
  end
119
119
 
120
120
  begin
121
- Superbara.current_context.__superbara_load(better_what)
121
+ Superbara.current_context.__superbara_load(better_what, params)
122
122
  rescue Exception => ex
123
123
  if ENV["SUPERBARA_ON_ERROR"] == "continue"
124
124
  colored_output = " ERROR: ".colorize(:red)
@@ -1,3 +1,3 @@
1
1
  module Superbara
2
- VERSION = "0.9.1"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -0,0 +1,7 @@
1
+ assert do
2
+ first == "hello"
3
+ end
4
+
5
+ assert do
6
+ second == "world"
7
+ end
@@ -0,0 +1,7 @@
1
+ assert do
2
+ ! respond_to? :first
3
+ end
4
+
5
+ assert do
6
+ ! respond_to? :second
7
+ end
data/tests/run/main.rb ADDED
@@ -0,0 +1,2 @@
1
+ run "has_locals", first: "hello", second: "world"
2
+ run "has_no_locals"
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.9.1
4
+ version: 0.10.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-05 00:00:00.000000000 Z
11
+ date: 2018-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -309,10 +309,13 @@ files:
309
309
  - docs/searchindex.js
310
310
  - docs/superbara.html
311
311
  - docs/tomorrow-night.css
312
- - examples/login-and-logout/common.rb
313
- - examples/login-and-logout/helpers/login.rb
314
- - examples/login-and-logout/helpers/logout.rb
315
- - examples/login-and-logout/main.rb
312
+ - examples/login-and-logout/using-globals/common.rb
313
+ - examples/login-and-logout/using-globals/helpers/login.rb
314
+ - examples/login-and-logout/using-globals/helpers/logout.rb
315
+ - examples/login-and-logout/using-globals/main.rb
316
+ - examples/login-and-logout/using-params/helpers/login.rb
317
+ - examples/login-and-logout/using-params/helpers/logout.rb
318
+ - examples/login-and-logout/using-params/main.rb
316
319
  - examples/sites/pharos.sh/main.rb
317
320
  - examples/sites/vr.fi/helsinki-tampere/main.rb
318
321
  - examples/tags/block.rb
@@ -351,6 +354,9 @@ files:
351
354
  - tests/features/type.rb
352
355
  - tests/features/wait.rb
353
356
  - tests/minimal/main.rb
357
+ - tests/run/has_locals.rb
358
+ - tests/run/has_no_locals.rb
359
+ - tests/run/main.rb
354
360
  - vendor/chromedriver/linux64/.gitkeep
355
361
  - vendor/chromedriver/linux64/chromedriver
356
362
  - vendor/chromedriver/mac64/.gitkeep