Sha256: b0e075810f70613fdc22d21ce60e8f093b673584b27631675d0501f734082d4e

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'
require 'ronin/sql/statement_list'

describe SQL::StatementList do
  describe "#initialize" do
    context "when given a block" do
      subject do
        described_class.new { @x = 1 }
      end

      it "should instance_eval the block" do
        subject.instance_variable_get(:@x).should == 1
      end

      context "that accepts an argument" do
        it "should yield itself" do
          yielded_statement_list = nil

          described_class.new do |statement_list|
            yielded_statement_list = statement_list
          end

          yielded_statement_list.should be_kind_of(described_class)
        end
      end
    end
  end

  describe "#<<" do
    let(:keyword) { :SELECT }

    before { subject << SQL::Statement.new(keyword) }

    it "should append a new statement" do
      subject.statements.last.keyword.should == keyword
    end
  end

  describe "#statement" do
    let(:keyword) { [:ALTER, :TABLE] }

    before { subject.statement(keyword) }

    it "should create and append a new Statement" do
      subject.statements.last.keyword.should == keyword
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-sql-1.1.0 spec/sql/statement_list_spec.rb
ronin-sql-1.0.0 spec/sql/statement_list_spec.rb