Sha256: c1eecb5839844cf11f98c9b6bc20d562e47756412356e10edf9a8839f7a47798

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

module Jschematic
  module Attributes
    describe Type do
      context "string" do
        subject { Type.new("string") }
        it { should_not accept(nil) }
      end

      context "number" do
        subject { Type.new("number") }
        it { should_not accept(nil) }
        it { should accept(2112) }
      end

      context "integer" do 
        subject { Type.new("integer") }
        it { should_not accept(nil) }
      end

      context "boolean" do
        subject { Type.new("boolean") }
        it { should_not accept(nil) }
        it { should_not accept("true") }
        it { should_not accept([1,2,3]) }
      end

      context "object" do
        subject { Type.new("object") }
        it { should_not accept(nil) }
        it { should_not accept([1,2,3]) }
        it { should_not accept("string") }
      end

      context "array" do
        subject { Type.new("array") }
        it { should_not accept(nil) }
        it { should_not accept({:foo => "bar"}) }
        it { should_not accept(1234) }
      end

      context "null" do
        subject { Type.new("null") }
        it { should accept(nil) }
        it { should_not accept(true) }
        it { should_not accept("string") }
        it { should_not accept([1,2,3]) }
      end

      context "any" do
        subject { Type.new("any") }
        it { should accept(nil) }
      end

      context "union" do
        subject { Type.new(["string", "integer"]) }
        it { should_not accept(nil) }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jschematic-0.1.0 spec/jschematic/attributes/type_spec.rb
jschematic-0.0.9 spec/jschematic/attributes/type_spec.rb
jschematic-0.0.6 spec/jschematic/attributes/type_spec.rb
jschematic-0.0.5 spec/jschematic/attributes/type_spec.rb
jschematic-0.0.2 spec/jschematic/attributes/type_spec.rb
jschematic-0.0.1 spec/jschematic/attributes/type_spec.rb