Sha256: edb78cd8eb970da338ec5e55c50a086e5f4683d5aae6c4717b5fb0c40b7ae6f2

Contents?: true

Size: 1.63 KB

Versions: 9

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
mock_controller do
  soap_action 'dispatcher_method', args: nil, return: nil

  def dispatcher_method
    # nothing
  end
end
describe WashoutBuilder::WashoutBuilderController, type: :controller do
  routes { WashoutBuilder::Engine.routes }

  let(:soap_config) do
    OpenStruct.new(
    camelize_wsdl: false,
    namespace: '/api/wsdl'
    )
  end

  let(:washout_builder) { stub(root_url: "#{request.protocol}#{request.host_with_port}/") }
  let(:route) { stub(defaults: { controller: 'api' }) }
  let(:params) { { name: 'some_name' } }

  before(:each) do
    ApiController.stubs(:soap_config).returns(soap_config)
    controller.stubs(:washout_builder).returns(washout_builder)
  end

  it 'gets the services' do
    get :all
    expect(assigns(:services)).to eq([{ 'service_name' => 'Api', 'namespace' => '/api/wsdl', 'endpoint' => '/api/action', 'documentation_url' => '/api/soap_doc' }])
  end

  it 'renders the template' do
    get :all
    expect(response).to render_template('wash_with_html/all_services')
  end

  it 'checks it controller is a service' do
    controller.send(:find_all_routes)
    expect(controller.send(:controller_is_a_service?, 'api')).not_to eq nil
  end

  it 'render a service documentation' do
    controller.stubs(:controller_class).returns(ApiController)
    controller.stubs(:controller_is_a_service?).with(params[:name]).returns(route)
    WashoutBuilder::Document::Generator.expects(:new).with(route, route.defaults[:controller])
    if Rails::VERSION::MAJOR >= 5
      get :all, params: params
    else
      get :all, params
    end
    expect(response).to render_template 'wash_with_html/doc'
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
washout_builder-1.7.3 spec/app/controllers/washout_builder_controller_spec.rb
washout_builder-1.7.2 spec/app/controllers/washout_builder_controller_spec.rb
washout_builder-1.7.1 spec/app/controllers/washout_builder_controller_spec.rb
washout_builder-1.7.0 spec/app/controllers/washout_builder_controller_spec.rb
washout_builder-1.6.5 spec/app/controllers/washout_builder_controller_spec.rb
washout_builder-1.6.4 spec/app/controllers/washout_builder_controller_spec.rb
washout_builder-1.6.3 spec/app/controllers/washout_builder_controller_spec.rb
washout_builder-1.6.2 spec/app/controllers/washout_builder_controller_spec.rb
washout_builder-1.6.1 spec/app/controllers/washout_builder_controller_spec.rb