Sha256: 3b1d6bfb51269ec30543e5174a2b215cbec5020d853f4c1bf44a9dab621ac6cb

Contents?: true

Size: 1.16 KB

Versions: 9

Compression:

Stored size: 1.16 KB

Contents

require File.dirname(__FILE__) + "/../spec_helper"

describe IMW::Metadata do

  describe "initalizing" do

    it "should accept a hash" do
      IMW::Metadata.new('a' => ['a', 'b']).should == { 'a' => [{:name => 'a'}, {:name => 'b'}] }
    end
  end

  describe 'loading' do

    it "should accept a Hash in a resource" do
      data = {'a' => ['a', 'b']}
      resource = IMW.open('some_resource')
      IMW.should_receive(:open).with(resource).and_return(resource)
      resource.should_receive(:load).and_return(data)
      IMW::Metadata.load(resource).should == { 'a' => [{:name => 'a'}, {:name => 'b'}] }
    end
  end

  describe "constructing absolute URIs" do

    before { @metadata = IMW::Metadata.new }
    
    it "should return the resource given without a base" do
      @metadata.send(:absolute_uri, 'path/to/something').should == 'path/to/something'
    end

    it "should return the absolute URI with a base" do
      path = File.join(IMWTest::TMP_DIR, 'metadata.yaml')
      FileUtils.mkdir_p(path)
      @metadata.base = path
      @metadata.send(:absolute_uri, 'path/to/something').should == File.join(IMWTest::TMP_DIR, '/path/to/something')
    end
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
imw-0.2.16 spec/imw/metadata_spec.rb
imw-0.2.15 spec/imw/metadata_spec.rb
imw-0.2.14 spec/imw/metadata_spec.rb
imw-0.2.13 spec/imw/metadata_spec.rb
imw-0.2.12 spec/imw/metadata_spec.rb
imw-0.2.11 spec/imw/metadata_spec.rb
imw-0.2.10 spec/imw/metadata_spec.rb
imw-0.2.9 spec/imw/metadata_spec.rb
imw-0.2.8 spec/imw/metadata_spec.rb