Created
June 3, 2013 13:40
-
-
Save guipdutra/5698205 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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