Degect

Dependency injection made easy

Installation

Add this line to your application's Gemfile:

gem 'degect'

And then execute:

$ bundle

Or install it yourself as:

$ gem install degect

Usage

Your Account class:

class Account
  extend Degect
  dependency(:authenticator) { RealAuthenticator.new }

  def authenticate
    authenticator.authenticate_with street_creds
  end
end

Your Account tests:

describe Account do

  it 'authenticates well' do
    fake_authenticator = FakeAuthenticator.new
    subject.authenticator = fake_authenticator

    subject.authenticate

    fake_authenticator.should be_authenticated
  end

end

Contributing

  1. Fork it
  2. Write features with tests
  3. Create new Pull Request