Sha256: e7ce0323dbc535928e24a5658cc0b070a277cca7914f9007e2d5a2f3efef3fe6

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

require File.expand_path('../spec_helper', __FILE__)

describe Verifier do

  let(:settings) do
    s = Settings.new
    s.manifest_path = File.expand_path('spec/data/')
    s.offline = true
    s
  end

  it "defines result class" do
    r = Verifier::Result.new
    r.valid?.should be_false
    r.errors.class.should == Array
  end
  
  it "verifies read manifests" do
    handler = ManifestHandler.new settings
    handler.read_remote
    
    verifier = Verifier.new settings
    verifier.verify( handler.manifest("awesomelib") ).class.should == Verifier::Result
    verifier.verify( handler.manifest("awesomelib") ).valid?.should be_true
  end

  it "detects incomplete manifest" do
    verifier = Verifier.new settings

    manifest = Hash.new
    verifier.verify( manifest ).valid?.should be_false
  end
      
  it "detects invalid entries" do
    handler = ManifestHandler.new settings
    handler.read_remote
    verifier = Verifier.new settings

    manifest = handler.manifest("awesomelib")
    verifier.verify(manifest).valid?.should be_true

    manifest["invalidentry"] = "something"
    verifier.verify(manifest).valid?.should be_false
    verifier.verify(manifest).errors.count.should == 1
  end

  it "detects name mismatch" do
    handler = ManifestHandler.new settings
    handler.read_remote
    verifier = Verifier.new settings

    manifest = handler.manifest("awesomelib")
    verifier.verify(manifest).valid?.should be_true
    
    manifest["filename"] = "wrongname"
    verifier.verify(manifest).valid?.should be_false
  end

  it "verifies file" do
    filename = File.join settings.manifest_path,
      "awesomelib/awesomelib.2013-09-08.manifest"
    
    verifier = Verifier.new settings

    expect( verifier.verify_file( filename ).valid? ).to be_true
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inqlude-0.0.8 spec/verifier_spec.rb