1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
require 'spec_helper'
describe Behance::Client::Collections do
before(:all) do
@client = Behance::Client.new(access_token: "abc123")
end
before do
@options = { api_key: @client.access_token }
end
describe "#collections" do
context "without parameters" do
before do
stub_get("collections").with(query: @options).
to_return(body: fixture("collections.json"))
@collections = @client.collections
end
it "makes a http request" do
a_get("collections").
with(query: @options).should have_been_made
end
it "gets an collections list" do
@collections.size.should == 10
end
end
context "with parameters" do
before do
@options.merge!(q: "-FASHION")
stub_get("collections").with(query: @options).
to_return(body: fixture("collections.json"))
end
it "gets an collections list" do
@collections = @client.collections(@options).size.should == 10
end
end
end
describe "#collection" do
before do
stub_get("collections/1").with(query: @options).
to_return(body: fixture("collection.json"))
@collection = @client.collection(1)
end
it "makes a http request" do
a_get("collections/1").
with(query: @options).should have_been_made
end
it "gets a single collection" do
@collection["id"].should == 9866
end
end
describe "#collection_projects" do
context "without parameters" do
before do
stub_get("collections/1/projects").with(query: @options).
to_return(body: fixture("collection_projects.json"))
@projects = @client.collection_projects(1)
end
it "makes a http request" do
a_get("collections/1/projects").
with(query: @options).should have_been_made
end
it "gets a list of projects" do
@projects.size.should == 12
end
end
context "with parameters" do
before do
@options.stub(page: 1, time: Time.new)
stub_get("collections/1/projects").with(query: @options).
to_return(body: fixture("collection_projects.json"))
end
it "gets a list of projects" do
@projects = @client.collection_projects(1, @options).
size.should == 12
end
end
end
end
|