Sha256: f70de2fc4851f782d9059fa3105aafe2c146d318a3b7a16a806d9c18025212e6

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'
describe Qfill::Filter do
  context "#new" do
    context "with processor" do
      before :each do
        @lambda = -> (object) { !object.nil? }
      end
      it "should instantiate with processor" do
        Qfill::Filter.new(@lambda).should be_a(Qfill::Filter)
      end
    end

    context "with processor and arguments" do
      before :each do
        @lambda = -> (object, first, second) { !object.nil? && first == first && second == 'second' }
        @arguments = ['first','second']
      end
      it "should instantiate with processor" do
        Qfill::Filter.new(@lambda, *@arguments).should be_a(Qfill::Filter)
      end
    end
  end

  context "#run" do
    before :each do
      @lambda = -> (object, first, second) { !object.nil? && first == first && second == 'second' }
      @arguments = ['first','second']
      @filter = Qfill::Filter.new(@lambda, *@arguments)
    end
    it "should return the correct result" do
      @filter.run('not nil').should == true
    end
    context "with extra arguments" do
      before :each do
        @lambda = -> (object, special_arg1, special_arg2, first, second, third) { !object.nil? && first == first && second == 'second' && special_arg1 = 'this' && special_arg2 == 'thing' && third == 'third' }
        @arguments = ['first','second','third']
        @filter = Qfill::Filter.new(@lambda, *@arguments)
      end
      it "should properly use arity" do
        @filter.run('not nil', 'this', 'thing').should == true
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
qfill-0.0.4 spec/qfill/filter_spec.rb
qfill-0.0.3 spec/qfill/filter_spec.rb
qfill-0.0.2 spec/qfill/filter_spec.rb
qfill-0.0.1 spec/qfill/filter_spec.rb