thoughtbot/shoulda-matchers — pull request #144 by jacobsimeon (2012-08-24 06:01:44+00:00)
Title: Allow testing a has_one relationship which uses a custom foreign_key

Allow testing a has_one relationship which uses a custom foreign_key.

Given these classes

```
class Name < ActiveRecord
end

class Person < ActiveRecord
end

class NamedPerson < Person
has_one :name, :foreign_key => :person_id
end
```

Using should-matchers as it exists now, this test will __fail__

```
describe NamedPerson
it { should have_one :name }
end
```

This pull request (should you choose to accept it) lets the developer write this __passing__ test

```
describe NamedPerson
it { should have_one(:name).with_foriegn_key(:person_id) }
end
```

I realize that an alternative to this contrived example would be to use the :as option in the has_one declaration, but checking the foreign_key option is still useful and it provides better parity with ActiveRecord relationship declaration syntax.