Sha256: 41b37c8d797a313d5617f4060e41eca2c9bbe2687f4508f36b80b82eb502275d

Contents?: true

Size: 1.51 KB

Versions: 74

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'
require 'rake'
require 'albacore/config_dsl'

class Example
  # self.include won't work: 'private method ...'
  self.extend ::Albacore::ConfigDSL

  attr_path :out, :in

  attr_path_accessor :a, :b

  attr_path :x do |path|
    @was_called = path
  end

  attr_path_accessor :y do |val|
    @y_called = val
  end

  def out
    @out
  end
  def in
    @in
  end

  def x
    @x
  end

  # whether the block was called
  def was_called
    @was_called
  end

  def y_called
    @y_called
  end
end

describe Example, 'when setting properties' do
  before do
    subject.out = 'a/b/c'
    subject.in  = 'a\\b\\c'
    subject.a   = 'a/b/c'
    subject.b   = 'a\\b\\c'
  end
  let :expected do
    ::Rake::Win32.windows? ? 'a\\b\\c' : 'a/b/c'
  end
  it 'should have remapped :in' do
    subject.in.should eq(expected)
  end
  it 'should have remapped :out' do
    subject.out.should eq(expected)
  end
  it 'should be able to read and write :a' do
    subject.a.should eq(expected)
  end
  it 'should be able to read and write :b' do
    subject.b.should eq(expected)
  end
end

describe Example, 'when using blocks for properties' do
  before do
    subject.x = 'a/b/c'
    subject.y = 'a\\b\\c'
  end
  let :expected do
    ::Rake::Win32.windows? ? 'a\\b\\c' : 'a/b/c'
  end
  it 'should have written x' do
    subject.x.should eq(expected)
  end
  it 'should have called x block' do
    subject.was_called.should eq(expected)
  end
  it 'should have called y block' do
    subject.y_called.should eq(expected)
  end
end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
albacore-2.4.2 spec/config_dsl_spec.rb
albacore-2.4.1 spec/config_dsl_spec.rb
albacore-2.4.0 spec/config_dsl_spec.rb
albacore-2.3.22 spec/config_dsl_spec.rb
albacore-2.3.21 spec/config_dsl_spec.rb
albacore-2.3.20 spec/config_dsl_spec.rb
albacore-2.3.19 spec/config_dsl_spec.rb
albacore-2.3.18 spec/config_dsl_spec.rb
albacore-2.3.17 spec/config_dsl_spec.rb
albacore-2.3.16 spec/config_dsl_spec.rb
albacore-2.3.15 spec/config_dsl_spec.rb
albacore-2.3.14 spec/config_dsl_spec.rb
albacore-2.3.13 spec/config_dsl_spec.rb
albacore-2.3.12 spec/config_dsl_spec.rb
albacore-2.3.11 spec/config_dsl_spec.rb
albacore-2.3.10 spec/config_dsl_spec.rb
albacore-2.3.9 spec/config_dsl_spec.rb
albacore-2.3.8 spec/config_dsl_spec.rb
albacore-2.3.7 spec/config_dsl_spec.rb
albacore-2.3.6 spec/config_dsl_spec.rb