mizzy/serverspec — pull request #86 by wubel (2013-05-04 18:20:24+00:00)
Title: added "be_reachable" matcher for connection checks

hello,

currently im writing tests for our server infrastructure with help from serverspec. we need to check if some servers can connect to a specific ip and port. so ive implementeted a be_reachable matcher. example:

```ruby
describe "my host" do
describe "can connect" do
context "to localhost on port ssh" do
it { should be_reachable }
end
context "10.0.0.1:22" do
it { should be_reachable.with("tcp") }
end
context "with udp to 127.0.0.1:5353" do
it { should be_reachable }
end
context "connect examplehost:22" do
it { should be_reachable.with(:proto => "tcp", :timeout => 5) }
end
end
end
```

you can specifiy the settings in the context string or by parameters. you can also pass names (from /etc/services) instead of port numbers because it uses nc as command line tool.

i hope this time i have implemented all necessary tests for the matcher right.

thx :)