Sha256: 31d95c13abfe94d0fe4903226554662fb16945e3e9f4ffa812b1cece240c12f7

Contents?: true

Size: 1.39 KB

Versions: 48

Compression:

Stored size: 1.39 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 { 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

Version data entries

48 entries across 42 versions & 2 rubygems

Version Path
tdiary-contrib-4.2.0 spec/opensearch_ad_spec.rb
tdiary-contrib-4.1.3 spec/opensearch_ad_spec.rb
tdiary-contrib-4.1.2 spec/opensearch_ad_spec.rb
tdiary-contrib-4.1.1 spec/opensearch_ad_spec.rb
tdiary-contrib-4.1.0 spec/opensearch_ad_spec.rb
tdiary-contrib-4.0.5.1 spec/opensearch_ad_spec.rb
tdiary-contrib-4.0.4 spec/opensearch_ad_spec.rb
tdiary-contrib-4.0.3 spec/opensearch_ad_spec.rb