howitzer 2.1.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +44 -1
- data/LICENSE +1 -1
- data/README.md +19 -17
- data/generators/base_generator.rb +5 -7
- data/generators/config/config_generator.rb +3 -4
- data/generators/config/templates/boot.rb +2 -2
- data/generators/config/templates/capybara.rb +4 -5
- data/generators/config/templates/default.yml +21 -11
- data/generators/config/templates/drivers/browserstack.rb +31 -4
- data/generators/config/templates/drivers/crossbrowsertesting.rb +9 -11
- data/generators/config/templates/drivers/headless_chrome.rb +1 -1
- data/generators/config/templates/drivers/headless_firefox.rb +23 -0
- data/generators/config/templates/drivers/lambdatest.rb +30 -0
- data/generators/config/templates/drivers/sauce.rb +30 -2
- data/generators/config/templates/drivers/selenium.rb +1 -1
- data/generators/config/templates/drivers/selenium_grid.rb +3 -3
- data/generators/config/templates/drivers/testingbot.rb +29 -2
- data/generators/cucumber/templates/cuke_sniffer.rake +2 -2
- data/generators/cucumber/templates/env.rb +8 -0
- data/generators/cucumber/templates/hooks.rb +9 -3
- data/generators/cucumber/templates/transformers.rb +1 -1
- data/generators/prerequisites/templates/factory_bot.rb +2 -1
- data/generators/root/root_generator.rb +1 -1
- data/generators/root/templates/Gemfile.erb +4 -10
- data/generators/rspec/templates/spec_helper.rb +6 -5
- data/generators/turnip/templates/spec_helper.rb +6 -5
- data/generators/web/templates/example_page.rb +1 -1
- data/lib/howitzer/cache.rb +20 -19
- data/lib/howitzer/capybara_helpers.rb +59 -14
- data/lib/howitzer/email.rb +3 -2
- data/lib/howitzer/exceptions.rb +21 -21
- data/lib/howitzer/gmail_api/client.rb +13 -4
- data/lib/howitzer/log.rb +6 -6
- data/lib/howitzer/mail_adapters/gmail.rb +3 -0
- data/lib/howitzer/mail_adapters/mailgun.rb +3 -1
- data/lib/howitzer/mail_adapters/mailtrap.rb +3 -0
- data/lib/howitzer/mailgun_api/client.rb +3 -2
- data/lib/howitzer/mailgun_api/connector.rb +1 -0
- data/lib/howitzer/mailgun_api/response.rb +1 -2
- data/lib/howitzer/mailtrap_api/client.rb +1 -1
- data/lib/howitzer/meta/actions.rb +35 -0
- data/lib/howitzer/meta/element.rb +40 -0
- data/lib/howitzer/meta/entry.rb +62 -0
- data/lib/howitzer/meta/iframe.rb +41 -0
- data/lib/howitzer/meta/section.rb +30 -0
- data/lib/howitzer/meta.rb +11 -0
- data/lib/howitzer/utils/string_extensions.rb +6 -2
- data/lib/howitzer/version.rb +1 -1
- data/lib/howitzer/web/base_section.rb +1 -1
- data/lib/howitzer/web/capybara_context_holder.rb +1 -0
- data/lib/howitzer/web/capybara_methods_proxy.rb +15 -6
- data/lib/howitzer/web/element_dsl.rb +104 -44
- data/lib/howitzer/web/iframe_dsl.rb +4 -2
- data/lib/howitzer/web/page.rb +14 -14
- data/lib/howitzer/web/page_dsl.rb +18 -6
- data/lib/howitzer/web/page_validator.rb +27 -26
- data/lib/howitzer/web/section.rb +13 -2
- data/lib/howitzer/web/section_dsl.rb +65 -30
- data/lib/howitzer.rb +40 -0
- metadata +31 -157
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.rubocop.yml +0 -51
- data/.ruby-gemset +0 -1
- data/.travis.yml +0 -7
- data/Gemfile +0 -14
- data/ISSUE_TEMPLATE.md +0 -16
- data/MAINTENANCE.md +0 -32
- data/Rakefile +0 -38
- data/features/cli_help.feature +0 -31
- data/features/cli_new.feature +0 -389
- data/features/cli_unknown.feature +0 -17
- data/features/cli_update.feature +0 -218
- data/features/cli_version.feature +0 -14
- data/features/step_definitions/common_steps.rb +0 -34
- data/features/support/env.rb +0 -1
- data/generators/config/templates/drivers/phantomjs.rb +0 -19
- data/generators/config/templates/drivers/poltergeist.rb +0 -11
- data/generators/config/templates/drivers/webkit.rb +0 -6
- data/generators/root/templates/.gitignore +0 -21
- data/generators/root/templates/.rubocop.yml +0 -35
- data/generators/turnip/templates/.rspec +0 -1
- data/howitzer.gemspec +0 -39
- data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
- data/spec/config/custom.yml +0 -9
- data/spec/spec_helper.rb +0 -73
- data/spec/support/generator_helper.rb +0 -21
- data/spec/support/logger_helper.rb +0 -13
- data/spec/support/shared_examples/capybara_context_holder.rb +0 -33
- data/spec/support/shared_examples/capybara_methods_proxy.rb +0 -94
- data/spec/support/shared_examples/dynamic_section_methods.rb +0 -35
- data/spec/support/shared_examples/element_dsl.rb +0 -242
- data/spec/unit/generators/base_generator_spec.rb +0 -283
- data/spec/unit/generators/config_generator_spec.rb +0 -59
- data/spec/unit/generators/cucumber_generator_spec.rb +0 -62
- data/spec/unit/generators/emails_generator_spec.rb +0 -35
- data/spec/unit/generators/prerequisites_generator_spec.rb +0 -53
- data/spec/unit/generators/root_generator_spec.rb +0 -75
- data/spec/unit/generators/rspec_generator_spec.rb +0 -36
- data/spec/unit/generators/tasks_generator_spec.rb +0 -31
- data/spec/unit/generators/turnip_generator_spec.rb +0 -52
- data/spec/unit/generators/web_generator_spec.rb +0 -52
- data/spec/unit/lib/cache_spec.rb +0 -85
- data/spec/unit/lib/capybara_helpers_spec.rb +0 -697
- data/spec/unit/lib/email_spec.rb +0 -186
- data/spec/unit/lib/gmail_api/client_spec.rb +0 -26
- data/spec/unit/lib/howitzer_spec.rb +0 -69
- data/spec/unit/lib/init_spec.rb +0 -2
- data/spec/unit/lib/log_spec.rb +0 -122
- data/spec/unit/lib/mail_adapters/abstract_spec.rb +0 -62
- data/spec/unit/lib/mail_adapters/gmail_spec.rb +0 -128
- data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -158
- data/spec/unit/lib/mail_adapters/mailtrap_spec.rb +0 -130
- data/spec/unit/lib/mailgun_api/client_spec.rb +0 -80
- data/spec/unit/lib/mailgun_api/connector_spec.rb +0 -54
- data/spec/unit/lib/mailgun_api/response_spec.rb +0 -28
- data/spec/unit/lib/mailtrap_api/client_spec.rb +0 -67
- data/spec/unit/lib/utils/string_extensions_spec.rb +0 -77
- data/spec/unit/lib/web/base_section_spec.rb +0 -43
- data/spec/unit/lib/web/element_dsl_spec.rb +0 -22
- data/spec/unit/lib/web/iframe_dsl_spec.rb +0 -203
- data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
- data/spec/unit/lib/web/page_spec.rb +0 -378
- data/spec/unit/lib/web/page_validator_spec.rb +0 -276
- data/spec/unit/lib/web/section_dsl_spec.rb +0 -165
- data/spec/unit/lib/web/section_spec.rb +0 -63
- data/spec/unit/version_spec.rb +0 -8
@@ -29,10 +29,15 @@ module Howitzer
|
|
29
29
|
# * `out` method extracts an instance variable from an original context if starts from @.
|
30
30
|
# Otherwise it executes a method from an original context
|
31
31
|
|
32
|
-
def method_missing(name, *args, &block)
|
32
|
+
def method_missing(name, *args, **options, &block)
|
33
33
|
return super if name =~ /\A(?:be|have)_/
|
34
|
-
return eval_in_out_context(*args, &block) if name == :out
|
35
|
-
|
34
|
+
return eval_in_out_context(*args, **options, &block) if name == :out
|
35
|
+
|
36
|
+
if options.present?
|
37
|
+
page_klass.given.send(name, *args, **options, &block)
|
38
|
+
else
|
39
|
+
page_klass.given.send(name, *args, &block)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
|
38
43
|
# Makes proxied methods to be evaludated and returned as a proc
|
@@ -44,11 +49,17 @@ module Howitzer
|
|
44
49
|
|
45
50
|
private
|
46
51
|
|
47
|
-
def eval_in_out_context(*args, &block)
|
52
|
+
def eval_in_out_context(*args, **options, &block)
|
48
53
|
return nil if args.size.zero?
|
54
|
+
|
49
55
|
name = args.shift
|
50
56
|
return get_outer_instance_variable(name) if name.to_s.start_with?('@')
|
51
|
-
|
57
|
+
|
58
|
+
if options.present?
|
59
|
+
outer_context.send(name, *args, **options, &block)
|
60
|
+
else
|
61
|
+
outer_context.send(name, *args, &block)
|
62
|
+
end
|
52
63
|
end
|
53
64
|
|
54
65
|
def get_outer_instance_variable(name)
|
@@ -58,9 +69,10 @@ module Howitzer
|
|
58
69
|
attr_accessor :page_klass, :outer_context
|
59
70
|
end
|
60
71
|
|
61
|
-
def self.included(base)
|
72
|
+
def self.included(base) # :nodoc:
|
62
73
|
base.extend(ClassMethods)
|
63
74
|
end
|
75
|
+
|
64
76
|
# This module holds page dsl class methods
|
65
77
|
module ClassMethods
|
66
78
|
# Allows to execute page methods in context of the page.
|
@@ -6,7 +6,7 @@ module Howitzer
|
|
6
6
|
module PageValidator
|
7
7
|
@validations = {}
|
8
8
|
|
9
|
-
def self.included(base)
|
9
|
+
def self.included(base) # :nodoc:
|
10
10
|
base.extend(ClassMethods)
|
11
11
|
end
|
12
12
|
|
@@ -21,17 +21,19 @@ module Howitzer
|
|
21
21
|
|
22
22
|
def check_validations_are_defined!
|
23
23
|
return if self.class.validations.present?
|
24
|
+
|
24
25
|
raise Howitzer::NoValidationError, "No any page validation was found for '#{self.class.name}' page"
|
25
26
|
end
|
26
27
|
|
27
28
|
# This module holds page validation class methods
|
28
29
|
module ClassMethods
|
29
30
|
# Adds validation to validation list for current page
|
30
|
-
# @param
|
31
|
-
# @param
|
31
|
+
# @param type [Symbol, String] a validation type. Possible values [:url, :element_presence, :title]
|
32
|
+
# @param pattern_or_element_name [Symbol, String, Regexp]
|
32
33
|
# For :url and :title validation types must be <b>Regexp</b>
|
33
|
-
# For :element_presence must be one of element names described for page
|
34
|
-
# @param
|
34
|
+
# For :element_presence must be one of element names described for the page
|
35
|
+
# @param args [Array] any arguments required to pass for a lambda selector (:element_presence type only)
|
36
|
+
# @param options [Hash] keyword arguments required to pass for a lambda selector (:element_presence type only)
|
35
37
|
# @raise [Howitzer::UnknownValidationError] if unknown validation type
|
36
38
|
# @raise [Howitzer::UndefinedElementError] if :element_presence validations refers to undefined element name
|
37
39
|
# @example
|
@@ -44,12 +46,23 @@ module Howitzer
|
|
44
46
|
# end
|
45
47
|
# @example
|
46
48
|
# class HomePage < Howitzer::Web::Page
|
47
|
-
# validate :element_presence, :menu_item, 'Logout'
|
48
|
-
# element :menu_item, :xpath, ->(
|
49
|
+
# validate :element_presence, :menu_item, lambda_args(text: 'Logout')
|
50
|
+
# element :menu_item, :xpath, ->(text:) { ".//a[.='#{text}']" }
|
49
51
|
# end
|
50
52
|
|
51
|
-
def validate(
|
52
|
-
|
53
|
+
def validate(type, pattern_or_element_name, *args, **options)
|
54
|
+
case type.to_s.to_sym
|
55
|
+
when :url, :title
|
56
|
+
if args.present? || options.present?
|
57
|
+
raise ArgumentError, "Additional arguments and options are not supported by '#{type}' the validator"
|
58
|
+
end
|
59
|
+
|
60
|
+
send("validate_by_#{type}", pattern_or_element_name)
|
61
|
+
when :element_presence
|
62
|
+
validate_by_element_presence(pattern_or_element_name, *args, **options)
|
63
|
+
else
|
64
|
+
raise Howitzer::UnknownValidationError, "unknown '#{type}' validation type"
|
65
|
+
end
|
53
66
|
end
|
54
67
|
|
55
68
|
# Check whether current page is opened or no
|
@@ -60,6 +73,7 @@ module Howitzer
|
|
60
73
|
|
61
74
|
def opened?(sync: true)
|
62
75
|
return validations.all? { |(_, validation)| validation.call(self, sync) } if validations.present?
|
76
|
+
|
63
77
|
raise Howitzer::NoValidationError, "No any page validation was found for '#{name}' page"
|
64
78
|
end
|
65
79
|
|
@@ -78,17 +92,17 @@ module Howitzer
|
|
78
92
|
|
79
93
|
private
|
80
94
|
|
81
|
-
def
|
95
|
+
def validate_by_element_presence(element_name, *args, **options)
|
82
96
|
validations[:element_presence] =
|
83
97
|
lambda do |web_page, sync|
|
84
98
|
if element_name.present? && !private_method_defined?("#{element_name}_element")
|
85
99
|
raise(Howitzer::UndefinedElementError, ':element_presence validation refers to ' \
|
86
|
-
|
100
|
+
"undefined '#{element_name}' element on '#{name}' page.")
|
87
101
|
end
|
88
102
|
if sync
|
89
|
-
web_page.instance.public_send(
|
103
|
+
web_page.instance.public_send("has_#{element_name}_element?", *args, **options)
|
90
104
|
else
|
91
|
-
!web_page.instance.public_send(
|
105
|
+
!web_page.instance.public_send("has_no_#{element_name}_element?", *args, **options)
|
92
106
|
end
|
93
107
|
end
|
94
108
|
end
|
@@ -102,19 +116,6 @@ module Howitzer
|
|
102
116
|
validations[:title] =
|
103
117
|
->(web_page, sync) { sync ? web_page.instance.has_title?(pattern) : pattern === web_page.instance.title }
|
104
118
|
end
|
105
|
-
|
106
|
-
def validate_by_type(type, value, additional_value)
|
107
|
-
case type.to_s.to_sym
|
108
|
-
when :url
|
109
|
-
validate_by_url(value)
|
110
|
-
when :element_presence
|
111
|
-
validate_element(value, additional_value)
|
112
|
-
when :title
|
113
|
-
validate_by_title(value)
|
114
|
-
else
|
115
|
-
raise Howitzer::UnknownValidationError, "unknown '#{type}' validation type"
|
116
|
-
end
|
117
|
-
end
|
118
119
|
end
|
119
120
|
end
|
120
121
|
end
|
data/lib/howitzer/web/section.rb
CHANGED
@@ -1,25 +1,36 @@
|
|
1
1
|
require 'howitzer/web/base_section'
|
2
|
+
require 'howitzer/meta'
|
2
3
|
|
3
4
|
module Howitzer
|
4
5
|
module Web
|
5
6
|
# This class uses for named sections which possible to reuse in different pages
|
6
7
|
class Section < BaseSection
|
8
|
+
# Provides access to meta information about entities in section
|
9
|
+
# @return [Meta::Entry]
|
10
|
+
def meta
|
11
|
+
@meta ||= Meta::Entry.new(self)
|
12
|
+
end
|
13
|
+
|
7
14
|
class << self
|
8
15
|
protected
|
9
16
|
|
10
17
|
# DSL method which specifies section container selector represented by HTML element.
|
11
18
|
# Any elements described in sections will start in this HTML element.
|
12
19
|
# @param args [Array] original Capybara arguments. For details, see `Capybara::Node::Finders#all.
|
20
|
+
# @param options [Array] original Capybara options. For details, see `Capybara::Node::Finders#all.
|
13
21
|
# @raise [ArgumentError] if no arguments were passed
|
14
22
|
# @example
|
15
23
|
# class MenuSection < Howitzer::Web::Section
|
16
|
-
# me :xpath, ".//*[@id='panel']"
|
24
|
+
# me :xpath, ".//*[@id='panel']",
|
17
25
|
# end
|
18
26
|
# @!visibility public
|
19
27
|
|
20
|
-
def me(*args)
|
28
|
+
def me(*args, **options)
|
21
29
|
raise ArgumentError, 'Finder arguments are missing' if args.blank?
|
30
|
+
|
22
31
|
@default_finder_args = args
|
32
|
+
@default_finder_options = options
|
33
|
+
self
|
23
34
|
end
|
24
35
|
end
|
25
36
|
end
|
@@ -5,7 +5,7 @@ module Howitzer
|
|
5
5
|
module SectionDsl
|
6
6
|
include CapybaraContextHolder
|
7
7
|
|
8
|
-
def self.included(base)
|
8
|
+
def self.included(base) # :nodoc:
|
9
9
|
base.extend(ClassMethods)
|
10
10
|
end
|
11
11
|
|
@@ -17,8 +17,9 @@ module Howitzer
|
|
17
17
|
|
18
18
|
# Instantiates an anynomous or named section and executes block code in the section scope
|
19
19
|
|
20
|
-
def initialize(name, *args, &block)
|
20
|
+
def initialize(name, *args, **options, &block)
|
21
21
|
@args = args
|
22
|
+
@options = options
|
22
23
|
self.section_class =
|
23
24
|
if block
|
24
25
|
Class.new(Howitzer::Web::BaseSection)
|
@@ -29,29 +30,40 @@ module Howitzer
|
|
29
30
|
end
|
30
31
|
|
31
32
|
# # Defines an element on the section
|
32
|
-
# # @see Howitzer::
|
33
|
+
# # @see Howitzer::Web::ElementDsl::ClassMethods#element
|
33
34
|
|
34
|
-
def element(*args)
|
35
|
-
section_class.send(:element, *args)
|
35
|
+
def element(*args, **options)
|
36
|
+
section_class.send(:element, *args, **options)
|
36
37
|
end
|
37
38
|
|
38
39
|
# Delegates a section describing to the section class
|
39
40
|
|
40
|
-
def section(name, *args, &block)
|
41
|
-
section_class.send(:section, name, *args, &block)
|
41
|
+
def section(name, *args, **options, &block)
|
42
|
+
section_class.send(:section, name, *args, **options, &block)
|
42
43
|
end
|
43
44
|
|
44
|
-
# Returns
|
45
|
+
# Returns selector arguments for the section.
|
45
46
|
# @note If anonymous section uses, then inline selector should be specified.
|
46
47
|
# Otherwise arguments should be defined with `.me` dsl method in named section
|
47
48
|
# @return [Array]
|
48
49
|
# @raise [ArgumentError] when finder arguments were not specified
|
49
50
|
|
50
51
|
def finder_args
|
51
|
-
@
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
return @args if @args.present?
|
53
|
+
|
54
|
+
@finder_args ||= (section_class.default_finder_args || raise(ArgumentError, 'Missing finder arguments'))
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns selector options for the section.
|
58
|
+
# @note If anonymous section uses, then inline selector should be specified.
|
59
|
+
# Otherwise arguments should be defined with `.me` dsl method in named section
|
60
|
+
# @return [Array]
|
61
|
+
# @raise [ArgumentError] when finder arguments were not specified
|
62
|
+
|
63
|
+
def finder_options
|
64
|
+
@options if @args.present? # it is ok to have blank options, so we rely here on the argments
|
65
|
+
|
66
|
+
@finder_options ||= (section_class.default_finder_options || {})
|
55
67
|
end
|
56
68
|
end
|
57
69
|
|
@@ -74,6 +86,9 @@ module Howitzer
|
|
74
86
|
# @param args [Array] original Capybara arguments. For details, see `Capybara::Node::Finders#all.
|
75
87
|
# (In most cases should be ommited for named sections because the section selector is specified
|
76
88
|
# with `#me` method. But must be specified for anonymous sections)
|
89
|
+
# @param options [Hash] original Capybara options. For details, see `Capybara::Node::Finders#all.
|
90
|
+
# (In most cases should be ommited for named sections because the section selector is specified
|
91
|
+
# with `#me` method. But may be specified for anonymous sections)
|
77
92
|
# @param block [Proc] this block can contain nested sections and elements
|
78
93
|
# @example Named section
|
79
94
|
# class MenuSection < Howitzer::Web::Section
|
@@ -109,37 +124,57 @@ module Howitzer
|
|
109
124
|
# HomePage.on { info_panel_section.edit_info(title: 'Test Title') }
|
110
125
|
# @!visibility public
|
111
126
|
|
112
|
-
def section(name, *args, &block)
|
113
|
-
scope = SectionScope.new(name, *args, &block)
|
114
|
-
define_section_method(scope.section_class, name, scope.finder_args)
|
115
|
-
define_sections_method(scope.section_class, name, scope.finder_args)
|
116
|
-
define_has_section_method(name, scope.finder_args)
|
117
|
-
define_has_no_section_method(name, scope.finder_args)
|
127
|
+
def section(name, *args, **options, &block)
|
128
|
+
scope = SectionScope.new(name, *args, **options, &block)
|
129
|
+
define_section_method(scope.section_class, name, *scope.finder_args, **scope.finder_options)
|
130
|
+
define_sections_method(scope.section_class, name, *scope.finder_args, **scope.finder_options)
|
131
|
+
define_has_section_method(name, *scope.finder_args, **scope.finder_options)
|
132
|
+
define_has_no_section_method(name, *scope.finder_args, **scope.finder_options)
|
118
133
|
end
|
119
134
|
|
120
135
|
private
|
121
136
|
|
122
|
-
def define_section_method(klass, name, args)
|
123
|
-
define_method("#{name}_section") do
|
124
|
-
|
137
|
+
def define_section_method(klass, name, *args, **options)
|
138
|
+
define_method("#{name}_section") do |**block_options|
|
139
|
+
kwdargs = options.transform_keys(&:to_sym).merge(block_options.transform_keys(&:to_sym))
|
140
|
+
if kwdargs.present?
|
141
|
+
klass.new(self, capybara_context.find(*args, **kwdargs))
|
142
|
+
else
|
143
|
+
klass.new(self, capybara_context.find(*args))
|
144
|
+
end
|
125
145
|
end
|
126
146
|
end
|
127
147
|
|
128
|
-
def define_sections_method(klass, name, args)
|
129
|
-
define_method("#{name}_sections") do
|
130
|
-
|
148
|
+
def define_sections_method(klass, name, *args, **options)
|
149
|
+
define_method("#{name}_sections") do |**block_options|
|
150
|
+
kwdargs = options.transform_keys(&:to_sym).merge(block_options.transform_keys(&:to_sym))
|
151
|
+
if kwdargs.present?
|
152
|
+
capybara_context.all(*args, **kwdargs).map { |el| klass.new(self, el) }
|
153
|
+
else
|
154
|
+
capybara_context.all(*args).map { |el| klass.new(self, el) }
|
155
|
+
end
|
131
156
|
end
|
132
157
|
end
|
133
158
|
|
134
|
-
def define_has_section_method(name, args)
|
135
|
-
define_method("has_#{name}_section?") do
|
136
|
-
|
159
|
+
def define_has_section_method(name, *args, **options)
|
160
|
+
define_method("has_#{name}_section?") do |**block_options|
|
161
|
+
kwdargs = options.transform_keys(&:to_sym).merge(block_options.transform_keys(&:to_sym))
|
162
|
+
if kwdargs.present?
|
163
|
+
capybara_context.has_selector?(*args, **kwdargs)
|
164
|
+
else
|
165
|
+
capybara_context.has_selector?(*args)
|
166
|
+
end
|
137
167
|
end
|
138
168
|
end
|
139
169
|
|
140
|
-
def define_has_no_section_method(name, args)
|
141
|
-
define_method("has_no_#{name}_section?") do
|
142
|
-
|
170
|
+
def define_has_no_section_method(name, *args, **options)
|
171
|
+
define_method("has_no_#{name}_section?") do |**block_options|
|
172
|
+
kwdargs = options.transform_keys(&:to_sym).merge(block_options.transform_keys(&:to_sym))
|
173
|
+
if kwdargs.present?
|
174
|
+
capybara_context.has_no_selector?(*args, **kwdarg)
|
175
|
+
else
|
176
|
+
capybara_context.has_no_selector?(*args)
|
177
|
+
end
|
143
178
|
end
|
144
179
|
end
|
145
180
|
end
|
data/lib/howitzer.rb
CHANGED
@@ -29,6 +29,45 @@ module Howitzer
|
|
29
29
|
::SexySettings::Base.instance.all['mailgun_idle_timeout']
|
30
30
|
end
|
31
31
|
|
32
|
+
# @return active session name
|
33
|
+
|
34
|
+
def session_name
|
35
|
+
@session_name ||= 'default'
|
36
|
+
end
|
37
|
+
|
38
|
+
# Sets new session name
|
39
|
+
#
|
40
|
+
# @param name [String] string identifier for the session
|
41
|
+
#
|
42
|
+
# @example Executing code in another browser
|
43
|
+
# Howitzer.session_name = 'browser2'
|
44
|
+
# LoginPage.on do
|
45
|
+
# expect(title).to eq('Login Page')
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# # Switching back to main browser
|
49
|
+
# Howitzer.session_name = 'default'
|
50
|
+
|
51
|
+
def session_name=(name)
|
52
|
+
@session_name = name
|
53
|
+
Capybara.session_name = @session_name
|
54
|
+
end
|
55
|
+
|
56
|
+
# Yield a block using a specific session name
|
57
|
+
#
|
58
|
+
# @param name [String] string identifier for the session
|
59
|
+
#
|
60
|
+
# @example Opening page in another browser
|
61
|
+
# Howitzer.using_session('browser2') do
|
62
|
+
# LoginPage.on do
|
63
|
+
# expect(title).to eq('Login Page')
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
|
67
|
+
def using_session(name, &block)
|
68
|
+
Capybara.using_session(name, &block)
|
69
|
+
end
|
70
|
+
|
32
71
|
attr_accessor :current_rake_task
|
33
72
|
end
|
34
73
|
|
@@ -60,6 +99,7 @@ module Howitzer
|
|
60
99
|
|
61
100
|
def self.sexy_setting!(name)
|
62
101
|
return Howitzer.public_send(name) if Howitzer.respond_to?(name)
|
102
|
+
|
63
103
|
raise UndefinedSexySettingError,
|
64
104
|
"Undefined '#{name}' setting. Please add the setting to config/default.yml:\n #{name}: some_value\n"
|
65
105
|
end
|