Sha256: 445b8ae81f22d48c939c5b6927e3cf4ff534cd27119aeadb264e40beef88c474

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

require File.dirname(__FILE__) + '/active_record_mock'
require File.dirname(__FILE__) + '/dummy_module'
require File.dirname(__FILE__) + '/property_column'

class Dummy < RubyLess::ActiveRecordMock
  include DummyModule
  include RubyLess

  attr_reader :name

  safe_method  [:ancestor?, Dummy]  => Boolean
  safe_method  :parent              => {:class => 'Dummy', :special_option => 'foobar'},
               :children            => ['Dummy'],
               :project             => 'Dummy',
               :image               => 'Dummy',
               :id                  => {:class => Number, :method => :zip},
               :name                => String,
               :foo                 => :bar,
               [:width, {:mode => String, :type => String, 'nice' => Boolean}] => String
  safe_context :spouse  => 'Dummy',
               :husband => {:class => 'Dummy', :context => {:clever => 'no'}}

  safe_attribute :age, :friend_id, :log_at, :format

  def initialize(name = 'dummy')
    @name = name
  end

  # Mock Property ================= [
  def self.schema; self; end
  def self.columns
    {
      'dog_name' => MockPropertyColumn.new('dog_name', nil, :string),
      'dog_age'  => MockPropertyColumn.new('dog_age', 0, :number),
    }
  end
  def prop
    {
      'dog_name' => 'Biscotte',
      'dog_age' => 6,
    }
  end
  # Mock Property ================= ]
  safe_property  :dog_name, :dog_age

  def width(opts = {})
    return 'nice!' if opts['nice']
    "mode: #{(opts[:mode] || 'none')}, type: #{(opts[:type] || 'none')}"
  end

  # This method returns pseudo-nil and does not need to be declared with :nil => true
  def project
    Dummy.new('project')
  end

  def image
    Dummy.new('image')
  end

  # This method can return nil and must be declared with :nil => true
  def spouse
    nil
  end

  def husband
    nil
  end

  def zip
    10
  end
end

class SubDummy < Dummy
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubyless-0.5.0 test/mock/dummy_class.rb