Sha256: 53cc17db4ed86c598fe51452a58a37eb7222afc286db0e43eddd0d196e145791

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe CopycopterClient::RequestSync do

  let(:cache) { {} }
  let(:response) { 'response' }
  let(:env) { 'env' }
  let(:app) { stub('app', :call => response) }
  before { cache.stubs(:flush => nil, :download => nil) }
  subject { CopycopterClient::RequestSync.new(app, :cache => cache) }

  it "invokes the upstream app" do
    result = subject.call(env)
    app.should have_received(:call).with(env)
    result.should == response
  end

  it "flushes defaults" do
    subject.call(env)
    cache.should have_received(:flush)
  end

  it "downloads new copy" do
    subject.call(env)
    cache.should have_received(:download)
  end
end

describe CopycopterClient::RequestSync, 'serving assets' do
  let(:env) do
    { "PATH_INFO" => '/assets/choper.png' }
  end
  let(:cache) { {} }
  let(:response) { 'response' }
  let(:app) { stub('app', :call => response) }
  before { cache.stubs(:flush => nil, :download => nil) }
  subject { CopycopterClient::RequestSync.new(app, :cache => cache) }

  it "does not flush defaults" do
    subject.call(env)
    cache.should_not have_received(:flush)
  end
  it "does not download new copy" do
    subject.call(env)
    cache.should_not have_received(:download)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
copycopter_client-2.0.1 spec/copycopter_client/request_sync_spec.rb
copycopter_client-2.0.0 spec/copycopter_client/request_sync_spec.rb
copycopter_client-1.1.2 spec/copycopter_client/request_sync_spec.rb