caramelize 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.editorconfig +30 -0
- data/.github/dependabot.yml +1 -1
- data/.github/workflows/main.yml +4 -4
- data/.ruby-version +1 -0
- data/Gemfile +6 -11
- data/Gemfile.lock +85 -90
- data/LICENSE.md +1 -1
- data/Rakefile +3 -3
- data/bin/caramelize +2 -3
- data/caramelize.gemspec +24 -20
- data/lib/caramelize/caramel.rb +23 -23
- data/lib/caramelize/content_transferer.rb +18 -18
- data/lib/caramelize/database_connector.rb +6 -6
- data/lib/caramelize/filters/camel_case_to_wiki_links.rb +2 -2
- data/lib/caramelize/filters/mediawiki_to_markdown.rb +4 -4
- data/lib/caramelize/filters/swap_wiki_links.rb +2 -2
- data/lib/caramelize/filters/wikka_to_markdown.rb +2 -2
- data/lib/caramelize/health_check.rb +1 -1
- data/lib/caramelize/health_checks/home_page_check.rb +2 -2
- data/lib/caramelize/health_checks/orphaned_pages_check.rb +1 -1
- data/lib/caramelize/health_checks/page.rb +2 -2
- data/lib/caramelize/input_wiki/media_wiki.rb +17 -17
- data/lib/caramelize/input_wiki/redmine_wiki.rb +23 -23
- data/lib/caramelize/input_wiki/wiki.rb +1 -1
- data/lib/caramelize/input_wiki/wikka_wiki.rb +15 -15
- data/lib/caramelize/output_wiki/gollum.rb +3 -3
- data/lib/caramelize/page.rb +11 -11
- data/lib/caramelize/services/page_builder.rb +4 -4
- data/lib/caramelize/version.rb +1 -1
- data/lib/caramelize.rb +16 -16
- data/samples/media_wiki.rb +4 -4
- data/spec/lib/caramelize/content_transferer_spec.rb +4 -4
- data/spec/lib/caramelize/filter_processor_spec.rb +7 -7
- data/spec/lib/caramelize/filters/add_newline_to_page_end_spec.rb +7 -7
- data/spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb +17 -19
- data/spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb +4 -4
- data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +15 -17
- data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +23 -25
- data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +82 -84
- data/spec/lib/caramelize/input_wiki/media_wiki_spec.rb +3 -3
- data/spec/lib/caramelize/input_wiki/wiki_spec.rb +21 -21
- data/spec/lib/caramelize/input_wiki/wikka_wiki_spec.rb +3 -3
- data/spec/lib/caramelize/output_wiki/gollum_spec.rb +39 -39
- data/spec/lib/caramelize/page_spec.rb +30 -30
- data/spec/lib/caramelize/services/page_builder_spec.rb +12 -12
- data/spec/spec_helper.rb +2 -3
- metadata +62 -9
- data/.rubocop.yml +0 -31
- data/.rubocop_todo.yml +0 -55
@@ -1,24 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Caramelize::MediawikiToMarkdown do
|
6
6
|
let(:filter) { described_class.new(body) }
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe "#run" do
|
9
9
|
subject { filter.run }
|
10
10
|
|
11
11
|
# the conversions are performed through pandoc-ruby.
|
12
12
|
# This is a smoke test to see if it's called at all,
|
13
13
|
# but not testing every single option.
|
14
14
|
|
15
|
-
context
|
15
|
+
context "when headline h1" do
|
16
16
|
let(:body) { "= Headline =\n" }
|
17
17
|
|
18
18
|
it { is_expected.to eq "# Headline\n" }
|
19
19
|
end
|
20
20
|
|
21
|
-
context
|
21
|
+
context "when headline h2" do
|
22
22
|
let(:body) { "== Headline ==\n" }
|
23
23
|
|
24
24
|
it { is_expected.to eq "## Headline\n" }
|
@@ -1,54 +1,52 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
|
-
# rubocop:todo RSpec/SpecFilePathFormat
|
6
|
-
describe Caramelize::RemoveTableTabLineEndings do # rubocop:todo RSpec/FilePath, RSpec/SpecFilePathFormat
|
7
|
-
# rubocop:enable RSpec/SpecFilePathFormat
|
5
|
+
describe Caramelize::RemoveTableTabLineEndings do # rubocop:todo RSpec/SpecFilePathFormat
|
8
6
|
subject(:run) { filter.run }
|
9
7
|
|
10
8
|
let(:filter) { described_class.new(body) }
|
11
9
|
|
12
|
-
describe
|
13
|
-
context
|
10
|
+
describe "#run" do
|
11
|
+
context "table with tabs at unix line-endings" do # rubocop:todo RSpec/ContextWording
|
14
12
|
let(:body) { "cell1\t|cell2\t|\t\t\n" }
|
15
13
|
|
16
|
-
it
|
14
|
+
it "removes tabs at end of line" do
|
17
15
|
expect(run).to eq "cell1\t|cell2\t|\n"
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
|
-
context
|
19
|
+
context "with spaces on line ending" do
|
22
20
|
let(:body) { "cell1\t|cell2\t|\t \n" }
|
23
21
|
|
24
|
-
it
|
22
|
+
it "removes spaces at end of line" do
|
25
23
|
expect(run).to eq "cell1\t|cell2\t|\n"
|
26
24
|
end
|
27
25
|
|
28
|
-
context
|
26
|
+
context "replace in full file" do # rubocop:todo RSpec/ContextWording
|
29
27
|
let(:body) do
|
30
|
-
File.read(File.join([
|
28
|
+
File.read(File.join(["spec", "fixtures", "markup", "table-tab-line-endings-input.textile"]))
|
31
29
|
end
|
32
30
|
|
33
|
-
it
|
34
|
-
output_text = File.read(File.join([
|
31
|
+
it "returns as expected" do
|
32
|
+
output_text = File.read(File.join(["spec", "fixtures", "markup", "table-tab-line-endings-output.textile"]))
|
35
33
|
expect(run).to eq output_text
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
40
|
-
context
|
38
|
+
context "with table having tabs at windows line-endings" do
|
41
39
|
let(:body) { "cell1\t|cell2\t|\t\t\r\n" }
|
42
40
|
|
43
|
-
it
|
41
|
+
it "removes tabs at end of line" do
|
44
42
|
expect(run).to eq "cell1\t|cell2\t|\n"
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
48
|
-
context
|
46
|
+
context "with spaces and windows line-endings" do
|
49
47
|
let(:body) { "cell1\t|cell2\t|\t \r\n" }
|
50
48
|
|
51
|
-
it
|
49
|
+
it "removes spaces at end of line" do
|
52
50
|
expect(run).to eq "cell1\t|cell2\t|\n"
|
53
51
|
end
|
54
52
|
end
|
@@ -1,51 +1,49 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
|
-
# rubocop:todo RSpec/SpecFilePathFormat
|
6
|
-
describe
|
7
|
-
# rubocop:enable RSpec/SpecFilePathFormat
|
8
|
-
describe '#run' do
|
5
|
+
describe Caramelize::SwapWikiLinks do # rubocop:todo RSpec/SpecFilePathFormat
|
6
|
+
describe "#run" do
|
9
7
|
subject(:run) { filter.run }
|
10
8
|
|
11
9
|
let(:filter) { described_class.new(body) }
|
12
10
|
|
13
|
-
context
|
14
|
-
let(:body) {
|
11
|
+
context "with wiki link with title" do
|
12
|
+
let(:body) { "[[statistics|Driver & Team Statistics]]" }
|
15
13
|
|
16
|
-
it
|
17
|
-
expect(run).to eq
|
14
|
+
it "swaps title and target" do
|
15
|
+
expect(run).to eq "[[Driver & Team Statistics|statistics]]"
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
|
-
context
|
22
|
-
let(:body) {
|
19
|
+
context "with wiki title with spaces" do
|
20
|
+
let(:body) { "[[Release 1 0]]" }
|
23
21
|
|
24
|
-
it
|
25
|
-
expect(run).to eq
|
22
|
+
it "replaces space with dashes" do
|
23
|
+
expect(run).to eq "[[Release 1 0|release_1_0]]"
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
context
|
30
|
-
let(:body) {
|
27
|
+
context "with wiki title with dashes" do
|
28
|
+
let(:body) { "[[Release-1.0]]" }
|
31
29
|
|
32
|
-
it
|
33
|
-
expect(run).to eq
|
30
|
+
it "removes dots" do
|
31
|
+
expect(run).to eq "[[Release-1.0|release-10]]"
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
37
|
-
context
|
38
|
-
let(:body) {
|
35
|
+
context "with wiki link with spaces and without title" do
|
36
|
+
let(:body) { "[[Intra wiki link]]" }
|
39
37
|
|
40
|
-
it
|
41
|
-
expect(run).to eq
|
38
|
+
it "simples link to hyperlink" do
|
39
|
+
expect(run).to eq "[[Intra wiki link|intra_wiki_link]]"
|
42
40
|
end
|
43
41
|
|
44
|
-
context
|
45
|
-
let(:body) { File.read(File.join([
|
42
|
+
context "with replace in full file" do
|
43
|
+
let(:body) { File.read(File.join(["spec", "fixtures", "markup", "swap-links-input.textile"])) }
|
46
44
|
|
47
|
-
it
|
48
|
-
output_text = File.read(File.join([
|
45
|
+
it "returns as expected" do
|
46
|
+
output_text = File.read(File.join(["spec", "fixtures", "markup", "swap-links-output.textile"]))
|
49
47
|
expect(run).to eq output_text
|
50
48
|
end
|
51
49
|
end
|
@@ -1,168 +1,166 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
|
-
# rubocop:todo RSpec/SpecFilePathFormat
|
6
|
-
describe Caramelize::WikkaToMarkdown do # rubocop:todo RSpec/FilePath, RSpec/SpecFilePathFormat
|
7
|
-
# rubocop:enable RSpec/SpecFilePathFormat
|
5
|
+
describe Caramelize::WikkaToMarkdown do # rubocop:todo RSpec/SpecFilePathFormat
|
8
6
|
let(:filter) { described_class.new(body) }
|
9
7
|
|
10
|
-
describe
|
8
|
+
describe "#run" do
|
11
9
|
subject { filter.run }
|
12
10
|
|
13
|
-
xcontext
|
11
|
+
xcontext "when keep line breaks" do # rubocop:todo RSpec/PendingWithoutReason
|
14
12
|
let(:body) { "line1\nline2" }
|
15
13
|
|
16
14
|
it { is_expected.to eq "line1 \nline2" }
|
17
15
|
end
|
18
16
|
|
19
|
-
context
|
20
|
-
let(:body) {
|
17
|
+
context "when headline h1" do
|
18
|
+
let(:body) { "======Headline======" }
|
21
19
|
|
22
|
-
it { is_expected.to eq
|
20
|
+
it { is_expected.to eq "# Headline" }
|
23
21
|
end
|
24
22
|
|
25
|
-
context
|
26
|
-
let(:body) {
|
23
|
+
context "when headline h2" do
|
24
|
+
let(:body) { "=====Headline=====" }
|
27
25
|
|
28
|
-
it { is_expected.to eq
|
26
|
+
it { is_expected.to eq "## Headline" }
|
29
27
|
end
|
30
28
|
|
31
|
-
context
|
32
|
-
let(:body) {
|
29
|
+
context "when headline h3" do
|
30
|
+
let(:body) { "====Headline====" }
|
33
31
|
|
34
|
-
it { is_expected.to eq
|
32
|
+
it { is_expected.to eq "### Headline" }
|
35
33
|
end
|
36
34
|
|
37
|
-
context
|
38
|
-
let(:body) {
|
35
|
+
context "when headline h4" do
|
36
|
+
let(:body) { "===Headline===" }
|
39
37
|
|
40
|
-
it { is_expected.to eq
|
38
|
+
it { is_expected.to eq "#### Headline" }
|
41
39
|
end
|
42
40
|
|
43
|
-
context
|
44
|
-
let(:body) {
|
41
|
+
context "when headline h5" do
|
42
|
+
let(:body) { "==Headline==" }
|
45
43
|
|
46
|
-
it { is_expected.to eq
|
44
|
+
it { is_expected.to eq "##### Headline" }
|
47
45
|
end
|
48
46
|
|
49
|
-
context
|
50
|
-
let(:body) {
|
47
|
+
context "when bold" do
|
48
|
+
let(:body) { "**Text is bold**" }
|
51
49
|
|
52
|
-
it { is_expected.to eq
|
50
|
+
it { is_expected.to eq "**Text is bold**" }
|
53
51
|
end
|
54
52
|
|
55
|
-
context
|
56
|
-
let(:body) {
|
53
|
+
context "when italic" do
|
54
|
+
let(:body) { "//Text is italic//" }
|
57
55
|
|
58
|
-
it { is_expected.to eq
|
56
|
+
it { is_expected.to eq "*Text is italic*" }
|
59
57
|
end
|
60
58
|
|
61
|
-
context
|
62
|
-
let(:body) {
|
59
|
+
context "when underline" do
|
60
|
+
let(:body) { "__Text is underlined__" }
|
63
61
|
|
64
|
-
it { is_expected.to eq
|
62
|
+
it { is_expected.to eq "<u>Text is underlined</u>" }
|
65
63
|
end
|
66
64
|
|
67
|
-
context
|
65
|
+
context "when line break" do
|
68
66
|
let(:body) { 'Text is---\nbroken to two lines.' }
|
69
67
|
|
70
68
|
it { is_expected.to eq 'Text is \nbroken to two lines.' }
|
71
69
|
end
|
72
70
|
|
73
|
-
context
|
74
|
-
context
|
71
|
+
context "when unordered list entry" do
|
72
|
+
context "with tabs" do
|
75
73
|
let(:body) { "\t-unordered list entry" }
|
76
74
|
|
77
|
-
it { is_expected.to eq
|
75
|
+
it { is_expected.to eq "- unordered list entry" }
|
78
76
|
end
|
79
77
|
|
80
|
-
context
|
81
|
-
let(:body) {
|
78
|
+
context "with tilde" do
|
79
|
+
let(:body) { "~-unordered list entry" }
|
82
80
|
|
83
|
-
it { is_expected.to eq
|
81
|
+
it { is_expected.to eq "- unordered list entry" }
|
84
82
|
end
|
85
83
|
|
86
|
-
context
|
87
|
-
let(:body) {
|
84
|
+
context "with spaces" do
|
85
|
+
let(:body) { " - unordered list entry" }
|
88
86
|
|
89
|
-
it { is_expected.to eq
|
87
|
+
it { is_expected.to eq "- unordered list entry" }
|
90
88
|
end
|
91
89
|
end
|
92
90
|
|
93
|
-
context
|
94
|
-
context
|
95
|
-
let(:body) {
|
91
|
+
context "when ordered list entry" do
|
92
|
+
context "without space" do
|
93
|
+
let(:body) { "~1)ordered list entry" }
|
96
94
|
|
97
|
-
it { is_expected.to eq
|
95
|
+
it { is_expected.to eq "1. ordered list entry" }
|
98
96
|
end
|
99
97
|
|
100
|
-
context
|
101
|
-
let(:body) {
|
98
|
+
context "with space" do
|
99
|
+
let(:body) { "~1) ordered list entry" }
|
102
100
|
|
103
|
-
it { is_expected.to eq
|
101
|
+
it { is_expected.to eq "1. ordered list entry" }
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
107
|
-
context
|
108
|
-
context
|
109
|
-
let(:body) {
|
105
|
+
context "when wikilink" do
|
106
|
+
context "with only url" do
|
107
|
+
let(:body) { "[[LemmaLemma]]" }
|
110
108
|
|
111
|
-
it { is_expected.to eq
|
109
|
+
it { is_expected.to eq "[[LemmaLemma]]" }
|
112
110
|
end
|
113
111
|
|
114
|
-
context
|
112
|
+
context "with only wikilink" do
|
115
113
|
let(:body) { "\n [[ComunitySiteIdeas]] \n" }
|
116
114
|
|
117
115
|
it { is_expected.to eq "\n [[ComunitySiteIdeas]] \n" }
|
118
116
|
end
|
119
117
|
|
120
|
-
context
|
121
|
-
let(:body) {
|
118
|
+
context "with url and pipe title" do
|
119
|
+
let(:body) { "[[SandBox|Test your formatting skills]]" }
|
122
120
|
|
123
|
-
it { is_expected.to eq
|
121
|
+
it { is_expected.to eq "[[Test your formatting skills|SandBox]]" }
|
124
122
|
end
|
125
123
|
|
126
|
-
context
|
127
|
-
let(:body) {
|
124
|
+
context "with url and title" do
|
125
|
+
let(:body) { "[[SandBox Test your formatting skills]]" }
|
128
126
|
|
129
|
-
it { is_expected.to eq
|
127
|
+
it { is_expected.to eq "[[Test your formatting skills|SandBox]]" }
|
130
128
|
end
|
131
129
|
end
|
132
130
|
|
133
|
-
context
|
134
|
-
context
|
135
|
-
let(:body) {
|
131
|
+
context "when hyperlink" do
|
132
|
+
context "with only url" do
|
133
|
+
let(:body) { "[[http://target]]" }
|
136
134
|
|
137
|
-
it { is_expected.to eq
|
135
|
+
it { is_expected.to eq "<http://target>" }
|
138
136
|
end
|
139
137
|
|
140
|
-
context
|
141
|
-
let(:body) {
|
138
|
+
context "with url with title" do
|
139
|
+
let(:body) { "[[http://target Title]]" }
|
142
140
|
|
143
|
-
it { is_expected.to eq
|
141
|
+
it { is_expected.to eq "[Title](http://target)" }
|
144
142
|
end
|
145
143
|
|
146
|
-
context
|
147
|
-
let(:body) {
|
144
|
+
context "with url with title and special characters" do
|
145
|
+
let(:body) { "- [[http://www.sourcepole.com/sources/programming/cpp/cppqref.html C++ Syntax Reference]]" }
|
148
146
|
|
149
|
-
it { is_expected.to eq
|
147
|
+
it { is_expected.to eq "- [C++ Syntax Reference](http://www.sourcepole.com/sources/programming/cpp/cppqref.html)" }
|
150
148
|
end
|
151
149
|
|
152
|
-
context
|
153
|
-
let(:body) {
|
150
|
+
context "with url with pipe" do
|
151
|
+
let(:body) { "[[http://target|Title]]" }
|
154
152
|
|
155
|
-
it { is_expected.to eq
|
153
|
+
it { is_expected.to eq "[Title](http://target)" }
|
156
154
|
end
|
157
155
|
end
|
158
156
|
|
159
|
-
context
|
160
|
-
let(:body) {
|
157
|
+
context "when inline code" do
|
158
|
+
let(:body) { "Code: %%Hello World%% // done" }
|
161
159
|
|
162
|
-
it { is_expected.to eq
|
160
|
+
it { is_expected.to eq "Code: `Hello World` // done" }
|
163
161
|
end
|
164
162
|
|
165
|
-
context
|
163
|
+
context "when code block" do
|
166
164
|
let(:body) do
|
167
165
|
<<~CPP
|
168
166
|
Text before
|
@@ -203,7 +201,7 @@ describe Caramelize::WikkaToMarkdown do # rubocop:todo RSpec/FilePath, RSpec/Spe
|
|
203
201
|
it { is_expected.to eq expected_result }
|
204
202
|
end
|
205
203
|
|
206
|
-
context
|
204
|
+
context "when code block with language" do
|
207
205
|
let(:body) do
|
208
206
|
<<~CPP
|
209
207
|
Text before
|
@@ -244,29 +242,29 @@ describe Caramelize::WikkaToMarkdown do # rubocop:todo RSpec/FilePath, RSpec/Spe
|
|
244
242
|
it { is_expected.to eq expected_result }
|
245
243
|
end
|
246
244
|
|
247
|
-
context
|
248
|
-
context
|
245
|
+
context "when image" do
|
246
|
+
context "with link" do
|
249
247
|
let(:body) { '{{image class="center" alt="DVD logo" title="An image link" url="images/dvdvideo.gif" link="RecentChanges"}}' }
|
250
248
|
|
251
249
|
it { is_expected.to eq '[[<img src="images/dvdvideo.gif" alt="DVD logo">|RecentChanges]]' }
|
252
250
|
end
|
253
251
|
|
254
|
-
context
|
252
|
+
context "with alt and with title" do
|
255
253
|
let(:body) { '{{image class="center" alt="DVD logo" title="An image link" url="images/dvdvideo.gif"}}' }
|
256
254
|
|
257
|
-
it { is_expected.to eq
|
255
|
+
it { is_expected.to eq "" }
|
258
256
|
end
|
259
257
|
|
260
|
-
context
|
258
|
+
context "without alt and with title" do
|
261
259
|
let(:body) { '{{image class="center" title="An image link" url="images/dvdvideo.gif"}}' }
|
262
260
|
|
263
|
-
it { is_expected.to eq
|
261
|
+
it { is_expected.to eq "" }
|
264
262
|
end
|
265
263
|
|
266
|
-
context
|
264
|
+
context "without alt and without title" do
|
267
265
|
let(:body) { '{{image class="center" url="images/dvdvideo.gif"}}' }
|
268
266
|
|
269
|
-
it { is_expected.to eq
|
267
|
+
it { is_expected.to eq "" }
|
270
268
|
end
|
271
269
|
end
|
272
270
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Caramelize::InputWiki::MediaWiki do
|
6
6
|
subject(:wiki) { described_class.new }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
8
|
+
describe "#filters" do
|
9
|
+
it "has 2 filters" do
|
10
10
|
expect(wiki.filters.count).to be(2)
|
11
11
|
end
|
12
12
|
end
|
@@ -1,56 +1,56 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Caramelize::InputWiki::Wiki do
|
6
6
|
subject(:wiki) { described_class.new }
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe "#latest_revisions" do
|
9
9
|
let(:page1) { double } # rubocop:todo RSpec/IndexedLet
|
10
10
|
let(:page2) { double } # rubocop:todo RSpec/IndexedLet
|
11
11
|
let(:page3) { double } # rubocop:todo RSpec/IndexedLet
|
12
12
|
|
13
|
-
context
|
14
|
-
it
|
13
|
+
context "without pages" do
|
14
|
+
it "return empty array" do
|
15
15
|
expect(wiki.latest_revisions).to eq []
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
context
|
20
|
-
it
|
19
|
+
context "with pages with revisions" do
|
20
|
+
it "returns list of latest pages" do # rubocop:todo RSpec/ExampleLength
|
21
21
|
wiki.titles = %w[allosaurus brachiosaurus]
|
22
22
|
allow(wiki).to receive(:revisions_by_title) # rubocop:todo RSpec/SubjectStub
|
23
|
-
.with(
|
23
|
+
.with("allosaurus").and_return([page1, page2])
|
24
24
|
allow(wiki).to receive(:revisions_by_title) # rubocop:todo RSpec/SubjectStub
|
25
|
-
.with(
|
25
|
+
.with("brachiosaurus").and_return([page3])
|
26
26
|
|
27
27
|
expect(wiki.latest_revisions).to eq([page2, page3])
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
33
|
-
context
|
34
|
-
context
|
35
|
-
it
|
32
|
+
describe "#revisions_by_author" do
|
33
|
+
context "with revisions is empty" do
|
34
|
+
context "with titles is empty" do
|
35
|
+
it "returns empty array" do
|
36
36
|
allow(wiki).to receive(:titles).and_return [] # rubocop:todo RSpec/SubjectStub
|
37
|
-
expect(wiki.revisions_by_title(
|
37
|
+
expect(wiki.revisions_by_title("title")).to eq []
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
context
|
43
|
-
context
|
44
|
-
it
|
42
|
+
context "with revisions are given" do
|
43
|
+
context "with title given" do
|
44
|
+
it "returns empty array" do # rubocop:todo RSpec/ExampleLength
|
45
45
|
pages = []
|
46
|
-
home1 = double(title:
|
46
|
+
home1 = double(title: "Home", time: Time.parse("2015-01-23")) # rubocop:todo RSpec/VerifiedDoubles
|
47
47
|
pages << home1
|
48
|
-
pages << double(title:
|
49
|
-
pages << double(title:
|
50
|
-
home2 = double(title:
|
48
|
+
pages << double(title: "Example", time: Time.parse("2015-01-20")) # rubocop:todo RSpec/VerifiedDoubles
|
49
|
+
pages << double(title: "Authors", time: Time.parse("2015-01-30")) # rubocop:todo RSpec/VerifiedDoubles
|
50
|
+
home2 = double(title: "Home", time: Time.parse("2014-01-23")) # rubocop:todo RSpec/VerifiedDoubles
|
51
51
|
pages << home2
|
52
52
|
allow(wiki).to receive(:revisions).and_return pages # rubocop:todo RSpec/SubjectStub
|
53
|
-
expect(wiki.revisions_by_title(
|
53
|
+
expect(wiki.revisions_by_title("Home")).to eq [home2, home1]
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Caramelize::InputWiki::WikkaWiki do
|
6
6
|
subject(:wiki) { described_class.new }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
8
|
+
describe "#filters" do
|
9
|
+
it "has 3 filters" do
|
10
10
|
expect(wiki.filters.count).to be(3)
|
11
11
|
end
|
12
12
|
end
|