Sha256: 00a55a9d8022294ede8d73d2916d28d8c15f91c2382de90e25668fd52878e438

Contents?: true

Size: 910 Bytes

Versions: 7

Compression:

Stored size: 910 Bytes

Contents

require 'spec_helper'
require 'tempfile'

describe Shb::Client do
  before do
    stub_request(:any, 'supremegolf.com')
  end

  it "does not debug by default" do
    shb = Shb::Client.new
    tmpfile = Tempfile.new('shb-debug')
    shb.class.config.debug_log = tmpfile.path
    expect(File).not_to receive(:open).with(tmpfile.path, 'a')
    shb.get('/')
  end

  it "debug to specified logfile" do
    shb = Shb::Client.new
    tmpfile = Tempfile.new('shb-debug')
    shb.class.config.debug = true
    shb.class.config.debug_log = tmpfile.path
    expect(File).to receive(:open).with(tmpfile.path, 'a').and_call_original
    shb.get('/')
  end

  it "debug to STDERR" do
    shb = Shb::Client.new
    tmpfile = Tempfile.new('shb-debug')
    shb.class.config.debug = true
    shb.class.config.debug_log = nil
    expect(STDERR).to receive(:puts).at_least(:twice).and_call_original
    shb.get('/')
  end


end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shb-0.1.4 spec/debug_spec.rb
shb-0.1.3 spec/debug_spec.rb
shb-0.1.2 spec/debug_spec.rb
shb-0.1.1 spec/debug_spec.rb
shb-0.1.0 spec/debug_spec.rb
shb-0.0.4 spec/debug_spec.rb
shb-0.0.3 spec/debug_spec.rb