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.2.2 test/test_parameters.rb
tracksperanto-3.2.1 test/test_parameters.rb
tracksperanto-3.2.0 test/test_parameters.rb
tracksperanto-3.1.0 test/test_parameters.rb
tracksperanto-3.0.1 test/test_parameters.rb
tracksperanto-3.0.0 test/test_parameters.rb
tracksperanto-2.12.0 test/test_parameters.rb
tracksperanto-2.11.3 test/test_parameters.rb
tracksperanto-2.11.2 test/test_parameters.rb
tracksperanto-2.11.1 test/test_parameters.rb
tracksperanto-2.11.0 test/test_parameters.rb
tracksperanto-2.10.0 test/test_parameters.rb
tracksperanto-2.9.9 test/test_parameters.rb
tracksperanto-2.9.8 test/test_parameters.rb
tracksperanto-2.9.7 test/test_parameters.rb
tracksperanto-2.9.6 test/test_parameters.rb