Skip to content

Instantly share code, notes, and snippets.

@guipdutra
Created June 3, 2013 13:40
Show Gist options
  • Save guipdutra/5698205 to your computer and use it in GitHub Desktop.
Save guipdutra/5698205 to your computer and use it in GitHub Desktop.
# encoding: utf-8
require "spec_helper"
describe "API::BudgetStructure", :api do
def get_budget_structures(params={})
get api_budget_structures_url, params, { "x-unico-api-customer-secret-token" => "1234" }
end
def get_budget_structure(id)
get api_budget_structure_url(id), {}, { "x-unico-api-customer-secret-token" => "1234" }
end
def budget_structure_ids
json.collect { |budget_structure| budget_structure[:id] }
end
context "without any parameters" do
let!(:budget_structures) { [BudgetStructure.make!(:current)] }
it "responds with Ok" do
get_budget_structures
expect(response.status).to eq(200)
end
it "includes the budget_structures in the response" do
get_budget_structures
expect(budget_structure_ids).to eq(budget_structures.collect(&:id))
end
end
context "with an id as parameter" do
let!(:budget_structure) { BudgetStructure.make!(:current) }
it "responds with Ok" do
get_budget_structure(budget_structure.id)
expect(response.status).to eq(200)
end
it "includes the budget_structures in the response" do
get_budget_structure(budget_structure.id)
expect(json[:description]).to eq(budget_structure.description)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment