Sha256: 0f082170bc68d5a3874eb2ed32839044520b881b7ab81f78f3e0a2a504de426c

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

require 'box/release/loader'

describe Box::Release::Loader do

  describe "#attributes" do

    let(:loader) { Box::Release::Loader.new("dummy") }

    it "should load attributes found in url" do
      Tempfile.open("release-loader") do |file|
        file.puts "dummy: true"
        file.close

        Box::Release::Loader.new(file.path).attributes.should == { "dummy" => true }
      end
    end

    it "should be empty if url isn't reachable" do
      loader.stub(:open).and_raise(SocketError)
      loader.attributes.should be_empty
    end

  end

  describe "#release" do

    let(:loader) { Box::Release::Loader.new("http://dummy") }
    
    it "should create a new Release with attributes" do
      loader.stub :attributes => { "checksum" => "dummy" }
      loader.release.checksum.should == "dummy"
    end

    it "should use Loader url as reference_url" do
      loader.stub :attributes => {}
      loader.release.reference_url.should == loader.url
    end

  end

  describe ".release_at" do

    let(:url) { "dummy://url" }
    let(:loaded_release) { Box::Release::Memory.new }

    it "should create a new Loader and load release" do
      Box::Release::Loader.should_receive(:new).with(url).and_return(stub(:release => loaded_release))
      Box::Release::Loader.release_at(url).should == loaded_release
    end

  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
box-release-0.0.4 spec/box/release/loader_spec.rb