Sha256: d37d581e37382e0889ab4397db91fbff68ba096934a29a7943a5c262a0a53969

Contents?: true

Size: 1.51 KB

Versions: 16

Compression:

Stored size: 1.51 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'rouge'

describe Rouge::Metadata do
  before do
    @class = Class.new do
      include Rouge::Metadata
    end
  end

  describe "the metadata accessors" do
    it "should be present on class instances" do
      @class.new.should respond_to(:meta).with(0).arguments
      @class.new.should respond_to(:meta=).with(1).argument
    end

    it "should default to nil" do
      @class.new.meta.should be_nil
    end

    it "should return the new value when set" do
      i = @class.new
      i.meta = {:x => 4}
      i.meta.to_s.should eq({:x => 4}.to_s)
    end

    it "should not allow being set to anything other than a Hash or nil" do
      lambda {
        @class.new.meta = {:a => 1}
        @class.new.meta = {}
        @class.new.meta = {1 => 2, 3 => 4, 5 => {}}
        @class.new.meta = nil
      }.should_not raise_exception

      lambda {
        @class.new.meta = 4
      }.should raise_exception(Rouge::Metadata::InvalidMetadataError)

      lambda {
        @class.new.meta = true
      }.should raise_exception(Rouge::Metadata::InvalidMetadataError)

      lambda {
        @class.new.meta = Rouge::Symbol[:blah]
      }.should raise_exception(Rouge::Metadata::InvalidMetadataError)

      lambda {
        @class.new.meta = []
      }.should raise_exception(Rouge::Metadata::InvalidMetadataError)

      lambda {
        @class.new.meta = Rouge::Seq::Cons["what"]
      }.should raise_exception(Rouge::Metadata::InvalidMetadataError)
    end
  end
end

# vim: set sw=2 et cc=80:

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rouge-lang-0.0.16 spec/metadata_spec.rb
rouge-lang-0.0.15 spec/metadata_spec.rb
rouge-lang-0.0.14 spec/metadata_spec.rb
rouge-lang-0.0.13 spec/metadata_spec.rb
rouge-lang-0.0.12 spec/metadata_spec.rb
rouge-lang-0.0.11 spec/metadata_spec.rb
rouge-lang-0.0.10 spec/metadata_spec.rb
rouge-lang-0.0.9 spec/metadata_spec.rb
rouge-lang-0.0.8 spec/metadata_spec.rb
rouge-lang-0.0.7 spec/metadata_spec.rb
rouge-lang-0.0.6 spec/metadata_spec.rb
rouge-lang-0.0.5 spec/metadata_spec.rb
rouge-lang-0.0.4 spec/metadata_spec.rb
rouge-lang-0.0.3 spec/metadata_spec.rb
rouge-lang-0.0.2 spec/metadata_spec.rb
rouge-lang-0.0.1 spec/metadata_spec.rb