$: << '../lib' require 'geo_graf' describe GeoGraf do describe "#intersections_for" do subject(:intersections_for_input) { described_class.intersections_for(input) } let(:calculator) { double('Calculator') } let(:input) { double('Input') } let(:intersection_calculator_output) { double('Output') } before do allow(GeoGraf::IntersectionCalculator).to receive(:new).with(input).and_return(calculator) allow(calculator).to receive(:intersections).and_return(intersection_calculator_output) end it "runs intersections on a new instance of IntersectionCalculator" do expect(intersections_for_input).to eq(intersection_calculator_output) end end end