You don't have to do this but FYI.  You're using the "expect" syntax for rspec which is good.  It introduced an "allow" syntax for receive:

```
allow(Socket).to receive(:gethostname).twice.and_return('notmatching.com')
```
```