Sha256: 05f08909b23198d2c3dba9b15968c6f7402d99d6d130b53c1e266942d52a584e

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

require 'helper'
require 'cassanity/removal'

describe Cassanity::Removal do
  describe "self named helper method" do
    it "returns instance" do
      Cassanity::Removal('foo').should eq(described_class.new('foo'))
    end
  end

  describe "#initialize" do
    context "with value" do
      before do
        @instance = described_class.new('foo')
      end

      it "sets value" do
        @instance.value.should eq(['foo'])
      end

      it "sets symbol" do
        @instance.symbol.should be(:-)
      end
    end

    context "with multiples values" do
      before do
        @instance = described_class.new('foo', 'bar')
      end

      it "sets values" do
        @instance.value.should eq(['foo', 'bar'])
      end
    end

    context "without value" do
      it "raises error" do
        expect {
          subject.value
        }.to raise_error(ArgumentError, "value cannot be nil")
      end
    end

    context "with nil" do
      it "raises error" do
        expect {
          described_class.new(nil)
        }.to raise_error(ArgumentError, "value cannot be nil")
      end
    end
  end

  shared_examples_for "removal equality" do |method_name|
    it "returns true for same class and value" do
      instance = described_class.new('foo')
      other = described_class.new('foo')
      instance.send(method_name, other).should be_true
    end

    it "returns false for same class and different value" do
      instance = described_class.new('foo')
      other = described_class.new('bar')
      instance.send(method_name, other).should be_false
    end

    it "returns false for different class" do
      instance = described_class.new('foo')
      other = Object.new
      instance.send(method_name, other).should be_false
    end
  end

  describe "#eql?" do
    include_examples "removal equality", :eql?
  end

  describe "#==" do
    include_examples "removal equality", :==
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cassanity-0.6.0 spec/unit/cassanity/removal_spec.rb