|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | # Name:: Automatic::Plugin::Store::Permalink |
3 | 3 | # Author:: 774 <http://id774.net> |
4 | | -# Updated:: Sep 18, 2012 |
| 4 | +# Updated:: Dec 17, 2012 |
5 | 5 | # Copyright:: 774 Copyright (c) 2012 |
6 | 6 | # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. |
7 | 7 |
|
|
11 | 11 | require 'pathname' |
12 | 12 |
|
13 | 13 | describe Automatic::Plugin::StorePermalink do |
14 | | - before do |
| 14 | + it "should store 1 record for the new link" do |
15 | 15 | @db_filename = "test_permalink.db" |
16 | 16 | db_path = Pathname(AutomaticSpec.db_dir).cleanpath+"#{@db_filename}" |
17 | 17 | db_path.delete if db_path.exist? |
18 | 18 | Automatic::Plugin::StorePermalink.new({"db" => @db_filename}).run |
19 | | - end |
20 | | - |
21 | | - it "should store 1 record for the new link" do |
22 | 19 | instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename}, |
23 | 20 | AutomaticSpec.generate_pipeline { |
24 | 21 | feed { item "http://github.com" } |
|
30 | 27 | end |
31 | 28 |
|
32 | 29 | 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 |
33 | 34 | instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename}, |
34 | 35 | AutomaticSpec.generate_pipeline { |
35 | 36 | feed { item "http://github.com" } |
|
43 | 44 | end |
44 | 45 |
|
45 | 46 | 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 |
46 | 51 | instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename}, |
47 | 52 | AutomaticSpec.generate_pipeline { |
48 | 53 | feed { |
|
68 | 73 | end |
69 | 74 |
|
70 | 75 | 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 |
71 | 80 | instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename}, |
72 | 81 | AutomaticSpec.generate_pipeline { |
73 | 82 | feed { |
|
92 | 101 | }.should change(Automatic::Plugin::Permalink, :count).by(0) |
93 | 102 | end |
94 | 103 |
|
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 |
96 | 184 | instance = Automatic::Plugin::StorePermalink.new({"db" => @db_filename}, |
97 | 185 | AutomaticSpec.generate_pipeline { |
98 | 186 | feed { |
|
0 commit comments