site_prism 3.0.1 → 3.0.2

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: 484d33816dfd3b61f4ebd4c4e0b96418877c84730b3d5edacc214895c17ac565
4
- data.tar.gz: 3c18ff1ba0590d025eea607b46bb44d733f67669d53fd5cc535491cc85e5eae1
3
+ metadata.gz: 99cb79c78e6dba7cac9a03b9bdc0bd5c3b68a25995ec38160e9705274ab04cfd
4
+ data.tar.gz: 6d91b63cd449fe3f16a364008d5178d7175bd6c4bf65297e5dfe5ae1a0673848
5
5
  SHA512:
6
- metadata.gz: 55df767a6fe3d3a2234c94d69c496396bcab8fd095177e780d2c16bc30ad8f08d5339e0e02a9f65be3d46c58b8d16718c56c52b9482db515ef5084dcef17dbd4
7
- data.tar.gz: 1bc2a80d5bb5926d4db0c209a14a6c368266329eb26e5ab8ddb17de7fbfbcb265f80b01edbdb9ded18e8d8a14f2ced7731f5cb1404c4fade0bda3aee9d2959d9
6
+ metadata.gz: 2de60bd237a1d29d1594ba3a8db75e01a09310fe78e48a81d7ea0b1dd7fa53a36d6bdb274c4b592daa0c39a2768c7a371a2939d35177598b146d018dd6ff35f9
7
+ data.tar.gz: bbc12f3639fc7bfe30ab28b3dd65b68f30f4c8c6943e306ae849a3b4e16dda104f96c746f21e3b5fe8162c7a4e05388ba9aebe5fd61c024fc27abc4df0b74a16
data/README.md CHANGED
@@ -17,7 +17,7 @@ We have a brief set of setup docs [HERE](https://github.com/natritmeyer/site_pri
17
17
 
18
18
  ## Supported Rubies / Browsers
19
19
 
20
- SitePrism is built and tested to work on Ruby 2.3 - 2.5. There is also some limited support for the Ruby 2.2 series.
20
+ SitePrism is built and tested to work on Ruby 2.3 - 2.6. There is also some limited support for the Ruby 2.2 series.
21
21
 
22
22
  SitePrism should run on all major browsers. The gem's integration tests are ran on Chrome and Firefox.
23
23
 
data/lib/site_prism.rb CHANGED
@@ -5,8 +5,8 @@ require 'addressable/template'
5
5
 
6
6
  module SitePrism
7
7
  autoload :AddressableUrlMatcher, 'site_prism/addressable_url_matcher'
8
+ autoload :DSL, 'site_prism/dsl'
8
9
  autoload :ElementChecker, 'site_prism/element_checker'
9
- autoload :ElementContainer, 'site_prism/element_container'
10
10
  autoload :Logger, 'site_prism/logger'
11
11
  autoload :Page, 'site_prism/page'
12
12
  autoload :Section, 'site_prism/section'
@@ -1,17 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SitePrism
4
- module ElementContainer
4
+ module DSL
5
5
  def self.included(klass)
6
6
  klass.extend ClassMethods
7
7
  end
8
8
 
9
9
  private
10
10
 
11
+ # The default waiting time set by Capybara's configuration settings.
11
12
  def wait_time
12
13
  Capybara.default_max_wait_time
13
14
  end
14
15
 
16
+ # Prevent users from calling methods with blocks when they shouldn't be.
17
+ #
18
+ # Example (Triggering error):
19
+ #
20
+ # class MyPage
21
+ # element :sample, '.css-locator' do
22
+ # puts "This won't be output"
23
+ # end
24
+ # end
25
+ #
26
+ # At runtime this will generate a `SitePrism::UnsupportedBlockError`
27
+ #
28
+ # The only DSL keywords that can use blocks are :section and :iframe
15
29
  def raise_if_block(obj, name, has_block, type)
16
30
  return unless has_block
17
31
 
@@ -52,6 +66,9 @@ module SitePrism
52
66
  options[:wait] = wait_time unless wait_key_present?(options)
53
67
  end
54
68
 
69
+ # True if the +wait+ key is present in the options hash.
70
+ #
71
+ # Note that setting it to to false or 0, still will return true here.
55
72
  def wait_key_present?(options)
56
73
  options.key?(:wait)
57
74
  end
@@ -2,26 +2,52 @@
2
2
 
3
3
  module SitePrism
4
4
  module ElementChecker
5
- def all_there?
6
- elements_to_check.all? { |item_name| there?(item_name) }
5
+ # Runnable in the scope of any SitePrism::Page or Section.
6
+ # Returns +true+ when "every item" that is being checked is
7
+ # present within the current scope. See #elements_to_check
8
+ # for how the definition of "every item" is derived.
9
+ #
10
+ # Example
11
+ # @my_page.mapped_items
12
+ # { element => :button_one, element => :button_two, section => :filters }
13
+ # @my_page.all_there?
14
+ # => true - If the three items above are all present
15
+ #
16
+ # Note that #elements_to_check will affect the hash of mapped_items
17
+ #
18
+ # When using the recursion parameter, one of three values is valid.
19
+ #
20
+ # Default: 'none' => Perform no recursion when calling #all_there?
21
+ # Override: 'one' => Perform one recursive dive into all section
22
+ # items and call #all_there? on those items too.
23
+ def all_there?(recursion: 'none')
24
+ SitePrism.logger.info('Setting for recursion is being ignored for now.')
25
+
26
+ if %w[none one].include?(recursion)
27
+ elements_to_check.all? { |item_name| there?(item_name) }
28
+ else
29
+ SitePrism.logger.error('Invalid recursion setting, Will not run.')
30
+ end
7
31
  end
8
32
 
9
33
  def elements_present
10
- mapped_items.select { |item_name| there?(item_name) }
34
+ _mapped_items.select { |item_name| there?(item_name) }
11
35
  end
12
36
 
13
37
  private
14
38
 
39
+ # If the page or section has expected_items set, return expected_items
40
+ # that are mapped; otherwise just return the list of all mapped_items
15
41
  def elements_to_check
16
- if expected_items
42
+ if _expected_items
17
43
  SitePrism.logger.debug('Expected Items has been set.')
18
- mapped_items.select { |item_name| expected_items.include?(item_name) }
44
+ _mapped_items.select { |item_name| _expected_items.include?(item_name) }
19
45
  else
20
- mapped_items
46
+ _mapped_items
21
47
  end
22
48
  end
23
49
 
24
- def mapped_items
50
+ def _mapped_items
25
51
  mapped_items_list.map(&:values).flatten
26
52
  end
27
53
 
@@ -29,7 +55,7 @@ module SitePrism
29
55
  self.class.mapped_items.uniq
30
56
  end
31
57
 
32
- def expected_items
58
+ def _expected_items
33
59
  self.class.expected_items
34
60
  end
35
61
 
@@ -7,7 +7,7 @@ module SitePrism
7
7
  include Capybara::DSL
8
8
  include ElementChecker
9
9
  include Loadable
10
- include ElementContainer
10
+ include DSL
11
11
 
12
12
  class << self
13
13
  attr_reader :url
@@ -7,7 +7,7 @@ module SitePrism
7
7
  include Capybara::DSL
8
8
  include ElementChecker
9
9
  include Loadable
10
- include ElementContainer
10
+ include DSL
11
11
  extend Forwardable
12
12
 
13
13
  attr_reader :root_element, :parent
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SitePrism
4
- VERSION = '3.0.1'.freeze
4
+ VERSION = '3.0.2'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_prism
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Ritmeyer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-08 00:00:00.000000000 Z
12
+ date: 2019-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -107,14 +107,14 @@ dependencies:
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.60.0
110
+ version: 0.62.0
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.60.0
117
+ version: 0.62.0
118
118
  - !ruby/object:Gem::Dependency
119
119
  name: selenium-webdriver
120
120
  requirement: !ruby/object:Gem::Requirement
@@ -157,8 +157,8 @@ files:
157
157
  - README.md
158
158
  - lib/site_prism.rb
159
159
  - lib/site_prism/addressable_url_matcher.rb
160
+ - lib/site_prism/dsl.rb
160
161
  - lib/site_prism/element_checker.rb
161
- - lib/site_prism/element_container.rb
162
162
  - lib/site_prism/error.rb
163
163
  - lib/site_prism/loadable.rb
164
164
  - lib/site_prism/logger.rb