spec/verifier_spec.rb in inqlude-0.0.8 vs spec/verifier_spec.rb in inqlude-0.7.0

- old
+ new

@@ -1,68 +1,99 @@ 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 - + include_context "manifest_files" + it "defines result class" do r = Verifier::Result.new - r.valid?.should be_false - r.errors.class.should == Array + expect(r.valid?).to be false + expect(r.errors.class).to be 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 + expect(verifier.verify( handler.manifest("awesomelib") ).class).to be Verifier::Result + expect(verifier.verify( handler.manifest("awesomelib") ).valid?).to be true end it "detects incomplete manifest" do verifier = Verifier.new settings manifest = Hash.new - verifier.verify( manifest ).valid?.should be_false + expect(verifier.verify( manifest ).valid?).to 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 + expect(verifier.verify(manifest).valid?).to be true manifest["invalidentry"] = "something" - verifier.verify(manifest).valid?.should be_false - verifier.verify(manifest).errors.count.should == 1 + expect(verifier.verify(manifest).valid?).to be false + expect(verifier.verify(manifest).errors.count).to eq 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 + expect(verifier.verify(manifest).valid?).to be true manifest["filename"] = "wrongname" - verifier.verify(manifest).valid?.should be_false + expect(verifier.verify(manifest).valid?).to be false end - it "verifies file" do - filename = File.join settings.manifest_path, - "awesomelib/awesomelib.2013-09-08.manifest" + it "verifies release manifest file" do + filename = File.join settings.manifest_path, awesomelib_manifest_file verifier = Verifier.new settings - expect( verifier.verify_file( filename ).valid? ).to be_true + expect( verifier.verify_file( filename ).valid? ).to be true + end + + it "verifies generic manifest file" do + filename = File.join settings.manifest_path, newlib_manifest_file + + verifier = Verifier.new settings + + verification_result = verifier.verify_file( filename ) + expect( verification_result.valid? ).to be true + end + + it "verifies proprietary release manifest file" do + filename = File.join settings.manifest_path, proprietarylib_manifest_file + + verifier = Verifier.new settings + + verification_result = verifier.verify_file( filename ) + expect( verification_result.valid? ).to be true + end + + it "verifies schema" do + manifest = Hash.new + manifest["name"] = "mylib" + manifest["release_date"] = "2013-02-28" + manifest["filename"] = "mylib.2013-02-28.manifest" + manifest["libraryname"] = "mylib" + manifest["$schema"] = "http://inqlude.org/schema/release-manifest-v1#" + manifest["schema_type"] = "release" + manifest["schema_version"] = 1 + + verifier = Verifier.new settings + + errors = verifier.verify(manifest).errors + + expect( errors.class ).to be Array + expect(errors[0]).to match /^Schema validation error/ + expect(errors.count).to eq 8 end end