Sha256: 5fb78432206bc45248b03a708b1c8b66f12a6eb185873bcf2c3f1291c4d33b65
Contents?: true
Size: 1.73 KB
Versions: 3
Compression:
Stored size: 1.73 KB
Contents
require 'spec_helper' describe ActiveSearch::Base do before do @klass = Class.new do include ActiveSearch::Base def self.after_save(*args); end def self.after_destroy(*args); end end end context "search_by" do let(:call_search_by) do @klass.class_eval do search_by [:field], if: :something_happens, unless: :its_friday end end it "should rely on after_save and after_destroy callbacks passing conditions" do @klass.should_receive(:after_save).with(:reindex, if: :something_happens, unless: :its_friday) @klass.should_receive(:after_destroy).with(:deindex, if: :something_happens, unless: :its_friday) call_search_by end it "should store the parameters in search_parameters" do call_search_by @klass.send(:search_parameters).should == [:field] end end context "utility methods with options" do before do @klass.stub(:search_parameters).and_return([:field, store: [:another_field]]) end it "search_options should return the hash at the end of the parameters" do @klass.new.search_options.should == {store: [:another_field]} end it "search_fields should return all parameters except the options" do @klass.new.search_fields.should == [:field] end end context "search_by with virtual parameters" do before do @klass.class_eval do def options_for_search [@field] end def initialize(field) @field = field end search_by :options_for_search end end it "should work" do @klass.new(:first).send(:search_parameters).should == [:first] @klass.new(:second).send(:search_parameters).should == [:second] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activesearch-0.3.2 | spec/engines/base_spec.rb |
activesearch-0.3.1 | spec/engines/base_spec.rb |
activesearch-0.3.0 | spec/engines/base_spec.rb |