
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Install this sunspot_test from rubygems either directly:
gem install sunspot_test
Or through bundler
# in Gemfile
gem "sunspot_test"
Then in Cucumber's env.rb:
require 'sunspot_test/cucumber'
This gem will automatically start and stop solr for cucumber tests when using the @search tag. For instance, if you have a searchable book model this will allow you to create/query/destroy books.
@search
Feature: Books
Scenario: Searching for a book
Given a book exists with a title of "Of Mice and Men"
If your feature is not tagged with @search the environment will use a sunspot test proxy object which will silently swallow all requests.
Starting solr will depend on your settings in config/sunspot.yml
(though this configuration file is optional). If you run into issues remember to look for existing java processes, starting solr may conflict with existing instances. You can also check out http://collectiveidea.com/blog/archives/2011/05/25/testing-with-sunspot-and-cucumber/ which contains a little more information.
In spec_helper.rb
require 'sunspot_test/rspec'
Then within your specs, you'll need to tag and explicitly commit changes to solr:
require 'spec_helper'
describe "searching", :search => true do
it 'returns book results' do
book = Factory(:book, :title => "Of Mice and Men")
Sunspot.commit
Book.search { keywords "mice"}.results.should == [book]
end
end
Same as RSpec.
In test_helper.rb
require 'sunspot_test/test_unit'
Then within your test, you'll need to tag and explicitly commit changes to solr:
test 'searching' do
book = Factory(:book, :title => "Of Mice and Men")
Sunspot.commit
assert_equal [book], Book.search { keywords "mice"}.results
end
The test suite will try and launch a solr process and wait for 15 seconds for the process to launch. You can configure this timeout by setting the following in env.rb:
SunspotTest.solr_startup_timeout = 60 # will wait 60 seconds for the solr process to start
Copyright (c) 2011 Zach Moazeni. See LICENSE for details.
FAQs
Unknown package
We found that sunspot_test demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.