Skip to content

Commit 1d8ae06

Browse files
committed
Spec File
1 parent 10e4780 commit 1d8ae06

15 files changed

+719
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
3+
<ShortName>Web Search</ShortName>
4+
<Description>Use Example.com to search the Web.</Description>
5+
<Tags>example web</Tags>
6+
<Contact>[email protected]</Contact>
7+
<Url type="application/atom+xml"
8+
template="http://example.com/?q={searchTerms}&amp;pw={startPage?}&amp;format=atom"/>
9+
<Url type="application/rss+xml"
10+
template="http://example.com/?q={searchTerms}&amp;pw={startPage?}&amp;format=rss"/>
11+
<Url type="text/html"
12+
template="http://example.com/?q={searchTerms}&amp;pw={startPage?}"/>
13+
<LongName>Example.com Web Search</LongName>
14+
<Image height="64" width="64" type="image/png">http://example.com/websearch.png</Image>
15+
<Image height="16" width="16" type="image/vnd.microsoft.icon">http://example.com/websearch.ico</Image>
16+
<Query role="example" searchTerms="cat" />
17+
<Developer>Example.com Development Team</Developer>
18+
<Attribution>
19+
Search data Copyright 2005, Example.com, Inc., All Rights Reserved
20+
</Attribution>
21+
<SyndicationRight>open</SyndicationRight>
22+
<AdultContent>false</AdultContent>
23+
<Language>en-us</Language>
24+
<OutputEncoding>UTF-8</OutputEncoding>
25+
<InputEncoding>UTF-8</InputEncoding>
26+
</OpenSearchDescription>

spec/.shell-opensearch/draft2.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
3+
<ShortName>Web Search</ShortName>
4+
<Description>Use Example.com to search the Web.</Description>
5+
<Tags>example web</Tags>
6+
<Contact>[email protected]</Contact>
7+
<Url type="application/rss+xml"
8+
template="http://example.com/?q={searchTerms}&amp;pw={startPage}&amp;format=rss"/>
9+
<Url type="application/atom+xml"
10+
template="http://example.com/?q={searchTerms}&amp;pw={startPage?}&amp;format=atom"/>
11+
<Url type="text/html"
12+
method="post"
13+
template="https://intranet/search?format=html">
14+
<Param name="s" value="{searchTerms}"/>
15+
<Param name="o" value="{startIndex?}"/>
16+
<Param name="c" value="{itemsPerPage?}"/>
17+
<Param name="l" value="{language?}"/>
18+
</Url>
19+
<LongName>Example.com Web Search</LongName>
20+
<Image height="64" width="64" type="image/png">http://example.com/websearch.png</Image>
21+
<Image height="16" width="16" type="image/vnd.microsoft.icon">http://example.com/websearch.ico</Image>
22+
<Query role="example" searchTerms="cat" />
23+
<Developer>Example.com Development Team</Developer>
24+
<Attribution>
25+
Search data &amp;copy; 2005, Example.com, Inc., All Rights Reserved
26+
</Attribution>
27+
<SyndicationRight>open</SyndicationRight>
28+
<AdultContent>false</AdultContent>
29+
<Language>en-us</Language>
30+
<OutputEncoding>UTF-8</OutputEncoding>
31+
<InputEncoding>UTF-8</InputEncoding>
32+
</OpenSearchDescription>

spec/.shell-opensearch/empty.xml

Whitespace-only changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
3+
<ShortName>Web Search</ShortName>
4+
<Description>Use Example.com to search the Web.</Description>
5+
<Tags>example web</Tags>
6+
<Contact>[email protected]</Contact>
7+
<Url type="application/rss+xml"
8+
template="http://example.com/?q={searchTerms}&amp;pw={startPage}&amp;format=rss"/>
9+
<Url type="application/atom+xml"
10+
template="http://example.com/?q={searchTerms}&amp;pw={startPage?}&amp;format=atom"/>
11+
<Url type="text/html"
12+
method="post"
13+
template="https://intranet/search?format=html">
14+
<Param name="s" value="{searchTerms}"/>
15+
<Param name="o" value="{startIndex?}"/>
16+
<Param name="c" value="{itemsPerPage?}"/>
17+
<Param name="l" value="{language?}"/>
18+
</Url>
19+
<LongName>Example.com Web Search</LongName>
20+
<Image height="64" width="64" type="image/png">http://example.com/websearch.png</Image>
21+
<Image height="16" width="16" type="image/vnd.microsoft.icon">http://example.com/websearch.ico</Image>
22+
<Query role="example" searchTerms="cat" />
23+
<Developer>Example.com Development Team</Developer>
24+
<Attribution>
25+
Search data &amp;copy; 2005, Example.com, Inc., All Rights Reserved
26+
</Attribution>
27+
<SyndicationRight>open</SyndicationRight>
28+
<AdultContent>false</AdultContent>
29+
<Language>en-us</Language>
30+
<OutputEncoding>UTF-8</OutputEncoding>
31+
<InputEncoding>UTF-8</InputEncoding>
32+
</OpenSearchDescription>

spec/.shell-opensearch/failure/empty.xml

Whitespace-only changes.

spec/.shell-opensearch/minimum.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
2+
<ShortName>Web Search</ShortName>
3+
<Description>Use Example.com to search the Web.</Description>
4+
<Url type="application/xhtml+xml"
5+
template="http://example.com/?q={searchTerms}"/>
6+
</OpenSearchDescription>

spec/.shell-opensearch/simple.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
3+
<ShortName>Web Search</ShortName>
4+
<Description>Use Example.com to search the Web.</Description>
5+
<Tags>example web</Tags>
6+
<Contact>[email protected]</Contact>
7+
<Url type="application/rss+xml"
8+
template="http://example.com/?q={searchTerms}&amp;pw={startPage?}&amp;format=rss"/>
9+
</OpenSearchDescription>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
3+
<ShortName>Web Search</ShortName>
4+
<Description>Use Example.com to search the Web.</Description>
5+
<Tags>example web</Tags>
6+
<Contact>[email protected]</Contact>
7+
<Url type="application/atom+xml"
8+
template="http://example.com/?q={searchTerms}&amp;pw={startPage?}&amp;format=atom"/>
9+
<Url type="application/rss+xml"
10+
template="http://example.com/?q={searchTerms}&amp;pw={startPage?}&amp;format=rss"/>
11+
<Url type="text/html"
12+
template="http://example.com/?q={searchTerms}&amp;pw={startPage?}"/>
13+
<LongName>Example.com Web Search</LongName>
14+
<Image height="64" width="64" type="image/png">http://example.com/websearch.png</Image>
15+
<Image height="16" width="16" type="image/vnd.microsoft.icon">http://example.com/websearch.ico</Image>
16+
<Query role="example" searchTerms="cat" />
17+
<Developer>Example.com Development Team</Developer>
18+
<Attribution>
19+
Search data Copyright 2005, Example.com, Inc., All Rights Reserved
20+
</Attribution>
21+
<SyndicationRight>open</SyndicationRight>
22+
<AdultContent>false</AdultContent>
23+
<Language>en-us</Language>
24+
<OutputEncoding>UTF-8</OutputEncoding>
25+
<InputEncoding>UTF-8</InputEncoding>
26+
</OpenSearchDescription>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
3+
<ShortName>Web Search</ShortName>
4+
<Description>Use Example.com to search the Web.</Description>
5+
<Tags>example web</Tags>
6+
<Contact>[email protected]</Contact>
7+
<Url type="application/rss+xml"
8+
template="http://example.com/?q={searchTerms}&amp;pw={startPage?}&amp;format=rss"/>
9+
</OpenSearchDescription>

spec/opensearch-contact_spec.sh

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/usr/bin/env sh
2+
3+
### File: opensearch-contact_spec.sh
4+
##
5+
## opensearch の contact テスト。
6+
##
7+
## Usage:
8+
##
9+
## ------ Text ------
10+
## shellspec opensearch-contact_spec.sh
11+
## ------------------
12+
##
13+
## Metadata:
14+
##
15+
## author - qq542vev <https://purl.org/meta/me/>
16+
## version - 1.0.0
17+
## date - 2022-11-23
18+
## since - 2022-11-23
19+
## copyright - Copyright (C) 2022 qq542vev. Some rights reserved.
20+
## license - CC-BY <https://creativecommons.org/licenses/by/4.0/>
21+
## package - shell-opensearch
22+
##
23+
## See Also:
24+
##
25+
## * Project homepage - <https://github.com/qq542vev/shell-opensearch>
26+
## * Bag report - <https://github.com/qq542vev/shell-opensearch/issues>
27+
28+
eval "$(shellspec - -c) exit 1"
29+
30+
Describe 'opensearch contact test'
31+
email_check() {
32+
eval "set -- ${1}"
33+
34+
printf '%s' "${email_check}" | awk -- "$(
35+
cat <<-'__EOF__'
36+
BEGIN {
37+
split("", arguments)
38+
39+
for(i = 1; i < ARGC; i++) {
40+
arguments[i] = ARGV[i]
41+
delete ARGV[i]
42+
}
43+
}
44+
45+
!(NR in arguments) || $0 != arguments[NR] {
46+
exit 1
47+
}
48+
__EOF__
49+
)" ${@+"${@}"}
50+
}
51+
52+
setup() {
53+
configDir="${PWD}/spec/.shell-opensearch"
54+
55+
}
56+
57+
BeforeAll 'setup'
58+
59+
Example 'Option: -h'
60+
When call ./opensearch contact -h
61+
The length of stdout should not eq 0
62+
The length of stderr should eq 0
63+
The status should eq 0
64+
End
65+
66+
Example 'Option: --nil'
67+
When call ./opensearch contact --nil
68+
The length of stdout should eq 0
69+
The length of stderr should not eq 0
70+
The status should eq 64
71+
End
72+
73+
Example '2個以上の引数'
74+
When call ./opensearch contact simple detailed
75+
The length of stdout should eq 0
76+
The length of stderr should not eq 0
77+
The status should eq 64
78+
End
79+
80+
Describe '基本となるテスト'
81+
Parameters:block
82+
'minimum' '' '1' '65'
83+
'simple' "${email}" '' '0'
84+
'empty' '' '1' '65'
85+
'draft2' '' '1' '65'
86+
'nil' '' '1' '65'
87+
'success/' "${email} ${email}" '' '0'
88+
'failure/' '' '1' '65'
89+
'empty/' '' '' '0'
90+
'nil/' '' '' '0'
91+
'simple,detailed' "${email} ${email}" '' '0'
92+
'simple,minimum' '' '1' '65'
93+
'simple,nil' '' '1' '65'
94+
'draft2,nil' '' '1' '65'
95+
'./spec/.shell-opensearch/simple.xml' "${email}" '' '0'
96+
'./spec/.shell-opensearch/minimul.xml' '' '1' '65'
97+
'./spec/.shell-opensearch/empty.xml' '' '1' '65'
98+
'./spec/.shell-opensearch/nil.xml' '' '1' '65'
99+
End
100+
101+
Example "オプションなしのテスト: '${1}'"
102+
When call ./opensearch -c "${configDir}" contact "${1}"
103+
The lines of stdout should eq "$(eval "set -- ${2}"; printf '%d' "${#}")"
104+
The stdout should satisfy email_check "${2}"
105+
The length of stderr should ${3:+'not'} eq 0
106+
The status should eq "${4}"
107+
End
108+
109+
Example "--extarnal のテスト: '${1}'"
110+
When call env 'MAILER=echo' ./opensearch -c "${configDir}" contact -e "${1}"
111+
The lines of stdout should eq "$(eval "set -- ${2}"; printf '%d' "$((1 <= ${#}))")"
112+
The length of stderr should ${3:+'not'} eq 0
113+
The status should eq "${4}"
114+
End
115+
116+
Example "--extarnal のテスト: '${1}'"
117+
When call ./opensearch -c "${configDir}" contact -e'awk "BEGIN { for(i = 1; i < ARGC; i++) { printf(\"Email: %s\\n\", ARGV[i]) } }"' "${1}"
118+
The lines of stdout should eq "$(eval "set -- ${2}"; printf '%d' "${#}")"
119+
The length of stderr should ${3:+'not'} eq 0
120+
The status should eq "${4}"
121+
End
122+
End
123+
124+
Describe '--skip-error を有効にする'
125+
126+
Parameters:block
127+
'success/' "${email} ${email}" '' '0'
128+
'failure/' '' '1' '65'
129+
'empty/' '' '' '0'
130+
'nil/' '' '' '0'
131+
'simple,detailed' "${email} ${email}" '' '0'
132+
'simple,minimum' "${email}" '1' '65'
133+
'simple,nil' "${email}" '1' '65'
134+
'draft2,nil' '' '1' '65'
135+
End
136+
137+
Example "--skip-error のテスト: '${1}'"
138+
When call ./opensearch -c "${configDir}" contact -s "${1}"
139+
The lines of stdout should eq "$(eval "set -- ${2}"; printf '%d' "${#}")"
140+
The stdout should satisfy email_check "${2}"
141+
The length of stderr should ${3:+'not'} eq 0
142+
The status should eq "${4}"
143+
End
144+
End
145+
End

0 commit comments

Comments
 (0)