Created
November 20, 2011 11:34
-
-
Save urbanautomaton/1380180 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@search | |
Scenario: List products | |
Given the system has the following products: | |
| id | name | | |
| 1 | Acme Flaming Hammer | | |
| 2 | Adidas Patented Truss | | |
| 3 | Corby Trouser Press | | |
And I authenticate as admin | |
And I send and accept XML | |
And the search index is updated | |
When I send a GET request for "/products" | |
Then the response should be "200" | |
And the XML response should be a "products" array with 3 "product" elements | |
expected: 3 | |
got: 0 (using ==) (RSpec::Expectations::ExpectationNotMetError) | |
./features/step_definitions/api_steps.rb:44:in `/^the XML response should be a "([^\"]*)" array with (\d+) "([^\"]*)" elements$/' | |
features/api/v1/product.feature:19:in `And the XML response should be a "products" array with 3 "product" elements' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product < ActiveRecord::Base | |
# ... | |
define_index do | |
indexes name, :sortable => true | |
end | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given 'the search index is updated' do | |
# Update all indexes | |
ThinkingSphinx::Test.index | |
sleep(0.25) # Wait for Sphinx to catch up | |
end | |
Given /^the search index for (\w+)s is updated$/ do |model| | |
# Update specific indexes | |
ThinkingSphinx::Test.index "#{model}_core" | |
sleep(0.25) # Wait for Sphinx to catch up | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'cucumber/thinking_sphinx/external_world' | |
Cucumber::ThinkingSphinx::ExternalWorld.new | |
Cucumber::Rails::World.use_transactional_fixtures = false | |
Before('@search') do | |
DatabaseCleaner.strategy = :truncation | |
end | |
Before('~@search') do | |
DatabaseCleaner.strategy = :transaction | |
end | |
Before do | |
DatabaseCleaner.start | |
end | |
After do | |
DatabaseCleaner.clean | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment