Sha256: ace5d7e8ed390a8247edae4a56439d07d4e9d5adcc042ef1d572e6df69965e01

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 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, "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(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))

      subject.execute dir
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nightcrawler_swift-0.2.1 spec/lib/nightcrawler_swift/sync_spec.rb
nightcrawler_swift-0.2.0 spec/lib/nightcrawler_swift/sync_spec.rb
nightcrawler_swift-0.1.1 spec/lib/nightcrawler_swift/sync_spec.rb
nightcrawler_swift-0.1.0 spec/lib/nightcrawler_swift/sync_spec.rb