Sha256: 829c3f209d0bf10f121f8d9b416a7cf644b2aa529cf9bab38e831e653a07e0fd

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

require_relative "spec_helper.rb"

include GivenFilesystemSpecHelpers

describe YSI::Engine do
  use_given_filesystem

  describe "#class_for_assertion_name" do
    it "creates VersionNumber class" do
      expect(YSI::Engine.class_for_assertion_name("version")).
        to be(YSI::Version)
    end

    it "creates ChangeLog class" do
      expect(YSI::Engine.class_for_assertion_name("change_log")).
        to be(YSI::ChangeLog)
    end
  end

  describe "#read" do
    it "reads valid configuration" do
      path = nil
      given_directory do
        path = given_file("yes_ship_it.conf")
      end

      ysi = YSI::Engine.new

      ysi.read(path)

      expect(ysi.assertions.count).to eq(2)
      expect(ysi.assertions[0].class).to eq(YSI::Version)
      expect(ysi.assertions[1].class).to eq(YSI::ChangeLog)
    end

    it "fails on configuration with unknown assertions" do
      path = nil
      given_directory do
        path = given_file("yes_ship_it.conf", from: "yes_ship_it.unknown.conf")
      end

      ysi = YSI::Engine.new

      expect {
        ysi.read(path)
      }.to raise_error YSI::Error
    end
  end

  it "runs assertions" do
    path = nil
    given_directory do
      path = given_file("yes_ship_it.conf")
    end

    ysi = YSI::Engine.new

    ysi.read(path)

    ysi.assertions.each do |a|
      expect(a).to receive(:check)
    end

    ysi.out = StringIO.new

    ysi.run
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yes_ship_it-0.0.1 spec/unit/engine_spec.rb