Sha256: 30f69dad853d828442de4cb08a3682071f14f007be6b06058756dcb4e2f2d1da

Contents?: true

Size: 1.86 KB

Versions: 12

Compression:

Stored size: 1.86 KB

Contents

# encoding: utf-8
require "spec_helper"

module Hexx
  describe Null do

    subject { Null }

    describe ".new" do

      it "constructs itself" do
        expect(Null.new).to eq Null
      end
    end

    describe "arbitrary method" do

      it "is defined" do
        expect(Null).to respond_to :drag_and_drop
      end

      it "yields a block" do
        test = double :test, check: nil
        expect(test).to receive :check
        Null.when_fishing { test.check }
      end

      it "returns itself" do
        expect(Null.is_an_eagle_owl?).to eq Null
      end
    end

    it "equals nil" do
      expect(Null).to eq nil
      expect(Null).to be_nil
    end

    it "equals Null" do
      expect(Null.eq? Null).to be_truthy
    end

    it "is less than any other object" do
      expect(Null).to be < -1
      expect(Null).to be < false
      expect(Null).to be < true
      expect(Null).to be < ""
    end

    it "is falsey" do
      expect(Null).to be_falsey
      expect(Null).not_to be_truthy
      expect(!Null).to eq true
    end

    describe "#to_a" do

      it "returns the empty array" do
        expect(Null.to_a).to eq []
      end
    end

    describe "#to_h" do

      it "returns the empty hash" do
        expect(Null.to_h).to eq({})
      end
    end

    describe "#to_s" do

      it "returns the empty string" do
        expect(Null.to_s).to eq ""
      end
    end

    describe "#to_i" do

      it "returns zero as an integer" do
        expect(Null.to_i).to eq 0
      end
    end

    describe "#to_f" do

      it "returns zero as a float" do
        expect(Null.to_f).to eq 0.0
      end
    end

    describe "#to_c" do

      it "returns zero as a complex" do
        expect(Null.to_c).to eq 0.to_c
      end
    end

    describe "#to_r" do

      it "returns zero as a rational" do
        expect(Null.to_r).to eq 0.to_r
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hexx-6.0.2 spec/hexx/null_spec.rb
hexx-6.0.1 spec/hexx/null_spec.rb
hexx-6.0.0 spec/hexx/null_spec.rb
hexx-5.4.0 spec/hexx/null_spec.rb
hexx-5.3.0 spec/hexx/null_spec.rb
hexx-5.2.0 spec/hexx/null_spec.rb
hexx-5.1.0 spec/hexx/null_spec.rb
hexx-5.0.0 spec/hexx/null_spec.rb
hexx-4.0.0 spec/hexx/null_spec.rb
hexx-3.2.1 spec/hexx/null_spec.rb
hexx-3.2.0 spec/hexx/null_spec.rb
hexx-3.1.0 spec/hexx/null_spec.rb