Sha256: 3bd7d977a2b829b566cc292399b4a2a092c84997dcdefb11943be51bc86ac46a

Contents?: true

Size: 1.44 KB

Versions: 15

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Trackman::Assets::Asset do
  
  class MyTestAsset < Asset
  end

  before :each do
    class Env
      def production?
        true
      end
    end
  end

  after :each do
    ENV['TRACKMAN_AUTOSYNC'] = nil
    begin
      Object.send(:remove_const, :Rails)
    rescue
    end
  end
  
  it "syncs without any special config" do
    MyTestAsset.should_receive(:sync)

    MyTestAsset.autosync
  end  
  
  it "doesnt autosync if ENV is set to false/0/FALSE" do
    MyTestAsset.should_not_receive(:sync)

    ['false', '0', 'FALSE'].each do |v|
      ENV['TRACKMAN_AUTOSYNC'] = v
      MyTestAsset.autosync
    end
  end
  
  it "doesn't autosync if the env is not in production" do
    class Rails
      def self.env
        Env.new
      end  
    end
    
    class Env
      def production?
        false
      end
    end
    MyTestAsset.should_not_receive(:sync)

    MyTestAsset.autosync
  end
  
  it "doesn't blow up when I autosync even though something is broken" do
    def MyTestAsset.sync
      raise "something is wrong"
    end
    result = true
    MyTestAsset.should_receive(:sync)

    lambda { result = MyTestAsset.autosync }.should_not raise_error
    
    result.should be_false
  end

  it "logs the error when sync is broken" do
    MyTestAsset.stub!(:sync).and_raise("something is wrong")

    RemoteAsset.should_receive(:log_exception).once

    lambda { result = MyTestAsset.autosync }.should_not raise_error
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
trackman-0.4.6 spec/sync_spec.rb
trackman-0.4.5 spec/sync_spec.rb
trackman-0.4.4 spec/sync_spec.rb
trackman-0.4.3 spec/sync_spec.rb
trackman-0.4.2 spec/sync_spec.rb
trackman-0.4.1 spec/sync_spec.rb
trackman-0.4.0 spec/sync_spec.rb
trackman-0.3.5 spec/sync_spec.rb
trackman-0.3.4 spec/sync_spec.rb
trackman-0.3.2 spec/sync_spec.rb
trackman-0.3.1 spec/sync_spec.rb
trackman-0.3.0 spec/sync_spec.rb
trackman-0.2.90 spec/sync_spec.rb
trackman-0.2.89 spec/sync_spec.rb
trackman-0.2.88 spec/sync_spec.rb