psyho/bogus — pull request #7 by chastell (2013-05-18 13:25:32+00:00)
Title: Keyword arguments’ defaults fixes

https://github.com/psyho/bogus/pull/4 made it possible to work with methods that take keyword arguments, but with that implementations the faked methods can’t be called with some of the arguments missing.

This takes the first step in making this possible by defaulting all kwargs to `nil` (much like all optional arguments are defaulted to `{}`). This is not a final solution, as `have_received` needs to explicitly expect a `nil`-ed default, but it’s better than what’s currently on master:

```Ruby
require 'bundler/setup'
require 'bogus/rspec'

class Registrar
def register client: raise, repos: {}
puts "registering #{client} into #{repos}"
end
end

class Handler
def handle client, registrar: Registrar.new
registrar.register client: client
end
end

describe Handler do
describe '#handle' do
it 'handles RGST inputs' do
registrar = fake :registrar
Handler.new.handle 'client', registrar: registrar
registrar.should have_received.register client: 'client', repos: nil
end
end
end
```

Note how the `repos` keyword argument is `nil` in the `have_received` call, while it’s `{}` in the actual kwarg default; still, the above spec at least passes, rather than blowing up.