Sha256: 0907c320ea3fbe1f5e2e9426009147b9bcfe4ce005a36e6ab0a610ca66e8864a

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe Gyazo::Image do
  let(:file_path) do
    File.join(File.dirname(__FILE__), "../fixtures/test_image.png")
  end

  let(:file) { File.open(file_path) }
  let(:params) do
    {
      :filename => "test_image.png",
      :type     => "text/plain",
      :name     => "imagedata",
      :tempfile => file,
      :head=>
        "Content-Disposition: form-data; name=\"imagedata\"; filename=\"test_image.png\"\r\nContent-Type: text/plain\r\nContent-Length: 35885\r\n"
    }
  end

  subject { ::Gyazo::Image.new(params) }

  describe "uploading" do
    it "delegates to the upload adapter" do
      mock_adapter_class = mock
      mock_adapter = mock
      mock_adapter.expects(:upload).returns("http://www.example.com")
      mock_adapter_class.expects(:new).returns(mock_adapter)
      ::Gyazo::Image.adapter = mock_adapter_class
      subject.upload
    end
  end

  describe "upload adapters" do
    it "allows the client to specify a symbol as an adapter" do
      ::Gyazo::Image.adapter = :fog
      ::Gyazo::Image.adapter_class.should eql(::Gyazo::UploadAdapters::Fog)
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack_gyazo-0.1.2 spec/gyazo/image_spec.rb
rack_gyazo-0.1.1 spec/gyazo/image_spec.rb
rack_gyazo-0.1.0 spec/gyazo/image_spec.rb