Sha256: 96ab7674321b83d036b78fa2070aebde1c887b898e49d52eabecc7c59d083865

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require "assert"
require "much-not-given"

module MuchNotGiven
  class UnitTests < Assert::Context
    desc "MuchNotGiven"
    subject { unit_module }

    let(:unit_module) { MuchNotGiven }

    should "inlcude MuchPlugin" do
      assert_that(unit_module).includes(MuchPlugin)
    end
  end

  class ReceiverTests < UnitTests
    desc "reciver"
    subject { receiver_class }

    let(:receiver_class) {
      Class.new do
        include MuchNotGiven
      end
    }

    let(:value1) {
      Factory.public_send(
        [:integer, :string, :float, :data, :time, :path, :boolean].sample
      )
    }

    should have_imeths :not_given, :not_given?, :given?

    should "have a not_given singleton value" do
      not_given = subject.not_given

      assert_that(not_given.blank?).is_true
      assert_that(not_given.present?).is_false
      assert_that(not_given.to_s).equals("#{subject.inspect}.not_given")
      assert_that(not_given.inspect).equals(not_given.to_s)

      assert_that(subject.not_given).is_the_same_as(not_given)
      assert_that(subject.not_given == not_given).is_true
      assert_that(value1 == not_given).is_false
    end

    should "know if values are given or not" do
      assert_that(subject.given?(value1)).is_true
      assert_that(subject.given?(subject.not_given)).is_false

      assert_that(subject.not_given?(value1)).is_false
      assert_that(subject.not_given?(subject.not_given)).is_true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
much-not-given-0.1.1 test/unit/much-not-given_tests.rb