Sha256: 95f5fe178f72002fee40fe5e099706469bcb4d48f21af838c48a7fac52e821ff

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'
module Alf
  module Operator::Relational
    describe Restrict do

      let(:operator_class){ Restrict }
      it_should_behave_like("An operator class")

      let(:input) {[
        {:tested => 1, :other => "b"},
        {:tested => 30, :other => "a"},
      ]}

      let(:expected){[
        {:tested => 1, :other => "b"}
      ]}

      subject{ operator.to_a }

      context "with no argument" do
        let(:operator){ Lispy.restrict(input) }
        it { should eq(input) }
      end

      context "with a string" do
        context "with Lispy" do
          let(:operator){ Lispy.restrict(input, "tested < 10") }
          it { should eq(expected) }
        end
      end

      context "with arguments" do
        context "with Lispy and Proc" do
          let(:operator){ Lispy.restrict(input, lambda{ tested < 10 }) }
          it { should eq(expected) }
        end
        context "with Lispy and array" do
          let(:operator){ Lispy.restrict(input, [:tested, 1]) }
          it { should eq(expected) }
        end
      end

    end 
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-core/operator/relational/test_restrict.rb
alf-0.12.1 spec/unit/alf-core/operator/relational/test_restrict.rb
alf-0.12.0 spec/unit/alf-core/operator/relational/test_restrict.rb
alf-0.11.1 spec/unit/alf-core/operator/relational/test_restrict.rb
alf-0.11.0 spec/unit/alf-core/operator/relational/test_restrict.rb