I have this method that I'm trying to test:
def build
return if !cookies["__utmz"] && !cookies["__utma"]
binding.pry
@data = GaCookieParser::GaCookieParser.new(
utmz: cookies["__utmz"],
utma: cookies["__utma"]
)
build_utmz
build_utma
TrafficSource.new(params)
end
This is my test:
context 'when cookies have necessary params' do
let(:cookies) { complete_cookies }
let(:complete_cookies) do
{
'__utmz' => 'something',
'__utma' => 'something'
}
end
I used a let and when I hit the binding, "cookies" does indeed return me complete_cookies.
let is only supposed to "stub" the method inside the test right whereas allow will stub the method anywhere in the actual code right?