savonrb/savon — pull request #595 by dwilkie (2014-07-08 12:21:20+00:00)
Title: Nori raises error when trying to return SoapFault error message

The problem happens when `SoapFault#to_hash` fails to parse the soap message and returns `nil` instead of a hash. The `to_s` method expects `to_hash` to return a hash and fails when it returns `nil`

Here's the relevant code:

```ruby
# lib/savon/soap_fault.rb

def to_s
fault = nori.find(to_hash, 'Fault') # raises error in Nori since to_hash returns nil
message_by_version(fault)
end

def to_hash
parsed = nori.parse(@http.body)
nori.find(parsed, 'Envelope', 'Body') # returns nil
end
```

and the relevant backtrace:

```
/nori-2.4.0/lib/nori.rb:71:in `find_value': undefined method `each' for nil:NilClass (NoMethodError)
from /home/dave/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/nori-2.4.0/lib/nori.rb:37:in `find'
from /home/dave/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/savon-2.6.0/lib/savon/soap_fault.rb:22:in `to_s'
```

This should be fairly trivial to fix so I'll write a test case and submit a pull request soon.