Sha256: 37ce66c2af567418e88eac2b56d65f8ef4348260bd0a9cdd291174f620d7acda

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

# encoding: UTF-8
require File.dirname(__FILE__) + '/test_helper.rb'

class TestInterface < Test::Unit::TestCase

  def setup
    files = [ File.dirname(__FILE__) + '/seriesindex_example.xml' ]

    @series_index = Sjunkieex::SeriesIndex.new(files: files)
  end


  def test_instantiating
    interface = Sjunkieex::Interface.new(@series_index)
    assert_instance_of Sjunkieex::Interface, interface
  end


  def test_option_passing
    url = "http://example.org"
    interface = Sjunkieex::Interface.new(@series_index, url: url)
    assert_equal interface.options[:url], url

    interface = Sjunkieex::Interface.new(@series_index)
    assert_equal interface.options[:url], "http://serienjunkies.org"
  end


  def test_parse_homepage
    filename = File.dirname(__FILE__) + '/site_dumps/homepage.html'
    interface = Sjunkieex::Interface.new(@series_index, url: filename)

    links = interface.look_for_new_episodes

    assert_equal false, links.empty?

    assert_equal true, links.include?("http://serienjunkies.org/serie/chase-2010/")
    assert_equal "chase", links["http://serienjunkies.org/serie/chase-2010/"]

    assert_equal true, links.include?("http://serienjunkies.org/serie/shameless-us/")
    assert_equal "shameless us", links["http://serienjunkies.org/serie/shameless-us/"]
  end


  def test_parse_series_page
    interface = Sjunkieex::Interface.new(@series_index)
    filename = File.dirname(__FILE__) + '/site_dumps/chase.html'

    link_data = interface.parse_series_page("Chase", filename)
    assert_instance_of Hash, link_data

    assert_equal 2, link_data.length

    assert_equal true, link_data["1_14"][:sd].include?(
      "http://download.serienjunkies.org/f-ddc2985db78e3e7d/nl_tvp-chase-xv-114.html")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sjunkieex-0.0.2 test/test_interface.rb