lopata 0.1.13 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,36 +1,36 @@
1
- module Lopata
2
- # Settings of test enviromnet the scenarios to be runned.
3
- #
4
- # Lopata allows to define different environments the scenarios to be runned on.
5
- # Set environment name via command line 'lopata -e stage' or via configuration:
6
- #
7
- # Lopata.configure do |c|
8
- # c.env = :stage
9
- # end
10
- #
11
- # The environment params are loaded from './config/environments/<env>.yml'.
12
- class Environment
13
- # Loads environment configuration for given env
14
- # @param env [Symbol] environment key
15
- # Loads golobl configured environment if not given.
16
- # @see Lopata::Configuration#env
17
- def initialize(env = Lopata.configuration.env)
18
- require 'yaml'
19
- @config = {}
20
- config_filename = "./config/environments/#{Lopata.configuration.env}.yml"
21
- @config = YAML::load(File.open(config_filename)) if File.exists?(config_filename)
22
- end
23
-
24
- # Access to environment settings
25
- # @param key [Symbol] environment configuration key is set on yml configuration.
26
- def [](key)
27
- @config[key]
28
- end
29
-
30
- %w{url}.each do |opt|
31
- define_method opt do
32
- @config[opt]
33
- end
34
- end
35
- end
1
+ module Lopata
2
+ # Settings of test enviromnet the scenarios to be runned.
3
+ #
4
+ # Lopata allows to define different environments the scenarios to be runned on.
5
+ # Set environment name via command line 'lopata -e stage' or via configuration:
6
+ #
7
+ # Lopata.configure do |c|
8
+ # c.env = :stage
9
+ # end
10
+ #
11
+ # The environment params are loaded from './config/environments/<env>.yml'.
12
+ class Environment
13
+ # Loads environment configuration for given env
14
+ # @param env [Symbol] environment key
15
+ # Loads golobl configured environment if not given.
16
+ # @see Lopata::Configuration#env
17
+ def initialize(env = Lopata.configuration.env)
18
+ require 'yaml'
19
+ @config = {}
20
+ config_filename = "./config/environments/#{Lopata.configuration.env}.yml"
21
+ @config = YAML::load(File.open(config_filename)) if File.exists?(config_filename)
22
+ end
23
+
24
+ # Access to environment settings
25
+ # @param key [Symbol] environment configuration key is set on yml configuration.
26
+ def [](key)
27
+ @config[key]
28
+ end
29
+
30
+ %w{url}.each do |opt|
31
+ define_method opt do
32
+ @config[opt]
33
+ end
34
+ end
35
+ end
36
36
  end
@@ -1,72 +1,72 @@
1
- require_relative 'active_record'
2
-
3
- module Lopata
4
- # Helpers for FactoryBot usage in tests.
5
- #
6
- # Make helpers available in scenarios by
7
- #
8
- # require 'lopata/factory_bot'
9
- #
10
- # Automatically adds ActiveRecord helpers.
11
- # @see Lopata::ActiveRecord
12
- #
13
- # Allows to create ActiveRecord object by FactoryBot definitions.
14
- # All the objects created by FactoryBot helpers will be destroyed automatically
15
- # at the end of scenario.
16
- # @see Lopata::ActiveRecord::Methods#cleanup
17
- #
18
- # @example
19
- #
20
- # # Configure db connection at config/environments/qa.yml like rails:
21
- # # db:
22
- # # adapter: postgresql
23
- # # host: your.database.host
24
- # # username: username
25
- # # password: password
26
- # # database: database
27
- # require 'active_record'
28
- # require 'factory_bot'
29
- # require 'lopata/facotory_bot'
30
- #
31
- # class User < ActiveRecord::Base; end
32
- #
33
- # FactoryBot.define do
34
- # factory :user do
35
- # username { 'testuser' }
36
- # end
37
- # end
38
- #
39
- # Lopata.define 'User creation' do
40
- # setup do
41
- # @user = create(:user)
42
- # end
43
- # # No cleanup needed - @user will be destroyed automatically
44
- # # cleanup :user
45
- #
46
- # it 'works' do
47
- # expect(@user).to_not be_nil
48
- # end
49
- # end
50
- #
51
- module FactoryBot
52
- # To be included in Lopata::Scenario
53
- module Methods
54
- # Wrapper for FactoryBot#create
55
- # Calls the FactoryBot#create with given paramters and returns it result.
56
- # Additionally store the created object for destroying at the end of scenario.
57
- # @see Lopata::ActiveRecord::Methods#cleanup
58
- def create(*params)
59
- cleanup_later ::FactoryBot.create(*params)
60
- end
61
- end
62
-
63
- # To be included in Lopata::ScenarioBuilder
64
- module DSL
65
- end
66
- end
67
- end
68
-
69
- Lopata::Scenario.include Lopata::FactoryBot::Methods
70
- Lopata::ScenarioBuilder.include Lopata::FactoryBot::DSL
71
-
72
- ::FactoryBot.find_definitions
1
+ require_relative 'active_record'
2
+
3
+ module Lopata
4
+ # Helpers for FactoryBot usage in tests.
5
+ #
6
+ # Make helpers available in scenarios by
7
+ #
8
+ # require 'lopata/factory_bot'
9
+ #
10
+ # Automatically adds ActiveRecord helpers.
11
+ # @see Lopata::ActiveRecord
12
+ #
13
+ # Allows to create ActiveRecord object by FactoryBot definitions.
14
+ # All the objects created by FactoryBot helpers will be destroyed automatically
15
+ # at the end of scenario.
16
+ # @see Lopata::ActiveRecord::Methods#cleanup
17
+ #
18
+ # @example
19
+ #
20
+ # # Configure db connection at config/environments/qa.yml like rails:
21
+ # # db:
22
+ # # adapter: postgresql
23
+ # # host: your.database.host
24
+ # # username: username
25
+ # # password: password
26
+ # # database: database
27
+ # require 'active_record'
28
+ # require 'factory_bot'
29
+ # require 'lopata/facotory_bot'
30
+ #
31
+ # class User < ActiveRecord::Base; end
32
+ #
33
+ # FactoryBot.define do
34
+ # factory :user do
35
+ # username { 'testuser' }
36
+ # end
37
+ # end
38
+ #
39
+ # Lopata.define 'User creation' do
40
+ # setup do
41
+ # @user = create(:user)
42
+ # end
43
+ # # No cleanup needed - @user will be destroyed automatically
44
+ # # cleanup :user
45
+ #
46
+ # it 'works' do
47
+ # expect(@user).to_not be_nil
48
+ # end
49
+ # end
50
+ #
51
+ module FactoryBot
52
+ # To be included in Lopata::Scenario
53
+ module Methods
54
+ # Wrapper for FactoryBot#create
55
+ # Calls the FactoryBot#create with given paramters and returns it result.
56
+ # Additionally store the created object for destroying at the end of scenario.
57
+ # @see Lopata::ActiveRecord::Methods#cleanup
58
+ def create(*params)
59
+ cleanup_later ::FactoryBot.create(*params)
60
+ end
61
+ end
62
+
63
+ # To be included in Lopata::ScenarioBuilder
64
+ module DSL
65
+ end
66
+ end
67
+ end
68
+
69
+ Lopata::Scenario.include Lopata::FactoryBot::Methods
70
+ Lopata::ScenarioBuilder.include Lopata::FactoryBot::DSL
71
+
72
+ ::FactoryBot.find_definitions
@@ -1,43 +1,43 @@
1
- module Lopata
2
- # @private
3
- module Generators
4
- # @private
5
- class App < Thor::Group
6
- include Thor::Actions
7
- argument :name
8
-
9
- def self.source_root
10
- File.join(File.dirname(__FILE__), 'templates')
11
- end
12
-
13
- def create_root_files
14
- template 'Lopatafile', "#{name}/Lopatafile"
15
- template 'Gemfile', "#{name}/Gemfile"
16
- template 'config/environments/qa.yml', "#{name}/config/environments/qa.yml"
17
- template 'config/initializers/capybara.rb', "#{name}/config/initializers/capybara.rb"
18
- end
19
-
20
- def init_dirs
21
- %w{models services pages}.each do |dir|
22
- empty_directory "#{name}/app/#{dir}"
23
- end
24
-
25
- %w{scenarios shared_steps config/initializers}.each do |dir|
26
- empty_directory "#{name}/#{dir}"
27
- end
28
- end
29
-
30
- def bundle
31
- Dir.chdir name do
32
- _bundle_command = Gem.bin_path('bundler', 'bundle')
33
-
34
- require 'bundler'
35
- Bundler.with_clean_env do
36
- output = `"#{Gem.ruby}" "#{_bundle_command}"`
37
- print output # unless options[:quiet]
38
- end
39
- end
40
- end
41
- end
42
- end
1
+ module Lopata
2
+ # @private
3
+ module Generators
4
+ # @private
5
+ class App < Thor::Group
6
+ include Thor::Actions
7
+ argument :name
8
+
9
+ def self.source_root
10
+ File.join(File.dirname(__FILE__), 'templates')
11
+ end
12
+
13
+ def create_root_files
14
+ template 'Lopatafile', "#{name}/Lopatafile"
15
+ template 'Gemfile', "#{name}/Gemfile"
16
+ template 'config/environments/qa.yml', "#{name}/config/environments/qa.yml"
17
+ template 'config/initializers/capybara.rb', "#{name}/config/initializers/capybara.rb"
18
+ end
19
+
20
+ def init_dirs
21
+ %w{models services pages}.each do |dir|
22
+ empty_directory "#{name}/app/#{dir}"
23
+ end
24
+
25
+ %w{scenarios shared_steps config/initializers}.each do |dir|
26
+ empty_directory "#{name}/#{dir}"
27
+ end
28
+ end
29
+
30
+ def bundle
31
+ Dir.chdir name do
32
+ _bundle_command = Gem.bin_path('bundler', 'bundle')
33
+
34
+ require 'bundler'
35
+ Bundler.with_clean_env do
36
+ output = `"#{Gem.ruby}" "#{_bundle_command}"`
37
+ print output # unless options[:quiet]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
43
  end
@@ -1,7 +1,7 @@
1
- source 'https://rubygems.org'
2
- gem 'selenium-webdriver'
3
- gem 'activerecord', '~> 6.0.2'
4
- gem 'capybara', '~> 3.11.1'
5
- gem 'thor'
6
- <% require "lopata/version" %>
7
- gem 'lopata', '<%= Lopata::Version::STRING %>'
1
+ source 'https://rubygems.org'
2
+ gem 'selenium-webdriver'
3
+ gem 'activerecord', '~> 6.0.2'
4
+ gem 'capybara', '~> 3.11.1'
5
+ gem 'thor'
6
+ <% require "lopata/version" %>
7
+ gem 'lopata', '<%= Lopata::Version::STRING %>'
@@ -1,20 +1,20 @@
1
- # coding: utf-8
2
- Encoding.default_external = Encoding::UTF_8
3
- Encoding.default_internal = Encoding::UTF_8
4
-
5
- require 'rubygems'
6
- require 'bundler/setup'
7
- require 'active_support/all'
8
- require 'capybara'
9
- require 'capybara/dsl'
10
- require 'selenium/webdriver'
11
- require 'fileutils'
12
- require 'active_support'
13
- require 'active_record'
14
- require 'lopata'
15
-
16
- relative_load_paths = %w[app/pages app/services app/models]
17
- ActiveSupport::Dependencies.autoload_paths += relative_load_paths
18
-
19
- Dir["./config/initializers/*.rb"].each { |f| require f }
20
-
1
+ # coding: utf-8
2
+ Encoding.default_external = Encoding::UTF_8
3
+ Encoding.default_internal = Encoding::UTF_8
4
+
5
+ require 'rubygems'
6
+ require 'bundler/setup'
7
+ require 'active_support/all'
8
+ require 'capybara'
9
+ require 'capybara/dsl'
10
+ require 'selenium/webdriver'
11
+ require 'fileutils'
12
+ require 'active_support'
13
+ require 'active_record'
14
+ require 'lopata'
15
+
16
+ relative_load_paths = %w[app/pages app/services app/models]
17
+ ActiveSupport::Dependencies.autoload_paths += relative_load_paths
18
+
19
+ Dir["./config/initializers/*.rb"].each { |f| require f }
20
+
@@ -1,7 +1,7 @@
1
- url: http://yourapp.com
2
- # db:
3
- # adapter: postgresql
4
- # host: localhost
5
- # username: username
6
- # password: password
7
- # database: database
1
+ url: http://yourapp.com
2
+ # db:
3
+ # adapter: postgresql
4
+ # host: localhost
5
+ # username: username
6
+ # password: password
7
+ # database: database
@@ -1 +1 @@
1
- Capybara.default_driver = :selenium if defined? Capybara
1
+ Capybara.default_driver = :selenium if defined? Capybara
data/lib/lopata/id.rb CHANGED
@@ -1,22 +1,22 @@
1
- module Lopata
2
- # @private
3
- module Id
4
- extend self
5
-
6
- def next(prefix = nil)
7
- id = "%d_%d" % [timestamp, seq_num]
8
- id = "%s_%s" % [prefix, id] if prefix
9
- id
10
- end
11
-
12
- def timestamp
13
- @timestamp ||= Time.now.strftime("%Y%m%d%H%M%S")
14
- end
15
-
16
- def seq_num
17
- @seq_num ||= 0
18
- @seq_num += 1
19
- @seq_num
20
- end
21
- end
22
- end
1
+ module Lopata
2
+ # @private
3
+ module Id
4
+ extend self
5
+
6
+ def next(prefix = nil)
7
+ id = "%d_%d" % [timestamp, seq_num]
8
+ id = "%s_%s" % [prefix, id] if prefix
9
+ id
10
+ end
11
+
12
+ def timestamp
13
+ @timestamp ||= Time.now.strftime("%Y%m%d%H%M%S")
14
+ end
15
+
16
+ def seq_num
17
+ @seq_num ||= 0
18
+ @seq_num += 1
19
+ @seq_num
20
+ end
21
+ end
22
+ end
data/lib/lopata/loader.rb CHANGED
@@ -1,32 +1,32 @@
1
- # @private
2
- module Lopata::Loader
3
- extend self
4
-
5
- # Loads scenarios for running in current session
6
- #
7
- # @param args [Array<String>] files to be load.
8
- # Mask (e. g. 'scenarios/**/*.rb') is can be passed as well.
9
- # All files from default location to be loaded if empty.
10
- def load_scenarios(*args)
11
- if args.empty?
12
- load_all_scenarios
13
- else
14
- args.each(&method(:load_by_mask))
15
- end
16
- end
17
-
18
- # Loads all scenarios from predefined paths
19
- def load_all_scenarios
20
- load_by_mask "scenarios/**/*.rb"
21
- end
22
-
23
- # Loads all shared steps from predefined paths
24
- def load_shared_steps
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) }
31
- end
1
+ # @private
2
+ module Lopata::Loader
3
+ extend self
4
+
5
+ # Loads scenarios for running in current session
6
+ #
7
+ # @param args [Array<String>] files to be load.
8
+ # Mask (e. g. 'scenarios/**/*.rb') is can be passed as well.
9
+ # All files from default location to be loaded if empty.
10
+ def load_scenarios(*args)
11
+ if args.empty?
12
+ load_all_scenarios
13
+ else
14
+ args.each(&method(:load_by_mask))
15
+ end
16
+ end
17
+
18
+ # Loads all scenarios from predefined paths
19
+ def load_all_scenarios
20
+ load_by_mask "scenarios/**/*.rb"
21
+ end
22
+
23
+ # Loads all shared steps from predefined paths
24
+ def load_shared_steps
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) }
31
+ end
32
32
  end