Sha256: 984d3892e1dc38539069c5a74b788317aeb8d882355926b0f3407022b6d08fd9

Contents?: true

Size: 771 Bytes

Versions: 3

Compression:

Stored size: 771 Bytes

Contents

require 'spec_helper'

module Test
  module Scorpion
    class Logger; end

    class Target
      include ::Scorpion::King

      feed_on do
        logger Logger, public: true
      end
    end
  end
end

describe Scorpion do
  let( :scorpion ){ Scorpion::Hunter.new }
  let( :target )  do
    Test::Scorpion::Target.new.tap do |target|
      target.instance_variable_set :@scorpion, scorpion
    end
  end

  describe "#feed" do
    it "injects attributes" do
      scorpion.feed target

      expect( target.logger ).to be_a Test::Scorpion::Logger
    end

    it "does not overwrite existing attributes" do
      logger = Test::Scorpion::Logger.new
      target.logger = logger
      scorpion.feed target

      expect( target.logger ).to be logger
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scorpion-ioc-0.3.1 spec/lib/scorpion_spec.rb
scorpion-ioc-0.3.0 spec/lib/scorpion_spec.rb
scorpion-ioc-0.2.0 spec/lib/scorpion_spec.rb