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
|
require 'spec_helper'
describe Behance::Client::Project do
before(:all) do
@client = Behance::Client.new(access_token: "abc123")
end
before do
@options = { api_key: @client.access_token }
end
describe "#projects" do
context "without parameters" do
before do
stub_get("projects").with(query: @options).
to_return(body: fixture("projects.json"))
@projects = @client.projects
end
it "makes a http request" do
a_get("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.merge!(q: "yolo", page: 2)
stub_get("projects").with(query: @options).
to_return(body: fixture("projects.json"))
end
it "gets a list of projects" do
@client.projects(@options).size.should == 12
end
end
end
describe "#project" do
before do
stub_get("projects/4889175").with(query: @options).
to_return(body: fixture("project.json"))
@project = @client.project(4889175)
end
it "makes a http request" do
a_get("projects/4889175").
with(query: @options).should have_been_made
end
it "gets a single project" do
@project["id"].should == 4889175
end
end
describe "#project_comments" do
before do
stub_get("projects/1/comments").with(query: @options).
to_return(body: fixture("project_comments.json"))
@comments = @client.project_comments(1)
end
it "makes a http request" do
a_get("projects/1/comments").
with(query: @options).should have_been_made
end
it "gets a list of comments" do
@comments.size.should == 396
end
end
end
|