Sha256: 2302f2bff469ad9641369318d364a886cac8853907cd221ffe266d07f5f31465

Contents?: true

Size: 846 Bytes

Versions: 15

Compression:

Stored size: 846 Bytes

Contents

shared_examples_for "a value" do

  def dup(val)
    Kernel.eval(val.to_ruby_literal)
  end
  
  it "should implement == correctly" do
    subject.should eq(dup(subject))
  end
  
  it "should implement eql? correctly" do
    {subject => true, dup(subject) => false}.size.should eq(1)
  end
  
  it "should implement class.parse / #to_s correctly" do
    if subject.class.respond_to?(:parse) && subject.respond_to?(:to_s)
      begin
        subject.class.parse(subject.to_s).should eq(subject)
      rescue
        t1 = subject.class.parse(subject.to_s)
        t2 = subject.class.parse(subject.to_s)
        t1.should eq(t2)
      end
    end
  end
  
  it "should implement Kernel.eval / to_ruby_literal correctly" do
    if subject.respond_to?(:to_ruby_literal)
      Kernel.eval(subject.to_ruby_literal).should eq(subject)
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
myrrha-3.1.0 spec/shared/a_value.rb
myrrha-3.0.0 spec/shared/a_value.rb
myrrha-3.0.0.rc7 spec/shared/a_value.rb
myrrha-3.0.0.rc6 spec/shared/a_value.rb
myrrha-3.0.0.rc5 spec/shared/a_value.rb
myrrha-3.0.0.rc4 spec/shared/a_value.rb
myrrha-3.0.0.rc3 spec/shared/a_value.rb
myrrha-3.0.0.rc2 spec/shared/a_value.rb
myrrha-3.0.0.rc1 spec/shared/a_value.rb
myrrha-2.0.0 spec/shared/a_value.rb
myrrha-1.2.2 spec/shared/a_value.rb
myrrha-1.2.1 spec/shared/a_value.rb
myrrha-1.2.0 spec/shared/a_value.rb
myrrha-1.1.0 spec/shared/a_value.rb
myrrha-1.0.0 spec/shared/a_value.rb