$:.unshift(File.dirname(__FILE__)) require 'spec_helper' describe "github link plugin" do let(:plugin) { fake_plugin(:github_link) } subject { plugin.gh_link(*args) } describe 'repository page' do let(:args) { ['tdiary/tdiary-contrib'] } it 'should render repository a tag' do is_expected.to eq(%(tdiary-contrib)) end end describe 'issues page' do let(:args) { ['tdiary/tdiary-contrib#100'] } it 'should render issues a tag' do is_expected.to eq(%(tdiary-contrib#100)) end end context "When given altenative text" do let(:text) { 'This project' } let(:github_identifier) { 'tdiary/tdiary-contrib' } let(:args) { [github_identifier, text] } it 'should render repository a tag with the specified text' do is_expected.to eq(%(#{text})) end context "but the text is including ' } it 'should render a link text after sanitizing.' do is_expected.not_to eq(%(#{text})) end end end end