Skip to content

Commit

Permalink
Reformatted parse_response respond_to? to be consistent
Browse files Browse the repository at this point in the history
Added spec for negative case of parse_request (where no parse method exists)
  • Loading branch information
jeremydurham committed Jan 6, 2009
1 parent 3cf5b76 commit 388edc8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/service_proxy.rb
Expand Up @@ -103,7 +103,8 @@ def setup_namespace

def build_request(method, options)
builder = underscore("build_#{method}")
self.respond_to?(builder) ? self.send(builder, options).target! : soap_envelope(options).target!
self.respond_to?(builder) ? self.send(builder, options).target! :
soap_envelope(options).target!
end

def parse_response(method, response)
Expand Down
11 changes: 11 additions & 0 deletions spec/service_helper.rb
Expand Up @@ -53,4 +53,15 @@ def parse_gen_ssha(response)
xml = Hpricot.XML(response.body)
xml.at("return").inner_text
end
end

class InvalidSHAGeneratorService < ServiceProxy

def build_gen_ssha(options)
soap_envelope(options) do |xml|
xml.text(options[:text])
xml.hashtype(options[:hash_type])
end
end

end
10 changes: 10 additions & 0 deletions spec/service_proxy_spec.rb
Expand Up @@ -63,6 +63,16 @@
end
end

describe "making a service call without a parse method" do
before do
@proxy = InvalidSHAGeneratorService.new('https://sec.neurofuzz-software.com/paos/genSSHA-SOAP.php?wsdl')
end

it "should raise a no method error" do
lambda { result = @proxy.genSSHA(:text => 'hello world', :hash_type => 'sha512') }.should raise_error(NoMethodError)
end
end

describe "using the #service_port hook" do
before do
@proxy = ISBNService.new('http://webservices.daehosting.com/services/isbnservice.wso?WSDL')
Expand Down

0 comments on commit 388edc8

Please sign in to comment.