Skip to content

Commit f63e78e

Browse files
committed
Add shellspec file
1 parent bd7ea54 commit f63e78e

File tree

6 files changed

+238
-1
lines changed

6 files changed

+238
-1
lines changed

.shellspec

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--require spec_helper
2+
3+
## Default kcov (coverage) options
4+
# --kcov-options "--include-path=. --path-strip-level=1"
5+
# --kcov-options "--include-pattern=.sh"
6+
# --kcov-options "--exclude-pattern=/.shellspec,/spec/,/coverage/,/report/"
7+
8+
## Example: Include script "myprog" with no extension
9+
# --kcov-options "--include-pattern=.sh,myprog"
10+
11+
## Example: Only specified files/directories
12+
# --kcov-options "--include-pattern=myprog,/lib/"

bin/addbookmark.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ comment_escape 'commentFeedTitle' "${feedTitle}"
821821
: ${ADDBOOKMARK_BEGIN_BOOKMARK_SYMBOL:="$(printf '\t\t\t<!-- *** BEGIN-BOOKMARK-SECTION *** -->')"}
822822
: ${ADDBOOKMARK_END_BOOKMARK_SYMBOL:="$(printf '\t\t\t<!-- *** END-BOOKMARK-SECTION *** -->')"}
823823
: ${ADDBOOKMARK_SECTION_TEMPLATE:="$(printf '\t\t\t\t<li>${feed_title}\n\t\t\t\t\t<ul>\n${ADDBOOKMARK_BEGIN_LIST_SYMBOL}\n${ADDBOOKMARK_END_LIST_SYMBOL}\n\t\t\t\t\t</ul>\n\t\t\t\t</li>')"}
824-
: ${ADDBOOKMARK_ITEM_TEMPLATE:="$(printf '\t\t\t\t\t\t<li><a rel="noreferrer" href="${uri}"${description:+" title=\"${description}\""}>${title}</a></li>')"}
824+
: ${ADDBOOKMARK_ITEM_TEMPLATE:="$(printf '\t\t\t\t\t\t<li><a rel="noreferrer" href="${uri}" title="${description-}">${title}</a></li>')"}
825825

826826
ADDBOOKMARK_BEGIN_SECTION_SYMBOL=$(printf "${ADDBOOKMARK_BEGIN_SECTION_SYMBOL:-\\t\\t\\t\\t<!-- *** BEGIN-SECTION: \"%s\" *** -->}" "${commentFeedTitle}")
827827
ADDBOOKMARK_END_SECTION_SYMBOL=$(printf "${ADDBOOKMARK_END_SECTION_SYMBOL:-\\t\\t\\t\\t<!-- *** END-SECTION *** -->}" "${commentFeedTitle}")

spec/addbookmark_spec.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env sh
2+
3+
### Script: addbookmark_spec.sh
4+
##
5+
## addbookmark.sh のテスト。
6+
##
7+
## Usage:
8+
##
9+
## ------ Text ------
10+
## shellspec addbookmark_spec.sh
11+
## ------------------
12+
##
13+
## Metadata:
14+
##
15+
## id - ba85c9ec-3d7d-4d38-985d-cb2d206cff3b
16+
## author - <qq542vev at https://purl.org/meta/me/>
17+
## version - 0.1.0
18+
## date - 2022-12-09
19+
## since - 2022-12-06
20+
## copyright - Copyright (C) 2022 qq542vev. Some rights reserved.
21+
## license - <CC-BY at https://creativecommons.org/licenses/by/4.0/>
22+
## package - vim-style-newsboat
23+
##
24+
## See Also:
25+
##
26+
## * <Project homepage at https://github.com/qq542vev/vim-style-newsboat>
27+
## * <Bug report at https://github.com/qq542vev/vim-style-newsboat/issues>
28+
29+
eval "$(shellspec - -c) exit 1"
30+
31+
Describe 'addbookmark.sh の検証'
32+
bookmark() {
33+
./bin/addbookmark.sh ${@+"${@}"}
34+
}
35+
36+
Describe '各種オプションの検証'
37+
Parameters:block
38+
'-h' '1' '' '0'
39+
'-v' '1' '' '0'
40+
'--nil' '' '1' '64'
41+
'-f' '' '1' '64'
42+
'-p' '' '1' '64'
43+
End
44+
45+
Example "addbookmark.sh ${1}"
46+
When call bookmark ${1}
47+
The length of stdout should ${2:+'not'} eq 0
48+
The length of stderr should ${3:+'not'} eq 0
49+
The status should eq "${4}"
50+
End
51+
End
52+
53+
Describe 'ブックマークの編集'
54+
add_bookmark() {
55+
bookmark -f "${bookmark}" 'http://www.example.com/t1'
56+
bookmark -f "${bookmark}" 'http://www.example.com/t1'
57+
bookmark -f "${bookmark}" "escape:&'--/t2"
58+
bookmark -f "${bookmark}" 'http://www.example.com/t3' "title text &<>'" "description text &<>'"
59+
bookmark -f "${bookmark}" 'about:t4' '' '' "New--Section${SHELLSPEC_LF}"
60+
bookmark -f "${bookmark}" -p 'bottom' 'about:t5' '' '' "New--Section${SHELLSPEC_LF}"
61+
bookmark -f "${bookmark}" -p 'top' 'about:t6' '' '' "New--Section${SHELLSPEC_LF}"
62+
bookmark -f "${bookmark}" -d 'http://www.example.com/t1' '' '' 'Move'
63+
}
64+
65+
del_bookmark() {
66+
bookmark -f "${bookmark}" -p 'none' 'http://www.example.com/t1'
67+
bookmark -f "${bookmark}" -p 'none' '' '' '' 'Move'
68+
bookmark -f "${bookmark}" -p 'none' 'about:t6' '' '' "New--Section${SHELLSPEC_LF}"
69+
bookmark -f "${bookmark}" -p 'none' 'about:t5' '' '' "New--Section${SHELLSPEC_LF}"
70+
bookmark -f "${bookmark}" -p 'none' 'about:t4' '' '' "New--Section${SHELLSPEC_LF}"
71+
}
72+
73+
setup() {
74+
bookmark='./spec/tmp/bookmark.html'
75+
bookmarkDir='./spec/bookmark'
76+
77+
mkdir -p -- './spec/tmp'
78+
}
79+
80+
cleanup() {
81+
rm -rf -- './spec/tmp'
82+
}
83+
84+
BeforeAll 'setup'
85+
AfterAll 'cleanup'
86+
87+
Example 'ブックマーク追加の検証'
88+
When call add_bookmark
89+
The status should eq 0
90+
Assert diff -- "${bookmark}" "${bookmarkDir}/success1.html"
91+
End
92+
93+
Example 'ブックマーク削除の検証'
94+
When call del_bookmark
95+
The status should eq 0
96+
Assert diff -- "${bookmark}" "${bookmarkDir}/success2.html"
97+
End
98+
End
99+
End

spec/bookmark/success1.html

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="generator" content="addbookmark.sh" />
6+
<meta name="referrer" content="no-referrer" />
7+
<meta name="robots" content="noindex,nofollow,noarchive" />
8+
<title>Bookmark</title>
9+
<link rel="profile" href="http://microformats.org/profile/xoxo" />
10+
</head>
11+
<body>
12+
<main id="main">
13+
<!-- Do not delete the "*** ~~~ ***" comment. -->
14+
15+
<ul class="xoxo">
16+
<!-- *** BEGIN-BOOKMARK-SECTION *** -->
17+
<!-- *** BEGIN-SECTION: "Unsorted Bookmarks" *** -->
18+
<li>Unsorted Bookmarks
19+
<ul>
20+
<!-- *** BEGIN-LIST *** -->
21+
<!-- *** BEGIN-ITEM: "http://www.example.com/t1" *** -->
22+
<li><a rel="noreferrer" href="http://www.example.com/t1" title="">http://www.example.com/t1</a></li>
23+
<!-- *** END-ITEM *** -->
24+
<!-- *** BEGIN-ITEM: "escape:&amp;&#39;&#45;&#45;/t2" *** -->
25+
<li><a rel="noreferrer" href="escape:&amp;&#39;--/t2" title="">escape:&amp;&#39;--/t2</a></li>
26+
<!-- *** END-ITEM *** -->
27+
<!-- *** BEGIN-ITEM: "http://www.example.com/t3" *** -->
28+
<li><a rel="noreferrer" href="http://www.example.com/t3" title="description text &amp;&lt;&gt;&#39;">title text &amp;&lt;&gt;&#39;</a></li>
29+
<!-- *** END-ITEM *** -->
30+
<!-- *** END-LIST *** -->
31+
</ul>
32+
</li>
33+
<!-- *** END-SECTION *** -->
34+
<!-- *** BEGIN-SECTION: "New&#45;&#45;Section&#10;" *** -->
35+
<li>New--Section
36+
37+
<ul>
38+
<!-- *** BEGIN-LIST *** -->
39+
<!-- *** BEGIN-ITEM: "about:t6" *** -->
40+
<li><a rel="noreferrer" href="about:t6" title="">about:t6</a></li>
41+
<!-- *** END-ITEM *** -->
42+
<!-- *** BEGIN-ITEM: "about:t4" *** -->
43+
<li><a rel="noreferrer" href="about:t4" title="">about:t4</a></li>
44+
<!-- *** END-ITEM *** -->
45+
<!-- *** BEGIN-ITEM: "about:t5" *** -->
46+
<li><a rel="noreferrer" href="about:t5" title="">about:t5</a></li>
47+
<!-- *** END-ITEM *** -->
48+
<!-- *** END-LIST *** -->
49+
</ul>
50+
</li>
51+
<!-- *** END-SECTION *** -->
52+
<!-- *** BEGIN-SECTION: "Move" *** -->
53+
<li>Move
54+
<ul>
55+
<!-- *** BEGIN-LIST *** -->
56+
<!-- *** BEGIN-ITEM: "http://www.example.com/t1" *** -->
57+
<li><a rel="noreferrer" href="http://www.example.com/t1" title="">http://www.example.com/t1</a></li>
58+
<!-- *** END-ITEM *** -->
59+
<!-- *** END-LIST *** -->
60+
</ul>
61+
</li>
62+
<!-- *** END-SECTION *** -->
63+
<!-- *** END-BOOKMARK-SECTION *** -->
64+
</ul>
65+
</main>
66+
</body>
67+
</html>

spec/bookmark/success2.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="generator" content="addbookmark.sh" />
6+
<meta name="referrer" content="no-referrer" />
7+
<meta name="robots" content="noindex,nofollow,noarchive" />
8+
<title>Bookmark</title>
9+
<link rel="profile" href="http://microformats.org/profile/xoxo" />
10+
</head>
11+
<body>
12+
<main id="main">
13+
<!-- Do not delete the "*** ~~~ ***" comment. -->
14+
15+
<ul class="xoxo">
16+
<!-- *** BEGIN-BOOKMARK-SECTION *** -->
17+
<!-- *** BEGIN-SECTION: "Unsorted Bookmarks" *** -->
18+
<li>Unsorted Bookmarks
19+
<ul>
20+
<!-- *** BEGIN-LIST *** -->
21+
<!-- *** BEGIN-ITEM: "escape:&amp;&#39;&#45;&#45;/t2" *** -->
22+
<li><a rel="noreferrer" href="escape:&amp;&#39;--/t2" title="">escape:&amp;&#39;--/t2</a></li>
23+
<!-- *** END-ITEM *** -->
24+
<!-- *** BEGIN-ITEM: "http://www.example.com/t3" *** -->
25+
<li><a rel="noreferrer" href="http://www.example.com/t3" title="description text &amp;&lt;&gt;&#39;">title text &amp;&lt;&gt;&#39;</a></li>
26+
<!-- *** END-ITEM *** -->
27+
<!-- *** END-LIST *** -->
28+
</ul>
29+
</li>
30+
<!-- *** END-SECTION *** -->
31+
<!-- *** END-BOOKMARK-SECTION *** -->
32+
</ul>
33+
</main>
34+
</body>
35+
</html>

spec/spec_helper.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# shellcheck shell=sh
2+
3+
# Defining variables and functions here will affect all specfiles.
4+
# Change shell options inside a function may cause different behavior,
5+
# so it is better to set them here.
6+
# set -eu
7+
8+
# This callback function will be invoked only once before loading specfiles.
9+
spec_helper_precheck() {
10+
# Available functions: info, warn, error, abort, setenv, unsetenv
11+
# Available variables: VERSION, SHELL_TYPE, SHELL_VERSION
12+
: minimum_version "0.28.1"
13+
}
14+
15+
# This callback function will be invoked after a specfile has been loaded.
16+
spec_helper_loaded() {
17+
:
18+
}
19+
20+
# This callback function will be invoked after core modules has been loaded.
21+
spec_helper_configure() {
22+
# Available functions: import, before_each, after_each, before_all, after_all
23+
: import 'support/custom_matcher'
24+
}

0 commit comments

Comments
 (0)