Sha256: a1f64ad24d07e5e834783c753c7033afe9b235de3fd36e5ebe1a461a32b156db

Contents?: true

Size: 1.6 KB

Versions: 8

Compression:

Stored size: 1.6 KB

Contents

# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Riak::MapReduce::FilterBuilder do
  subject { Riak::MapReduce::FilterBuilder.new }
  it "should evaluate the passed block on initialization" do
    subject.class.new do
      matches "foo"
    end.to_a.should == [[:matches, "foo"]]
  end

  it "should add filters to the list" do
    subject.to_lower
    subject.similar_to("ripple", 3)
    subject.to_a.should == [[:to_lower],[:similar_to, "ripple", 3]]
  end

  it "should add a logical operation with a block" do
    subject.OR do
      starts_with "foo"
      ends_with "bar"
    end
    subject.to_a.should == [[:or, [[:starts_with, "foo"],[:ends_with, "bar"]]]]
  end

  it "should raise an error on a filter arity mismatch" do
    lambda { subject.less_than }.should raise_error(ArgumentError)
  end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
riak-client-0.9.8 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-0.9.5 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-0.9.4 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-0.9.3 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-0.9.2 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-0.9.1 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-0.9.0 spec/riak/map_reduce/filter_builder_spec.rb
riak-client-0.9.0.beta2 spec/riak/map_reduce/filter_builder_spec.rb