Sha256: f8c95cd641bcf751b902c909c47b428a04faa772c44448af2726f409e42a5e31

Contents?: true

Size: 1.59 KB

Versions: 2

Compression:

Stored size: 1.59 KB

Contents

# encoding: utf-8
require "spec_helper"

module Okei
  module Api
    module V1
      describe ResponderController do

        routes { Okei::Engine.routes }

        describe "#on_success" do

          controller(ResponderController) { def index; on_success :units; end }
          before { get :index, format: :json }

          it "sets @units" do
            expect(assigns(:units)).to eq :units
          end

          it "renders 'index'" do
            expect(response).to render_template "index"
          end

          it "responds with 200" do
            expect(response.status).to eq 200
          end
        end

        describe "#on_found" do

          controller(ResponderController) { def index; on_found :unit; end }
          before { get :index, format: :json }

          it "sets @unit" do
            expect(assigns(:unit)).to eq :unit
          end

          it "renders 'index'" do
            expect(response).to render_template "show"
          end

          it "responds with 200" do
            expect(response.status).to eq 200
          end
        end

        describe "#on_not_found" do

          controller(ResponderController) do
            def index; on_not_found :messages; end
          end
          before { get :index, format: :json }

          it "sets @messages" do
            expect(assigns(:messages)).to eq :messages
          end

          it "renders 'errors'" do
            expect(response).to render_template "errors"
          end

          it "responds with 404" do
            expect(response.status).to eq 404
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
okei-1.0.2 spec/controllers/okei/api/v1/responder_controller_spec.rb
okei-1.0.1 spec/controllers/okei/api/v1/responder_controller_spec.rb