Sha256: f4bbfcbabef62e4c27af734de8f22340a9d8a735e62f5230ba876f078b629330

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Praxis::RequestStages::Validate do
  let(:dispatcher) { Praxis::Dispatcher.new }

  # Instances controller is defined in the 'app' folder and is already in scope. Using this
  # controller for the specs instead of creating a simple controller.
  let(:controller) { Instances }

  let(:action) { controller.definition.actions[:show] }

  let(:env) do
    e = Rack::MockRequest.env_for('/instances/1?cloud_id=1&api_version=1.0')
    e['rack.input'] = StringIO.new('something=given')
    e['HTTP_VERSION'] = 'HTTP/1.1'
    e['HTTP_HOST'] = 'rightscale'
    e
  end

  let(:request) do
    r = Praxis::Request.new(env)
    r.route_params = {id: 1}
    r.action = action
    r
  end

  context 'given a request' do
    it 'should validate params and headers from the request' do
      expect(request).to receive(:validate_headers).and_return([])
      expect(request).to receive(:validate_params).and_return([])
      dispatcher.dispatch(controller, action, request)
    end

    it 'should validate payload from the request' do
      expect(request).to receive(:validate_payload).and_return([])
      dispatcher.dispatch(controller, action, request)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
praxis-0.16.1 spec/praxis/request_stages_validate_spec.rb
praxis-0.16.0 spec/praxis/request_stages_validate_spec.rb
praxis-0.15.0 spec/praxis/request_stages_validate_spec.rb
praxis-0.14.0 spec/praxis/request_stages_validate_spec.rb