|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# Name:: Automatic::Plugin::Subscription::g_guide |
| 3 | +# Author:: soramugi <http://soramugi.net> |
| 4 | +# Created:: May 21, 2013 |
| 5 | +# Updated:: May 21, 2013 |
| 6 | +# Copyright:: Copyright (c) 2012-2013 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 'subscription/g_guide' |
| 12 | + |
| 13 | +def g_guide(config = {}, pipeline = []) |
| 14 | + Automatic::Plugin::SubscriptionGGuide.new(config,pipeline) |
| 15 | +end |
| 16 | + |
| 17 | +describe 'Automatic::Plugin::SubscriptionGGuide' do |
| 18 | + context 'when config' do |
| 19 | + describe 'is empty' do |
| 20 | + subject { g_guide } |
| 21 | + |
| 22 | + its(:feed_url) { |
| 23 | + should == Automatic::Plugin::SubscriptionGGuide::G_GUIDE_RSS + |
| 24 | + 'stationPlatformId=0&' |
| 25 | + } |
| 26 | + end |
| 27 | + describe 'keyword is anime' do |
| 28 | + config = { 'keyword' => 'anime' } |
| 29 | + subject { g_guide(config) } |
| 30 | + |
| 31 | + its(:feed_url) { |
| 32 | + should == URI.encode( |
| 33 | + Automatic::Plugin::SubscriptionGGuide::G_GUIDE_RSS + |
| 34 | + "condition.keyword=#{config['keyword']}&" + |
| 35 | + 'stationPlatformId=0&') |
| 36 | + } |
| 37 | + end |
| 38 | + describe 'station is 地上波' do |
| 39 | + config = { 'station' => '地上波' } |
| 40 | + subject { g_guide(config) } |
| 41 | + |
| 42 | + its(:feed_url) { |
| 43 | + should == URI.encode( |
| 44 | + Automatic::Plugin::SubscriptionGGuide::G_GUIDE_RSS + |
| 45 | + 'stationPlatformId=1&') |
| 46 | + } |
| 47 | + end |
| 48 | + end |
| 49 | + context 'when feed is empty' do |
| 50 | + |
| 51 | + describe 'attestation error' do |
| 52 | + subject { g_guide } |
| 53 | + before do |
| 54 | + subject.should_receive(:feed_url).and_return('') |
| 55 | + end |
| 56 | + its(:run) { should be_empty } |
| 57 | + end |
| 58 | + |
| 59 | + describe 'interval & retry was used error' do |
| 60 | + config = {'interval' => 1, 'retry' => 1} |
| 61 | + subject { g_guide(config) } |
| 62 | + before do |
| 63 | + subject.should_receive(:feed_url).exactly(2).times.and_return('') |
| 64 | + end |
| 65 | + its(:run) { should be_empty } |
| 66 | + end |
| 67 | + |
| 68 | + end |
| 69 | + |
| 70 | + context 'when feed' do |
| 71 | + describe 'config keyword' do |
| 72 | + config = { 'keyword' => 'アニメ', 'station' => '地上波' } |
| 73 | + subject { g_guide(config) } |
| 74 | + its(:run) { should have(1).feed } |
| 75 | + end |
| 76 | + |
| 77 | + end |
| 78 | +end |
0 commit comments