Skip to content

Instantly share code, notes, and snippets.

@azuby
Created November 16, 2012 08:01
Show Gist options
  • Save azuby/4085298 to your computer and use it in GitHub Desktop.
Save azuby/4085298 to your computer and use it in GitHub Desktop.
require 'spec_helper'
require_relative 'shared_examples'
describe Api::Beta::ClocksController do
let(:user) { create(:user, authentication_token: "qlnwenc") }
def self.valid_parameters
{ format: 'json', api_key: "asdlfnasldkfn",
authentication_token: user.authentication_token
}
end
%w[create].each do |action, valid_parameters|
it_should_behave_like "a resource", action, valid_attributes
end
describe "POST 'create'" do
it "returns 406 status without json format" do
post :create
response.status.should == 406
response_body = JSON.parse(response.body)
response_body["message"].should == "This request must be json."
end
it "returns 400 status without an authentication_token" do
post :create, valid_parameters.merge(authentication_token: nil)
response.status.should == 400
response_body = JSON.parse(response.body)
response_body["message"].should == "This request is missing parameters."
response_body["missing_parameters"].should include("authentication_token")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment