|
136 | 136 | specify %(the current link has aria-current='page') do |
137 | 137 | expect(rendered_content).to have_tag('a', text: 'Item two', with: { href: '/item-two', 'aria-current' => 'page' }) |
138 | 138 | end |
| 139 | + |
| 140 | + specify %(only current links have an aria-current attribute) do |
| 141 | + expect(rendered_content).to have_tag('a', with: { 'aria-current' => 'page' }, count: 1) |
| 142 | + expect(rendered_content).not_to have_tag('a', with: { 'aria-current' => true }) |
| 143 | + end |
139 | 144 | end |
140 | 145 |
|
141 | 146 | describe 'matching the current page' do |
|
155 | 160 | end |
156 | 161 | end |
157 | 162 | end |
| 163 | + |
| 164 | + specify %(only current links have an aria-current attribute) do |
| 165 | + expect(rendered_content).to have_tag('a', with: { 'aria-current' => 'page' }, count: 1) |
| 166 | + expect(rendered_content).not_to have_tag('a', with: { 'aria-current' => true }) |
| 167 | + end |
158 | 168 | end |
159 | 169 | end |
160 | 170 |
|
|
179 | 189 | specify %(the active link has aria-current='true') do |
180 | 190 | expect(rendered_content).to have_tag('a', text: 'Item two', with: { href: '/item-two', 'aria-current' => 'true' }) |
181 | 191 | end |
| 192 | + |
| 193 | + specify %(only active links have an aria-current attribute) do |
| 194 | + expect(rendered_content).to have_tag('a', with: { 'aria-current' => true }, count: 1) |
| 195 | + expect(rendered_content).not_to have_tag('a', with: { 'aria-current' => 'page' }) |
| 196 | + end |
182 | 197 | end |
183 | 198 |
|
184 | 199 | context 'when active_when is set with a string' do |
|
201 | 216 | specify %(the active link has aria-current='true') do |
202 | 217 | expect(rendered_content).to have_tag('a', text: 'Admin', with: { href: '/admin', 'aria-current' => 'true' }) |
203 | 218 | end |
| 219 | + |
| 220 | + specify %(only active links have an aria-current attribute) do |
| 221 | + expect(rendered_content).to have_tag('a', with: { 'aria-current' => true }, count: 1) |
| 222 | + expect(rendered_content).not_to have_tag('a', with: { 'aria-current' => 'page' }) |
| 223 | + end |
204 | 224 | end |
205 | 225 |
|
206 | 226 | context 'when active_when is set with an array' do |
|
223 | 243 | specify %(the active link has aria-current='true') do |
224 | 244 | expect(rendered_content).to have_tag('a', text: 'Sales', with: { href: '/sales', 'aria-current' => 'true' }) |
225 | 245 | end |
| 246 | + |
| 247 | + specify %(only active links have an aria-current attribute) do |
| 248 | + expect(rendered_content).to have_tag('a', with: { 'aria-current' => true }, count: 1) |
| 249 | + expect(rendered_content).not_to have_tag('a', with: { 'aria-current' => 'page' }) |
| 250 | + end |
226 | 251 | end |
227 | 252 |
|
228 | 253 | context 'when active_when is set with a regular expression' do |
|
245 | 270 | specify %(the active link has aria-current='true') do |
246 | 271 | expect(rendered_content).to have_tag('a', text: 'Finance', with: { href: '/finance', 'aria-current' => 'true' }) |
247 | 272 | end |
| 273 | + |
| 274 | + specify %(only active links have an aria-current attribute) do |
| 275 | + expect(rendered_content).to have_tag('a', with: { 'aria-current' => true }, count: 1) |
| 276 | + expect(rendered_content).not_to have_tag('a', with: { 'aria-current' => 'page' }) |
| 277 | + end |
248 | 278 | end |
249 | 279 | end |
250 | 280 |
|
|
0 commit comments