site_prism-all_there 0.2 → 0.2.1

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: 33b0ff10287854efb639165548ea3718efc57094ab5e0e1f11daf8ec7a0f58c6
4
- data.tar.gz: 9257c12cd32806afeca3a0891754d942b3cfeac06dc62b082680bf2bac2ee9dd
3
+ metadata.gz: 98959a1d3f689e5d849760ef9a7960ef696cac8cb8e19c52cfc56da862eabf3d
4
+ data.tar.gz: 331306ed4ffa6f70922d21da78b1cdbe18b25da839d8fce1afb796d9db0c92d9
5
5
  SHA512:
6
- metadata.gz: 5a2603278f614090cd7ecca80d1baf2ae6cf4085eec044fbb68df527d89e1dcec8729e634b89b5fcf70f5eef28bcf529e4f8be60bedd5ef2905c002390f02a14
7
- data.tar.gz: 4357d5ce9856f1e9b0193481d813e3f6aeb9189e1950ed5b212e219144b66b3307ab9a710fb5150e8d3711551b1c57faef52bed3a896395fd2ba46accd320951
6
+ metadata.gz: 9e37113f2844e37e68dc9e4f5e5d3c9324cd4b46f9341a001a70dbfe9ea0cdb538b0700201eabba77265b3ec822ab1774bc3ea2225823cd7170ede0e3c8ea34f
7
+ data.tar.gz: 8e4ae6832dc3cd2d09d65fbb0af6f13089b65c33286f4c2b3f509b7a4764910cfd58330b09d7385971614516711b970cc81035d14eff8e092737ccee99748c90
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SitePrism
4
+ module AllThere
5
+ # Returns the Expected Item Map on a specific SitePrism object
6
+ #
7
+ # api private
8
+ #
9
+ class ExpectedItems
10
+ attr_reader :instance
11
+ private :instance
12
+
13
+ def initialize(instance)
14
+ @instance = instance
15
+ end
16
+
17
+ def array
18
+ [
19
+ mapped_checklist_of(:element),
20
+ mapped_checklist_of(:elements),
21
+ mapped_checklist_of(:section),
22
+ mapped_checklist_of(:sections),
23
+ mapped_checklist_of(:iframe),
24
+ ]
25
+ end
26
+
27
+ private
28
+
29
+ def mapped_checklist_of(type)
30
+ mapped_items.hash[type].select { |name| mapped_checklist.include?(name) }
31
+ end
32
+
33
+ # If the page or section has expected_items set, return expected_items that are mapped
34
+ # otherwise just return the list of all mapped_items
35
+ def mapped_checklist
36
+ if checklist
37
+ SitePrism.logger.debug('Expected Items has been set.')
38
+ mapped_items.array.select { |name| checklist.include?(name) }
39
+ else
40
+ mapped_items.array
41
+ end
42
+ end
43
+
44
+ # List of expected_items as defined during build phase
45
+ def checklist
46
+ instance.class.expected_items
47
+ end
48
+
49
+ def mapped_items
50
+ @mapped_items ||= MappedItems.new(instance)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -54,34 +54,7 @@ module SitePrism
54
54
  end
55
55
 
56
56
  def expected_item_map
57
- [
58
- expected(:element),
59
- expected(:elements),
60
- expected(:section),
61
- expected(:sections),
62
- expected(:iframe),
63
- ]
64
- end
65
-
66
- def expected(type)
67
- MappedItems.new(instance).hash[type].select { |name| elements_to_check.include?(name) }
68
- end
69
-
70
- # If the page or section has expected_items set, return expected_items that are mapped
71
- # otherwise just return the list of all mapped_items
72
- def elements_to_check
73
- if _expected_items
74
- SitePrism.logger.debug('Expected Items has been set.')
75
- MappedItems.new(instance).array.select do |name|
76
- _expected_items.include?(name)
77
- end
78
- else
79
- MappedItems.new(instance).array
80
- end
81
- end
82
-
83
- def _expected_items
84
- instance.class.expected_items
57
+ ExpectedItems.new(instance).array
85
58
  end
86
59
 
87
60
  def there?(name)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SitePrism
4
4
  module AllThere
5
- VERSION = '0.2'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_prism-all_there
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Hill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-11 00:00:00.000000000 Z
11
+ date: 2019-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -92,6 +92,7 @@ files:
92
92
  - LICENSE.md
93
93
  - README.md
94
94
  - lib/site_prism/all_there.rb
95
+ - lib/site_prism/all_there/expected_items.rb
95
96
  - lib/site_prism/all_there/mapped_items.rb
96
97
  - lib/site_prism/all_there/recursion_checker.rb
97
98
  - lib/site_prism/all_there/version.rb