baf 0.6.2 → 0.7.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
  SHA1:
3
- metadata.gz: f1a22622dd602a592828ff11f450a861883355d1
4
- data.tar.gz: 83d308e32b89f49d4298122231fbd457ae3f0c70
3
+ metadata.gz: c706eccaeb576703318da1f4b064a6ad6022b120
4
+ data.tar.gz: 8317a9cc42d852c2dcce64e3e31d10fecb33846b
5
5
  SHA512:
6
- metadata.gz: e286d14950f9dffd81ea0d642489b15ad140cbd10d6ca00f278dfb313a0bd4f8f2150a1118ab64b5aba7b4e43f57b861c3e0b30f80d160b8dee1454a9eb76f7f
7
- data.tar.gz: bb3d0466a293136ffac2f1453718b4fb7e82fa1e4b06a5ddc543faeafde189d780067406cdc7b2ab537b6b86dca8cf0fe2a5d969fa0f6b9b6d92bb1857bdbaef
6
+ metadata.gz: cd2ecfe25f573437c0d4d2611ddf9653418eb6bda3cb703d1901b4dedd1d5193bac918fa3fcd6d144145b25369af7ce64cf32f40a5f55a379cfb1cea1b27f156
7
+ data.tar.gz: c327237b3b0bd01196b080713c710efe8eea223a35b104d201d736dddfd8340ad4407c67a016b7021232f8f119c2bc5cccd3d86d5ffed14930d5673975afdd2d
data/lib/baf/cli.rb CHANGED
@@ -15,7 +15,7 @@ module Baf
15
15
 
16
16
  class << self
17
17
  def run arguments, stdout: $stdout, stderr: $stderr
18
- cli = new env_class.new(stdout), arguments
18
+ cli = new env_class.new(output: stdout), arguments
19
19
  cli.parse_arguments!
20
20
  cli.run
21
21
  rescue ArgumentError => e
data/lib/baf/env.rb CHANGED
@@ -5,7 +5,7 @@ module Baf
5
5
  extend Forwardable
6
6
  def_delegators :@output, :print, :puts
7
7
 
8
- def initialize output
8
+ def initialize output: $stdout
9
9
  @output = output
10
10
  end
11
11
  end
@@ -0,0 +1,3 @@
1
+ When /^I input "([^"]+)"$/ do |content|
2
+ last_command_started.write unescape_text content
3
+ end
@@ -8,8 +8,9 @@ def build_regexp pattern, options
8
8
  end)
9
9
  end
10
10
 
11
- def expect_output content
12
- expect(last_command_started.output).to eq unescape_text content
11
+ def expect_output content, stream: :output
12
+ stream = :stderr if stream == :error
13
+ expect(last_command_started.send stream).to eq unescape_text content
13
14
  end
14
15
 
15
16
 
@@ -17,12 +18,17 @@ Then /^the output must contain "([^"]+)"$/ do |content|
17
18
  expect(last_command_started.output).to include unescape_text content
18
19
  end
19
20
 
21
+ Then /^the output must not contain "([^"]+)"$/ do |content|
22
+ expect(last_command_started.output).not_to include unescape_text content
23
+ end
24
+
20
25
  Then /^the output must contain exactly:$/ do |content|
21
26
  expect_output content + $/
22
27
  end
23
28
 
24
- Then /^the output must contain exactly "([^"]+)"$/ do |content|
25
- expect_output content
29
+ Then /^the( error)? output must contain exactly "([^"]+)"$/ do |stream, content|
30
+ stream = stream ? :error : :output
31
+ expect_output content, stream: stream
26
32
  end
27
33
 
28
34
  Then /^the output must match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
@@ -13,14 +13,15 @@ module Baf
13
13
  end
14
14
  end
15
15
 
16
- def wait_output! pattern
16
+ def wait_output! pattern, times: 1, results: nil
17
17
  output = -> { last_command_started.output }
18
18
  wait_until do
19
19
  case pattern
20
- when Regexp then output.call =~ pattern
20
+ when Regexp then (results = output.call.scan(pattern)).size >= times
21
21
  when String then output.call.include? pattern
22
22
  end
23
23
  end
24
+ results
24
25
  rescue Baf::Testing::WaitError => e
25
26
  fail <<-eoh
26
27
  expected `#{pattern}' not seen after #{e.timeout} seconds in:
@@ -29,7 +30,9 @@ expected `#{pattern}' not seen after #{e.timeout} seconds in:
29
30
  end
30
31
 
31
32
  def wait_until message: 'condition not met after %d seconds'
32
- timeout = 2
33
+ timeout = ENV.key?('BAF_TEST_TIMEOUT') ?
34
+ ENV['BAF_TEST_TIMEOUT'].to_i :
35
+ 2
33
36
  Timeout.timeout(timeout) do
34
37
  loop do
35
38
  break if yield
@@ -45,6 +48,10 @@ Then /^the output will match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
45
48
  wait_output! build_regexp(pattern, options)
46
49
  end
47
50
 
51
+ Then /^the output will contain:$/ do |content|
52
+ wait_output! content + $/
53
+ end
54
+
48
55
  Then /^the output will contain "([^"]+)"$/ do |content|
49
56
  wait_output! content
50
57
  end
data/lib/baf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Baf
2
- VERSION = '0.6.2'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2016-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: baf-testing
@@ -52,6 +52,7 @@ files:
52
52
  - lib/baf/options_registrant.rb
53
53
  - lib/baf/testing/cucumber.rb
54
54
  - lib/baf/testing/cucumber/steps/execution.rb
55
+ - lib/baf/testing/cucumber/steps/input.rb
55
56
  - lib/baf/testing/cucumber/steps/output.rb
56
57
  - lib/baf/testing/cucumber/steps/output_wait.rb
57
58
  - lib/baf/version.rb