Sha256: bfaac590c8a27c634023a837ac42d27c6281533f8b9abe229807a8fce468b78a

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

$:.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 { @header_snippet.should == 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 { @header_snippet.should == 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 { @header_snippet.should 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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tdiary-contrib-4.0.2.1 spec/opensearch_ad_spec.rb
tdiary-contrib-4.0.2 spec/opensearch_ad_spec.rb
tdiary-contrib-3.2.2.20130614 spec/opensearch_ad_spec.rb
tdiary-contrib-3.2.2.20130518 spec/opensearch_ad_spec.rb