Sha256: f684a984a2c4f51939e7f965128b8b1232e4fab4ade67ca34c2ebfd29c3816a6

Contents?: true

Size: 1.75 KB

Versions: 27

Compression:

Stored size: 1.75 KB

Contents

 require "spec_helper"

describe "Temperature example" do

  it "converts 30 degrees celsius to 86 degrees fahrenheit" do
    client = Savon.client do
      # The WSDL document provided by the service.
      wsdl "http://www.webservicex.net/ConvertTemperature.asmx?WSDL"

      # Needed because (up until now), Savon doesn't match XS types to Hash keys,
      # but defaults to convert Hash message Symbols (like :from_unit) to lowerCamelCase.
      # The service expects these to be CamelCase instead. Look at Savon's log output
      # and compare it with an example request generated by soapUI.
      convert_request_keys_to :camelcase

      # Lower timeouts so these specs don't take forever when the service is not available.
      open_timeout 10
      read_timeout 10

      # Disable logging for cleaner spec output.
      log false
    end

    response = call_and_fail_gracefully(client, :convert_temp) do
      # For the corrent values to pass for :from_unit and :to_unit, I searched the WSDL for
      # the "FromUnit" type which is a "TemperatureUnit" enumeration that looks like this:
      #
      # <s:simpleType name="TemperatureUnit">
      #   <s:restriction base="s:string">
      #     <s:enumeration value="degreeCelsius"/>
      #     <s:enumeration value="degreeFahrenheit"/>
      #     <s:enumeration value="degreeRankine"/>
      #     <s:enumeration value="degreeReaumur"/>
      #     <s:enumeration value="kelvin"/>
      #   </s:restriction>
      # </s:simpleType>
      #
      # Support for XS schema types needs to be improved.
      message(:temperature => 30, :from_unit => "degreeCelsius", :to_unit => "degreeFahrenheit")
    end

    fahrenheit = response.body[:convert_temp_response][:convert_temp_result]
    expect(fahrenheit).to eq("86")
  end

end

Version data entries

27 entries across 27 versions & 4 rubygems

Version Path
savon-2.12.1 spec/integration/temperature_example_spec.rb
savon-2.12.0 spec/integration/temperature_example_spec.rb
savon-2.11.2 spec/integration/temperature_example_spec.rb
savon-SU-2.11.1b spec/integration/temperature_example_spec.rb
savon-SU-2.11.1 spec/integration/temperature_example_spec.rb
savon-2.11.1 spec/integration/temperature_example_spec.rb
savon-2.11.0 spec/integration/temperature_example_spec.rb
savon-2.10.1 spec/integration/temperature_example_spec.rb
savon-2.10.0 spec/integration/temperature_example_spec.rb
savon-2.9.0 spec/integration/temperature_example_spec.rb
savon-2.8.1 spec/integration/temperature_example_spec.rb
savon-2.8.0 spec/integration/temperature_example_spec.rb
savon-2.7.2 spec/integration/temperature_example_spec.rb
savon-2.7.1 spec/integration/temperature_example_spec.rb
savon-2.7.0 spec/integration/temperature_example_spec.rb
savon-2.6.0 spec/integration/temperature_example_spec.rb
savon-2.5.1 spec/integration/temperature_example_spec.rb
savon-2.5.0 spec/integration/temperature_example_spec.rb
savon_with_adapter-2.4.1 spec/integration/temperature_example_spec.rb
savon-2.4.0 spec/integration/temperature_example_spec.rb