Created
May 6, 2015 18:42
-
-
Save jeremyf/4272657d50c4f5c7caf3 to your computer and use it in GitHub Desktop.
Dependency Injection for Sipity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Etd::Mapper | |
def initialize(work:, repository: default_repository) | |
self.work = work | |
self.repository = repository | |
end | |
def call | |
# do things | |
end | |
private | |
attr_accessor :work, :repository | |
def default_repository | |
QueryRepository.new | |
end | |
end | |
RSpec.describe Etd::Mapper do | |
let(:work) { double } | |
let(:repository) { QueryRepositoryInterface.new } | |
subject { described_class.new(work: work, repository: repository) } | |
it 'will map additional attributes' do | |
expect(repository).to receive(:work_attribute_key_value_pairs).with(work: work).and_return([['language', 'eng']]) | |
subject.call | |
end | |
end |
banurekha
commented
May 6, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment