Sha256: bd46e064f0a85d37cd35f26e6102969c10aae539b45e93a86f3d14fd8d29e968

Contents?: true

Size: 1.06 KB

Versions: 36

Compression:

Stored size: 1.06 KB

Contents

# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__)) + '/helper'

class TestParameters < Test::Unit::TestCase
  
  def setup
    @class = Class.new do
      include Tracksperanto::Parameters
    end
  end
  
  def test_parameters_empty_by_default
    assert_equal [], @class.parameters
  end
  
  def test_parameter_initialization
    flexmock(@class).should_receive(:attr_accessor).once.with(:foo)
    @class.parameter :foo
    assert_equal 1, @class.parameters.length
    
    first_param = @class.parameters[0]
    assert_equal :foo, first_param.name
    assert_nil first_param.desc
  end

  def test_parameter_initialization_with_safety
    flexmock(@class).should_receive(:attr_accessor).once.with(:foo)
    flexmock(@class).should_receive(:safe_reader).once.with(:foo)
    @class.parameter :foo, :required => true
  end
  
  def test_parameter_initialization_with_cast
    flexmock(@class).should_receive(:attr_accessor).once.with(:foo)
    flexmock(@class).should_receive(:cast_to_junk).once.with(:foo)
    @class.parameter :foo, :cast => :junk
  end
  
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
tracksperanto-3.5.9 test/test_parameters.rb
tracksperanto-3.5.8 test/test_parameters.rb
tracksperanto-3.5.7 test/test_parameters.rb
tracksperanto-3.5.6 test/test_parameters.rb
tracksperanto-3.5.5 test/test_parameters.rb
tracksperanto-3.5.4 test/test_parameters.rb
tracksperanto-3.5.2 test/test_parameters.rb
tracksperanto-3.5.1 test/test_parameters.rb
tracksperanto-3.5.0 test/test_parameters.rb
tracksperanto-3.4.1 test/test_parameters.rb
tracksperanto-3.4.0 test/test_parameters.rb
tracksperanto-3.3.13 test/test_parameters.rb
tracksperanto-3.3.12 test/test_parameters.rb
tracksperanto-3.3.11 test/test_parameters.rb
tracksperanto-3.3.10 test/test_parameters.rb
tracksperanto-3.3.9 test/test_parameters.rb
tracksperanto-3.3.8 test/test_parameters.rb
tracksperanto-3.3.7 test/test_parameters.rb
tracksperanto-3.3.6 test/test_parameters.rb
tracksperanto-3.3.0.pre test/test_parameters.rb