Skip to content

Instantly share code, notes, and snippets.

@zspencer
Created July 25, 2011 22:49
Show Gist options
  • Save zspencer/1105462 to your computer and use it in GitHub Desktop.
Save zspencer/1105462 to your computer and use it in GitHub Desktop.
# I want to inject a dependency, but I don't want to pass it in the constructor....
# Basically testing around it was getting fairly bulky and ungainly, so I extracted the functionality
module ThatHadTooMuchComplexityInItsConstructor
def initialize(stuff)
@stuff = stuff
a = ThatBetterConformsToSRP.new
b = a.yea_do_your_thing stuff
end
end
class ThatBetterConformsToSRP
end
describe ThatHadTooMuchCOmplexityInItsConstructor
context "All the stuff that was extracted into the new class"
end
context "the classes current responsibility"
end
end
# I want to inject a dependency, but I don't want to pass it in the constructor....
module ThatHadTooMuchComplexityInItsConstructor
def initialize(stuff)
@stuff = stuff
a = ThatBetterConformsToSRP.new
b = a.yea_do_your_thing(@stuff)
end
end
module ThatBetterConformsToSRP
end
describe ThatHadTooMuchComplexityInItsConstructor
context "ahhh, only the stuff this class does! isolation FTW!"
end
end
describe ThatBetterConformsToSRP
context "actually is more appropriate now"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment