Skip to content
This repository

Check out these resources:

In a nutshell be sure to use render_views to get tests passing:

describe ApplicationsController do
  render_views

  let(:model) { Factory.create(:model) }

  subject { model }

  context "JSON" do

    describe "creating a new model" do
      context "when not authorized" do
        it "should not allow creation of an application" do
          json = { :format => 'json', :model => { :name => "foo", :description => "bar" } }

          post :create, json

          Application.count.should == 0
          response.status.should eq(401)
          JSON.parse(response.body)["status"].should == "error"
          JSON.parse(response.body)["message"].should =~ /authorized/
        end 
      end 
    end

  end
end

This advice might only pertain to Rails. In Sinatra or Padrino, my understanding is that this wouldn't be necessary.

Something went wrong with that request. Please try again.