Sha256: 99387fa18d4174d3e8e0709ec377a90300e6c2f548c884b06edea9662bf6174c

Contents?: true

Size: 955 Bytes

Versions: 4

Compression:

Stored size: 955 Bytes

Contents

require 'spec_helper'

describe Casino::Query do

  let(:label) { "women's boots" }
  let(:criteria) { [ /page_gender=f/i, /offer_cohort=boots/i ] }
  let(:query) { Casino::Query.new(label, [], *criteria) }

  subject { query }

  it { subject.label.must_equal label }
  it { subject.criteria.must_equal criteria }
  it { subject.conditions.must_equal [] }

  describe '#merge' do

    let(:field) { :created_at }
    let(:queries) { :method_name }
    let(:and_approach) { { operator: :and } }

    let(:dimension) do
      Casino::Dimension.new("Date", field, queries, and_approach)
    end

    let(:conditions) do
      query.criteria.map do |condition|
        [ :and, { dimension.field => condition } ]
      end
    end

    subject { query.merge(dimension) }

    it "merges the dimension data in" do
      subject.conditions.must_equal conditions
    end

    it "produces a different object" do
      subject.wont_equal query
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongoid-casino-0.0.4 spec/lib/casino/query_spec.rb
mongoid-casino-0.0.3 spec/lib/casino/query_spec.rb
mongoid-casino-0.0.2 spec/lib/casino/query_spec.rb
mongoid-casino-0.0.1 spec/lib/casino/query_spec.rb