Skip to content

Commit

Permalink
Adding feature and tweaking specs for allowing scopes to work with se…
Browse files Browse the repository at this point in the history
…arch_count.
  • Loading branch information
pat committed Nov 30, 2009
1 parent 93059be commit 482a8f6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions features/sphinx_scopes.feature
Expand Up @@ -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
4 changes: 4 additions & 0 deletions features/step_definitions/scope_steps.rb
Expand Up @@ -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
4 changes: 2 additions & 2 deletions spec/thinking_sphinx/active_record/scopes_spec.rb
Expand Up @@ -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

Expand Down

0 comments on commit 482a8f6

Please sign in to comment.