summaryrefslogtreecommitdiff
path: root/spec/commands/gist_spec.rb
blob: 09d1ffa94e3ccb4d1a04f8c5a360ede050a0b2fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# These tests are out of date.
# They need to be updated for the new 'gist' API, but im too sleepy to
# do that now.

require_relative '../helper'

describe 'gist' do
  it 'has a dependency on the jist gem' do
    expect(Pry::Command::Gist.command_options[:requires_gem]).to eq("gist")
  end

  before do
    Pad.gist_calls = {}
  end

  # In absence of normal mocking, just monkeysmash these with no undoing after.
  module ::Gist
    class << self
      def login!; Pad.gist_calls[:login!] = true end

      def gist(*args)
        Pad.gist_calls[:gist_args] = args
        {'html_url' => 'http://gist.blahblah'}
      end

      def copy(content); Pad.gist_calls[:copy_args] = content end
    end
  end

  it 'nominally logs in' do
    pry_eval 'gist --login'
    expect(Pad.gist_calls[:login!]).not_to be_nil
  end
end