Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 64 lines (49 sloc) 2.701 kB
02fd5de @mjankowski change to use rspec
mjankowski authored
1 require 'spec_helper'
2
3 describe 'Search' do
4
5 before do
a619187 @mjankowski avoid factory girl syntax deprecation warnings
mjankowski authored
6 @abe = create :user, :first_name => 'Abe', :last_name => 'Anderson', :description => 'Apple'
7 @bob = create :user, :first_name => 'Bob', :last_name => 'Babson', :description => 'Banana'
8 @cindy = create :user, :first_name => 'Cindy', :last_name => 'Clarkson', :description => 'Cookie'
9 @dave = create :user, :first_name => 'Dave'
10 @ed = create :user, :last_name => 'Dave'
11 @frank = create :user, :description => 'Dave'
12 @george = create :user, :first_name => 'Dave', :last_name => 'Dave', :description => 'Dave'
13
14 @null = create :user, :first_name => nil, :last_name => nil, :description => nil
02fd5de @mjankowski change to use rspec
mjankowski authored
15 end
16
17 it "should set the correct expected values for a _equals column method" do
18 User.first_name_equals('Abe').should == [@abe]
19 end
20
21 it "should set the correct expected values for a _equals column method with an Array as value" do
22 User.first_name_equals(['Abe', 'Bob']).should == [@abe, @bob]
23 end
24
25 it "should set the correct expected values for a _equals column method with nil as value" do
26 User.first_name_equals(nil).should == [@ed, @frank, @null]
27 end
28
29 it "should set the correct expected values for a _matches column method" do
30 User.first_name_matches('ind').should == [@cindy]
31 User.first_name_matches('IND').should == [@cindy]
32 end
33
34 it "should set the correct expected values for a _starts_with column method" do
35 User.first_name_starts_with('Ab').should == [@abe]
36 User.first_name_starts_with('aB').should == [@abe]
37 end
38
39 it "should set the correct expected values for a _ends_with column method" do
40 User.first_name_ends_with('ob').should == [@bob]
41 User.first_name_ends_with('Ob').should == [@bob]
42 end
43
44 it "should set the correct expected values for a search_for method" do
45 User.search_for('Dave').should == [@dave, @ed, @frank, @george]
46 User.search_for('dave').should == [@dave, @ed, @frank, @george]
47 end
48
49 it "should set the correct expected values for a search_for method with :on option" do
50 User.search_for('Dave', :on => [:first_name, :description]).should == [@dave, @frank, @george]
51 User.search_for('dave', :on => [:first_name, :description]).should == [@dave, @frank, @george]
52 end
53
54 it "should set the correct expected values for a search_for method with an :require option" do
55 User.search_for('Dave', :require => :all).should == [@george]
56 User.search_for('dave', :require => :all).should == [@george]
57 end
58
59 it "should set the correct expected values for a search_for method on a class with no columns" do
60 Mammal.search_for('test').should == []
61 end
62
63 end
Something went wrong with that request. Please try again.