Sha256: 00f3f372e1bbe61ef1e95feded5e86285cff68ff15b8da3581e074528fac412c

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

require "spec_helper"

describe NightcrawlerSwift::Sync do

  subject do
    NightcrawlerSwift::Sync.new
  end

  before do
    NightcrawlerSwift.logger = Logger.new(StringIO.new)
  end

  describe "#execute" do

    let :upload do
      NightcrawlerSwift::Upload.new
    end

    it "executes upload command for each file of a directory" do
      dir = File.expand_path(File.join(File.dirname(__FILE__), "../../fixtures/assets"))

      subject.instance_variable_set(:@upload, upload)
      expect(File).to receive(:open).with(File.join(dir, "css1.css"), "r").and_call_original
      expect(File).to receive(:open).with(File.join(dir, "ex1.txt"), "r").and_call_original
      expect(File).to receive(:open).with(File.join(dir, "ex2.txt"), "r").and_call_original
      expect(File).to receive(:open).with(File.join(dir, "ex3/ex4.txt"), "r").and_call_original
      expect(File).to receive(:open).with(File.join(dir, "js1.js"), "r").and_call_original

      expect(upload).to receive(:execute).with("css1.css", instance_of(File))
      expect(upload).to receive(:execute).with("ex1.txt", instance_of(File))
      expect(upload).to receive(:execute).with("ex2.txt", instance_of(File))
      expect(upload).to receive(:execute).with("ex3/ex4.txt", instance_of(File))
      expect(upload).to receive(:execute).with("js1.js", instance_of(File))

      subject.execute dir
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nightcrawler_swift-0.3.0 spec/lib/nightcrawler_swift/sync_spec.rb
nightcrawler_swift-0.2.3 spec/lib/nightcrawler_swift/sync_spec.rb
nightcrawler_swift-0.2.2 spec/lib/nightcrawler_swift/sync_spec.rb