Sha256: fd399c715b4cfd132923217bec0ac3895c38e946bf92a3b614f0f64a70b6e198

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

require_relative "spec_helper"

describe YSI::Assertion do
  describe ".class_for_name" do
    it "creates VersionNumber class" do
      expect(YSI::Assertion.class_for_name("version")).
        to be(YSI::Version)
    end

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

  describe "parameters" do
    class MyAssertion < YSI::Assertion
      parameter :some_thing
      parameter :some_other_thing, "default_hello"

      def display_name
        "My Assertion"
      end

      def check
      end

      def assert
      end
    end

    it "has methods for parameter" do
      my = MyAssertion.new(YSI::Engine.new)
      my.some_thing = "hello"
      expect(my.some_thing).to eq("hello")
    end

    it "has default value for parameter" do
      my = MyAssertion.new(YSI::Engine.new)
      expect(my.some_other_thing).to eq("default_hello")
    end

    it "returns nil when parameter is not set" do
      my = MyAssertion.new(YSI::Engine.new)
      expect(my.some_thing).to be(nil)
    end

    it "reads parameter from config" do
      config = <<EOT
assertions:
  my_assertion:
    some_thing: world
EOT
      engine = YSI::Engine.new
      engine.read_config(config)
      my = engine.assertions.first

      expect(my.some_thing).to eq("world")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yes_ship_it-0.0.5 spec/unit/assertion_spec.rb
yes_ship_it-0.0.4 spec/unit/assertion_spec.rb
yes_ship_it-0.0.3 spec/unit/assertion_spec.rb