简体   繁体   中英

How to test wash_out controller with Rspec

I have implemented a Rails controller with the wash_out gem.

My controller look like this:

class TestController < ApplicationController
  include WashOut::SOAP

  soap_action "int_to_string",
              :args   => :integer,
              :return => :string
  def int_to_string
    render :soap => params[:value].to_s
  end
end

routes.rb:

MyApp::Application.routes.draw do
  wash_out :test
end

I am not sure how I can test this controller with Rspec.

Any ideas?

In this link you can find a good aproach

http://blog.johnsonch.com/2013/04/18/rails-3-soap-and-testing-oh-my/

The aproach is:

  • Create a client with savonrb gem
  • compare the result in your test

you can spec the default wsdl route with something like:

 require "spec_helper"

describe MywsdlController do
  describe "routing" do

    it "mywsdl/wsdl route to mywsdl#_generate_wsdl" do 
      get("/mywsdl/wsdl").should route_to("mywsdl#_generate_wsdl")
    end

  end
end

then Id suggest to have a soap dir within spec one and a spec file per available service so you can init soap client before:each with testing params, that might give you a spec scenario.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM