lopata 0.1.8 → 0.1.13

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: a6234b218190d6aad3d2465c4ca3c5ab638701cf2afcc13db718546f87d0fa57
4
- data.tar.gz: 4d6312f8f421f834f2bc8412e30307ab29e3c377b256edbe891cc4efaf42315e
3
+ metadata.gz: 19371c76dcc39807c50470e95f365a09c1c33a8193a25b9d98d4d5648f5eaa59
4
+ data.tar.gz: 25c3b8ea2efe44f5cf31f51cea04aa05f2ea35f364ed2167f9cdd466fa6a5e46
5
5
  SHA512:
6
- metadata.gz: 1f1e130381f9551a7b8d2862788478384798d8fbf6ca91d388bb0a54e3c0cc52ccff95542fe6d33f94e4a99d7008c9b258e8f4f2ef8a32f8557b87b35f6e32fe
7
- data.tar.gz: ae371bc70669b963546f1676ec539ffa116a1458582c1547a973a75c66f8d477958494b78c422ababca9b7a0ce725d4dd6d77fd95f377a57d34c73d6ec935d83
6
+ metadata.gz: 7b7378f73bd4fe3c7ce18bcd7e7a0d5f45b05cafac689d764ad3030f879ad1e0c1843e67ddd886ba68643632c33eea9824efbe0b370dea76fe911e03d95fc355
7
+ data.tar.gz: af7ba11d74022ab03a11a62bec31291edba71e6b5c93f1229b765a159e2ce3d14813af5f2967c1d054d7f5e2fc656b593bdce876fbcb9a03cade19a0fbcb3753
data/exe/lopata CHANGED
@@ -4,7 +4,7 @@ require 'lopata/runner'
4
4
 
5
5
  # use default command with arguments if given command is unknown.
6
6
  argv = ARGV.dup
7
- unless Lopata::Runner.all_commands.keys.include? argv
7
+ unless Lopata::Runner.all_commands.keys.map(&:to_s).include? argv.first
8
8
  argv.unshift 'test'
9
9
  end
10
10
 
@@ -20,6 +20,8 @@ module Lopata
20
20
  condition.keys.all? { |k| metadata[k] == condition[k] }
21
21
  when Array
22
22
  condition.map { |key| metadata[key] }.all?
23
+ when TrueClass, FalseClass
24
+ condition
23
25
  else
24
26
  metadata[condition]
25
27
  end
data/lib/lopata/loader.rb CHANGED
@@ -5,24 +5,28 @@ module Lopata::Loader
5
5
  # Loads scenarios for running in current session
6
6
  #
7
7
  # @param args [Array<String>] files to be load.
8
+ # Mask (e. g. 'scenarios/**/*.rb') is can be passed as well.
8
9
  # All files from default location to be loaded if empty.
9
10
  def load_scenarios(*args)
10
11
  if args.empty?
11
12
  load_all_scenarios
12
13
  else
13
- args.each do |file|
14
- load File.expand_path(file)
15
- end
14
+ args.each(&method(:load_by_mask))
16
15
  end
17
16
  end
18
17
 
19
18
  # Loads all scenarios from predefined paths
20
19
  def load_all_scenarios
21
- Dir["scenarios/**/*.rb"].each { |f| load File.expand_path(f) }
20
+ load_by_mask "scenarios/**/*.rb"
22
21
  end
23
22
 
24
23
  # Loads all shared steps from predefined paths
25
24
  def load_shared_steps
26
- Dir["shared_steps/**/*rb"].each { |f| load File.expand_path(f) }
25
+ load_by_mask "shared_steps/**/*rb"
26
+ end
27
+
28
+ # @private
29
+ def load_by_mask(mask)
30
+ Dir[mask].each { |f| load File.expand_path(f) }
27
31
  end
28
32
  end
data/lib/lopata/role.rb CHANGED
@@ -45,6 +45,24 @@ module Lopata
45
45
  def as(*args, &block)
46
46
  @roles = args.flatten
47
47
  @roles << Lopata::ScenarioBuilder::CalculatedValue.new(&block) if block_given?
48
+ @use_all_roles = true
49
+ @role_options = nil
50
+ end
51
+
52
+ # Enumerate the roles the scenario can be run.
53
+ #
54
+ # The scenario should be set to use the role via before_scenario step using #current_role param.
55
+ #
56
+ # Only first role will be used if scenario has no options or diagonales. Some first roles will be used if
57
+ # options or diagonales are declared, in order of appearence.
58
+ #
59
+ # Use this to describe possible roles, but not needed to run scenario with all of them in order to save time
60
+ # of running.
61
+ #
62
+ # @param args [Array<Symbol>] list of roles the scenario to be runned with.
63
+ def as_first(*args, &block)
64
+ @roles = args.flatten
65
+ @use_all_roles = false
48
66
  @role_options = nil
49
67
  end
50
68
 
@@ -69,7 +87,8 @@ module Lopata
69
87
  # @private
70
88
  def build_role_options
71
89
  return [] unless roles
72
- [Lopata::ScenarioBuilder::Diagonal.new(:as, roles.map { |r| [Lopata.configuration.role_descriptions[r], r] })]
90
+ role_variants = roles.map { |r| [Lopata.configuration.role_descriptions[r], r] }
91
+ [Lopata::ScenarioBuilder::Diagonal.new(:as, role_variants, @use_all_roles)]
73
92
  end
74
93
 
75
94
  # @private
@@ -448,8 +448,8 @@ class Lopata::ScenarioBuilder
448
448
 
449
449
  # @private
450
450
  class Option
451
- attr_reader :variants, :key
452
- def initialize(key, variants)
451
+ attr_reader :variants, :key, :use_all_variants
452
+ def initialize(key, variants, use_all_variants = true)
453
453
  @key = key
454
454
  @variants =
455
455
  if variants.is_a? Hash
@@ -458,6 +458,7 @@ class Lopata::ScenarioBuilder
458
458
  # Array of arrays of two elements
459
459
  variants.map { |v| Variant.new(self, key, *v) }
460
460
  end
461
+ @use_all_variants = use_all_variants
461
462
  end
462
463
 
463
464
  # Variants to apply at one level
@@ -469,6 +470,7 @@ class Lopata::ScenarioBuilder
469
470
  @current ||= 0
470
471
  selected_variant = variants[@current]
471
472
  @current += 1
473
+ @complete = true unless use_all_variants # not need to verify all variants, just use first ones.
472
474
  if @current >= variants.length
473
475
  @current = 0
474
476
  @complete = true # all variants have been selected
@@ -1,6 +1,6 @@
1
1
  module Lopata
2
2
  # @private
3
3
  module Version
4
- STRING = '0.1.8'
4
+ STRING = '0.1.13'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lopata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Volochnev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-25 00:00:00.000000000 Z
11
+ date: 2021-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.11.0
19
+ version: 0.18.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.11.0
26
+ version: 0.18.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -138,5 +138,5 @@ requirements: []
138
138
  rubygems_version: 3.0.3
139
139
  signing_key:
140
140
  specification_version: 4
141
- summary: lopata-0.1.8
141
+ summary: lopata-0.1.13
142
142
  test_files: []