Sha256: a94479dc00e5d819a01d6f09e0f5d3556fe1fddbf4e35ae25351b4d348df3e0c

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

require "test_helper"
require "webmock/test_unit"

class ClientTest < Test::Unit::TestCase
  test "retrieve" do
    stub_request(:post, "https://getpocket.com/v3/get")
      .with(
        body: "{\"detailType\":\"complete\",\"count\":1,\"consumer_key\":null,\"access_token\":\"access_token\"}",
        headers: {
          "Content-Type" => "application/json",
          "User-Agent" => "Pocket Ruby Gem #{Pocket::VERSION}"
        }
      )
      .to_return(status: 200, body: "body response", headers: {})
    client = Pocket.client(access_token: "access_token")

    result = client.retrieve(detailType: :complete, count: 1)

    assert_equal "body response", result
  end

  test "favorite" do
    success_response = '{"action_results":[true],"status":1}'

    stub_request(:post, "https://getpocket.com/v3/send")
      .with(
        body: "{\"actions\":[{\"action\":\"favorite\",\"item_id\":\"123456\"}],\"consumer_key\":null,\"access_token\":\"access_token\"}",
        headers: {
          "Content-Type" => "application/json",
          "User-Agent" => "Pocket Ruby Gem #{Pocket::VERSION}"
        }
      )
      .to_return(status: 200, body: success_response, headers: {})
    client = Pocket.client(access_token: "access_token")

    result = client.favorite("123456")

    assert_equal success_response, result
  end

  test "unfavorite" do
    success_response = '{"action_results":[true],"status":1}'

    stub_request(:post, "https://getpocket.com/v3/send")
      .with(
        body: "{\"actions\":[{\"action\":\"unfavorite\",\"item_id\":\"123456\"}],\"consumer_key\":null,\"access_token\":\"access_token\"}",
        headers: {
          "Content-Type" => "application/json",
          "User-Agent" => "Pocket Ruby Gem #{Pocket::VERSION}"
        }
      )
      .to_return(status: 200, body: success_response, headers: {})
    client = Pocket.client(access_token: "access_token")

    result = client.unfavorite("123456")

    assert_equal success_response, result
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pocket-ruby-0.5.0 test/pocket/client_test.rb