Sha256: f3be0ee5928d8619163ef5cad58f93b9c1cffc14e3b99a0a2c2402b45c4a7ee9

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require "spec_helper"

describe Schematic::Generator::Sandbox do
  subject { Schematic::Generator::Sandbox.new(klass) }
  let(:klass) { Object }

  describe "ignoring elements" do
    it "should add the method to the ignored list" do
      subject.run do
        ignore :foo
      end
      subject.ignored_elements.should include(:foo)
    end

    it "accepts multiple fields" do
      subject.run do
        ignore :foo, :bar
      end
      subject.ignored_elements.should include(:foo)
      subject.ignored_elements.should include(:bar)
    end
  end

  describe "adding elements" do
    context "given a single element" do
      it "should add the method to the element list" do
        subject.run do
          element :foo
        end
        subject.added_elements.keys.should include(:foo)
      end
    end

    context "nesting elements" do
      it "should add the method to the element list" do
        subject.run do
          element :foo => { :bar => nil }
        end
        subject.added_elements[:foo].should == { :bar => nil }
      end
    end

    context "sequence of subelements" do
      it "should add the method to the element list" do
        subject.run do
          element :foo => [:bar]
        end
        subject.added_elements[:foo].should == [:bar]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
schematic-0.4.0 spec/schematic/generator/sandbox_spec.rb