lopata 0.1.5 → 0.1.6

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.
@@ -79,6 +79,10 @@ module Lopata
79
79
  steps.reject { |s| s.teardown_group?(self) } + steps.select { |s| s.teardown_group?(self) }
80
80
  end
81
81
 
82
+ def let_methods
83
+ @let_methods ||= {}
84
+ end
85
+
82
86
  private
83
87
 
84
88
  # Group step's block is a block in context of builder, not scenario. So hide the @block to not be used in scenario.
@@ -112,7 +116,6 @@ module Lopata
112
116
 
113
117
  def run(scenario)
114
118
  @status = :running
115
- world.notify_observers(:step_started, self)
116
119
  begin
117
120
  run_step(scenario)
118
121
  if pending?
@@ -125,7 +128,6 @@ module Lopata
125
128
  @status = :failed unless pending?
126
129
  @exception = e
127
130
  end
128
- world.notify_observers(:step_finished, self)
129
131
  end
130
132
 
131
133
  def run_step(scenario)
@@ -133,10 +135,6 @@ module Lopata
133
135
  scenario.instance_exec(&block)
134
136
  end
135
137
 
136
- def world
137
- @world ||= Lopata::Config.world
138
- end
139
-
140
138
  def failed?
141
139
  status == :failed
142
140
  end
@@ -176,7 +174,12 @@ module Lopata
176
174
 
177
175
  # Step metadata is a combination of metadata given for step and all contexts (groups) the step included
178
176
  def metadata
179
- ([step] + groups).compact.inject({}) { |merged, part| merged.merge(part.metadata) }
177
+ (groups + [step]).compact.inject({}) { |merged, part| merged.merge(part.metadata) }
178
+ end
179
+
180
+ # Step methods is a combination of let_methods for all contexts (group) the step included
181
+ def let_methods
182
+ (groups).compact.inject({}) { |merged, part| merged.merge(part.let_methods) }
180
183
  end
181
184
  end
182
185
  end
@@ -1,5 +1,5 @@
1
1
  module Lopata
2
2
  module Version
3
- STRING = '0.1.5'
3
+ STRING = '0.1.6'
4
4
  end
5
5
  end
@@ -22,8 +22,10 @@ class Lopata::World
22
22
  end
23
23
  end
24
24
 
25
+ private
26
+
25
27
  # Define observers based on configuration
26
28
  def observers
27
- @observers ||= [Lopata::Observers::ConsoleOutputObserver.new]
29
+ Lopata.configuration.observers
28
30
  end
29
31
  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.5
4
+ version: 0.1.6
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-05-24 00:00:00.000000000 Z
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -92,15 +92,14 @@ files:
92
92
  - lib/lopata.rb
93
93
  - lib/lopata/active_record.rb
94
94
  - lib/lopata/condition.rb
95
- - lib/lopata/config.rb
95
+ - lib/lopata/configuration.rb
96
+ - lib/lopata/environment.rb
96
97
  - lib/lopata/factory_bot.rb
97
98
  - lib/lopata/generators/app.rb
98
- - lib/lopata/generators/templates/.rspec
99
99
  - lib/lopata/generators/templates/Gemfile
100
100
  - lib/lopata/generators/templates/Lopatafile
101
101
  - lib/lopata/generators/templates/config/environments/qa.yml
102
102
  - lib/lopata/generators/templates/config/initializers/capybara.rb
103
- - lib/lopata/generators/templates/spec/spec_helper.rb
104
103
  - lib/lopata/id.rb
105
104
  - lib/lopata/loader.rb
106
105
  - lib/lopata/observers.rb
@@ -108,8 +107,7 @@ files:
108
107
  - lib/lopata/observers/base_observer.rb
109
108
  - lib/lopata/observers/console_output_observer.rb
110
109
  - lib/lopata/observers/web_logger.rb
111
- - lib/lopata/rspec/dsl.rb
112
- - lib/lopata/rspec/role.rb
110
+ - lib/lopata/role.rb
113
111
  - lib/lopata/runner.rb
114
112
  - lib/lopata/scenario.rb
115
113
  - lib/lopata/scenario_builder.rb
@@ -139,5 +137,5 @@ requirements: []
139
137
  rubygems_version: 3.0.3
140
138
  signing_key:
141
139
  specification_version: 4
142
- summary: lopata-0.1.5
140
+ summary: lopata-0.1.6
143
141
  test_files: []
@@ -1,97 +0,0 @@
1
- module Lopata
2
- module Config
3
- extend self
4
-
5
- attr_accessor :build_number, :lopata_host, :lopata_code, :only_roles, :role_descriptions,
6
- :default_role, :ops
7
-
8
- def init(env)
9
- require 'yaml'
10
- @config = {}
11
- config_filename = "./config/environments/#{env}.yml"
12
- @config = YAML::load(File.open(config_filename)) if File.exists?(config_filename)
13
- init_db
14
- @role_descriptions ||= {}
15
- # init_includes
16
- end
17
-
18
- def [](key)
19
- @config[key]
20
- end
21
-
22
- %w{url name readonly}.each do |opt|
23
- define_method opt do
24
- raise "Lopata::Config unititlalized, use Lopata::Config#init(env) to set environment" unless @config
25
- @config[opt]
26
- end
27
- end
28
-
29
- def init_db
30
- ActiveRecord::Base.establish_connection(@config['db']) if @config['db']
31
- end
32
-
33
- def init_rspec
34
- require 'lopata/rspec/dsl'
35
- require 'lopata/rspec/role'
36
- ::RSpec.configure do |c|
37
- c.include Lopata::RSpec::DSL
38
- c.include Lopata::RSpec::Role
39
- end
40
- init_rspec_filters
41
- end
42
-
43
- def init_lopata_logging(build)
44
- self.build_number = build
45
- require 'lopata/observers/web_logger'
46
- add_observer Lopata::Observers::WebLogger.new
47
- end
48
-
49
- def init_rspec_filters
50
- filters = {}
51
- filters[:focus] = true if ops[:focus]
52
- unless filters.blank?
53
- ::RSpec.configure do |c|
54
- c.inclusion_filter = filters
55
- end
56
- end
57
- end
58
-
59
- def before_start(&block)
60
- @before_start = block
61
- end
62
-
63
- def before_scenario(*steps, &block)
64
- before_scenario_steps.append(*steps) unless steps.empty?
65
- before_scenario_steps.append(block) if block_given?
66
- end
67
-
68
- def before_scenario_steps
69
- @before_scenario_steps ||= []
70
- end
71
-
72
- def after_scenario(*steps, &block)
73
- after_scenario_steps.append(*steps) unless steps.empty?
74
- after_scenario_steps.append(block) if block_given?
75
- end
76
-
77
- def after_scenario_steps
78
- @after_scenario_steps ||= []
79
- end
80
-
81
- def initialize_test
82
- @before_start.call if @before_start
83
- end
84
-
85
- def world
86
- @world ||= Lopata::World.new
87
- end
88
-
89
- def filters
90
- @filters ||= []
91
- end
92
-
93
- def add_observer(observer)
94
- world.observers << observer
95
- end
96
- end
97
- end
@@ -1,3 +0,0 @@
1
- --color
2
- --format documentation
3
- --require spec_helper
@@ -1,2 +0,0 @@
1
- Lopata::Config.role_descriptions = { user: 'User' }
2
- Lopata::Config.default_role = :user
@@ -1,39 +0,0 @@
1
- module Lopata
2
- module RSpec
3
- module DSL
4
- def self.included(base)
5
- base.extend(ClassMethods)
6
- end
7
-
8
- module ClassMethods
9
- def action *contexts, &block
10
- contexts.each do |context|
11
- if context.is_a?(Proc)
12
- action(&context)
13
- else
14
- verify context
15
- end
16
- end
17
- before(:all, &block) if block_given?
18
- end
19
-
20
- def setup *contexts, &block
21
- root_setup = false
22
- unless @doing_setup
23
- root_setup = true
24
- @doing_setup = true
25
- end
26
- action *contexts, &block
27
- if root_setup
28
- # action Config.after_setup if Config.after_setup
29
- @doing_setup = false
30
- end
31
- end
32
-
33
- def teardown &block
34
- after(:all, &block) if block_given?
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,74 +0,0 @@
1
- module Lopata::RSpec::Role
2
- def self.included(base)
3
- base.extend(ClassMethods)
4
- end
5
-
6
- # Filter names
7
- def self.filter_roles *names
8
- allowed = Lopata::Config.only_roles
9
- selected = names.flatten.select { |n| allowed.blank? || allowed.member?(n) }
10
- # ENV['quick'] ? [selected.first] : selected
11
- selected
12
- end
13
-
14
- # http://jorgemanrubia.net/2010/01/16/using-macros-to-create-custom-example-groups-in-rspec/
15
- module ClassMethods
16
- def as *names, &block
17
- return if current_role && !Lopata::RSpec::Role.filter_roles(*names).include?(current_role)
18
- if current_role
19
- self.class_eval(&block)
20
- else
21
- Lopata::RSpec::Role.filter_roles(*names).each do |name|
22
- example_group_class = describe role_description(name), :current_role => name do
23
- define_method :current_role do
24
- name
25
- end
26
- end
27
- example_group_class.class_eval(&block)
28
- end
29
- end
30
- end
31
-
32
- def except(*names, &block)
33
- raise "'expecpt' block must be neseted for 'as' block" unless current_role
34
- return if names.include? current_role
35
- self.class_eval(&block)
36
- end
37
-
38
- def current_role
39
- metadata[:current_role]
40
- end
41
-
42
- # To be redefined in impelemntations so RSpec descriptions to be more verbal
43
- def role_description(name)
44
- Lopata::Config.role_descriptions[name] || name
45
- end
46
-
47
- def scenario(*args, &block)
48
- raise "scenario required a name in first argument" unless args.first.is_a? String
49
- example_group_class = describe(*args)
50
- example_group_class.nested_with_as(*args, &block)
51
- end
52
-
53
- def nested_with_as(*args, &block)
54
- if (args.last.is_a?(Hash) && args.last[:as])
55
- roles = args.last[:as]
56
- roles = [roles] unless roles.is_a?(Array)
57
- class_eval { as(*roles, &block) }
58
- else
59
- class_eval(&block)
60
- end
61
- end
62
- end
63
- end
64
-
65
- module Lopata
66
- # Adds the #scenario method to the top-level namespace.
67
- def self.scenario(*args, &block)
68
- raise "scenario required a name in first argument" unless args.first.is_a? String
69
- example_group_class = RSpec.describe(*args)
70
- example_group_class.nested_with_as(*args, &block)
71
- # example_group_class.register
72
- end
73
- end
74
-