Sha256: f717d57381b437e7ed03a1aec025f69d79d9be941c61f9b53cc1aab468e210ea

Contents?: true

Size: 1.55 KB

Versions: 14

Compression:

Stored size: 1.55 KB

Contents

require_relative "spec_helper"

Sequel.extension :s

describe "s extension as refinement" do
  include Sequel::S

  before do
    @db = Sequel.mock
  end

  it "S should be callable with different arguments" do
    @db.literal(S(:s) + 1).must_equal "(s + 1)"
    @db.literal(S('s') + '1').must_equal "('s' || '1')"
    @db.literal(~S([[:s, 1], [:z, 2]])).must_equal "((s != 1) OR (z != 2))"
  end

  it "S should be callable with blocks" do
    @db.literal(S{x + 1}).must_equal "(x + 1)"
  end

  it "S should raise an error if called with multiple objects" do
    proc{S(:x, 1)}.must_raise ArgumentError
  end

  it "S should raise an error if called with objects and block" do
    proc{S(:x){}}.must_raise Sequel::Error
  end
end


if (RUBY_VERSION >= '2.0.0' && RUBY_ENGINE == 'ruby') || (RUBY_ENGINE == 'jruby' && (JRUBY_VERSION >= '9.3' || (JRUBY_VERSION.match(/\A9\.2\.(\d+)/) && $1.to_i >= 7)))
using Sequel::S

describe "s extension as refinement" do
  before do
    @db = Sequel.mock
  end

  it "S should be callable with different arguments" do
    @db.literal(S(:s) + 1).must_equal "(s + 1)"
    @db.literal(S('s') + '1').must_equal "('s' || '1')"
    @db.literal(~S([[:s, 1], [:z, 2]])).must_equal "((s != 1) OR (z != 2))"
  end

  it "S should be callable with blocks" do
    @db.literal(S{x + 1}).must_equal "(x + 1)"
  end

  it "S should raise an error if called with multiple objects" do
    proc{S(:x, 1)}.must_raise ArgumentError
  end

  it "S should raise an error if called with objects and block" do
    proc{S(:x){}}.must_raise Sequel::Error
  end
end
end


Version data entries

14 entries across 13 versions & 2 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/spec/extensions/s_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/spec/extensions/s_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/sequel-5.29.0/spec/extensions/s_spec.rb
sequel-5.29.0 spec/extensions/s_spec.rb
sequel-5.28.0 spec/extensions/s_spec.rb
sequel-5.27.0 spec/extensions/s_spec.rb
tdiary-5.1.0 vendor/bundle/gems/sequel-5.26.0/spec/extensions/s_spec.rb
sequel-5.26.0 spec/extensions/s_spec.rb
sequel-5.25.0 spec/extensions/s_spec.rb
sequel-5.24.0 spec/extensions/s_spec.rb
sequel-5.23.0 spec/extensions/s_spec.rb
sequel-5.22.0 spec/extensions/s_spec.rb
sequel-5.21.0 spec/extensions/s_spec.rb
sequel-5.20.0 spec/extensions/s_spec.rb