pinterest-ruby 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +7 -0
 - data/.rubocop.yml +63 -0
 - data/.travis-gemfile +17 -0
 - data/.travis.yml +12 -0
 - data/.yardopts +1 -0
 - data/CHANGELOG.md +3 -0
 - data/Gemfile +24 -0
 - data/README.md +34 -0
 - data/Rakefile +44 -0
 - data/docs/FaradayMiddleware/SafeOj.html +218 -0
 - data/docs/FaradayMiddleware.html +125 -0
 - data/docs/Pinterest/Board.html +410 -0
 - data/docs/Pinterest/Client.html +1894 -0
 - data/docs/Pinterest/Collection.html +1877 -0
 - data/docs/Pinterest/Endpoints/Authentication.html +578 -0
 - data/docs/Pinterest/Endpoints/Boards.html +1443 -0
 - data/docs/Pinterest/Endpoints/Pins.html +1296 -0
 - data/docs/Pinterest/Endpoints/Users.html +1220 -0
 - data/docs/Pinterest/Endpoints.html +127 -0
 - data/docs/Pinterest/Entity.html +473 -0
 - data/docs/Pinterest/Errors/AuthorizationError.html +158 -0
 - data/docs/Pinterest/Errors/BadRequestError.html +158 -0
 - data/docs/Pinterest/Errors/BaseError.html +487 -0
 - data/docs/Pinterest/Errors/MethodNotAllowedError.html +158 -0
 - data/docs/Pinterest/Errors/NotFoundError.html +158 -0
 - data/docs/Pinterest/Errors/NotImplementedError.html +158 -0
 - data/docs/Pinterest/Errors/PermissionsError.html +158 -0
 - data/docs/Pinterest/Errors/RateLimitError.html +158 -0
 - data/docs/Pinterest/Errors/ServerError.html +158 -0
 - data/docs/Pinterest/Errors/TimeoutError.html +158 -0
 - data/docs/Pinterest/Errors.html +377 -0
 - data/docs/Pinterest/Image.html +617 -0
 - data/docs/Pinterest/Interest.html +402 -0
 - data/docs/Pinterest/Pin.html +511 -0
 - data/docs/Pinterest/User.html +408 -0
 - data/docs/Pinterest/Version.html +187 -0
 - data/docs/Pinterest.html +130 -0
 - data/docs/_index.html +401 -0
 - data/docs/class_list.html +51 -0
 - data/docs/css/common.css +1 -0
 - data/docs/css/full_list.css +58 -0
 - data/docs/css/style.css +492 -0
 - data/docs/file.README.html +106 -0
 - data/docs/file_list.html +56 -0
 - data/docs/frames.html +17 -0
 - data/docs/index.html +106 -0
 - data/docs/js/app.js +243 -0
 - data/docs/js/full_list.js +216 -0
 - data/docs/js/jquery.js +4 -0
 - data/docs/method_list.html +643 -0
 - data/docs/top-level-namespace.html +110 -0
 - data/lib/pinterest/client.rb +146 -0
 - data/lib/pinterest/collection.rb +97 -0
 - data/lib/pinterest/endpoints/authentication.rb +99 -0
 - data/lib/pinterest/endpoints/boards.rb +193 -0
 - data/lib/pinterest/endpoints/pins.rb +187 -0
 - data/lib/pinterest/endpoints/users.rb +158 -0
 - data/lib/pinterest/errors.rb +94 -0
 - data/lib/pinterest/models/board.rb +34 -0
 - data/lib/pinterest/models/entity.rb +42 -0
 - data/lib/pinterest/models/image.rb +49 -0
 - data/lib/pinterest/models/interest.rb +30 -0
 - data/lib/pinterest/models/pin.rb +43 -0
 - data/lib/pinterest/models/user.rb +33 -0
 - data/lib/pinterest/safe_oj.rb +25 -0
 - data/lib/pinterest/version.rb +23 -0
 - data/lib/pinterest.rb +31 -0
 - data/pinterest.gemspec +32 -0
 - data/spec/cassettes/Pinterest_Client/_perform_network_request_private_/should_correctly_handle_malformed_requests.yml +51 -0
 - data/spec/cassettes/Pinterest_Endpoints_Authentication/_fetch_access_token/should_make_the_call_to_Pinterest_and_return_the_authorization_token_also_saving_it.yml +58 -0
 - data/spec/cassettes/Pinterest_Endpoints_Authentication/_verify_access_token/should_return_an_exception_when_using_an_invalid_token.yml +52 -0
 - data/spec/cassettes/Pinterest_Endpoints_Authentication/_verify_access_token/should_verify_the_token.yml +59 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_board/should_complain_for_invalid_boards.yml +48 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_board/should_get_the_current_informations.yml +63 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_board/should_restrict_to_requested_fields.yml +57 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_boards/should_only_get_requested_fields.yml +57 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_boards/should_return_a_list_of_boards.yml +74 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_create_board/should_create_the_board_and_return_it_with_only_the_requested_fields.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_delete_board/should_perform_the_call_and_return_an_error.yml +48 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_delete_board/should_perform_the_call_and_return_true.yml +109 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_edit_board/should_edit_the_board_and_return_it_with_only_the_requested_fields.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_follow_board/should_complain_for_invalid_boards.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_follow_board/should_perform_the_call_and_return_true.yml +109 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_following_boards/should_only_get_requested_fields.yml +59 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_following_boards/should_paginate_correctly.yml +72 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_following_boards/should_return_the_followed_boards.yml +72 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_search_my_boards/should_only_get_requested_fields.yml +59 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_search_my_boards/should_paginate_correctly.yml +66 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_search_my_boards/should_search_boards.yml +75 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_suggested_boards/should_return_the_suggested_boards_returning_only_the_requested_fields.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_unfollow_board/should_complain_for_invalid_boards.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Boards/_unfollow_board/should_perform_the_call_and_return_true.yml +109 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_board_pins/should_only_get_requested_fields.yml +59 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_board_pins/should_paginate_correctly.yml +85 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_board_pins/should_return_the_pins_of_the_board.yml +85 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_create_pin/should_create_a_pin_by_using_a_image_URL.yml +71 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_create_pin/should_create_a_pin_by_using_a_image_file.yml +1997 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_create_pin/should_return_a_pin_containing_only_requested_fields.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_delete_pin/should_perform_the_call_and_return_an_error.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_delete_pin/should_perform_the_call_and_return_true.yml +109 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_edit_pin/should_edit_the_pin_and_return_it_with_only_the_requested_fields.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_likes/should_only_get_requested_fields.yml +58 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_likes/should_paginate_correctly.yml +87 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_likes/should_return_the_list_of_liked_pins.yml +85 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_pin/should_complain_for_non_existent_pins.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_pin/should_get_the_current_informations.yml +71 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_pin/should_restrict_to_requested_fields.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_pins/should_only_get_requested_fields.yml +59 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_pins/should_paginate_correctly.yml +808 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_pins/should_return_my_pins.yml +88 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_search_my_pins/should_only_get_requested_fields.yml +61 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_search_my_pins/should_paginate_correctly.yml +89 -0
 - data/spec/cassettes/Pinterest_Endpoints_Pins/_search_my_pins/should_search_my_pins.yml +89 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_follow_interest/should_perform_the_call_and_return_an_error.yml +48 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_follow_user/should_complain_for_invalid_users.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_follow_user/should_perform_the_call_and_return_true.yml +109 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_followers/should_only_get_requested_fields.yml +62 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_followers/should_paginate_correctly.yml +62 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_followers/should_return_a_list_of_followers.yml +62 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_following_users/should_only_get_requested_fields.yml +62 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_following_users/should_paginate_correctly.yml +131 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_following_users/should_return_a_list_of_followed_users.yml +66 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_interests/should_paginate_correctly.yml +112 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_interests/should_return_a_list_of_followed_interest.yml +58 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_me/should_get_the_current_informations.yml +62 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_me/should_restrict_to_requested_fields.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_unfollow_interest/should_perform_the_call_and_return_an_error.yml +48 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_unfollow_user/should_complain_for_invalid_users.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_unfollow_user/should_perform_the_call_and_return_true.yml +109 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_user/should_complain_for_non_existent_users.yml +56 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_user/should_get_the_current_informations.yml +60 -0
 - data/spec/cassettes/Pinterest_Endpoints_Users/_user/should_restrict_to_requested_fields.yml +56 -0
 - data/spec/pinterest/client_spec.rb +70 -0
 - data/spec/pinterest/collection_spec.rb +82 -0
 - data/spec/pinterest/endpoints/authentication_spec.rb +81 -0
 - data/spec/pinterest/endpoints/boards_spec.rb +209 -0
 - data/spec/pinterest/endpoints/pins_spec.rb +239 -0
 - data/spec/pinterest/endpoints/users_spec.rb +194 -0
 - data/spec/pinterest/errors_spec.rb +59 -0
 - data/spec/pinterest/fixtures/first.jpg +0 -0
 - data/spec/pinterest/models/board_spec.rb +48 -0
 - data/spec/pinterest/models/entity_spec.rb +35 -0
 - data/spec/pinterest/models/image_spec.rb +50 -0
 - data/spec/pinterest/models/interest_spec.rb +20 -0
 - data/spec/pinterest/models/pin_spec.rb +55 -0
 - data/spec/pinterest/models/user_spec.rb +45 -0
 - data/spec/spec_helper.rb +49 -0
 - data/tester.rb +19 -0
 - metadata +341 -0
 
| 
         @@ -0,0 +1,209 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #
         
     | 
| 
      
 2 
     | 
    
         
            +
            # This file is part of the pinterest-ruby gem. Copyright (C) 2017 and above Shogun <shogun@cowtech.it>.
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
         
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            describe Pinterest::Endpoints::Boards, vcr: true do
         
     | 
| 
      
 9 
     | 
    
         
            +
              subject {
         
     | 
| 
      
 10 
     | 
    
         
            +
                Pinterest::Client.new(access_token: "AVP99QpzwII-f1I2p5gyHi8CiCeQFJkDr8dP-JpDs-LEtAAyegAAAAA")
         
     | 
| 
      
 11 
     | 
    
         
            +
              }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              context "#board" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                it "should get the current informations" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  response = subject.board("491736921752475493")
         
     | 
| 
      
 16 
     | 
    
         
            +
                  expect(response).to be_a(Pinterest::Board)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  expect(response.as_json).to eq({
         
     | 
| 
      
 19 
     | 
    
         
            +
                    counts: {"pins" => 3423, "collaborators" => 0, "followers" => 7618},
         
     | 
| 
      
 20 
     | 
    
         
            +
                    created_at: DateTime.civil(2012, 9, 15, 14, 10, 33),
         
     | 
| 
      
 21 
     | 
    
         
            +
                    creator: {
         
     | 
| 
      
 22 
     | 
    
         
            +
                      id: "491736990471948025",
         
     | 
| 
      
 23 
     | 
    
         
            +
                      username: "dderse",
         
     | 
| 
      
 24 
     | 
    
         
            +
                      first_name: "Daniel",
         
     | 
| 
      
 25 
     | 
    
         
            +
                      last_name: "Derse",
         
     | 
| 
      
 26 
     | 
    
         
            +
                      bio: "",
         
     | 
| 
      
 27 
     | 
    
         
            +
                      created_at: DateTime.civil(2012, 9, 3, 13, 21, 48),
         
     | 
| 
      
 28 
     | 
    
         
            +
                      counts: {"pins" => 23400, "following" => 691, "followers" => 13079, "boards" => 37, "likes" => 35},
         
     | 
| 
      
 29 
     | 
    
         
            +
                      image: {
         
     | 
| 
      
 30 
     | 
    
         
            +
                        "60x60" => {"url" => "https://s-media-cache-ak0.pinimg.com/avatars/dderse_1477012877_60.jpg", "width" => 60, "height" => 60}
         
     | 
| 
      
 31 
     | 
    
         
            +
                      }
         
     | 
| 
      
 32 
     | 
    
         
            +
                    },
         
     | 
| 
      
 33 
     | 
    
         
            +
                    description: "",
         
     | 
| 
      
 34 
     | 
    
         
            +
                    id: "491736921752475493",
         
     | 
| 
      
 35 
     | 
    
         
            +
                    image: {
         
     | 
| 
      
 36 
     | 
    
         
            +
                      "60x60" => {"url" => "https://s-media-cache-ak0.pinimg.com/60x60/8f/a3/01/8fa3011c924838a3afe246419486dde3.jpg", "width" => 60, "height" => 60}
         
     | 
| 
      
 37 
     | 
    
         
            +
                    },
         
     | 
| 
      
 38 
     | 
    
         
            +
                    name: "Woodworking",
         
     | 
| 
      
 39 
     | 
    
         
            +
                    url: "https://www.pinterest.com/dderse/woodworking/"
         
     | 
| 
      
 40 
     | 
    
         
            +
                  })
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                it "should restrict to requested fields" do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  response = subject.board("491736921752475493", fields: ["abc", "url"])
         
     | 
| 
      
 45 
     | 
    
         
            +
                  expect(response.url).to eq("https://www.pinterest.com/dderse/woodworking/")
         
     | 
| 
      
 46 
     | 
    
         
            +
                  expect(response.name).to be_nil
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                it "should complain for invalid boards" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                  expect { subject.board("invalid-board") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              context "#boards" do
         
     | 
| 
      
 55 
     | 
    
         
            +
                it "should return a list of boards" do
         
     | 
| 
      
 56 
     | 
    
         
            +
                  response = subject.boards
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 59 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::Board])
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  expect(response.records.first.name).to eq("9GAG")
         
     | 
| 
      
 62 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/shogunpanda/9gag/")
         
     | 
| 
      
 63 
     | 
    
         
            +
                end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                it "should only get requested fields" do
         
     | 
| 
      
 66 
     | 
    
         
            +
                  response = subject.boards(fields: ["name"])
         
     | 
| 
      
 67 
     | 
    
         
            +
                  expect(response.records.first.name).to eq("9GAG")
         
     | 
| 
      
 68 
     | 
    
         
            +
                  expect(response.records.first.url).to be_nil
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
              context "#create_board" do
         
     | 
| 
      
 73 
     | 
    
         
            +
                it "should complain when the name is missing" do
         
     | 
| 
      
 74 
     | 
    
         
            +
                  expect { subject.create_board("") }.to raise_error(ArgumentError, "You have to specify the board name.")
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                it "should create the board and return it with only the requested fields" do
         
     | 
| 
      
 78 
     | 
    
         
            +
                  response = subject.create_board("Foo", "Bar", fields: ["name"])
         
     | 
| 
      
 79 
     | 
    
         
            +
                  expect(response).to be_a(Pinterest::Board)
         
     | 
| 
      
 80 
     | 
    
         
            +
                  expect(response.name).to eq("Foo")
         
     | 
| 
      
 81 
     | 
    
         
            +
                  expect(response.creator).to be_nil
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              context "#edit_board" do
         
     | 
| 
      
 86 
     | 
    
         
            +
                it "should validate the board" do
         
     | 
| 
      
 87 
     | 
    
         
            +
                  expect { subject.edit_board(nil, name: "") }.to raise_error(ArgumentError, "You have to specify a board or its id.")
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                it "should edit the board and return it with only the requested fields" do
         
     | 
| 
      
 91 
     | 
    
         
            +
                  response = subject.edit_board("559853866116962371", description: "Baz", fields: ["description"])
         
     | 
| 
      
 92 
     | 
    
         
            +
                  expect(response).to be_a(Pinterest::Board)
         
     | 
| 
      
 93 
     | 
    
         
            +
                  expect(response.description).to eq("Baz")
         
     | 
| 
      
 94 
     | 
    
         
            +
                  expect(response.creator).to be_nil
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              context "#delete_board" do
         
     | 
| 
      
 99 
     | 
    
         
            +
                it "should validate the board" do
         
     | 
| 
      
 100 
     | 
    
         
            +
                  expect { subject.delete_board(nil) }.to raise_error(ArgumentError, "You have to specify a board or its id.")
         
     | 
| 
      
 101 
     | 
    
         
            +
                end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                it "should perform the call and return true" do
         
     | 
| 
      
 104 
     | 
    
         
            +
                  expect(subject.delete_board("559853866116962371")).to be_truthy
         
     | 
| 
      
 105 
     | 
    
         
            +
                  expect { subject.board("559853866116962371") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                it "should perform the call and return an error" do
         
     | 
| 
      
 109 
     | 
    
         
            +
                  expect { subject.delete_board("invalid-board") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 110 
     | 
    
         
            +
                end
         
     | 
| 
      
 111 
     | 
    
         
            +
              end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
              context "#search_my_boards" do
         
     | 
| 
      
 114 
     | 
    
         
            +
                it "should validate the query" do
         
     | 
| 
      
 115 
     | 
    
         
            +
                  expect { subject.search_my_boards(nil) }.to raise_error(ArgumentError, "You have to specify a query.")
         
     | 
| 
      
 116 
     | 
    
         
            +
                  expect { subject.search_my_boards(" ") }.to raise_error(ArgumentError, "You have to specify a query.")
         
     | 
| 
      
 117 
     | 
    
         
            +
                end
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                it "should search boards" do
         
     | 
| 
      
 120 
     | 
    
         
            +
                  response = subject.search_my_boards("foo", limit: 2)
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 123 
     | 
    
         
            +
                  expect(response.next_cursor).to eq("b28yfGNhZGY0ZDM1MjlhNjEwNGYzZTAxYTVjNDlkYjE4MDk2MDczNDMyNTc4ZjYyYmM3Zjg3NWU0ZjA1NDYzYTAyMmE=")
         
     | 
| 
      
 124 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::Board])
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
                  expect(response.records.first.name).to eq("Foo 3")
         
     | 
| 
      
 127 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/shogunpanda/foo-3/")
         
     | 
| 
      
 128 
     | 
    
         
            +
                end
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
                it "should paginate correctly" do
         
     | 
| 
      
 131 
     | 
    
         
            +
                  response = subject.search_my_boards("foo", limit: 2, cursor: "b28yfGNhZGY0ZDM1MjlhNjEwNGYzZTAxYTVjNDlkYjE4MDk2MDczNDMyNTc4ZjYyYmM3Zjg3NWU0ZjA1NDYzYTAyMmE=")
         
     | 
| 
      
 132 
     | 
    
         
            +
                  expect(response.records.first.name).to eq("Foo 1")
         
     | 
| 
      
 133 
     | 
    
         
            +
                  expect(response.size).to eq(1)
         
     | 
| 
      
 134 
     | 
    
         
            +
                end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                it "should only get requested fields" do
         
     | 
| 
      
 137 
     | 
    
         
            +
                  response = subject.search_my_boards("foo", limit: 2, fields: ["url"])
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                  expect(response.records.first.name).to be_nil
         
     | 
| 
      
 140 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/shogunpanda/foo-3/")
         
     | 
| 
      
 141 
     | 
    
         
            +
                end
         
     | 
| 
      
 142 
     | 
    
         
            +
              end
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
              context "#suggested_boards" do
         
     | 
| 
      
 145 
     | 
    
         
            +
                it "should return the suggested boards returning only the requested fields" do
         
     | 
| 
      
 146 
     | 
    
         
            +
                  response = subject.suggested_boards(limit: 2, fields: ["url"])
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 149 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::Board])
         
     | 
| 
      
 150 
     | 
    
         
            +
                  expect(response.records.first.name).to be_nil
         
     | 
| 
      
 151 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/shogunpanda/foo-3/")
         
     | 
| 
      
 152 
     | 
    
         
            +
                end
         
     | 
| 
      
 153 
     | 
    
         
            +
              end
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
              context "#following_boards" do
         
     | 
| 
      
 156 
     | 
    
         
            +
                it "should return the followed boards" do
         
     | 
| 
      
 157 
     | 
    
         
            +
                  response = subject.following_boards(limit: 2)
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 160 
     | 
    
         
            +
                  expect(response.next_cursor).to eq("Pz9Nakl5TlRvNE5UazVNRGMwTWpneU5ESXhPVEF5TnpvNU1qSXpNemN3TlRVeU5qTXhNRE16TnpZenw0ZjEwYWZkYWRlOGI2MjMzMzk1ZGJiYjllYjBmMWY3NzVjNTg4OTc3ODRlNWJjZTdlMTliN2UyYzQ5Njc4MWY5")
         
     | 
| 
      
 161 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::Board])
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                  expect(response.records.first.name).to eq("Drinks")
         
     | 
| 
      
 164 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/gemmorgan/drinks/")
         
     | 
| 
      
 165 
     | 
    
         
            +
                end
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
                it "should paginate correctly" do
         
     | 
| 
      
 168 
     | 
    
         
            +
                  response = subject.following_boards(limit: 2, cursor: "Pz9Nakl5TlRvNE5UazVNRGMwTWpneU5ESXhPVEF5TnpvNU1qSXpNemN3TlRVeU5qTXhNRE16TnpZenw0ZjEwYWZkYWRlOGI2MjMzMzk1ZGJiYjllYjBmMWY3NzVjNTg4OTc3ODRlNWJjZTdlMTliN2UyYzQ5Njc4MWY5")
         
     | 
| 
      
 169 
     | 
    
         
            +
                  expect(response.records.first.name).to eq("Tigers")
         
     | 
| 
      
 170 
     | 
    
         
            +
                end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                it "should only get requested fields" do
         
     | 
| 
      
 173 
     | 
    
         
            +
                  response = subject.following_boards(limit: 2, fields: ["url"])
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                  expect(response.records.first.name).to be_nil
         
     | 
| 
      
 176 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/gemmorgan/drinks/")
         
     | 
| 
      
 177 
     | 
    
         
            +
                end
         
     | 
| 
      
 178 
     | 
    
         
            +
              end
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
              context "#follow_board" do
         
     | 
| 
      
 181 
     | 
    
         
            +
                it "should validate the board" do
         
     | 
| 
      
 182 
     | 
    
         
            +
                  expect { subject.follow_board(nil) }.to raise_error(ArgumentError, "You have to specify a board or its id.")
         
     | 
| 
      
 183 
     | 
    
         
            +
                end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
                it "should perform the call and return true" do
         
     | 
| 
      
 186 
     | 
    
         
            +
                  expect(subject.follow_board("491736921752475493")).to be_truthy
         
     | 
| 
      
 187 
     | 
    
         
            +
                  expect(subject.follow_board("491736921752475493")).to be_truthy
         
     | 
| 
      
 188 
     | 
    
         
            +
                end
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                it "should complain for invalid boards" do
         
     | 
| 
      
 191 
     | 
    
         
            +
                  expect { subject.follow_board("invalid-board") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 192 
     | 
    
         
            +
                end
         
     | 
| 
      
 193 
     | 
    
         
            +
              end
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
              context "#unfollow_board" do
         
     | 
| 
      
 196 
     | 
    
         
            +
                it "should validate the board" do
         
     | 
| 
      
 197 
     | 
    
         
            +
                  expect { subject.unfollow_board(nil) }.to raise_error(ArgumentError, "You have to specify a board or its id.")
         
     | 
| 
      
 198 
     | 
    
         
            +
                end
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
                it "should perform the call and return true" do
         
     | 
| 
      
 201 
     | 
    
         
            +
                  expect(subject.unfollow_board("491736921752475493")).to be_truthy
         
     | 
| 
      
 202 
     | 
    
         
            +
                  expect(subject.unfollow_board("491736921752475493")).to be_truthy
         
     | 
| 
      
 203 
     | 
    
         
            +
                end
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
                it "should complain for invalid boards" do
         
     | 
| 
      
 206 
     | 
    
         
            +
                  expect { subject.follow_board("invalid-board") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 207 
     | 
    
         
            +
                end
         
     | 
| 
      
 208 
     | 
    
         
            +
              end
         
     | 
| 
      
 209 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,239 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #
         
     | 
| 
      
 2 
     | 
    
         
            +
            # This file is part of the pinterest-ruby gem. Copyright (C) 2017 and above Shogun <shogun@cowtech.it>.
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
         
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            describe Pinterest::Endpoints::Pins, vcr: true do
         
     | 
| 
      
 9 
     | 
    
         
            +
              subject {
         
     | 
| 
      
 10 
     | 
    
         
            +
                Pinterest::Client.new(access_token: "AVP99QpzwII-f1I2p5gyHi8CiCeQFJkDr8dP-JpDs-LEtAAyegAAAAA")
         
     | 
| 
      
 11 
     | 
    
         
            +
              }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              context "#pin" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                it "should get the current informations" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  response = subject.pin("491736853043758927")
         
     | 
| 
      
 16 
     | 
    
         
            +
                  expect(response).to be_a(Pinterest::Pin)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  expect(response.as_json).to eq({
         
     | 
| 
      
 19 
     | 
    
         
            +
                    attribution: nil,
         
     | 
| 
      
 20 
     | 
    
         
            +
                    board: {
         
     | 
| 
      
 21 
     | 
    
         
            +
                      id: "491736921752475493",
         
     | 
| 
      
 22 
     | 
    
         
            +
                      name: "Woodworking",
         
     | 
| 
      
 23 
     | 
    
         
            +
                      url: "https://www.pinterest.com/dderse/woodworking/",
         
     | 
| 
      
 24 
     | 
    
         
            +
                      description: "",
         
     | 
| 
      
 25 
     | 
    
         
            +
                      creator: {
         
     | 
| 
      
 26 
     | 
    
         
            +
                        id: "491736990471948025",
         
     | 
| 
      
 27 
     | 
    
         
            +
                        username: nil,
         
     | 
| 
      
 28 
     | 
    
         
            +
                        first_name: nil,
         
     | 
| 
      
 29 
     | 
    
         
            +
                        last_name: nil,
         
     | 
| 
      
 30 
     | 
    
         
            +
                        bio: nil,
         
     | 
| 
      
 31 
     | 
    
         
            +
                        created_at: nil,
         
     | 
| 
      
 32 
     | 
    
         
            +
                        counts: nil,
         
     | 
| 
      
 33 
     | 
    
         
            +
                        image: nil
         
     | 
| 
      
 34 
     | 
    
         
            +
                      },
         
     | 
| 
      
 35 
     | 
    
         
            +
                      created_at: DateTime.civil(2012, 9, 15, 14, 10, 33),
         
     | 
| 
      
 36 
     | 
    
         
            +
                      counts: {"pins" => 3423, "collaborators" => 0, "followers" => 7618},
         
     | 
| 
      
 37 
     | 
    
         
            +
                      image: {
         
     | 
| 
      
 38 
     | 
    
         
            +
                        "60x60" => {"url" => "https://s-media-cache-ak0.pinimg.com/60x60/8f/a3/01/8fa3011c924838a3afe246419486dde3.jpg", "width" => 60, "height" => 60}
         
     | 
| 
      
 39 
     | 
    
         
            +
                      }
         
     | 
| 
      
 40 
     | 
    
         
            +
                    },
         
     | 
| 
      
 41 
     | 
    
         
            +
                    color: "#ffffff",
         
     | 
| 
      
 42 
     | 
    
         
            +
                    counts: {"likes" => 2, "comments" => 0, "repins" => 12},
         
     | 
| 
      
 43 
     | 
    
         
            +
                    created_at: DateTime.civil(2015, 11, 13, 12, 30, 13),
         
     | 
| 
      
 44 
     | 
    
         
            +
                    creator: {
         
     | 
| 
      
 45 
     | 
    
         
            +
                      id: "491736990471948025",
         
     | 
| 
      
 46 
     | 
    
         
            +
                      username: "dderse",
         
     | 
| 
      
 47 
     | 
    
         
            +
                      first_name: "Daniel",
         
     | 
| 
      
 48 
     | 
    
         
            +
                      last_name: "Derse",
         
     | 
| 
      
 49 
     | 
    
         
            +
                      bio: "",
         
     | 
| 
      
 50 
     | 
    
         
            +
                      created_at: DateTime.civil(2012, 9, 3, 13, 21, 48),
         
     | 
| 
      
 51 
     | 
    
         
            +
                      counts: {"pins" => 23400, "following" => 691, "followers" => 13079, "boards" => 37, "likes" => 35},
         
     | 
| 
      
 52 
     | 
    
         
            +
                      image: {
         
     | 
| 
      
 53 
     | 
    
         
            +
                        "60x60" => {"url" => "https://s-media-cache-ak0.pinimg.com/avatars/dderse_1477012877_60.jpg", "width" => 60, "height" => 60}
         
     | 
| 
      
 54 
     | 
    
         
            +
                      }
         
     | 
| 
      
 55 
     | 
    
         
            +
                    },
         
     | 
| 
      
 56 
     | 
    
         
            +
                    id: "491736853043758927",
         
     | 
| 
      
 57 
     | 
    
         
            +
                    image: {
         
     | 
| 
      
 58 
     | 
    
         
            +
                      "original" => {"url" => "https://s-media-cache-ak0.pinimg.com/originals/ad/90/47/ad90475f646cb866b31a1dc5c4f754f3.jpg", "width" => 480, "height" => 1056}
         
     | 
| 
      
 59 
     | 
    
         
            +
                    },
         
     | 
| 
      
 60 
     | 
    
         
            +
                    link: "https://www.pinterest.com/r/pin/491736853043758927/4878490596204882047/cea63543062d06243202ee09a1ae786da38078b5c996f5072a58fc89618443a7",
         
     | 
| 
      
 61 
     | 
    
         
            +
                    media: {"type" => "image"},
         
     | 
| 
      
 62 
     | 
    
         
            +
                    note: "Great tip! A really easy way to figure out tricky angles when you're installing moldings, trim, and baseboards.",
         
     | 
| 
      
 63 
     | 
    
         
            +
                    url: "https://www.pinterest.com/pin/491736853043758927/",
         
     | 
| 
      
 64 
     | 
    
         
            +
                  })
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                it "should restrict to requested fields" do
         
     | 
| 
      
 68 
     | 
    
         
            +
                  response = subject.pin("491736853043758927", fields: ["color", "abc"])
         
     | 
| 
      
 69 
     | 
    
         
            +
                  expect(response.color).to eq("#ffffff")
         
     | 
| 
      
 70 
     | 
    
         
            +
                  expect(response.link).to be_nil
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                it "should complain for non existent pins" do
         
     | 
| 
      
 74 
     | 
    
         
            +
                  expect { subject.pin("invalid-pin") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              context "#create_pin" do
         
     | 
| 
      
 79 
     | 
    
         
            +
                it "should validate the board" do
         
     | 
| 
      
 80 
     | 
    
         
            +
                  expect { subject.create_pin(nil, "http://placehold.it/300x300.png") }.to raise_error(ArgumentError, "You have to specify a board or its id.")
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                it "should create a pin by using a image URL" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                  expect(subject.create_pin("shogunpanda/foo-1", "http://placehold.it/300x300.png")).to be_a(Pinterest::Pin)
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                it "should create a pin by using a image file" do
         
     | 
| 
      
 88 
     | 
    
         
            +
                  expect(subject.create_pin("shogunpanda/foo-1", __dir__ + "/../fixtures/first.jpg")).to be_a(Pinterest::Pin)
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                it "should return a pin containing only requested fields" do
         
     | 
| 
      
 92 
     | 
    
         
            +
                  response = subject.create_pin("shogunpanda/foo-1", "http://placehold.it/300x300.png", note: "NOTE", link: "http://google.it", fields: ["note"])
         
     | 
| 
      
 93 
     | 
    
         
            +
                  expect(response.note).to eq("NOTE")
         
     | 
| 
      
 94 
     | 
    
         
            +
                  expect(response.link).to be_nil
         
     | 
| 
      
 95 
     | 
    
         
            +
                  expect(response.url).to be_nil
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              context "#edit_pin" do
         
     | 
| 
      
 100 
     | 
    
         
            +
                it "should validate the pin" do
         
     | 
| 
      
 101 
     | 
    
         
            +
                  expect { subject.edit_pin(nil) }.to raise_error(ArgumentError, "You have to specify a pin or its id.")
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                it "should edit the pin and return it with only the requested fields" do
         
     | 
| 
      
 105 
     | 
    
         
            +
                  response = subject.edit_pin("559853797412741144", note: "Ok", fields: ["note"])
         
     | 
| 
      
 106 
     | 
    
         
            +
                  expect(response.note).to eq("Ok")
         
     | 
| 
      
 107 
     | 
    
         
            +
                  expect(response.link).to be_nil
         
     | 
| 
      
 108 
     | 
    
         
            +
                  expect(response.url).to be_nil
         
     | 
| 
      
 109 
     | 
    
         
            +
                end
         
     | 
| 
      
 110 
     | 
    
         
            +
              end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
              context "#delete_pin" do
         
     | 
| 
      
 113 
     | 
    
         
            +
                it "should validate the pin" do
         
     | 
| 
      
 114 
     | 
    
         
            +
                  expect { subject.delete_pin(nil) }.to raise_error(ArgumentError, "You have to specify a pin or its id.")
         
     | 
| 
      
 115 
     | 
    
         
            +
                end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                it "should perform the call and return true" do
         
     | 
| 
      
 118 
     | 
    
         
            +
                  expect(subject.delete_pin("559853797412741144")).to be_truthy
         
     | 
| 
      
 119 
     | 
    
         
            +
                  expect { subject.delete_pin("559853797412741144") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 120 
     | 
    
         
            +
                end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                it "should perform the call and return an error" do
         
     | 
| 
      
 123 
     | 
    
         
            +
                  expect { subject.delete_pin("invalid-pin") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 124 
     | 
    
         
            +
                end
         
     | 
| 
      
 125 
     | 
    
         
            +
              end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
              context "#pins" do
         
     | 
| 
      
 128 
     | 
    
         
            +
                it "should return my pins" do
         
     | 
| 
      
 129 
     | 
    
         
            +
                  response = subject.pins(limit: 2)
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 132 
     | 
    
         
            +
                  expect(response.next_cursor).to eq("LT41NTk4NTM3OTc0MTI3NDExNTc6MnxhYzA2ZDAwYjI4NDhjNTVhMDMxMDU5NWNlODFmOTg5MzIzZmVlNmQ1MDdiZjIxNjY0NDgwYjVkZWZkYjEwNTg3")
         
     | 
| 
      
 133 
     | 
    
         
            +
                  expect(response.size).to eq(2)
         
     | 
| 
      
 134 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::Pin])
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                  expect(response.records.first.note).to eq("NOTE")
         
     | 
| 
      
 137 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/559853797412741158/")
         
     | 
| 
      
 138 
     | 
    
         
            +
                end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
                it "should paginate correctly" do
         
     | 
| 
      
 141 
     | 
    
         
            +
                  response = subject.pins(limit: 50, cursor: "LT41NTk4NTM3OTc0MTI3NDExNTc6MnxhYzA2ZDAwYjI4NDhjNTVhMDMxMDU5NWNlODFmOTg5MzIzZmVlNmQ1MDdiZjIxNjY0NDgwYjVkZWZkYjEwNTg3")
         
     | 
| 
      
 142 
     | 
    
         
            +
                  expect(response.records.first.note).to eq(" ")
         
     | 
| 
      
 143 
     | 
    
         
            +
                  expect(response.size).to eq(47)
         
     | 
| 
      
 144 
     | 
    
         
            +
                end
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
                it "should only get requested fields" do
         
     | 
| 
      
 147 
     | 
    
         
            +
                  response = subject.pins(limit: 2, fields: ["url"])
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
                  expect(response.records.first.note).to be_nil
         
     | 
| 
      
 150 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/559853797412741158/")
         
     | 
| 
      
 151 
     | 
    
         
            +
                end
         
     | 
| 
      
 152 
     | 
    
         
            +
              end
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
              context "#search_my_pins" do
         
     | 
| 
      
 155 
     | 
    
         
            +
                it "should validate the query" do
         
     | 
| 
      
 156 
     | 
    
         
            +
                  expect { subject.search_my_pins(nil) }.to raise_error(ArgumentError, "You have to specify a query.")
         
     | 
| 
      
 157 
     | 
    
         
            +
                  expect { subject.search_my_pins(" ") }.to raise_error(ArgumentError, "You have to specify a query.")
         
     | 
| 
      
 158 
     | 
    
         
            +
                end
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                it "should search my pins" do
         
     | 
| 
      
 161 
     | 
    
         
            +
                  response = subject.search_my_pins("kitten", limit: 2)
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 164 
     | 
    
         
            +
                  expect(response.next_cursor).to eq("b28yfGNhZGY0ZDM1MjlhNjEwNGYzZTAxYTVjNDlkYjE4MDk2MDczNDMyNTc4ZjYyYmM3Zjg3NWU0ZjA1NDYzYTAyMmE=")
         
     | 
| 
      
 165 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::Pin])
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
                  expect(response.records.first.note).to eq("Kitten streching")
         
     | 
| 
      
 168 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/559853797412741184/")
         
     | 
| 
      
 169 
     | 
    
         
            +
                end
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
                it "should paginate correctly" do
         
     | 
| 
      
 172 
     | 
    
         
            +
                  response = subject.search_my_pins("kitten", limit: 50, cursor: "b28yfGNhZGY0ZDM1MjlhNjEwNGYzZTAxYTVjNDlkYjE4MDk2MDczNDMyNTc4ZjYyYmM3Zjg3NWU0ZjA1NDYzYTAyMmE=")
         
     | 
| 
      
 173 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/559853797398871450/")
         
     | 
| 
      
 174 
     | 
    
         
            +
                  expect(response.size).to eq(2)
         
     | 
| 
      
 175 
     | 
    
         
            +
                end
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
                it "should only get requested fields" do
         
     | 
| 
      
 178 
     | 
    
         
            +
                  response = subject.search_my_pins("kitten", limit: 50, fields: ["url"])
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                  expect(response.records.first.note).to be_nil
         
     | 
| 
      
 181 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/559853797412741184/")
         
     | 
| 
      
 182 
     | 
    
         
            +
                end
         
     | 
| 
      
 183 
     | 
    
         
            +
              end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
              context "#board_pins" do
         
     | 
| 
      
 186 
     | 
    
         
            +
                it "should validate the board" do
         
     | 
| 
      
 187 
     | 
    
         
            +
                  expect { subject.board_pins(nil) }.to raise_error(ArgumentError, "You have to specify a board or its id.")
         
     | 
| 
      
 188 
     | 
    
         
            +
                end
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                it "should return the pins of the board" do
         
     | 
| 
      
 191 
     | 
    
         
            +
                  response = subject.board_pins("491736921752475493", limit: 2)
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 194 
     | 
    
         
            +
                  expect(response.next_cursor).to eq("LT40OTE3MzY4NTMwNDk4MzYwNTE6Mnw5ZTRiNmEyOGM5MDMwY2U5MmRkMTNmOWIyMDQyYTIzMjU5NTA2YzAzNTgzY2EwNzlhODBiMzNhOGQwNzg1NTNj")
         
     | 
| 
      
 195 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::Pin])
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
                  expect(response.records.first.note).to eq("Wooden pallet Shamrock by DoodlesbyDiana on Etsy")
         
     | 
| 
      
 198 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/491736853049887002/")
         
     | 
| 
      
 199 
     | 
    
         
            +
                end
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
                it "should paginate correctly" do
         
     | 
| 
      
 202 
     | 
    
         
            +
                  response = subject.board_pins("491736921752475493", limit: 2, cursor: "LT40OTE3MzY4NTMwNDk4MzYwNTE6Mnw5ZTRiNmEyOGM5MDMwY2U5MmRkMTNmOWIyMDQyYTIzMjU5NTA2YzAzNTgzY2EwNzlhODBiMzNhOGQwNzg1NTNj")
         
     | 
| 
      
 203 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/491736853049727534/")
         
     | 
| 
      
 204 
     | 
    
         
            +
                end
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
                it "should only get requested fields" do
         
     | 
| 
      
 207 
     | 
    
         
            +
                  response = subject.board_pins("491736921752475493", limit: 2, fields: ["url"])
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
                  expect(response.records.first.note).to be_nil
         
     | 
| 
      
 210 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/491736853049887002/")
         
     | 
| 
      
 211 
     | 
    
         
            +
                end
         
     | 
| 
      
 212 
     | 
    
         
            +
              end
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
              context "#likes" do
         
     | 
| 
      
 215 
     | 
    
         
            +
                it "should return the list of liked pins" do
         
     | 
| 
      
 216 
     | 
    
         
            +
                  response = subject.likes(limit: 2)
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 219 
     | 
    
         
            +
                  expect(response.next_cursor).to eq("LT41MjcyNzMwNjg4NTkwMDQwMTA6MnxmYWJkMDlhOGI4MmQ3ZTJmNGZhM2ZjMTQ2Y2UwOTdkZTI2ZTA1NmRjYzZhZWQ3NTJlODFhNjBmNThhYzEwNjkw")
         
     | 
| 
      
 220 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::Pin])
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
                  expect(response.records.first.note).to eq("best-kitten-names-1.jpg (680×411)")
         
     | 
| 
      
 223 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/414049759476182583/")
         
     | 
| 
      
 224 
     | 
    
         
            +
                end
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
                it "should paginate correctly" do
         
     | 
| 
      
 227 
     | 
    
         
            +
                  response = subject.likes(limit: 2, cursor: "LT41MjcyNzMwNjg4NTkwMDQwMTA6MnxmYWJkMDlhOGI4MmQ3ZTJmNGZhM2ZjMTQ2Y2UwOTdkZTI2ZTA1NmRjYzZhZWQ3NTJlODFhNjBmNThhYzEwNjkw")
         
     | 
| 
      
 228 
     | 
    
         
            +
                  expect(response.size).to eq(2)
         
     | 
| 
      
 229 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/115052965460744443/")
         
     | 
| 
      
 230 
     | 
    
         
            +
                end
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
      
 232 
     | 
    
         
            +
                it "should only get requested fields" do
         
     | 
| 
      
 233 
     | 
    
         
            +
                  response = subject.likes(limit: 1, fields: ["url"])
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
                  expect(response.records.first.note).to be_nil
         
     | 
| 
      
 236 
     | 
    
         
            +
                  expect(response.records.first.url).to eq("https://www.pinterest.com/pin/414049759476182583/")
         
     | 
| 
      
 237 
     | 
    
         
            +
                end
         
     | 
| 
      
 238 
     | 
    
         
            +
              end
         
     | 
| 
      
 239 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,194 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #
         
     | 
| 
      
 2 
     | 
    
         
            +
            # This file is part of the pinterest-ruby gem. Copyright (C) 2017 and above Shogun <shogun@cowtech.it>.
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
         
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            describe Pinterest::Endpoints::Users, vcr: true do
         
     | 
| 
      
 9 
     | 
    
         
            +
              subject {
         
     | 
| 
      
 10 
     | 
    
         
            +
                Pinterest::Client.new(access_token: "AVP99QpzwII-f1I2p5gyHi8CiCeQFJkDr8dP-JpDs-LEtAAyegAAAAA")
         
     | 
| 
      
 11 
     | 
    
         
            +
              }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              context "#me" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                it "should get the current informations" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  response = subject.me
         
     | 
| 
      
 16 
     | 
    
         
            +
                  expect(response).to be_a(Pinterest::User)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  expect(response.as_json).to eq({
         
     | 
| 
      
 19 
     | 
    
         
            +
                    id: "559853934835925315",
         
     | 
| 
      
 20 
     | 
    
         
            +
                    username: "shogunpanda",
         
     | 
| 
      
 21 
     | 
    
         
            +
                    first_name: "Paolo",
         
     | 
| 
      
 22 
     | 
    
         
            +
                    last_name: "Insogna",
         
     | 
| 
      
 23 
     | 
    
         
            +
                    bio: "Senior developer in Ruby on Rails, jQuery, HTML5, CSS3, BootStrap, Backbone.JS and others. LARV addicted and nerd on many things. From Molise, Italy.",
         
     | 
| 
      
 24 
     | 
    
         
            +
                    created_at: DateTime.civil(2012, 8, 12, 6, 28, 34),
         
     | 
| 
      
 25 
     | 
    
         
            +
                    counts: {"pins" => 46, "following" => 8, "followers" => 9, "boards" => 2, "likes" => 1},
         
     | 
| 
      
 26 
     | 
    
         
            +
                    image: {
         
     | 
| 
      
 27 
     | 
    
         
            +
                      "60x60" => {"url" => "https://s-media-cache-ak0.pinimg.com/avatars/shogunpanda_1344752914_60.jpg", "width" => 60, "height" => 60
         
     | 
| 
      
 28 
     | 
    
         
            +
                      }
         
     | 
| 
      
 29 
     | 
    
         
            +
                    }
         
     | 
| 
      
 30 
     | 
    
         
            +
                  })
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                it "should restrict to requested fields" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  response = subject.me(fields: ["username", "abc"])
         
     | 
| 
      
 35 
     | 
    
         
            +
                  expect(response.username).to eq("shogunpanda")
         
     | 
| 
      
 36 
     | 
    
         
            +
                  expect(response.first_name).to be_nil
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              context "#user" do
         
     | 
| 
      
 41 
     | 
    
         
            +
                it "should get the current informations" do
         
     | 
| 
      
 42 
     | 
    
         
            +
                  response = subject.user("testerfb11")
         
     | 
| 
      
 43 
     | 
    
         
            +
                  expect(response).to be_a(Pinterest::User)
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  expect(response.as_json).to eq({
         
     | 
| 
      
 46 
     | 
    
         
            +
                    id: "332914734862997577",
         
     | 
| 
      
 47 
     | 
    
         
            +
                    username: "testerfb11",
         
     | 
| 
      
 48 
     | 
    
         
            +
                    first_name: "Tester",
         
     | 
| 
      
 49 
     | 
    
         
            +
                    last_name: "tes",
         
     | 
| 
      
 50 
     | 
    
         
            +
                    bio: "",
         
     | 
| 
      
 51 
     | 
    
         
            +
                    created_at: DateTime.civil(2014, 10, 10, 18, 52, 41),
         
     | 
| 
      
 52 
     | 
    
         
            +
                    counts: {"pins" => 1835, "following" => 2, "followers" => 6, "boards" => 18, "likes" => 9},
         
     | 
| 
      
 53 
     | 
    
         
            +
                    image: {
         
     | 
| 
      
 54 
     | 
    
         
            +
                      "60x60" => {"url" => "https://s.pinimg.com/images/user/default_60.png", "width" => 60, "height" => 60
         
     | 
| 
      
 55 
     | 
    
         
            +
                      }
         
     | 
| 
      
 56 
     | 
    
         
            +
                    }
         
     | 
| 
      
 57 
     | 
    
         
            +
                  })
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                it "should restrict to requested fields" do
         
     | 
| 
      
 61 
     | 
    
         
            +
                  response = subject.user("testerfb11", fields: ["username", "abc"])
         
     | 
| 
      
 62 
     | 
    
         
            +
                  expect(response.username).to eq("testerfb11")
         
     | 
| 
      
 63 
     | 
    
         
            +
                  expect(response.first_name).to be_nil
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                it "should complain for non existent users" do
         
     | 
| 
      
 67 
     | 
    
         
            +
                  expect { subject.user("invalid-user") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              context "#followers" do
         
     | 
| 
      
 72 
     | 
    
         
            +
                it "should return a list of followers" do
         
     | 
| 
      
 73 
     | 
    
         
            +
                  response = subject.followers(limit: 1)
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 76 
     | 
    
         
            +
                  expect(response.next_cursor).to eq("Pz9Nakl5TXpvek16STNOek01T1Rjek56UTJOVEV6TVRRNk9USXlNek0zTWpBek5UUXpNak00T1RneE9GOUZ8NjY4OTYzMGIyMmVhNTVjYjliMzY2NmY1YWVmMWQxODU5MDlhMjk4MjdlYWJmMDc4MTk3NWEzZWM1NWVmMGI4NQ==")
         
     | 
| 
      
 77 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::User])
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                  expect(response.records.first.username).to eq("ges_si")
         
     | 
| 
      
 80 
     | 
    
         
            +
                  expect(response.records.first.first_name).to eq("Gessica")
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                it "should paginate correctly" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                  response = subject.followers(limit: 1, cursor: "Pz9Nakl5TXpvME9UUTVNRE0xT0RNNU5UazVPREU1TlRrNk9USXlNek0zTURVNE5EZ3hOamcwT0RVeE9WOUZ8ZTQ5MDlkYTI3YTQ1N2Y5NWZiMzQ5YTVjNWI4MjAzZmM5NTBlZWNiNDFiNGI5NmMyMGQyZDdmMzA0MjNhODg1Ng==")
         
     | 
| 
      
 85 
     | 
    
         
            +
                  expect(response.records.first.username).to eq("ges_si")
         
     | 
| 
      
 86 
     | 
    
         
            +
                  expect(response.next?).to be_truthy
         
     | 
| 
      
 87 
     | 
    
         
            +
                end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                it "should only get requested fields" do
         
     | 
| 
      
 90 
     | 
    
         
            +
                  response = subject.followers(fields: ["username"])
         
     | 
| 
      
 91 
     | 
    
         
            +
                  expect(response.records.first.username).to eq("ges_si")
         
     | 
| 
      
 92 
     | 
    
         
            +
                  expect(response.records.first.first_name).to be_nil
         
     | 
| 
      
 93 
     | 
    
         
            +
                end
         
     | 
| 
      
 94 
     | 
    
         
            +
              end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
              context "#following_users" do
         
     | 
| 
      
 97 
     | 
    
         
            +
                it "should return a list of followed users" do
         
     | 
| 
      
 98 
     | 
    
         
            +
                  response = subject.following_users(limit: 2)
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 101 
     | 
    
         
            +
                  expect(response.next_cursor).to eq("Pz9Nakl5TXpvMk9EQTBOamM0TVRjM09ESXpOVFl4TnpvNU1qSXpNemN5TURNMU5EYzJOakUxTWpZNVgwVT18ZmY3MzQyMTMyNWI2ZGVjZTIyODZmZjI2ZGJmMGNjZDEzNWVlZjM2MGRkOWY4ZDQ5YmM2YjdiMzViNTk4MWEyMg==")
         
     | 
| 
      
 102 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::User])
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                  expect(response.records.first.username).to eq("rajkadam")
         
     | 
| 
      
 105 
     | 
    
         
            +
                  expect(response.records.first.first_name).to eq("Raj")
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                it "should paginate correctly" do
         
     | 
| 
      
 109 
     | 
    
         
            +
                  expect(subject.following_users(limit: 2).size).to eq(2)
         
     | 
| 
      
 110 
     | 
    
         
            +
                  response = subject.following_users(limit: 2, cursor: "Pz9Nakl5TXpvMk9EQTBOamM0TVRjM09ESXpOVFl4TnpvNU1qSXpNemN5TURNMU5EYzJOakUxTWpZNVgwVT18ZmY3MzQyMTMyNWI2ZGVjZTIyODZmZjI2ZGJmMGNjZDEzNWVlZjM2MGRkOWY4ZDQ5YmM2YjdiMzViNTk4MWEyMg==")
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                  expect(response.records.first.username).to eq("eileenrene11")
         
     | 
| 
      
 113 
     | 
    
         
            +
                  expect(response.size).to eq(2)
         
     | 
| 
      
 114 
     | 
    
         
            +
                  expect(response.next?).to be_truthy
         
     | 
| 
      
 115 
     | 
    
         
            +
                end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                it "should only get requested fields" do
         
     | 
| 
      
 118 
     | 
    
         
            +
                  response = subject.following_users(fields: ["username"])
         
     | 
| 
      
 119 
     | 
    
         
            +
                  expect(response.records.first.username).to eq("rajkadam")
         
     | 
| 
      
 120 
     | 
    
         
            +
                  expect(response.records.first.first_name).to be_nil
         
     | 
| 
      
 121 
     | 
    
         
            +
                end
         
     | 
| 
      
 122 
     | 
    
         
            +
              end
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
              context "#follow_user" do
         
     | 
| 
      
 125 
     | 
    
         
            +
                it "should validate the user" do
         
     | 
| 
      
 126 
     | 
    
         
            +
                  expect { subject.follow_user(nil) }.to raise_error(ArgumentError, "You have to specify a user or its id.")
         
     | 
| 
      
 127 
     | 
    
         
            +
                end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                it "should perform the call and return true" do
         
     | 
| 
      
 130 
     | 
    
         
            +
                  expect(subject.follow_user("testerfb11")).to be_truthy
         
     | 
| 
      
 131 
     | 
    
         
            +
                  expect(subject.follow_user("testerfb11")).to be_truthy
         
     | 
| 
      
 132 
     | 
    
         
            +
                end
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                it "should complain for invalid users" do
         
     | 
| 
      
 135 
     | 
    
         
            +
                  expect { subject.follow_user("invalid-user") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 136 
     | 
    
         
            +
                end
         
     | 
| 
      
 137 
     | 
    
         
            +
              end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
              context "#unfollow_user" do
         
     | 
| 
      
 140 
     | 
    
         
            +
                it "should validate the user" do
         
     | 
| 
      
 141 
     | 
    
         
            +
                  expect { subject.unfollow_user(nil) }.to raise_error(ArgumentError, "You have to specify a user or its id.")
         
     | 
| 
      
 142 
     | 
    
         
            +
                end
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
                it "should perform the call and return true" do
         
     | 
| 
      
 145 
     | 
    
         
            +
                  expect(subject.unfollow_user("testerfb11")).to be_truthy
         
     | 
| 
      
 146 
     | 
    
         
            +
                  expect(subject.unfollow_user("testerfb11")).to be_truthy
         
     | 
| 
      
 147 
     | 
    
         
            +
                end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
                it "should complain for invalid users" do
         
     | 
| 
      
 150 
     | 
    
         
            +
                  expect { subject.unfollow_user("invalid-user") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 151 
     | 
    
         
            +
                end
         
     | 
| 
      
 152 
     | 
    
         
            +
              end
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
              context "#interests" do
         
     | 
| 
      
 155 
     | 
    
         
            +
                it "should return a list of followed interest" do
         
     | 
| 
      
 156 
     | 
    
         
            +
                  response = subject.interests
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
                  expect(response).to be_a(::Pinterest::Collection)
         
     | 
| 
      
 159 
     | 
    
         
            +
                  expect(response.records.map(&:class).uniq).to eq([::Pinterest::Interest])
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                  expect(response.records.map(&:name)).to eq(["cats", "puppies", "food"])
         
     | 
| 
      
 162 
     | 
    
         
            +
                end
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
                it "should paginate correctly" do
         
     | 
| 
      
 165 
     | 
    
         
            +
                  first_page = subject.interests(limit: 2)
         
     | 
| 
      
 166 
     | 
    
         
            +
                  expect(first_page.size).to eq(2)
         
     | 
| 
      
 167 
     | 
    
         
            +
                  response = subject.interests(limit: 2, cursor: first_page.next_cursor)
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
                  expect(response.records.map(&:name)).to eq(["food"])
         
     | 
| 
      
 170 
     | 
    
         
            +
                  expect(response.size).to eq(1)
         
     | 
| 
      
 171 
     | 
    
         
            +
                  expect(response.next?).to be_falsey
         
     | 
| 
      
 172 
     | 
    
         
            +
                end
         
     | 
| 
      
 173 
     | 
    
         
            +
              end
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
              context "#follow_interest" do
         
     | 
| 
      
 176 
     | 
    
         
            +
                it "should validate the user" do
         
     | 
| 
      
 177 
     | 
    
         
            +
                  expect { subject.follow_interest(nil) }.to raise_error(ArgumentError, "You have to specify a interest or its id.")
         
     | 
| 
      
 178 
     | 
    
         
            +
                end
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                it "should perform the call and return an error" do
         
     | 
| 
      
 181 
     | 
    
         
            +
                  expect { subject.follow_interest("905661505034") }.to raise_error(::Pinterest::Errors::MethodNotAllowedError)
         
     | 
| 
      
 182 
     | 
    
         
            +
                end
         
     | 
| 
      
 183 
     | 
    
         
            +
              end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
              context "#unfollow_interest" do
         
     | 
| 
      
 186 
     | 
    
         
            +
                it "should validate the user" do
         
     | 
| 
      
 187 
     | 
    
         
            +
                  expect { subject.unfollow_interest(nil) }.to raise_error(ArgumentError, "You have to specify a interest or its id.")
         
     | 
| 
      
 188 
     | 
    
         
            +
                end
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                it "should perform the call and return an error" do
         
     | 
| 
      
 191 
     | 
    
         
            +
                  expect { subject.unfollow_interest("905661505034") }.to raise_error(::Pinterest::Errors::NotFoundError)
         
     | 
| 
      
 192 
     | 
    
         
            +
                end
         
     | 
| 
      
 193 
     | 
    
         
            +
              end
         
     | 
| 
      
 194 
     | 
    
         
            +
            end
         
     |