spec/wikilink/converter/namespace_spec.rb in wikilink-converter-0.1.0 vs spec/wikilink/converter/namespace_spec.rb in wikilink-converter-0.2.1
- old
+ new
@@ -7,11 +7,11 @@
let(:converter) { klass.new.config { 'it works' } }
describe '#run' do
subject { converter.method(:run) }
it 'forwards to the block' do
- subject.should convert(':', 'Home', 'Home', '/').to('it works')
+ subject.should convert(name: 'Home', path: 'Home').to('it works')
end
end
end
context 'given block accessing options in constructor through #config' do
@@ -20,45 +20,47 @@
}
describe '#run' do
subject { converter.method(:run) }
it 'forwards to the block and allows options access' do
- subject.should convert(':', 'Home', 'Home', '/').to('fake')
+ subject.should convert(name: 'Home', path: 'Home').to('fake')
end
end
end
end
describe Wikilink::Converter::Namespace do
let(:converter) { Wikilink::Converter::Namespace.new }
describe '#run' do
subject { converter.method(:run) }
it 'does nothing' do
- subject.should convert(':', 'Home', 'Home', '/').to(nil)
+ subject.should convert(name: 'Home', path: 'Home').to(nil)
end
end
it_behaves_like 'converter that can forward to given block'
end
describe Wikilink::Converter::Namespace::Default do
+ let(:run_options) { { name: 'Name', path: 'Home' } }
+
shared_examples 'converter that keeps query fragment only path untouched' do
- it { should convert(':', '#toc-1', 'Header 1', '/').
+ it { should convert(path: '#toc-1', name: 'Header 1').
to('<a href="#toc-1">Header 1</a>')
}
- it { should convert(':', '?q=keyword', 'Search keyword', '/').
+ it { should convert(path: '?q=keyword', name: 'Search keyword').
to('<a href="?q=keyword">Search keyword</a>')
}
- it { should convert(':', '?q=keyword#page-10', 'Search keyword (page 10)', '/').
+ it { should convert(path: '?q=keyword#page-10', name: 'Search keyword (page 10)').
to('<a href="?q=keyword#page-10">Search keyword (page 10)</a>')
}
end
let(:converter) { self.class.describes.new }
describe '#run' do
subject { converter.method(:run) }
- it { should convert(':', 'Home', 'Name', '/').
+ it { should convert(run_options).
to('<a href="Home">Name</a>')
}
it_behaves_like 'converter that keeps query fragment only path untouched'
end
@@ -72,39 +74,39 @@
context 'given option :suffix "/index.html"' do
let(:converter) { self.class.describes.new suffix: '/index.html' }
describe '#run' do
subject { converter.method(:run) }
- it { should convert(':', 'Home', 'Name', '/').
+ it { should convert(run_options).
to('<a href="Home/index.html">Name</a>')
}
it_behaves_like 'converter that keeps query fragment only path untouched'
end
end
context 'given option :external true' do
let(:converter) { self.class.describes.new external: true }
describe '#run' do
subject { converter.method(:run) }
- it { should convert(':', 'Home', 'Name', '/').
+ it { should convert(run_options).
to('<a class="external" href="Home">Name</a>')
}
end
end
context 'given option :class "fancy"' do
let(:converter) { self.class.describes.new class: 'fancy' }
describe '#run' do
subject { converter.method(:run) }
- it { should convert(':', 'Home', 'Name', '/').
+ it { should convert(run_options).
to('<a class="fancy" href="Home">Name</a>')
}
end
end
context 'given option :external true and :class "fancy"' do
let(:converter) { self.class.describes.new external: true, class: 'fancy' }
describe '#run' do
subject { converter.method(:run) }
- it { should convert(':', 'Home', 'Name', '/').
+ it { should convert(run_options).
to('<a class="fancy external" href="Home">Name</a>')
}
end
end