Sha256: 26a77e897e765d6054fbb65d3b99a2b8a2c4d568c7fa7d9c3d7530dcad625095

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

require './lib/second_curtain/upload'
require 'uri'

describe Upload do
  it "should have instance variables set correctly upon initialization" do
    upload = Upload.new('expected', 'actual')
    expect(upload.expected_path).to eq('expected')
    expect(upload.actual_path).to eq('actual')
  end

  it "should upload properly" do
    path = "test/folder"
    expected_double = double()
    actual_double = double()
    bucket = double()

    doubles = {
      "test/folder/expected.png" => expected_double,
      "test/folder/actual.png" => actual_double
    }
    expect(bucket).to receive(:objects).twice.and_return(doubles)

    expect(expected_double).to receive(:write).with(anything)
    expect(expected_double).to receive(:public_url).and_return("http://exmaple.com/1.png")
    expect(actual_double).to receive(:write).with(anything)
    expect(actual_double).to receive(:public_url).and_return("http://exmaple.com/2.png")

    upload = Upload.new('/path/to/expected.png', '/path/to/actual.png')
    upload.upload(bucket, path)

    expect(upload.uploaded_expected_url).to eq("http://exmaple.com/1.png")
    expect(upload.uploaded_actual_url).to eq("http://exmaple.com/2.png")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
second_curtain-0.5.0 spec/second_shutter/upload_spec.rb
second_curtain-0.4.0 spec/second_shutter/upload_spec.rb
second_curtain-0.3.0 spec/second_shutter/upload_spec.rb
second_curtain-0.2.4 spec/second_shutter/upload_spec.rb
second_curtain-0.2.3 spec/second_shutter/upload_spec.rb