Sha256: c4bb2e01e0d20ca7042aa02496f389b6ee16ef56a3c296862c5b996617d3764b

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

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

describe Ronin::Code::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
        expect(subject.instance_variable_get(:@x)).to eq(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

          expect(yielded_statement_list).to be_kind_of(described_class)
        end
      end
    end
  end

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

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

    it "should append a new statement" do
      expect(subject.statements.last.keyword).to eq(keyword)
    end
  end

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

    before { subject.statement(keyword) }

    it "should create and append a new Statement" do
      expect(subject.statements.last.keyword).to eq(keyword)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-code-sql-2.0.0.beta1 spec/sql/statement_list_spec.rb