Sha256: c3b89dd8c78ff1d76f8b345d26d3a42ff05b3c4b1be36d183c6122e78abcde35

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

require 'minitest/autorun'
require_relative './test_helper'
require 'gistdoit/github/client'

module Github
  class ClientTest < Minitest::Test
    def setup
      @gist_data = Struct.new(:gist_data) {
        def username
          'liamseanbrady'
        end

        def summary
          'This is a cool gist'
        end

        def name
          'file.rb'
        end

        def content
          'def new_test; end'
        end
      }.new
    end

    def teardown
      @gist_data = nil
    end

    def test_client_gets_response_from_service
      fixture_path = File.expand_path('../fixtures/create_gist_response', __FILE__)
      response = File.read(fixture_path)

      user_config = Struct.new(:user_config) {
        def token
          'ab12345'
        end
      }.new

      test_scope = self

      network_adapter = Struct.new(:network_adapter) {
        def post_with_token(token, uri, data)
          fixture_path = File.expand_path('../fixtures/create_gist_response', __FILE__)
          File.read(fixture_path)
        end
      }.new

      client = Client.new(user_config, network_adapter)
      client.create_gist(@gist_data)

      assert_equal(response, client.response)
    end

    def test_token
      user_config = Struct.new(:user_config) {
        def token
          'ab12345'
        end
      }.new
        
      client = Client.new(user_config)
      
      assert_equal('ab12345', client.token)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gistdoit-0.0.1 test/client_test.rb