Sha256: 91d869139a40ece5ca2017dbabf07f018a67704f6fc27d807cfa07a607f238dd

Contents?: true

Size: 1008 Bytes

Versions: 12

Compression:

Stored size: 1008 Bytes

Contents

require 'spec_helper'
require 'ronin/mixin'

module Mixins
  module Test1
  end

  module Test2
  end
end

describe Mixin do
  subject do
    Module.new do
      include Mixin

      mixin Mixins::Test1, Mixins::Test2
      mixin { @var = 1 }
    end
  end

  context "when included" do
    before(:all) do
      @base = Class.new
      @base.send :include, subject
    end

    it "should include the mixed in modules" do
      @base.should include(Mixins::Test1)
      @base.should include(Mixins::Test2)
    end

    it "should evaluate the mixin block" do
      @base.instance_variable_get("@var").should == 1
    end
  end

  context "when extended" do
    before(:all) do
      @base = Object.new
      @base.send :extend, subject
    end

    it "should extend the mixed in modules" do
      @base.should be_kind_of(Mixins::Test1)
      @base.should be_kind_of(Mixins::Test2)
    end

    it "should evaluate the mixin block" do
      @base.instance_variable_get("@var").should == 1
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ronin-support-0.5.1 spec/mixin_spec.rb
ronin-support-0.5.0 spec/mixin_spec.rb
ronin-support-0.5.0.rc2 spec/mixin_spec.rb
ronin-support-0.5.0.rc1 spec/mixin_spec.rb
ronin-support-0.4.1 spec/mixin_spec.rb
ronin-support-0.4.0 spec/mixin_spec.rb
ronin-support-0.4.0.rc2 spec/mixin_spec.rb
ronin-support-0.4.0.rc1 spec/mixin_spec.rb
ronin-support-0.3.0 spec/mixin_spec.rb
ronin-support-0.2.0 spec/mixin_spec.rb
ronin-support-0.2.0.rc2 spec/mixin_spec.rb
ronin-support-0.2.0.rc1 spec/mixin_spec.rb