Sha256: 95da62962d4a6c4af40f1ae260b9763b4ec39c82eb9c542caa7594a19b6c0d43

Contents?: true

Size: 833 Bytes

Versions: 9

Compression:

Stored size: 833 Bytes

Contents

require 'spec_helper'

describe Helpers::MethodBuilder do

  describe 'a builder method' do
    let :model do
      model_class = Class.new do
        extend Helpers::MethodBuilder

        builder_method :name
      end
      model_class.new
    end

    it 'should set a value' do
      model.name(:joe)
      model.name.should == :joe
    end

    it 'should chain' do
      model.name(:joe).should == model
    end

    it 'should work with booleans' do
      model.name(false)
      model.name.should == false
    end
  end


  it 'should let you define more than one builder method at a time' do
    model_class = Class.new do
      extend Helpers::MethodBuilder
      builder_methods :foo, :bar
    end
    model = model_class.new
    model.respond_to?(:foo).should be_true
    model.respond_to?(:bar).should be_true
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
mirage-3.0.12 spec/mirage/client/helpers/method_builder_spec.rb
mirage-3.0.11 spec/mirage/client/helpers/method_builder_spec.rb
mirage-3.0.10 spec/client/helpers/method_builder_spec.rb
mirage-3.0.9 spec/client/helpers/method_builder_spec.rb
mirage-on-thin-3.0.8 spec/client/helpers/method_builder_spec.rb
mirage-3.0.8 spec/client/helpers/method_builder_spec.rb
mirage-3.0.7 spec/client/helpers/method_builder_spec.rb
mirage-3.0.6 spec/client/helpers/method_builder_spec.rb
mirage-3.0.5 spec/client/helpers/method_builder_spec.rb