Sha256: 913aa8ff13e481b5088c77280e1b4f31f88d592611fc31409df75fdef1c83d58
Contents?: true
Size: 1.34 KB
Versions: 16
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' class Birthplace # Mock AR model attr_accessor :id, :city, :state def initialize(params={}); params.each{|k,v| self.send("#{k}=",v) if self.respond_to?(k)}; end def attributes; {:id => self.id, :city => self.city, :state => self.state}; end def reload; self; end end module MyApi class MyApi::Application < Rails::Application end class Birthplace include Faceted::Presenter presents :birthplace field :city field :state end class BirthplacesController < ActionController::Base include Faceted::Controller include Rails.application.routes.url_helpers def show @birthplace = MyApi::Birthplace.first render_response @birthplace end end end describe MyApi::BirthplacesController, :type => :controller do before do MyApi::Birthplace.stub(:first) { MyApi::Birthplace.new } MyApi::Application.routes.draw do namespace :my_api do resources :birthplaces end end end it 'renders with a 200 when the operation is successful' do MyApi::Birthplace.any_instance.stub(:success) { true } get :show, :id => 1 response.code.should == "200" end it 'renders with a 400 when the operation is unsuccessful' do MyApi::Birthplace.any_instance.stub(:success) { false } get :show, :id => 1 response.code.should == "400" end end
Version data entries
16 entries across 16 versions & 1 rubygems