Sha256: d0007194ee0ce49943e59b21635759f6ca2102bd031df91975c1323d03349a75

Contents?: true

Size: 1.49 KB

Versions: 31

Compression:

Stored size: 1.49 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_VERSION >= '2.3.0' && RUBY_ENGINE == 'jruby')
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

31 entries across 28 versions & 2 rubygems

Version Path
tdiary-5.0.13 vendor/bundle/gems/sequel-5.18.0/spec/extensions/s_spec.rb
sequel-5.19.0 spec/extensions/s_spec.rb
tdiary-5.0.12.1 vendor/bundle/gems/sequel-5.18.0/spec/extensions/s_spec.rb
sequel-5.18.0 spec/extensions/s_spec.rb
sequel-5.17.0 spec/extensions/s_spec.rb
sequel-5.16.0 spec/extensions/s_spec.rb
tdiary-5.0.11 vendor/bundle/gems/sequel-5.15.0/spec/extensions/s_spec.rb
tdiary-5.0.11 vendor/bundle/gems/sequel-5.11.0/spec/extensions/s_spec.rb
sequel-5.15.0 spec/extensions/s_spec.rb
sequel-5.14.0 spec/extensions/s_spec.rb
sequel-5.13.0 spec/extensions/s_spec.rb
sequel-5.12.0 spec/extensions/s_spec.rb
sequel-5.11.0 spec/extensions/s_spec.rb
sequel-5.10.0 spec/extensions/s_spec.rb
tdiary-5.0.9 vendor/bundle/gems/sequel-5.9.0/spec/extensions/s_spec.rb
sequel-5.9.0 spec/extensions/s_spec.rb
sequel-5.8.0 spec/extensions/s_spec.rb
sequel-5.7.1 spec/extensions/s_spec.rb
sequel-5.7.0 spec/extensions/s_spec.rb
tdiary-5.0.8 vendor/bundle/gems/sequel-5.6.0/spec/extensions/s_spec.rb