File: wips_spec.rb

package info (click to toggle)
ruby-behance 0.6.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,344 kB
  • sloc: ruby: 715; makefile: 4
file content (107 lines) | stat: -rw-r--r-- 2,569 bytes parent folder | download
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
require 'spec_helper'

describe Behance::Client::Wips do

  before(:all) do
    @client = Behance::Client.new(access_token: "abc123")
  end

  before do
    @options = { api_key: @client.access_token }
  end

  describe "#wips" do
    context "without parameters" do
      before do
        stub_get("wips").with(query: @options).
          to_return(body: fixture("wips.json"))
        @wips = @client.wips
      end

      it "makes a http request" do
        a_get("wips").with(query: @options).should have_been_made
      end

      it "gets a list of wips" do
        @wips.size.should == 12
      end
    end

    context "with parameters" do
      before do
        @options.merge!(time: "today", page: 2)
        stub_get("wips").with(query: @options).
          to_return(body: fixture("wips.json"))
      end

      it "gets a list of wips" do
        @client.wips(@options).size.should == 12
      end
    end
  end

  describe "#wip" do
    before do
      stub_get("wips/69").with(query: @options).
        to_return(body: fixture("wip.json"))
      @wip = @client.wip(69)
    end

    it "should make a http request" do
      a_get("wips/69").with(query: @options).should have_been_made
    end

    it "gets a wip" do
      @wip["id"].should == 69
    end
  end

  describe "#wip_revision" do
    before do
      stub_get("wips/1/2").with(query: @options).
        to_return(body: fixture("wip_revision.json"))
      @revision = @client.wip_revision(1, 2)
    end

    it "makes a http request" do
      a_get("wips/1/2").with(query: @options).
        should have_been_made
    end

    it "gets a revision" do
      @revision["id"].should == 133
    end
  end

  describe "#wip_revision_comments" do
    context "without parameters" do
      before do
        stub_get("wips/1/2/comments").with(query: @options).
          to_return(body: fixture("wip_revision_comments.json"))
        @comments = @client.wip_revision_comments(1, 2)
      end

      it "makes a http request" do
        a_get("wips/1/2/comments").with(query: @options).
          should have_been_made
      end

      it "gets a list of comments" do
        @comments.size.should == 6
      end
    end

    context "with parameters" do
      before do
        @options.merge!(page: 2)
        stub_get("wips/1/2/comments").with(query: @options).
          to_return(body: fixture("wip_revision_comments.json"))
      end

      it "gets a list of comments" do
        @comments = @client.wip_revision_comments(1, 2, @options).size.
          should == 6
      end
    end
  end
end