Sha256: 32b18ec4531fd6a72b98abd8aabbc0a57bcd4188824bc53fbddac1d572cc7f98

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

require 'fileutils'

require "rabbit-test-utils"

require "rabbit/source"
require "rabbit/logger"

class RabbitSourceTest < Test::Unit::TestCase

  def setup
    logger = Rabbit::Logger::STDERR.new
    
    @argf_input, @argf_output = IO.pipe
    @argf = Rabbit::Source::ARGF.new("UTF-8", logger, @argf_input)

    @file_dir_name = File.dirname(__FILE__)
    @file_name = File.join(@file_dir_name, "sample.rd")
    FileUtils.touch(@file_name)
    @file = Rabbit::Source::File.new("UTF-8", logger, @file_name)

    @uri_name = "http://example.com/sample/rabbit.rd"
    @uri_base_name = File.dirname(@uri_name)
    @uri = Rabbit::Source::URI.new("UTF-8", logger, @uri_name)
  end

  def teardown
    FileUtils.rm_f(@file_name)
  end
  
  def test_base
    assert_equal(".", @argf.base)
    assert_equal(File.dirname(@file_name), @file.base)

    base_uri = URI.parse(@uri_name)
    base_uri.path = File.dirname(base_uri.path)
    assert_equal(base_uri.to_s, @uri.base)
  end

  def test_full_path
    image = "sample.png"
    
    assert_equal(File.join(".", image), @argf.full_path(image))
    assert_equal(File.join(@file_dir_name, image), @file.full_path(image))
    assert_equal(File.join(@uri_base_name, image), @uri.full_path(image))
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rabbit-2.1.2 test/test-source.rb
rabbit-2.1.1 test/test-source.rb
rabbit-2.1.0 test/test-source.rb
rabbit-2.0.9 test/test-source.rb
rabbit-2.0.8 test/test-source.rb
rabbit-2.0.7 test/test-source.rb