Sha256: 1728007578f847b9a452c7ee5bc34648b0cfba9c0d5662f9cde220990c1f0482

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe Itiel::Script::SQLScript do
  before :each do
    @sql_script = Itiel::Script::SQLScript.new("DELETE FROM orders")
    @data_stream = { "c" => "v" }
  end

  describe :sanity_check do
    describe "no connection specified" do
      it "raises Itiel::MissingConnection" do
        expect { @sql_script.sanity_check }.to raise_error Itiel::MissingConnection
      end
    end

    describe "No SQL sentence is given" do
      before :each do
        @sql_script.connection = Itiel::DB::Connection.new
        @sql_script.sql = nil
      end

      it "raises Itiel::SQLSentenceNotProvided" do
        expect { @sql_script.sanity_check }.to raise_error Itiel::SQLSentenceNotProvided
      end
    end
  end

  describe :execute do
    before :each do
      @connection = double
      @sql_script.connection = :test
      allow(Itiel::Script::SQLScript).to receive(:sequel_connection).with(:test).and_return @connection
    end

    it "Executes the specified SQL script with the given connection" do
      expect(@connection).to receive(:<<).with(@sql_script.sql)
      @sql_script.execute
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itiel-0.1.0 spec/script/sql_script_spec.rb