Sha256: 0b3576f7122ab12a33042e852b1aa36382e42a9a9607ed6a8e9ed263a0433f08

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

require "test/unit"
require File.dirname(__FILE__) + "/../lib/ventouse/module_declarations"

module SmokeExt
  declarations do
    self.class_var= "ok"
  end
end

module SecondExt
  declarations do
    self.class_var= "ok2"
  end
end

module MultipleDeclarationsModule
  declarations do
    self.class_var= "x"
  end

  declarations do
    self.class_var+= "x"
  end
end

module IncludedModule
  declarations do
    self.class_var+= "y"
  end
end

module IncludingModule
  declarations do
    self.class_var= "x"
  end

  include IncludedModule

  declarations do
    self.class_var+= "z"
  end
end

class SmokeExpandable
  def self.class_var= var
    @@class_var = var
  end
  
  def self.class_var
    @@class_var if defined? @@class_var
  end
end

class DeclarationsTest < Test::Unit::TestCase
  def test_smoke
    SmokeExpandable.send :include, SmokeExt
    assert_equal "ok", SmokeExpandable.class_var
  end

  def test_second_module
    SmokeExpandable.send :include, SmokeExt
    assert_equal "ok", SmokeExpandable.class_var

    SmokeExpandable.send :include, SecondExt
    assert_equal "ok2", SmokeExpandable.class_var
  end

  def test_multiple_declarations
    SmokeExpandable.send :include, MultipleDeclarationsModule
    assert_equal "xx", SmokeExpandable.class_var
  end

  def test_module_including
    SmokeExpandable.send :include, IncludingModule
    assert_equal "xyz", SmokeExpandable.class_var
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
programmable-ventouse-0.1.0 test/declarations_test.rb
programmable-ventouse-0.1.1 test/declarations_test.rb
programmable-ventouse-0.1.2 test/declarations_test.rb
programmable-ventouse-0.1.3 test/declarations_test.rb
programmable-ventouse-0.1.4 test/declarations_test.rb
programmable-ventouse-0.1.5 test/declarations_test.rb
ventouse-0.1.6 test/declarations_test.rb