thoughtbot/shoulda-matchers — pull request #536 by osamutake (2014-06-02 08:10:51+00:00)
Title: Bug fix for set_session(:key).to(nil) : it did not check anything

I noticed that when ``set_session`` is followed by ``.to(nil)``, it did not check anything.
```rb
it 'does not check anything when nil is given to "to()"' do
expect(controller_with_session({}).to set_session(:key_absent).to(nil)
expect(controller_with_session(key_present: 'here')).to set_session(:key_present).to(nil)
end
```
This was because the function ``assigned_correct_value?`` had the following lines:
```rb
if assigned_value?
if @value.nil?
true
else
assigned_value == @value
end
end
```
When ``@value`` is completely unset, i.e. ``not defined?(@value)``, this worked perfectly because ``@value.nil?==true`` stands and the test for ``assigned_value == @value`` is skipped. On the other hand, even when ``@value`` is set to ``nil`` intentionally, no additional test was made.

So, I changed the code as the following.
```rb
if assigned_value?
if not defined?(@value)
true
else
assigned_value == @value
end
end
```
Now, passing ``nil`` to ``to()`` does check that either ``nil`` or nothing is assigned to the key. (Assigning nothing is allowed by the function ``cleared_value?``.)
I also added some specs to cover more features of ``set_session``.