superbara 0.9.0 → 0.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b471220fa7a1ad1859a0c2b42685210eb6785ad3b2b00409af719c6bb2c8a228
4
- data.tar.gz: 9d5fcfd54166dfb7293dd52d0d13808c486634111d0d76b2f90094ed2deb42ec
3
+ metadata.gz: b9f3a8603cefb2c738a232b7b59fc8f12420bb4290cf7e1ae19833fd1b0b392c
4
+ data.tar.gz: c04c50f6b234649f9361bba1129fd8a0d2c42c355fb69b00da48c3a093de58cf
5
5
  SHA512:
6
- metadata.gz: 53a1072e41dded5d705a6703030c73ee9ca8ae546cb1f92469f08c1f6f9e7deebc9bb1f05f29d5c1abd402bdbfd63cf6a543d731ff6a744456c3dcfa4e1f8da4
7
- data.tar.gz: b13287fe45fe64ba3773bda6818059a6128a0da738c76379302913984f4e35cd150de0e0ce0ad0ba31a6eb72712a50d4242affca3b92a3ec512abd50aa718f0d
6
+ metadata.gz: 8aaf995a69d5c8c26e0702f6763999d9d79bad6031b3f362b1223bf33b9aeac5deeedabc8f0c44f20582f87053b856b929c46d04558e2a10755da0fa96e147f6
7
+ data.tar.gz: 7c6934809be18de784b8f6fff38c50aa9d282229a7d979a574120dedbe991b619ff27a8f53050ccfc5b80b90e3e89e25bb878e45dcd15a780ec80f096972deb0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superbara (0.9.0)
4
+ superbara (0.9.1)
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)
@@ -18,7 +18,7 @@ GEM
18
18
  binding_of_caller (0.8.0)
19
19
  debug_inspector (>= 0.0.1)
20
20
  byebug (10.0.2)
21
- capybara (3.2.0)
21
+ capybara (3.2.1)
22
22
  addressable
23
23
  mini_mime (>= 0.1.3)
24
24
  nokogiri (~> 1.8)
data/bin/release CHANGED
@@ -21,5 +21,3 @@ gem build superbara.gemspec
21
21
  KUNG_ENV=build VERSION=$version kung build
22
22
 
23
23
  rake release
24
-
25
- rubyc -c --gem=superbara --gem-version=${version} superbara
data/bin/tests CHANGED
@@ -24,4 +24,24 @@ if [ "$exit_status" != 1 ]; then
24
24
  exit 1
25
25
  fi
26
26
 
27
+ set +e
28
+ SUPERBARA_ON_ERROR=continue exe/superbara run tests/envs/on_error
29
+ exit_status=$?
30
+ set -e
31
+
32
+ if [ "$exit_status" != 1 ]; then
33
+ echo "err! SUPERBARA_ON_ERROR=continue"
34
+ exit 1
35
+ fi
36
+
37
+ set +e
38
+ exe/superbara run tests/envs/on_error
39
+ exit_status=$?
40
+ set -e
41
+
42
+ if [ "$exit_status" != 1 ]; then
43
+ echo "err! tests/envs/on_error"
44
+ exit 1
45
+ fi
46
+
27
47
  echo "success!"
@@ -0,0 +1,3 @@
1
+ tag "example", "block" do
2
+ visit "example.com"
3
+ end
@@ -0,0 +1,2 @@
1
+ run "simple"
2
+ run "block"
@@ -0,0 +1,3 @@
1
+ tag "example", "simple"
2
+
3
+ visit "example.com"
data/lib/superbara.rb CHANGED
@@ -13,6 +13,8 @@ require_relative "pry_monkey"
13
13
 
14
14
  ::Kernel.send :undef_method, :p
15
15
 
16
+ require_relative "superbara/config"
17
+
16
18
  module Superbara
17
19
  @@project_name = nil
18
20
  @@shell = false
@@ -20,6 +22,8 @@ module Superbara
20
22
  @@visual = false
21
23
  @@started_at = Time.now
22
24
  @@project_path = Dir.pwd
25
+ @@config = Superbara::Config.new
26
+ @@errored_runs = []
23
27
 
24
28
  def self.start!
25
29
  @@started_at = Time.now
@@ -138,6 +142,14 @@ module Superbara
138
142
  end
139
143
  end
140
144
 
145
+ def self.errored_runs
146
+ @@errored_runs
147
+ end
148
+
149
+ def self.config
150
+ @@config
151
+ end
152
+
141
153
  def self.toast(text, duration: 1, delay: nil)
142
154
  return unless Superbara.visual?
143
155
 
@@ -206,6 +218,7 @@ require_relative "superbara/chrome"
206
218
  require_relative "superbara/cli"
207
219
  require_relative "superbara/context"
208
220
  require_relative "superbara/web"
221
+ require_relative "superbara/errors/not_desired_tag_error"
209
222
 
210
223
  trap "SIGINT" do
211
224
  puts "
data/lib/superbara/cli.rb CHANGED
@@ -159,7 +159,25 @@ scroll 50
159
159
 
160
160
  case main_command
161
161
  when "run"
162
- exit 0
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?
178
+ else
179
+ exit 0
180
+ end
163
181
  when "start"
164
182
  Superbara.current_context.__superbara_eval """
165
183
  debug disable_whereami: true, help: false;
@@ -0,0 +1,15 @@
1
+ module Superbara
2
+ class Config
3
+ def tags
4
+ tags_string = ENV["SUPERBARA_TAGS"]
5
+ return [] unless tags_string
6
+
7
+ tags = tags_string.split(",")
8
+ if tags.any?
9
+ tags
10
+ else
11
+ []
12
+ end
13
+ end
14
+ end
15
+ end
@@ -15,7 +15,11 @@ sleep 0.0001
15
15
  end
16
16
 
17
17
  def __superbara_load(path)
18
- load path, true
18
+ begin
19
+ load path, true
20
+ rescue Superbara::Errors::NotDesiredTagError
21
+ Superbara.output " ..skipped due to tag not found"
22
+ end
19
23
  end
20
24
 
21
25
  def __superbara_eval(str)
data/lib/superbara/dsl.rb CHANGED
@@ -117,7 +117,19 @@ return Array.from(
117
117
  Superbara.project_path = File.dirname(better_what)
118
118
  end
119
119
 
120
- Superbara.current_context.__superbara_load(better_what)
120
+ begin
121
+ Superbara.current_context.__superbara_load(better_what)
122
+ rescue Exception => ex
123
+ if ENV["SUPERBARA_ON_ERROR"] == "continue"
124
+ colored_output = " ERROR: ".colorize(:red)
125
+ colored_output << ex.message
126
+ #TODO: output to support "colored tags" and nesting
127
+ Superbara.output colored_output
128
+ Superbara.errored_runs << what
129
+ else
130
+ raise ex
131
+ end
132
+ end
121
133
  Superbara.project_path = old_project_path
122
134
  end
123
135
 
@@ -188,6 +200,35 @@ return Array.from(
188
200
  true
189
201
  end
190
202
 
203
+ def tag(*tags, &block)
204
+ tags.flatten!
205
+
206
+ desired = if Superbara.config.tags.empty?
207
+ true
208
+ else
209
+ found = false
210
+ for tag in tags do
211
+ if Superbara.config.tags.include? tag
212
+ found = true
213
+ break
214
+ end
215
+ end
216
+
217
+ found
218
+ end
219
+
220
+ if desired
221
+ if block.nil?
222
+ return
223
+ else
224
+ value = block.call
225
+ return value
226
+ end
227
+ else
228
+ raise Superbara::Errors::NotDesiredTagError
229
+ end
230
+ end
231
+
191
232
  def wait(seconds=5, &block)
192
233
  def wait_formatted_output(status, took_delta)
193
234
  word, color = if status
@@ -0,0 +1,6 @@
1
+ module Superbara
2
+ module Errors
3
+ class NotDesiredTagError < StandardError
4
+ end
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Superbara
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -0,0 +1 @@
1
+ asdf_first
@@ -0,0 +1,3 @@
1
+ run "first_failing"
2
+ run "second_ok"
3
+ run "third_failing"
File without changes
@@ -0,0 +1 @@
1
+ asdf_third
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.0
4
+ version: 0.9.1
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-04 00:00:00.000000000 Z
11
+ date: 2018-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -315,6 +315,9 @@ files:
315
315
  - examples/login-and-logout/main.rb
316
316
  - examples/sites/pharos.sh/main.rb
317
317
  - examples/sites/vr.fi/helsinki-tampere/main.rb
318
+ - examples/tags/block.rb
319
+ - examples/tags/main.rb
320
+ - examples/tags/simple.rb
318
321
  - exe/superbara
319
322
  - lib/capybara_monkey.rb
320
323
  - lib/pry_monkey.rb
@@ -322,8 +325,10 @@ files:
322
325
  - lib/superbara.rb
323
326
  - lib/superbara/chrome.rb
324
327
  - lib/superbara/cli.rb
328
+ - lib/superbara/config.rb
325
329
  - lib/superbara/context.rb
326
330
  - lib/superbara/dsl.rb
331
+ - lib/superbara/errors/not_desired_tag_error.rb
327
332
  - lib/superbara/helpers.rb
328
333
  - lib/superbara/rspec.rb
329
334
  - lib/superbara/version.rb
@@ -333,6 +338,10 @@ files:
333
338
  - tests/common/main.rb
334
339
  - tests/common/vars.rb
335
340
  - tests/common/webapp.rb
341
+ - tests/envs/on_error/first_failing.rb
342
+ - tests/envs/on_error/main.rb
343
+ - tests/envs/on_error/second_ok.rb
344
+ - tests/envs/on_error/third_failing.rb
336
345
  - tests/fail/main.rb
337
346
  - tests/features/examplecom.rb
338
347
  - tests/features/find.rb