root/platform/tdiary/spec/opensearch_ad_spec.rb

Revision 5423, 1.4 kB (checked in by hsbt, 10 months ago)

platform/tdiary/spec: fix some spec files. add chomp for expected string.

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