1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
$:.unshift(File.dirname(__FILE__))
require 'spec_helper'
describe "opensearch_ad plugin w/" do
def setup_opensearch_ad_plugin(title, xml, mode)
fake_plugin(:opensearch_ad) { |plugin|
plugin.mode = mode
plugin.conf['opensearch.title'] = title
plugin.conf['opensearch.xml'] = xml
}
end
describe "in day mode" do
before do
plugin = setup_opensearch_ad_plugin('OpenSearch', 'http://example.com/opensearch.xml', 'day')
@header_snippet = plugin.header_proc
end
it { expect(@header_snippet).to eq(expected_link_tag_with(
:title => 'OpenSearch',
:xml => 'http://example.com/opensearch.xml'))}
end
describe "in latest mode" do
before do
plugin = setup_opensearch_ad_plugin('OpenSearch', 'http://example.com/opensearch.xml', 'latest')
@header_snippet = plugin.header_proc
end
it { expect(@header_snippet).to eq(expected_link_tag_with(
:title => 'OpenSearch',
:xml => 'http://example.com/opensearch.xml'))}
end
describe "in edit mode" do
before do
plugin = setup_opensearch_ad_plugin('OpenSearch', 'http://example.com/opensearch.xml', 'edit')
@header_snippet = plugin.header_proc
end
it { expect(@header_snippet).to be_empty }
end
def expected_link_tag_with(options)
result = <<-HTML
<link type="application/opensearchdescription+xml" rel="search" title="#{options[:title]}" href="#{options[:xml]}">
HTML
result.gsub( /^\t/, '' ).chomp
end
end
|