Sha256: 34268bd18f6aef0c42cf3fa8e6d844039e09494c973fba22ed19977cbdbc3c87

Contents?: true

Size: 949 Bytes

Versions: 1

Compression:

Stored size: 949 Bytes

Contents

require_relative 'spec_helper'
require 'mocha'

require_relative '../lib/doc_juan/url_helper'

describe 'DocJuan#url' do
  before :each do
    DocJuan.config.host = 'doc-juan.example.com'
    DocJuan.config.secret = 'zecret'
  end

  it 'passes its arguments to a UrlGenerator instance and uses it to generate the url' do
    generator = stub
    generator.expects(:generate).returns 'generated-url'
    DocJuan::UrlGenerator.expects(:new).
      with('http://example.com', 'the_file', nil, size: 'A4').
      returns(generator)

    url = DocJuan.url 'http://example.com', 'the_file', size: 'A4'

    url.must_equal 'generated-url'
  end

  it 'passes format if set to UrlGenerator instance' do
    generator = stub
    generator.expects(:generate)
    DocJuan::UrlGenerator.expects(:new).
      with('http://example.com', 'the_file', 'jpg', {}).
      returns(generator)

    DocJuan.url 'http://example.com', 'the_file', format: 'jpg'
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
doc_juan-1.2.0 spec/url_helper_spec.rb