superbara 0.12.0 → 0.13.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 +10 -4
- data/README.md +2 -2
- data/lib/pry_monkey.rb +1 -1
- data/lib/superbara.rb +29 -15
- data/lib/superbara/cli.rb +69 -89
- data/lib/superbara/context.rb +8 -87
- data/lib/superbara/context/base.rb +15 -0
- data/lib/superbara/context/eval.rb +12 -0
- data/lib/superbara/context/run.rb +15 -0
- data/lib/superbara/context/shell.rb +16 -0
- data/lib/superbara/context/start.rb +31 -0
- data/lib/superbara/dsl.rb +13 -19
- data/lib/superbara/version.rb +1 -1
- data/superbara.gemspec +1 -0
- data/tests/all/main.rb +1 -1
- data/tests/common/main.rb +1 -1
- data/tests/envs/on_error/main.rb +3 -3
- data/tests/envs/on_error/second_ok.rb +1 -1
- data/tests/features/find.rb +4 -1
- data/tests/minimal/main.rb +6 -1
- data/tests/minimal/minimal.rb +12 -0
- data/tests/run/main.rb +25 -0
- data/tests/run/once.rb +1 -0
- data/tests/run/value.rb +1 -0
- data/tests/tags/block.rb +1 -1
- data/tests/tags/notags.rb +1 -1
- data/tests/tags/simple.rb +1 -1
- metadata +30 -3
- data/lib/superbara/errors/export_stops_error.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab8bf36370219d9cdc7b4519eee57b6a8fed48128f0d41b0e98a450c4cd88357
|
4
|
+
data.tar.gz: d89410c70aca07dc35dbe3696e53e7c7901f9206a1bcfa438749cb362b0a4547
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb4124bad9f79400663e58eba62389c0b7e6dca4fe692dd43703ed90c6890289f0af7f8160e39028138009cebd01f46ac2650287e9e1a91b4b6375e45305355a
|
7
|
+
data.tar.gz: 0cec8306e977a827ddc049b013c31e89fb1216697e0ca1bc42c070c5ece5f4445a75b93fc3cdd7a685f510286c20b6c2f33e765889e2190ebffd939583a28486
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
superbara (0.
|
4
|
+
superbara (0.13.0)
|
5
|
+
astrolabe (~> 1.3, >= 1.3.1)
|
5
6
|
binding_of_caller (~> 0.8, >= 0.8.0)
|
6
7
|
capybara (~> 3.1, >= 3.1.0)
|
7
8
|
colorize (~> 0.8, >= 0.8.1)
|
@@ -15,6 +16,9 @@ GEM
|
|
15
16
|
specs:
|
16
17
|
addressable (2.5.2)
|
17
18
|
public_suffix (>= 2.0.2, < 4.0)
|
19
|
+
ast (2.4.0)
|
20
|
+
astrolabe (1.3.1)
|
21
|
+
parser (~> 2.2)
|
18
22
|
binding_of_caller (0.8.0)
|
19
23
|
debug_inspector (>= 0.0.1)
|
20
24
|
byebug (10.0.2)
|
@@ -44,6 +48,8 @@ GEM
|
|
44
48
|
mustermann (1.0.2)
|
45
49
|
nokogiri (1.8.2)
|
46
50
|
mini_portile2 (~> 2.3.0)
|
51
|
+
parser (2.5.1.0)
|
52
|
+
ast (~> 2.4.0)
|
47
53
|
pry (0.11.3)
|
48
54
|
coderay (~> 1.1.0)
|
49
55
|
method_source (~> 0.9.0)
|
@@ -52,7 +58,7 @@ GEM
|
|
52
58
|
pry (~> 0.10)
|
53
59
|
public_suffix (3.0.2)
|
54
60
|
rack (2.0.5)
|
55
|
-
rack-protection (2.0.
|
61
|
+
rack-protection (2.0.3)
|
56
62
|
rack
|
57
63
|
rack-test (1.0.0)
|
58
64
|
rack (>= 1.0, < 3)
|
@@ -74,10 +80,10 @@ GEM
|
|
74
80
|
selenium-webdriver (3.12.0)
|
75
81
|
childprocess (~> 0.5)
|
76
82
|
rubyzip (~> 1.2)
|
77
|
-
sinatra (2.0.
|
83
|
+
sinatra (2.0.3)
|
78
84
|
mustermann (~> 1.0)
|
79
85
|
rack (~> 2.0)
|
80
|
-
rack-protection (= 2.0.
|
86
|
+
rack-protection (= 2.0.3)
|
81
87
|
tilt (~> 2.0)
|
82
88
|
tilt (2.0.8)
|
83
89
|
xpath (3.1.0)
|
data/README.md
CHANGED
@@ -74,10 +74,10 @@ find "h1"
|
|
74
74
|
run "vars"
|
75
75
|
|
76
76
|
# possible to run just once per session (superbara start) to speed up
|
77
|
-
run "login", once: true
|
77
|
+
run "login", {}, once: true
|
78
78
|
|
79
79
|
# ..and do something when already ran
|
80
|
-
run "login", once: true do
|
80
|
+
run "login", {}, once: true do
|
81
81
|
# when already logged in
|
82
82
|
visit "http://www.example.com/main"
|
83
83
|
end
|
data/lib/pry_monkey.rb
CHANGED
data/lib/superbara.rb
CHANGED
@@ -11,8 +11,6 @@ require_relative "selenium_monkey"
|
|
11
11
|
require_relative "capybara_monkey"
|
12
12
|
require_relative "pry_monkey"
|
13
13
|
|
14
|
-
::Kernel.send :undef_method, :p
|
15
|
-
|
16
14
|
require_relative "superbara/config"
|
17
15
|
|
18
16
|
module Superbara
|
@@ -24,16 +22,6 @@ module Superbara
|
|
24
22
|
@@project_path = Dir.pwd
|
25
23
|
@@config = Superbara::Config.new
|
26
24
|
@@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
|
-
|
37
25
|
|
38
26
|
def self.start!
|
39
27
|
@@started_at = Time.now
|
@@ -96,6 +84,14 @@ module Superbara
|
|
96
84
|
@@current_context
|
97
85
|
end
|
98
86
|
|
87
|
+
@@last_context_return_value = nil
|
88
|
+
def self.last_context_return_value=(value)
|
89
|
+
@@last_context_return_value = value
|
90
|
+
end
|
91
|
+
def self.last_context_return_value
|
92
|
+
@@last_context_return_value
|
93
|
+
end
|
94
|
+
|
99
95
|
def self.output(str)
|
100
96
|
if Superbara.shell? || Superbara.seconds_since_start.nil?
|
101
97
|
puts str
|
@@ -152,6 +148,19 @@ module Superbara
|
|
152
148
|
end
|
153
149
|
end
|
154
150
|
|
151
|
+
def self.print_error(ex)
|
152
|
+
puts ""
|
153
|
+
print "Error: ".colorize(:red)
|
154
|
+
puts ex.message.split(" for #<Superbara::Context").first
|
155
|
+
puts " in #{ex.backtrace_locations.first.path}:#{ex.backtrace_locations.first.lineno}"
|
156
|
+
end
|
157
|
+
|
158
|
+
def self.print_tag_skip(ex)
|
159
|
+
test_tags = Marshal.load(ex.message).join(",")
|
160
|
+
allowed_tags = Superbara.config.tags.join(",")
|
161
|
+
Superbara.output " ..skipped due to test tags (#{test_tags}) not found in current tags: #{allowed_tags}"
|
162
|
+
end
|
163
|
+
|
155
164
|
def self.errored_runs
|
156
165
|
@@errored_runs
|
157
166
|
end
|
@@ -160,6 +169,14 @@ module Superbara
|
|
160
169
|
@@config
|
161
170
|
end
|
162
171
|
|
172
|
+
def self.start_did_open_debug
|
173
|
+
@@start_did_open_debug
|
174
|
+
end
|
175
|
+
|
176
|
+
def self.start_did_open_debug=(value)
|
177
|
+
@@start_did_open_debug = value
|
178
|
+
end
|
179
|
+
|
163
180
|
def self.toast(text, duration: 1, delay: nil)
|
164
181
|
return unless Superbara.visual?
|
165
182
|
|
@@ -222,8 +239,6 @@ if (window.document.body) {
|
|
222
239
|
end
|
223
240
|
end
|
224
241
|
|
225
|
-
Superbara.main = self
|
226
|
-
|
227
242
|
require_relative "superbara/version"
|
228
243
|
require_relative "superbara/helpers"
|
229
244
|
require_relative "superbara/chrome"
|
@@ -231,7 +246,6 @@ require_relative "superbara/cli"
|
|
231
246
|
require_relative "superbara/context"
|
232
247
|
require_relative "superbara/web"
|
233
248
|
require_relative "superbara/errors/not_desired_tag_error"
|
234
|
-
require_relative "superbara/errors/export_stops_error"
|
235
249
|
|
236
250
|
trap "SIGINT" do
|
237
251
|
puts "
|
data/lib/superbara/cli.rb
CHANGED
@@ -110,109 +110,89 @@ scroll 50
|
|
110
110
|
end
|
111
111
|
|
112
112
|
Pry.start if ENV['SUPERBARA_DEBUG']
|
113
|
-
ctx = nil
|
114
113
|
webapp_thread = nil
|
115
114
|
puts "== superbara #{Superbara::VERSION} =="
|
115
|
+
|
116
116
|
loop do
|
117
|
-
|
117
|
+
case main_command
|
118
|
+
when "web"
|
119
|
+
webapp = Superbara::Web.new port: (ENV['SUPERBARA_WEB_PORT'] || 4567)
|
120
|
+
webapp.run!
|
121
|
+
exit 0
|
122
|
+
when "shell"
|
123
|
+
Superbara.visual_enable!
|
124
|
+
Superbara.shell_enable!
|
125
|
+
|
126
|
+
unless webapp_thread
|
127
|
+
webapp_thread = Thread.new do
|
128
|
+
webapp = Superbara::Web.new access_log: false
|
129
|
+
webapp.run!
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
Superbara::Context::Shell.new "visit 'localhost:4567'"
|
135
|
+
when "run", "start"
|
136
|
+
puts "project: #{Superbara.project_name}"
|
137
|
+
puts ""
|
138
|
+
puts "t action".colorize(:light_black)
|
139
|
+
|
140
|
+
Superbara.start!
|
141
|
+
|
142
|
+
Superbara.visual_disabled do
|
143
|
+
Superbara::Context::Eval.new "visit 'about:blank'"
|
144
|
+
end
|
118
145
|
|
119
|
-
begin
|
120
146
|
case main_command
|
121
|
-
when "
|
122
|
-
webapp = Superbara::Web.new port: (ENV['SUPERBARA_WEB_PORT'] || 4567)
|
123
|
-
webapp.run!
|
124
|
-
exit 0
|
125
|
-
when "shell"
|
147
|
+
when "start"
|
126
148
|
Superbara.visual_enable!
|
127
|
-
Superbara.shell_enable!
|
128
149
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
150
|
+
Superbara.start_did_open_debug = false
|
151
|
+
Superbara::Context::Start.new File.join(Superbara.project_path, project_entrypoint)
|
152
|
+
unless Superbara.start_did_open_debug
|
153
|
+
puts
|
154
|
+
print "WARNING: ".colorize(:yellow)
|
155
|
+
puts "your script had a return statement - local variables NOT available in debugger"
|
156
|
+
Superbara::Context::Shell.new
|
134
157
|
end
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
Superbara
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
Superbara.current_context.__superbara_eval "visit 'about:blank'"
|
158
|
+
when "run"
|
159
|
+
begin
|
160
|
+
Superbara::Context::Run.new File.join(Superbara.project_path, project_entrypoint)
|
161
|
+
rescue Superbara::Errors::NotDesiredTagError => ex
|
162
|
+
test_tags = Marshal.load(ex.message).join(",")
|
163
|
+
allowed_tags = Superbara.config.tags.join(",")
|
164
|
+
Superbara.output " ..skipped due to test tags (#{test_tags}) not found in current tags: #{allowed_tags}"
|
165
|
+
rescue => ex
|
166
|
+
Superbara.print_error ex
|
167
|
+
exit 1
|
168
|
+
else
|
169
|
+
puts """
|
170
|
+
🏁 🏁 🏁 done."""
|
149
171
|
end
|
150
172
|
|
151
|
-
|
152
|
-
|
153
|
-
Superbara.
|
154
|
-
|
155
|
-
|
156
|
-
Superbara.current_context.__superbara_load File.join(Superbara.project_path, project_entrypoint)
|
157
|
-
puts """
|
158
|
-
🏁 🏁 🏁 done."""
|
159
|
-
|
160
|
-
case main_command
|
161
|
-
when "run"
|
162
|
-
if Superbara.errored_runs.any?
|
163
|
-
puts ""
|
164
|
-
error_or_errors = if Superbara.errored_runs.size > 1
|
165
|
-
"errors"
|
166
|
-
else
|
167
|
-
"error"
|
168
|
-
end
|
169
|
-
|
170
|
-
puts "Run had #{Superbara.errored_runs.size} #{error_or_errors}!".colorize(:red)
|
171
|
-
puts ""
|
172
|
-
puts "Following runs errored:"
|
173
|
-
for errored_run in Superbara.errored_runs
|
174
|
-
puts " #{errored_run}"
|
175
|
-
end
|
176
|
-
|
177
|
-
exit! 1 #TODO: at_exit handler instead?
|
173
|
+
if Superbara.errored_runs.any?
|
174
|
+
puts ""
|
175
|
+
error_or_errors = if Superbara.errored_runs.size > 1
|
176
|
+
"errors"
|
178
177
|
else
|
179
|
-
|
178
|
+
"error"
|
180
179
|
end
|
181
|
-
when "start"
|
182
|
-
Superbara.current_context.__superbara_eval """
|
183
|
-
debug disable_whereami: true, help: false;
|
184
|
-
sleep 0.0001
|
185
|
-
"""
|
186
|
-
end
|
187
|
-
else
|
188
|
-
puts "Unknown command: #{main_command}"
|
189
|
-
exit 1
|
190
|
-
end
|
191
|
-
rescue Exception => ex
|
192
|
-
return if ex.class == SystemExit
|
193
|
-
|
194
|
-
begin
|
195
|
-
offending_file_path_and_line_in_this = ex.backtrace.detect { |line| line.end_with?("`<top (required)>'") }
|
196
|
-
offending_file_path, offending_line, _ = offending_file_path_and_line_in_this.split(":")
|
197
|
-
offending_code = IO.readlines(offending_file_path)[offending_line.to_i-1]
|
198
|
-
rescue Exception => ex_while_parsing
|
199
|
-
raise ex
|
200
|
-
end
|
201
|
-
puts """
|
202
|
-
== Exception ==""".colorize(:red)
|
203
|
-
puts """#{ex.class}
|
204
|
-
#{ex.message}
|
205
|
-
in #{offending_file_path}:#{offending_line}
|
206
|
-
#{offending_line}: #{offending_code}""".colorize(:light_black)
|
207
180
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
""
|
213
|
-
|
214
|
-
|
181
|
+
puts "Run had #{Superbara.errored_runs.size} #{error_or_errors}!".colorize(:red)
|
182
|
+
puts ""
|
183
|
+
puts "Following runs errored:"
|
184
|
+
for errored_run in Superbara.errored_runs
|
185
|
+
puts " #{errored_run}"
|
186
|
+
end
|
187
|
+
|
188
|
+
exit 1
|
189
|
+
else
|
190
|
+
exit 0
|
191
|
+
end
|
215
192
|
end
|
193
|
+
else
|
194
|
+
puts "Unknown command: #{main_command}"
|
195
|
+
exit 1
|
216
196
|
end
|
217
197
|
end
|
218
198
|
end
|
data/lib/superbara/context.rb
CHANGED
@@ -1,89 +1,10 @@
|
|
1
|
-
module Superbara
|
2
|
-
|
3
|
-
include Capybara::DSL
|
4
|
-
include Superbara::DSL
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@__superbara_binding = binding
|
8
|
-
end
|
9
|
-
|
10
|
-
def __superbara_debug
|
11
|
-
__superbara_eval """
|
12
|
-
debug disable_whereami: true, help: false
|
13
|
-
sleep 0.0001
|
14
|
-
"""
|
15
|
-
end
|
16
|
-
|
17
|
-
def __superbara_load(path, params={})
|
18
|
-
params.each_pair do |k,v|
|
19
|
-
eval = "@#{k} = "
|
20
|
-
eval << "'" if v.class == String
|
21
|
-
eval << v
|
22
|
-
eval << "'" if v.class == String
|
23
|
-
Superbara.main.instance_eval "@#{k} = #{eval}"
|
24
|
-
end
|
25
|
-
|
26
|
-
not_desired_tag_error_occurred = false
|
27
|
-
export_stops_error = nil
|
28
|
-
begin
|
29
|
-
load path, true
|
30
|
-
rescue Superbara::Errors::ExportStopsError => ex
|
31
|
-
export_stops_error = ex
|
32
|
-
rescue Superbara::Errors::NotDesiredTagError => ex
|
33
|
-
not_desired_tag_error_occurred = true
|
34
|
-
test_tags = Marshal.load(ex.message).join(",")
|
35
|
-
allowed_tags = Superbara.config.tags.join(",")
|
36
|
-
Superbara.output " ..skipped due to test tags (#{test_tags}) not found in current tags: #{allowed_tags}"
|
37
|
-
ensure
|
38
|
-
params.each_pair do |k,v|
|
39
|
-
Superbara.main.instance_eval "remove_instance_variable '@#{k}'"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
if export_stops_error
|
44
|
-
# sending it forward for run to return what's inside
|
45
|
-
raise export_stops_error
|
46
|
-
end
|
47
|
-
|
48
|
-
if not_desired_tag_error_occurred
|
49
|
-
# FAKENEWS: sending it forward for run to return false
|
50
|
-
raise Superbara::Errors::NotDesiredTagError
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def __superbara_eval(str)
|
55
|
-
@__superbara_binding.eval str
|
56
|
-
end
|
57
|
-
|
58
|
-
def method_missing(m, *args, &block)
|
59
|
-
super unless Superbara.shell?
|
60
|
-
|
61
|
-
selector = m.to_s
|
62
|
-
finder_args = args[0] if args.any?
|
63
|
-
|
64
|
-
would_find_size = evaluate_script "document.querySelectorAll('#{m}').length"
|
65
|
-
if would_find_size > 50
|
66
|
-
puts "tried to find with selector '#{m}', but would return over 50 elements (#{would_find_size}) and hang."
|
67
|
-
return false
|
68
|
-
end
|
69
|
-
|
70
|
-
print "finding all '#{m}'"
|
71
|
-
|
72
|
-
results = if finder_args
|
73
|
-
puts " #{finder_args}"
|
74
|
-
all selector, finder_args
|
75
|
-
else
|
76
|
-
puts ""
|
77
|
-
all selector
|
78
|
-
end
|
79
|
-
|
80
|
-
if results.size == 1
|
81
|
-
results.first.show
|
82
|
-
elsif results.size > 1
|
83
|
-
results.show(styles: [{"border" => "20px dashed Red"}])
|
84
|
-
else
|
85
|
-
[]
|
86
|
-
end
|
1
|
+
module Superbara
|
2
|
+
module Context
|
87
3
|
end
|
4
|
+
end
|
88
5
|
|
89
|
-
|
6
|
+
require_relative "context/base"
|
7
|
+
require_relative "context/shell"
|
8
|
+
require_relative "context/start"
|
9
|
+
require_relative "context/run"
|
10
|
+
require_relative "context/eval"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Superbara
|
2
|
+
module Context
|
3
|
+
class Base
|
4
|
+
require_relative "../dsl"
|
5
|
+
include Capybara::DSL
|
6
|
+
include Superbara::DSL
|
7
|
+
|
8
|
+
def initialize(path_or_contents, params = {})
|
9
|
+
params.each_pair do |k,v|
|
10
|
+
instance_variable_set "@#{k}", v
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Superbara
|
2
|
+
module Context
|
3
|
+
class Eval < Base
|
4
|
+
def initialize(__SUPERBARA_CONTENTS__, __SUPERBARA_PARAMS__={})
|
5
|
+
super __SUPERBARA_CONTENTS__, __SUPERBARA_PARAMS__
|
6
|
+
lambda do
|
7
|
+
instance_eval __SUPERBARA_CONTENTS__
|
8
|
+
end.call
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Superbara
|
2
|
+
module Context
|
3
|
+
class Run < Base
|
4
|
+
def initialize(__SUPERBARA_FILE__, __SUPERBARA_PARAMS__={})
|
5
|
+
super __SUPERBARA_FILE__, __SUPERBARA_PARAMS__
|
6
|
+
|
7
|
+
Superbara.last_context_return_value = lambda do
|
8
|
+
instance_eval """
|
9
|
+
#{File.read(File.realpath(__SUPERBARA_FILE__))}
|
10
|
+
""", File.realpath(__SUPERBARA_FILE__), 1
|
11
|
+
end.call
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Superbara
|
2
|
+
module Context
|
3
|
+
class Shell < Base
|
4
|
+
def initialize(__SUPERBARA_CONTENTS__="", __SUPERBARA_PARAMS__={})
|
5
|
+
super __SUPERBARA_CONTENTS__, __SUPERBARA_PARAMS__
|
6
|
+
lambda do
|
7
|
+
instance_eval """
|
8
|
+
#{__SUPERBARA_CONTENTS__}
|
9
|
+
debug disable_whereami: true, help: false
|
10
|
+
sleep 0.001
|
11
|
+
"""
|
12
|
+
end.call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Superbara
|
2
|
+
module Context
|
3
|
+
class Start < Base
|
4
|
+
def initialize(__SUPERBARA_FILE__, __SUPERBARA_PARAMS__={})
|
5
|
+
super __SUPERBARA_FILE__, __SUPERBARA_PARAMS__
|
6
|
+
|
7
|
+
lambda do
|
8
|
+
instance_eval """
|
9
|
+
begin
|
10
|
+
#{File.read(File.realpath(__SUPERBARA_FILE__))}
|
11
|
+
rescue Superbara::Errors::NotDesiredTagError
|
12
|
+
Superbara.print_tag_skip $!
|
13
|
+
rescue
|
14
|
+
Superbara.print_error $!
|
15
|
+
else
|
16
|
+
puts '
|
17
|
+
🏁 🏁 🏁 done.'
|
18
|
+
end
|
19
|
+
|
20
|
+
debug disable_whereami: true, help: false
|
21
|
+
sleep 0.001
|
22
|
+
""",
|
23
|
+
File.realpath(__SUPERBARA_FILE__),
|
24
|
+
1
|
25
|
+
end.call
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
data/lib/superbara/dsl.rb
CHANGED
@@ -17,9 +17,9 @@ module Superbara; module DSL
|
|
17
17
|
return unless failed
|
18
18
|
|
19
19
|
if message
|
20
|
-
Superbara.output ("FAIL: ".colorize(:red) + message)
|
20
|
+
Superbara.output ("FAIL: ".colorize(:red) + message.inspect)
|
21
21
|
else
|
22
|
-
Superbara.output "FAIL
|
22
|
+
Superbara.output "FAIL".colorize(:red)
|
23
23
|
end
|
24
24
|
|
25
25
|
exit 1
|
@@ -86,19 +86,18 @@ return Array.from(
|
|
86
86
|
e.click
|
87
87
|
end
|
88
88
|
|
89
|
-
def export(e)
|
90
|
-
raise Superbara::Errors::ExportStopsError, Marshal.dump(e)
|
91
|
-
end
|
92
|
-
|
93
89
|
@@once_runs = []
|
94
|
-
def run(what,
|
95
|
-
|
90
|
+
def run(what, params={}, args={}, &block)
|
91
|
+
Superbara.last_context_return_value = nil
|
92
|
+
|
93
|
+
if args[:once] == true
|
96
94
|
if @@once_runs.include? what
|
97
95
|
if block
|
98
96
|
value = block.call
|
99
97
|
return value
|
100
98
|
else
|
101
|
-
|
99
|
+
Superbara.output "run #{what} skip"
|
100
|
+
return nil
|
102
101
|
end
|
103
102
|
else
|
104
103
|
@@once_runs << what
|
@@ -121,13 +120,10 @@ return Array.from(
|
|
121
120
|
Superbara.project_path = File.dirname(better_what)
|
122
121
|
end
|
123
122
|
|
124
|
-
export_object = nil
|
125
123
|
begin
|
126
|
-
Superbara.
|
124
|
+
Superbara::Context::Run.new better_what, params
|
127
125
|
rescue Superbara::Errors::NotDesiredTagError
|
128
|
-
rescue
|
129
|
-
export_object = Marshal.load ex.message
|
130
|
-
rescue Exception => ex
|
126
|
+
rescue => ex
|
131
127
|
if ENV["SUPERBARA_ON_ERROR"] == "continue"
|
132
128
|
colored_output = " ERROR: ".colorize(:red)
|
133
129
|
colored_output << ex.message
|
@@ -141,8 +137,7 @@ return Array.from(
|
|
141
137
|
end
|
142
138
|
|
143
139
|
Superbara.project_path = old_project_path
|
144
|
-
|
145
|
-
export_object
|
140
|
+
Superbara.last_context_return_value
|
146
141
|
end
|
147
142
|
|
148
143
|
def visit(visit_uri_or_domain_or_path)
|
@@ -242,6 +237,8 @@ return Array.from(
|
|
242
237
|
end
|
243
238
|
|
244
239
|
def wait(seconds=5, &block)
|
240
|
+
raise "block not given" unless block
|
241
|
+
|
245
242
|
def wait_formatted_output(status, took_delta)
|
246
243
|
word, color = if status
|
247
244
|
["ok", :green]
|
@@ -370,6 +367,3 @@ return Array.from(
|
|
370
367
|
Pry.start(binding.of_caller(1))
|
371
368
|
end
|
372
369
|
end; end
|
373
|
-
|
374
|
-
extend Capybara::DSL
|
375
|
-
extend Superbara::DSL # override Capybara methods
|
data/lib/superbara/version.rb
CHANGED
data/superbara.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency 'selenium-webdriver', '~> 3.12', '>= 3.12.0'
|
31
31
|
spec.add_dependency 'faker', '~> 1.8', '>= 1.8.7'
|
32
32
|
spec.add_dependency 'sinatra', '~> 2.0', '>= 2.0.1'
|
33
|
+
spec.add_dependency 'astrolabe', '~> 1.3', '>= 1.3.1'
|
33
34
|
|
34
35
|
spec.add_development_dependency 'bundler', '~> 1.15', '>= 1.15.0'
|
35
36
|
spec.add_development_dependency 'rake', '~> 10.0', '>= 10.0.0'
|
data/tests/all/main.rb
CHANGED
data/tests/common/main.rb
CHANGED
data/tests/envs/on_error/main.rb
CHANGED
@@ -2,14 +2,14 @@ first = run "first_failing"
|
|
2
2
|
second = run "second_ok"
|
3
3
|
third = run "third_failing"
|
4
4
|
|
5
|
-
assert
|
5
|
+
assert first do
|
6
6
|
first == nil
|
7
7
|
end
|
8
8
|
|
9
|
-
assert
|
9
|
+
assert second do
|
10
10
|
second == "second"
|
11
11
|
end
|
12
12
|
|
13
|
-
assert
|
13
|
+
assert third do
|
14
14
|
third == nil
|
15
15
|
end
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
return "second"
|
data/tests/features/find.rb
CHANGED
data/tests/minimal/main.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
hello = "local hello"
|
2
|
+
@hello = "instance hello"
|
3
|
+
|
4
|
+
assert local_variables.inspect do
|
5
|
+
local_variables == [:hello, :__SUPERBARA_FILE__, :__SUPERBARA_PARAMS__]
|
6
|
+
end
|
7
|
+
|
8
|
+
assert "instance" do
|
9
|
+
instance_variables == [:@hello]
|
10
|
+
end
|
11
|
+
|
12
|
+
"hello from minimal.rb"
|
data/tests/run/main.rb
CHANGED
@@ -1,2 +1,27 @@
|
|
1
1
|
run "has_instance_variables", first: "hello", second: "world"
|
2
|
+
|
3
|
+
assert "first" do
|
4
|
+
@first.nil?
|
5
|
+
end
|
6
|
+
|
7
|
+
assert "second" do
|
8
|
+
@first.nil?
|
9
|
+
end
|
10
|
+
|
2
11
|
run "has_no_instance_variables"
|
12
|
+
|
13
|
+
value = run "value"
|
14
|
+
|
15
|
+
assert "value" do
|
16
|
+
value == "hello"
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
values = []
|
21
|
+
3.times do
|
22
|
+
values << (run "once", {}, once: true)
|
23
|
+
end
|
24
|
+
|
25
|
+
assert "once" do
|
26
|
+
values == ["once", nil, nil]
|
27
|
+
end
|
data/tests/run/once.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
return "once"
|
data/tests/run/value.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"hello"
|
data/tests/tags/block.rb
CHANGED
data/tests/tags/notags.rb
CHANGED
data/tests/tags/simple.rb
CHANGED
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.
|
4
|
+
version: 0.13.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-
|
11
|
+
date: 2018-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -150,6 +150,26 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 2.0.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: astrolabe
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.3'
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 1.3.1
|
163
|
+
type: :runtime
|
164
|
+
prerelease: false
|
165
|
+
version_requirements: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - "~>"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '1.3'
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 1.3.1
|
153
173
|
- !ruby/object:Gem::Dependency
|
154
174
|
name: bundler
|
155
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -327,8 +347,12 @@ files:
|
|
327
347
|
- lib/superbara/cli.rb
|
328
348
|
- lib/superbara/config.rb
|
329
349
|
- lib/superbara/context.rb
|
350
|
+
- lib/superbara/context/base.rb
|
351
|
+
- lib/superbara/context/eval.rb
|
352
|
+
- lib/superbara/context/run.rb
|
353
|
+
- lib/superbara/context/shell.rb
|
354
|
+
- lib/superbara/context/start.rb
|
330
355
|
- lib/superbara/dsl.rb
|
331
|
-
- lib/superbara/errors/export_stops_error.rb
|
332
356
|
- lib/superbara/errors/not_desired_tag_error.rb
|
333
357
|
- lib/superbara/helpers.rb
|
334
358
|
- lib/superbara/rspec.rb
|
@@ -352,9 +376,12 @@ files:
|
|
352
376
|
- tests/features/type.rb
|
353
377
|
- tests/features/wait.rb
|
354
378
|
- tests/minimal/main.rb
|
379
|
+
- tests/minimal/minimal.rb
|
355
380
|
- tests/run/has_instance_variables.rb
|
356
381
|
- tests/run/has_no_instance_variables.rb
|
357
382
|
- tests/run/main.rb
|
383
|
+
- tests/run/once.rb
|
384
|
+
- tests/run/value.rb
|
358
385
|
- tests/tags/block.rb
|
359
386
|
- tests/tags/fails.rb
|
360
387
|
- tests/tags/main.rb
|