Sha256: 000e4c4e75361a225ff7f322c4aa21e0f66dee1c78ce7307267c3dc6bddd5054
Contents?: true
Size: 1.9 KB
Versions: 6
Compression:
Stored size: 1.9 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(subject.instance_variable_get(:@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(subject.instance_variable_get(:@file_to_serve)).to eq('wash_with_html/all_services') expect(response.media_type).to eq("text/html") expect(response).to have_http_status(:ok) 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(subject.instance_variable_get(:@file_to_serve)).to eq('wash_with_html/doc') expect(response.media_type).to eq("text/html") expect(response).to have_http_status(:ok) end end
Version data entries
6 entries across 6 versions & 1 rubygems