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-5.3.0 spec/opensearch_ad_spec.rb
tdiary-contrib-5.2.4 spec/opensearch_ad_spec.rb
tdiary-contrib-5.2.3 spec/opensearch_ad_spec.rb
tdiary-contrib-5.2.2 spec/opensearch_ad_spec.rb
tdiary-contrib-5.2.1 spec/opensearch_ad_spec.rb
tdiary-contrib-5.2.0 spec/opensearch_ad_spec.rb
tdiary-contrib-5.1.7 spec/opensearch_ad_spec.rb
tdiary-contrib-5.1.6 spec/opensearch_ad_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/spec/opensearch_ad_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/bundler/gems/tdiary-contrib-d1e41204db13/spec/opensearch_ad_spec.rb
tdiary-contrib-5.1.5 spec/opensearch_ad_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/spec/opensearch_ad_spec.rb
tdiary-contrib-5.1.4 spec/opensearch_ad_spec.rb
tdiary-contrib-5.1.3 spec/opensearch_ad_spec.rb
tdiary-contrib-5.1.2 spec/opensearch_ad_spec.rb
tdiary-contrib-5.1.1 spec/opensearch_ad_spec.rb
tdiary-contrib-5.1.0 spec/opensearch_ad_spec.rb
tdiary-contrib-5.0.13 spec/opensearch_ad_spec.rb
tdiary-contrib-5.0.12 spec/opensearch_ad_spec.rb
tdiary-contrib-5.0.11 spec/opensearch_ad_spec.rb