diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-04-09 13:59:37 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2019-04-09 13:59:37 +0300 |
commit | 84229cee50420df84984ec08344a1854532ccf42 (patch) | |
tree | b1d09c16dcf4fc39705f514c6491a9cb3d6e4205 /spec/gitlab | |
parent | 351ba813dbc89d25b7fe1d457dde8297fdf59348 (diff) |
Add support for URL-encoded anchors
Diffstat (limited to 'spec/gitlab')
-rw-r--r-- | spec/gitlab/docs/page_spec.rb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/spec/gitlab/docs/page_spec.rb b/spec/gitlab/docs/page_spec.rb index 64cc98da..a9ee3264 100644 --- a/spec/gitlab/docs/page_spec.rb +++ b/spec/gitlab/docs/page_spec.rb @@ -25,8 +25,11 @@ describe Gitlab::Docs::Page do <a href="../link.html#my-anchor">See external file</a> <a href="#internal-anchor">See internal section</a> <a href="#internal-anchor-2">See internal section broken</a> + <a href="#utf-8-id-✔">See utf-8 anchor</a> + <a href="#utf-8-id-%E2%9C%94">See utf-8 anchor 2</a> <h1 id="internal-anchor">Some section</h1> + <h1 id="utf-8-id-✔">Some section 2</h1> </body </html> HTML @@ -34,7 +37,7 @@ describe Gitlab::Docs::Page do describe '#links' do it 'collects links on a page' do - expect(subject.links.count).to eq 3 + expect(subject.links.count).to eq 4 end end @@ -42,23 +45,31 @@ describe Gitlab::Docs::Page do it 'collects all hrefs' do expect(subject.hrefs).to match_array %w[../link.html#my-anchor #internal-anchor - #internal-anchor-2] + #internal-anchor-2 + #utf-8-id-✔] end end describe '#ids' do it 'collects all ids' do - expect(subject.ids).to match_array %w[internal-anchor] + expect(subject.ids).to match_array %w[internal-anchor + utf-8-id-✔] end end describe '#has_anchor?' do it 'returns true when anchor exists on a page' do - expect(subject.has_anchor?('internal-anchor')).to be true + expect(subject).to have_anchor('internal-anchor') end it 'returns false when anchors does not exist' do - expect(subject.has_anchor?('internal-anchor-2')).to be false + expect(subject).not_to have_anchor('internal-anchor-2') + end + + it 'returns true when UTF-8 encoded anchors are compared' do + expect(subject).to have_anchor('utf-8-id-✔') + expect(subject).to have_anchor('utf-8-id-%E2%9C%94') + expect(subject).to have_anchor('utf-8-id-%e2%9c%94') end end end |