我正在为solr搜索编写控制器规范。 这是我的控制器
@search = Plan.available_plans.search do
fulltext params[:zip_code] do
end
all_of do
with :status, "active"
with(:price).greater_than(10)
with(:end_date).greater_than Time.now
end
规范是:
it "should list active plans" do
get :index
Sunspot.session.should be_a_search_for(Plan)
Sunspot.session.should_not have_search_params(:with, :status, "inactive")
end
it "should not list plans with price < 10" do
get :index
Sunspot.session.should be_a_search_for(Plan)
Sunspot.session.should_not have_search_params(:with, :price, :less_than => 10)
end
it "should not list plans that have expired" do
get :index
Sunspot.session.should be_a_search_for(Plan)
Sunspot.session.should_not have_search_params(:with, :end_date, :less_than => Date.today)
end
第一个工作正常。我搜索了很多但是找不到合适的语法来测试其他场景。 Plz帮助我。