Sha256: a6f37d2d655a11954cf1b11355e1484a33476cf8d24dba3f58ba907bfb37b990
Contents?: true
Size: 1.58 KB
Versions: 10
Compression:
Stored size: 1.58 KB
Contents
require 'helper' require 'cassanity/increment' describe Cassanity::Increment do describe "self named helper method" do it "returns instance" do Cassanity::Increment(5).should eq(described_class.new(5)) end end describe "#initialize" do context "with value" do before do @instance = described_class.new(5) end it "sets value" do @instance.value.should be(5) end it "sets symbol" do @instance.symbol.should be(:+) end end context "without value" do it "defaults value to 1" do subject.value.should be(1) 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 "increment equality" do |method_name| it "returns true for same class and value" do instance = described_class.new(5) other = described_class.new(5) instance.send(method_name, other).should be_true end it "returns false for same class and different value" do instance = described_class.new(5) other = described_class.new(7) instance.send(method_name, other).should be_false end it "returns false for different class" do instance = described_class.new(5) other = Object.new instance.send(method_name, other).should be_false end end describe "#eql?" do include_examples "increment equality", :eql? end describe "#==" do include_examples "increment equality", :== end end
Version data entries
10 entries across 10 versions & 1 rubygems