Sha256: 8e461789bd2a90ed46c611165be19750f1f48100da6b1209fcf89618d973f1df

Contents?: true

Size: 1.91 KB

Versions: 2

Compression:

Stored size: 1.91 KB

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

require 'tempfile'

# Time to add your specs!
# http://rspec.info/

describe "XbmcInfo" do

  before(:all) do
    logger = Log4r::Logger.new('dvdprofiler2xbmc')
    logger.outputters = Log4r::StdoutOutputter.new(:console)
    Log4r::Outputter[:console].formatter  = Log4r::PatternFormatter.new(:pattern => "%m")
    logger.level = Log4r::WARN
    AppConfig.default
    AppConfig[:logger] = logger
    AppConfig.load
    File.mkdirs(TMPDIR)
  end

  before(:each) do
    filespec = File.expand_path(File.join(File.dirname(__FILE__), 'samples/Die Hard - 1988.nfo'))
    @xbmc_info = XbmcInfo.new(filespec)
  end

  after(:all) do
    Dir.glob(File.join(TMPDIR,'xbmcinfo_*')).each { |filename| File.delete(filename) }
  end

  describe "File" do
    it "should load from the .nfo file" do
      @xbmc_info.movie['title'].first.should == 'Die Hard'
    end

    it "should create a .nfo file" do
      outfile = Tempfile.new('xbmcinfo_spec_create', TMPDIR)
      new_xbmc_info = XbmcInfo.new(outfile.path)
      new_xbmc_info.movie = @xbmc_info.movie
      new_xbmc_info.save
      (File.exist?(outfile.path).should be_true) && (File.size(outfile.path).should > 0)
    end

    it "should overwrite the .nfo file" do
      outfile = Tempfile.new('xbmcinfo_spec_overwrite', TMPDIR)
      new_xbmc_info = XbmcInfo.new(outfile.path)
      new_xbmc_info.movie = @xbmc_info.movie
      new_xbmc_info.save
      verify_xbmc_info = XbmcInfo.new(outfile.path)
      verify_xbmc_info.movie.should == @xbmc_info.movie
    end

    it "should not overwrite the .nfo file if not changed"

    it "should overwrite the .nfo file when changed"
  end

  describe "XML" do
    it "should be able to convert to xml and then from xml" do
      hash = nil
      begin
        xml = @xbmc_info.to_xml
        hash = XmlSimple.xml_in(xml)
      rescue
        hash = nil
      end
      hash.should_not be_nil
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
royw-dvdprofiler2xbmc-0.1.4 spec/xbmc_info_spec.rb
royw-dvdprofiler2xbmc-0.1.5 spec/xbmc_info_spec.rb