@@ -80,33 +80,42 @@ def assert_has_contents_list(contents)
80
80
end
81
81
end
82
82
83
- def assert_has_published_dates ( published = nil , last_updated = nil , history_link = false , element_index = 0 )
83
+ def assert_has_published_dates ( first_published = nil , last_updated = nil , history_link = false )
84
84
text = [ ]
85
- text << published if published
85
+ text << first_published if first_published
86
86
text << last_updated if last_updated
87
- within ( all ( ".app-c-published-dates" ) [ element_index ] ) do
87
+ within ".app-c-published-dates:last-of-type" do
88
88
assert page . has_text? ( text . join ( "\n " ) ) , "Published dates #{ text . join ( "\n " ) } not found"
89
89
if history_link
90
90
assert page . has_link? ( "see all updates" , href : "#history" ) , "Updates link not found"
91
91
end
92
92
end
93
93
end
94
94
95
- def assert_has_publisher_metadata_other ( metadata )
96
- within ( ".gem-c-metadata" ) do
97
- assert_has_metadata (
98
- metadata , ".gem-c-metadata__term" , ".gem-c-metadata__definition"
99
- )
95
+ def assert_has_publisher_metadata_other ( any_args )
96
+ assert_has_metadata ( any_args )
97
+ end
98
+
99
+ def assert_has_metadata ( any_args )
100
+ within ".gem-c-metadata" do
101
+ any_args . each do |_key , value |
102
+ value = { value => nil } if value . is_a? ( String )
103
+ value . each do |text , href |
104
+ if href
105
+ assert page . has_link? ( text , href : href ) , "Metadata text '#{ text } with link of #{ href } ' not found"
106
+ else
107
+ assert page . has_text? ( text ) , "Metadata value '#{ text } ' not found"
108
+ end
109
+ end
110
+ end
100
111
end
101
112
end
102
113
103
- def assert_has_metadata ( metadata , term_selector , definition_selector )
114
+ def assert_has_metadata_local ( metadata , term_selector , definition_selector )
104
115
metadata . each do |key , value |
105
116
assert page . has_css? ( term_selector , text : key ) ,
106
117
"Metadata term '#{ key } ' not found"
107
-
108
118
value = { value => nil } if value . is_a? ( String )
109
-
110
119
value . each do |text , href |
111
120
within ( definition_selector , text : text ) do
112
121
if href
@@ -120,22 +129,22 @@ def assert_has_metadata(metadata, term_selector, definition_selector)
120
129
end
121
130
122
131
def assert_has_publisher_metadata ( options )
123
- within ( ".gem-c -metadata" ) do
124
- assert_has_published_dates ( options [ :published ] , options [ :last_updated ] , options [ :history_link ] )
132
+ within ( ".app-c-publisher -metadata" ) do
133
+ assert_has_published_dates ( options [ :first_published ] , options [ :last_updated ] , options [ :history_link ] )
125
134
assert_has_publisher_metadata_other ( options [ :metadata ] )
126
135
end
127
136
end
128
137
129
138
def assert_has_important_metadata ( metadata )
130
139
within ( ".app-c-important-metadata" ) do
131
- assert_has_metadata (
140
+ assert_has_metadata_local (
132
141
metadata , ".app-c-important-metadata__term" , ".app-c-important-metadata__definition"
133
142
)
134
143
end
135
144
end
136
145
137
- def assert_footer_has_published_dates ( published = nil , last_updated = nil , history_link = false )
138
- assert_has_published_dates ( published , last_updated , history_link , 1 )
146
+ def assert_footer_has_published_dates ( first_published = nil , last_updated = nil , history_link = false )
147
+ assert_has_published_dates ( first_published , last_updated , history_link )
139
148
end
140
149
141
150
def setup_and_visit_content_item ( name , parameter_string = "" )
0 commit comments