# 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