summaryrefslogtreecommitdiff
path: root/spec/features/markdown_spec.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-07-19 19:41:54 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-07-28 18:56:26 -0400
commitb07ecbb5e37530e7754dc267da4ded1d7d2d736d (patch)
treef2d58ce64936fdb36eaed52e52168dbb33357f2d /spec/features/markdown_spec.rb
parentf8bfd065aa010955e9435347cb92b92006f0d5bf (diff)
downloadgitlab-ce-b07ecbb5e37530e7754dc267da4ded1d7d2d736d.tar.gz
Simplify AutolinkFilter specs
Diffstat (limited to 'spec/features/markdown_spec.rb')
-rw-r--r--spec/features/markdown_spec.rb28
1 files changed, 12 insertions, 16 deletions
diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb
index b8199aa5e61..b8a846c7015 100644
--- a/spec/features/markdown_spec.rb
+++ b/spec/features/markdown_spec.rb
@@ -195,45 +195,41 @@ describe 'GitLab Markdown', feature: true do
end
describe 'AutolinkFilter' do
- let(:list) { get_section('autolinkfilter').next_element }
+ def body
+ get_section('autolinkfilter').next_element
+ end
- def item(index)
- list.at_css("li:nth-child(#{index})")
+ # Override Capybara's `have_link` matcher to simplify our use case
+ def have_link(link)
+ super(link, href: link)
end
it 'autolinks http://' do
- expect(item(1).children.first.name).to eq 'a'
- expect(item(1).children.first['href']).to eq 'http://about.gitlab.com/'
+ expect(body).to have_link('http://about.gitlab.com/')
end
it 'autolinks https://' do
- expect(item(2).children.first.name).to eq 'a'
- expect(item(2).children.first['href']).to eq 'https://google.com/'
+ expect(body).to have_link('https://google.com/')
end
it 'autolinks ftp://' do
- expect(item(3).children.first.name).to eq 'a'
- expect(item(3).children.first['href']).to eq 'ftp://ftp.us.debian.org/debian/'
+ expect(body).to have_link('ftp://ftp.us.debian.org/debian/')
end
it 'autolinks smb://' do
- expect(item(4).children.first.name).to eq 'a'
- expect(item(4).children.first['href']).to eq 'smb://foo/bar/baz'
+ expect(body).to have_link('smb://foo/bar/baz')
end
it 'autolinks irc://' do
- expect(item(5).children.first.name).to eq 'a'
- expect(item(5).children.first['href']).to eq 'irc://irc.freenode.net/git'
+ expect(body).to have_link('irc://irc.freenode.net/git')
end
it 'autolinks short, invalid URLs' do
- expect(item(6).children.first.name).to eq 'a'
- expect(item(6).children.first['href']).to eq 'http://localhost:3000'
+ expect(body).to have_link('http://localhost:3000')
end
%w(code a kbd).each do |elem|
it "ignores links inside '#{elem}' element" do
- body = get_section('autolinkfilter')
expect(body).not_to have_selector("#{elem} a")
end
end