Sha256: 848d4fcf2ecab2bf258d8e8f519bb79d0fe479f630b751f105f8643222df1214

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe DataForge::DSL::Commands do

  let(:dsl_object) { Object.new.tap { |object| object.extend DataForge::DSL::Commands } }
  let(:block) { lambda {} }

  describe "#file" do
    it "should register a file descriptor" do
      expect(DataForge::File).to receive(:register_file_definition).with(:name) { |&blk| expect(blk).to be block }

      dsl_object.file :name, &block
    end
  end


  describe "#transform" do
    it "should create a file transformation and execute it" do
      transformation = instance_double "DataForge::Transformation::RubyTransformation"

      allow(DataForge::Transformation::RubyTransformation).to receive(:from_input)
                                                              .with(:source, into: :target) { |&blk| expect(blk).to be block }
                                                              .and_return(transformation)
      expect(transformation).to receive(:execute)

      dsl_object.transform :source, into: :target, &block
    end
  end


  describe "#deduplicate" do
    it "should create a deduplication transformation and execute it" do
      deduplication = instance_double "DataForge::Transformation::Deduplication"
      allow(DataForge::Transformation::Deduplication).to receive(:from_input).with(:items, into: :unique_items, using: :item_id).and_return(deduplication)

      expect(deduplication).to receive(:execute)

      dsl_object.deduplicate :items, into: :unique_items, using: :item_id
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
data_forge-0.1 spec/data_forge/dsl/commands_spec.rb