|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# Name:: Automatic::Plugin::Filter::GoogleNews |
| 3 | +# Author:: 774 <http://id774.net> |
| 4 | +# Created:: Oct 12, 2014 |
| 5 | +# Updated:: Oct 12, 2014 |
| 6 | +# Copyright:: Copyright (c) 2014 Automatic Ruby Developers. |
| 7 | +# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. |
| 8 | + |
| 9 | +require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper') |
| 10 | + |
| 11 | +require 'filter/google_news' |
| 12 | + |
| 13 | +describe Automatic::Plugin::FilterGoogleNews do |
| 14 | + |
| 15 | + context "It should be not rewrite link other urls" do |
| 16 | + |
| 17 | + subject { |
| 18 | + Automatic::Plugin::FilterGoogleNews.new( |
| 19 | + {}, |
| 20 | + AutomaticSpec.generate_pipeline { |
| 21 | + feed { |
| 22 | + item "http://test1.id774.net", |
| 23 | + "dummy title", |
| 24 | + "aaa bbb ccc http://test2.id774.net ddd eee", |
| 25 | + "Mon, 07 Mar 2011 15:54:11 +0900" |
| 26 | + } |
| 27 | + } |
| 28 | + ) |
| 29 | + } |
| 30 | + |
| 31 | + describe "#run" do |
| 32 | + its(:run) { should have(1).feeds } |
| 33 | + |
| 34 | + specify { |
| 35 | + subject.run |
| 36 | + subject.instance_variable_get(:@pipeline)[0].items[0].link. |
| 37 | + should == "http://test1.id774.net" |
| 38 | + } |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + context "It should be rewrite link for google news urls" do |
| 43 | + |
| 44 | + subject { |
| 45 | + Automatic::Plugin::FilterGoogleNews.new( |
| 46 | + {}, |
| 47 | + AutomaticSpec.generate_pipeline { |
| 48 | + feed { |
| 49 | + item "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNGhIFo1illQ6jFyVGPZtfkttFaJYQ&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779138313507&ei=Pts3VLDAD4X7kgWO9oGIBg&url=http://www.yomiuri.co.jp/world/20141010-OYT1T50090.html", |
| 50 | + "dummy title", |
| 51 | + "aaa bbb ccc http://test2.id774.net ddd eee", |
| 52 | + "Mon, 07 Mar 2011 15:54:11 +0900" |
| 53 | + } |
| 54 | + } |
| 55 | + ) |
| 56 | + } |
| 57 | + |
| 58 | + describe "#run" do |
| 59 | + its(:run) { should have(1).feeds } |
| 60 | + |
| 61 | + specify { |
| 62 | + subject.run |
| 63 | + subject.instance_variable_get(:@pipeline)[0].items[0].link. |
| 64 | + should == "http://www.yomiuri.co.jp/world/20141010-OYT1T50090.html" |
| 65 | + } |
| 66 | + end |
| 67 | + end |
| 68 | + |
| 69 | +end |
0 commit comments