baf 0.6.1 → 0.6.2
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/lib/baf/testing/cucumber/steps/execution.rb +12 -8
- data/lib/baf/testing/cucumber/steps/output_wait.rb +50 -0
- data/lib/baf/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1a22622dd602a592828ff11f450a861883355d1
|
4
|
+
data.tar.gz: 83d308e32b89f49d4298122231fbd457ae3f0c70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e286d14950f9dffd81ea0d642489b15ad140cbd10d6ca00f278dfb313a0bd4f8f2150a1118ab64b5aba7b4e43f57b861c3e0b30f80d160b8dee1454a9eb76f7f
|
7
|
+
data.tar.gz: bb3d0466a293136ffac2f1453718b4fb7e82fa1e4b06a5ddc543faeafde189d780067406cdc7b2ab537b6b86dca8cf0fe2a5d969fa0f6b9b6d92bb1857bdbaef
|
@@ -1,8 +1,12 @@
|
|
1
|
-
def program_run check: false, opts: nil, args: nil
|
1
|
+
def program_run check: false, opts: nil, args: nil, wait: true
|
2
2
|
cmd = [*@_baf_program ||= %w[ruby baf]]
|
3
3
|
cmd << opts if opts
|
4
4
|
cmd << args.split(' ') if args
|
5
|
-
|
5
|
+
if wait
|
6
|
+
run_simple cmd.join(' '), fail_on_error: false
|
7
|
+
else
|
8
|
+
run cmd.join ' '
|
9
|
+
end
|
6
10
|
program_run_check if check
|
7
11
|
end
|
8
12
|
|
@@ -20,16 +24,16 @@ rescue RSpec::Expectations::ExpectationNotMetError => e
|
|
20
24
|
end
|
21
25
|
|
22
26
|
|
23
|
-
When /^I( successfully)? run the program$/ do |check|
|
24
|
-
program_run check: !!check
|
27
|
+
When /^I( successfully)? (run|\w+) the program$/ do |check, run|
|
28
|
+
program_run check: !!check, wait: run == 'run'
|
25
29
|
end
|
26
30
|
|
27
|
-
When /^I( successfully)? run the program with arguments (.+)$/ do |check, args|
|
28
|
-
program_run check: !!check, args: args
|
31
|
+
When /^I( successfully)? (run|\w+) the program with arguments (.+)$/ do |check, run, args|
|
32
|
+
program_run check: !!check, args: args, wait: run == 'run'
|
29
33
|
end
|
30
34
|
|
31
|
-
When /^I( successfully)? run the program with options? (-.+)$/ do |check, opts|
|
32
|
-
program_run check: !!check, opts: opts
|
35
|
+
When /^I( successfully)? (run|\w+) the program with options? (-.+)$/ do |check, run, opts|
|
36
|
+
program_run check: !!check, opts: opts, wait: run == 'run'
|
33
37
|
end
|
34
38
|
|
35
39
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
3
|
+
module Baf
|
4
|
+
module Testing
|
5
|
+
class WaitError < ::StandardError
|
6
|
+
attr_reader :timeout
|
7
|
+
|
8
|
+
def initialize message, timeout
|
9
|
+
super message
|
10
|
+
@timeout = timeout
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def wait_output! pattern
|
17
|
+
output = -> { last_command_started.output }
|
18
|
+
wait_until do
|
19
|
+
case pattern
|
20
|
+
when Regexp then output.call =~ pattern
|
21
|
+
when String then output.call.include? pattern
|
22
|
+
end
|
23
|
+
end
|
24
|
+
rescue Baf::Testing::WaitError => e
|
25
|
+
fail <<-eoh
|
26
|
+
expected `#{pattern}' not seen after #{e.timeout} seconds in:
|
27
|
+
```\n#{output.call.lines.map { |l| " #{l}" }.join} ```
|
28
|
+
eoh
|
29
|
+
end
|
30
|
+
|
31
|
+
def wait_until message: 'condition not met after %d seconds'
|
32
|
+
timeout = 2
|
33
|
+
Timeout.timeout(timeout) do
|
34
|
+
loop do
|
35
|
+
break if yield
|
36
|
+
sleep 0.05
|
37
|
+
end
|
38
|
+
end
|
39
|
+
rescue Timeout::Error
|
40
|
+
raise Baf::Testing::WaitError.new(message % timeout, timeout)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
Then /^the output will match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
|
45
|
+
wait_output! build_regexp(pattern, options)
|
46
|
+
end
|
47
|
+
|
48
|
+
Then /^the output will contain "([^"]+)"$/ do |content|
|
49
|
+
wait_output! content
|
50
|
+
end
|
data/lib/baf/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/baf/testing/cucumber.rb
|
54
54
|
- lib/baf/testing/cucumber/steps/execution.rb
|
55
55
|
- lib/baf/testing/cucumber/steps/output.rb
|
56
|
+
- lib/baf/testing/cucumber/steps/output_wait.rb
|
56
57
|
- lib/baf/version.rb
|
57
58
|
homepage: https://rubygems.org/gems/baf
|
58
59
|
licenses:
|