require 'spec_helper'

describe Slipsquare::CLI do
  include_context "spec"

  describe "ls called with no path" do
    it "returns confirmation text when verify passes" do
      stub_request(:get, "https://api.dropbox.com/1/metadata/dropbox/?").
      with(:headers => {'Accept'=>'*/*', 'Authorization'=> /OAuth oauth_consumer_key="#{app_key}", oauth_nonce="\S+", oauth_signature="\S+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\S+", oauth_token="#{app_token}", oauth_version="1.0"/, 'User-Agent'=>'OAuth gem v0.4.7'}).
      to_return(:status => 200, :body => fixture("ls_success"))
      @cli.ls
      expect($stdout.string).to eq <<-eos
Listing files from Dropbox...
PATH                 | MIME_TYPE       | SIZE   
------------------------------------------------
/Getting_Started.pdf | application/pdf | 225.4KB
      eos
    end

    it "ls called with basic path" do
      stub_request(:get, "https://api.dropbox.com/1/metadata/dropbox/awesome?").
      with(:headers => {'Accept'=>'*/*', 'Authorization'=> /OAuth oauth_consumer_key="#{app_key}", oauth_nonce="\S+", oauth_signature="\S+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\S+", oauth_token="#{app_token}", oauth_version="1.0"/, 'User-Agent'=>'OAuth gem v0.4.7'}).
      to_return(:status => 200, :body => fixture("ls_path_success"))
      @cli.ls('awesome')
      expect($stdout.string).to eq <<-eos
Listing files from Dropbox...
PATH                | MIME_TYPE  | SIZE   
------------------------------------------
/Awesome/latest.txt | text/plain | 0 bytes
      eos
    end

  end

end

