Sha256: dcc7e4da9918128fe12eb4104c3c0276fc7329266e433cdb51e121498ec25a03

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

module Render
  describe Attribute do
    context "generators" do
      before(:each) do
        @original_generators = Render.generators.dup
        Render.stub({ live: false })
      end

      after(:each) do
        Render.generators = @original_generators
      end

      it "uses matching generator for #faux_value" do
        name = "Canada Dry"
        generator = Generator.new({ type: String, matcher: %r{.*name.*}, algorithm: proc { name } })
        Render.generators << generator

        HashAttribute.new({ name: { type: String } }).default_value.should == name
      end

      it "uses bare-boned type if no generator is found" do
        bare_boned_string = "the_attribute_name (generated)"
        HashAttribute.new({ the_attribute_name: { type: String } }).default_value.should == bare_boned_string
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
render-0.0.4 spec/functional/representation/attribute_spec.rb