Sha256: 2370decf2780e8fcd0764ad09db8ac1b6ac85ed697ba78c37ba6576d6bf6fe06

Contents?: true

Size: 1.93 KB

Versions: 1

Compression:

Stored size: 1.93 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::SafeClass

  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,
               [:width]             => 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.4.0 test/mock/dummy_class.rb