Sha256: 0c00c3d4d31f04cc7214cfd7ddbf2446b7601d66a44760808dd5d02efd4f2bae

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'
require 'ronin/code/sql/emittable'
require 'ronin/code/sql/literal'

describe Ronin::Code::SQL::Emittable do
  subject { Ronin::Code::SQL::Literal.new('hello') }

  describe "#emitter" do
    it "should return an Ronin::Code::SQL::Emitter" do
      expect(subject.emitter).to be_kind_of(Ronin::Code::SQL::Emitter)
    end

    it "should accept Emitter options" do
      expect(subject.emitter(case: :lower).case).to eq(:lower)
    end
  end

  describe "#to_sql" do
    it "should emit the object" do
      expect(subject.to_sql).to eq("'hello'")
    end

    context "when given options" do
      it "should pass them to #emitter" do
        expect(subject.to_sql(quotes: :double)).to eq('"hello"')
      end
    end
  end

  describe "#to_s" do
    it "should call #to_sql with no arguments" do
      expect(subject.to_s).to eq(subject.to_sql)
    end
  end

  describe "#inspect" do
    it "should call #to_sql with no arguments" do
      expect(subject.inspect).to include(subject.to_sql)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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