Sha256: 3f7e69b7e72f7fbe027671d356307bfdae70ee60019a10cd6597a41dd31408ce

Contents?: true

Size: 921 Bytes

Versions: 11

Compression:

Stored size: 921 Bytes

Contents

require 'spec_helper'

describe Riak::MapReduce::FilterBuilder do
  subject { Riak::MapReduce::FilterBuilder.new }
  it "evaluates the passed block on initialization" do
    expect(subject.class.new do
      matches "foo"
    end.to_a).to eq([[:matches, "foo"]])
  end

  it "adds filters to the list" do
    subject.to_lower
    subject.similar_to("ripple", 3)
    expect(subject.to_a).to eq([[:to_lower], [:similar_to, "ripple", 3]])
  end

  it "adds a logical operation with a block" do
    subject.OR do
      starts_with "foo"
      ends_with "bar"
    end
    expect(subject.to_a).to eq([[:or, [[:starts_with, "foo"], [:ends_with, "bar"]]]])
  end

  it "raises an error on a filter arity mismatch" do
    expect { subject.less_than }.to raise_error(ArgumentError)
  end

  it "raises an error when a block is not given to a logical operation" do
    expect { subject._or }.to raise_error(ArgumentError)
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
riak-client-2.5.0 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-2.4.1 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-2.4.0 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-2.4.0.pre1 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-2.3.2 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-2.3.1 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-2.3.0 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-2.2.2 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-2.2.1 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-noenc-1.0.0 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-2.2.0 spec/riak/map_reduce/filter_builder_spec.rb