Sha256: 7923f70efa7a30554b3655fa3699434bd9e19840cbdc87d5ff9c56cd56049fd5

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

require 'helper'
require 'cassanity/argument_generators/set_clause'

describe Cassanity::ArgumentGenerators::SetClause do
  describe "#call" do
    it "returns array of arguments" do
      subject.call({
        set: {
          name: 'GitHub',
        }
      }).should eq([
        " SET name = ?",
        'GitHub',
      ])
    end

    context "with multiple :set keys/values" do
      it "returns array of arguments where each SET is comma separated" do
        time = Time.now

        subject.call({
          set: {
            name: 'GitHub',
            created_at: time,
          }
        }).should eq([
          " SET name = ?, created_at = ?",
          'GitHub',
          time,
        ])
      end
    end

    context "with increment" do
      it "returns array of arguments with SET including counter increment" do
        subject.call(set: {views: Cassanity::Increment.new(5)}).
          should eq([" SET views = views + ?", 5])
      end
    end

    context "with decrement" do
      it "returns array of arguments with SET including counter decrement" do
        subject.call(set: {views: Cassanity::Decrement.new(3)}).
          should eq([" SET views = views - ?", 3])
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cassanity-0.6.0.beta5 spec/unit/cassanity/argument_generators/set_clause_spec.rb
cassanity-0.6.0.beta4 spec/unit/cassanity/argument_generators/set_clause_spec.rb
cassanity-0.6.0.beta3 spec/unit/cassanity/argument_generators/set_clause_spec.rb
cassanity-0.6.0.beta2 spec/unit/cassanity/argument_generators/set_clause_spec.rb
cassanity-0.6.0.beta1 spec/unit/cassanity/argument_generators/set_clause_spec.rb
cassanity-0.5.1 spec/unit/cassanity/argument_generators/set_clause_spec.rb
cassanity-0.5.0 spec/unit/cassanity/argument_generators/set_clause_spec.rb
cassanity-0.4.0 spec/unit/cassanity/argument_generators/set_clause_spec.rb
cassanity-0.3.0 spec/unit/cassanity/argument_generators/set_clause_spec.rb