Skip to content

Instantly share code, notes, and snippets.

@seivan
Created July 12, 2011 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seivan/1077713 to your computer and use it in GitHub Desktop.
Save seivan/1077713 to your computer and use it in GitHub Desktop.
def respond_with_error(message = "Unauthorized User", error_code = :unauthorized)
Rails.logger.info "RESPONDING WITH ERROR #{message} and #{params}"
@data = {:error=> {:message => message,
:params => params},
:status => error_code }
respond_with @data, :status => @data[:status], :location => nil
#render :json => @data, :status => @data[:status], :location => nil
end
context "with invalid user parameter for existing user" do
let(:user_params) { invalid_user_params }
it { assigns(:current_user).should be_nil }
it { assigns(:data)[:error].should_not be_empty}
it {puts subject.inspect }
it { subject["error"].should_not be_empty }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment