From 482a8f6024c1eaa218024f4d86f544d04eff80f1 Mon Sep 17 00:00:00 2001 From: Pat Allan Date: Mon, 30 Nov 2009 16:16:27 +1100 Subject: [PATCH] Adding feature and tweaking specs for allowing scopes to work with search_count. --- features/sphinx_scopes.feature | 7 +++++++ features/step_definitions/scope_steps.rb | 4 ++++ spec/thinking_sphinx/active_record/scopes_spec.rb | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/features/sphinx_scopes.feature b/features/sphinx_scopes.feature index 8c961ad51..c5e0d84fc 100644 --- a/features/sphinx_scopes.feature +++ b/features/sphinx_scopes.feature @@ -33,3 +33,10 @@ Feature: Sphinx Scopes And I am searching on people When I use the ids_only scope Then I should have an array of integers + + Scenario: Counts with scopes + Given Sphinx is running + And I am searching on people + When I use the with_first_name scope set to "Andrew" + And I am retrieving the scoped result count + Then I should get a value of 7 diff --git a/features/step_definitions/scope_steps.rb b/features/step_definitions/scope_steps.rb index 438cbc814..16e667281 100644 --- a/features/step_definitions/scope_steps.rb +++ b/features/step_definitions/scope_steps.rb @@ -9,3 +9,7 @@ When /^I use the ([\w]+) scope set to (\d+)$/ do |scope, int| @results = results.send(scope.to_sym, int.to_i) end + +When /^I am retrieving the scoped result count$/ do + @results = results.search_count +end diff --git a/spec/thinking_sphinx/active_record/scopes_spec.rb b/spec/thinking_sphinx/active_record/scopes_spec.rb index 6d5d2cef8..3f889ac8b 100644 --- a/spec/thinking_sphinx/active_record/scopes_spec.rb +++ b/spec/thinking_sphinx/active_record/scopes_spec.rb @@ -149,13 +149,13 @@ end it "should return the total number of results" do - Alpha.by_name.search_count.should == 43 + Alpha.by_name('foo').search_count.should == 43 end it "should not make any calls to the database" do Alpha.should_not_receive(:find) - Alpha.by_name.search_count + Alpha.by_name('foo').search_count end end