Skip to content

Commit 303b81e

Browse files
committed
220 Increase test cases for Store::Database
1 parent 6d3e411 commit 303b81e

1 file changed

Lines changed: 94 additions & 6 deletions

File tree

spec/plugins/store/permalink_spec.rb

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# Name:: Automatic::Plugin::Store::Permalink
33
# Author:: 774 <http://id774.net>
4-
# Updated:: Sep 18, 2012
4+
# Updated:: Dec 17, 2012
55
# Copyright:: 774 Copyright (c) 2012
66
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
77

@@ -11,14 +11,11 @@
1111
require 'pathname'
1212

1313
describe Automatic::Plugin::StorePermalink do
14-
before do
14+
it "should store 1 record for the new link" do
1515
@db_filename = "test_permalink.db"
1616
db_path = Pathname(AutomaticSpec.db_dir).cleanpath+"#{@db_filename}"
1717
db_path.delete if db_path.exist?
1818
Automatic::Plugin::StorePermalink.new({"db" => @db_filename}).run
19-
end
20-
21-
it "should store 1 record for the new link" do
2219
instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename},
2320
AutomaticSpec.generate_pipeline {
2421
feed { item "http://github.com" }
@@ -30,6 +27,10 @@
3027
end
3128

3229
it "should not store record for the existent link" do
30+
@db_filename = "test_permalink.db"
31+
db_path = Pathname(AutomaticSpec.db_dir).cleanpath+"#{@db_filename}"
32+
db_path.delete if db_path.exist?
33+
Automatic::Plugin::StorePermalink.new({"db" => @db_filename}).run
3334
instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename},
3435
AutomaticSpec.generate_pipeline {
3536
feed { item "http://github.com" }
@@ -43,6 +44,10 @@
4344
end
4445

4546
it "should be considered the case of the feed link nil" do
47+
@db_filename = "test_permalink.db"
48+
db_path = Pathname(AutomaticSpec.db_dir).cleanpath+"#{@db_filename}"
49+
db_path.delete if db_path.exist?
50+
Automatic::Plugin::StorePermalink.new({"db" => @db_filename}).run
4651
instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename},
4752
AutomaticSpec.generate_pipeline {
4853
feed {
@@ -68,6 +73,10 @@
6873
end
6974

7075
it "should be considered the case of duplicated links" do
76+
@db_filename = "test_permalink.db"
77+
db_path = Pathname(AutomaticSpec.db_dir).cleanpath+"#{@db_filename}"
78+
db_path.delete if db_path.exist?
79+
Automatic::Plugin::StorePermalink.new({"db" => @db_filename}).run
7180
instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename},
7281
AutomaticSpec.generate_pipeline {
7382
feed {
@@ -92,7 +101,86 @@
92101
}.should change(Automatic::Plugin::Permalink, :count).by(0)
93102
end
94103

95-
it "Only new feed is used when there is new feed." do
104+
it "No feed should be generated when there is same feed." do
105+
@db_filename = "test_permalink.db"
106+
db_path = Pathname(AutomaticSpec.db_dir).cleanpath+"#{@db_filename}"
107+
db_path.delete if db_path.exist?
108+
Automatic::Plugin::StorePermalink.new({"db" => @db_filename}).run
109+
instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename},
110+
AutomaticSpec.generate_pipeline {
111+
feed {
112+
item "http://id774.net/images/link_1.jpg"
113+
item "http://id774.net/images/link_1.jpg"
114+
item "http://id774.net/images/link_3.JPG"
115+
item "http://id774.net/images/link_4.png"
116+
item "http://id774.net/images/link_5.jpeg"
117+
item "http://id774.net/images/link_6.PNG"
118+
item nil
119+
item "http://id774.net/images/link_8.gif"
120+
item "http://id774.net/images/link_9.GIF"
121+
item "http://id774.net/images/link_10.tiff"
122+
item "http://id774.net/images/link_11.TIFF"
123+
}
124+
}
125+
)
126+
127+
instance.run.should have(1).feed
128+
lambda {
129+
instance.run.should have(0).feed
130+
}.should change(Automatic::Plugin::Permalink, :count).by(0)
131+
Automatic::Plugin::StorePermalink.new({"db" => @db_filename}).run
132+
instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename},
133+
AutomaticSpec.generate_pipeline {
134+
feed {
135+
item "http://id774.net/images/link_1.jpg"
136+
item "http://id774.net/images/link_1.jpg"
137+
item "http://id774.net/images/link_3.JPG"
138+
item "http://id774.net/images/link_4.png"
139+
item "http://id774.net/images/link_5.jpeg"
140+
item "http://id774.net/images/link_6.PNG"
141+
item nil
142+
item "http://id774.net/images/link_8.gif"
143+
item "http://id774.net/images/link_9.GIF"
144+
item "http://id774.net/images/link_10.tiff"
145+
item "http://id774.net/images/link_11.TIFF"
146+
}
147+
}
148+
)
149+
150+
instance.run.should have(0).feed
151+
lambda {
152+
instance.run.should have(0).feed
153+
}.should change(Automatic::Plugin::Permalink, :count).by(0)
154+
end
155+
156+
it "Only new feed should be generated when there is new feed." do
157+
@db_filename = "test_permalink.db"
158+
db_path = Pathname(AutomaticSpec.db_dir).cleanpath+"#{@db_filename}"
159+
db_path.delete if db_path.exist?
160+
Automatic::Plugin::StorePermalink.new({"db" => @db_filename}).run
161+
instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename},
162+
AutomaticSpec.generate_pipeline {
163+
feed {
164+
item "http://id774.net/images/link_1.jpg"
165+
item "http://id774.net/images/link_1.jpg"
166+
item "http://id774.net/images/link_3.JPG"
167+
item "http://id774.net/images/link_4.png"
168+
item "http://id774.net/images/link_5.jpeg"
169+
item "http://id774.net/images/link_6.PNG"
170+
item nil
171+
item "http://id774.net/images/link_8.gif"
172+
item "http://id774.net/images/link_9.GIF"
173+
item "http://id774.net/images/link_10.tiff"
174+
item "http://id774.net/images/link_11.TIFF"
175+
}
176+
}
177+
)
178+
179+
instance.run.should have(1).feed
180+
lambda {
181+
instance.run.should have(0).feed
182+
}.should change(Automatic::Plugin::Permalink, :count).by(0)
183+
Automatic::Plugin::StorePermalink.new({"db" => @db_filename}).run
96184
instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename},
97185
AutomaticSpec.generate_pipeline {
98186
feed {

0 commit comments

Comments
 (0)