Skip to content

Instantly share code, notes, and snippets.

@gaahrdner
Created March 5, 2012 23:37

Revisions

  1. gaahrdner created this gist Mar 5, 2012.
    35 changes: 35 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    describe ApplicationsController do
    render_views
    disconnect_sunspot

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

    subject { application }

    context "JSON" do

    describe "creating a new application" do

    context "when not authorized" do
    before do
    # how do i set the content type here to JSON or XML ?
    post :create, :format => :json, { :application => { :name => "balls", :description => "balls" } }
    end

    it "should not allow creation of an application" do
    Application.count.should == 0
    end

    it "should respond with a 401" do
    response.status.should eq(401)
    end

    it "should have a status and message key in the hash" do
    JSON.parse(response.body)["status"] == "errors"
    JSON.parse(response.body)["message"] =~ /authorized/
    end
    end

    context "authorized" do
    end
    end