sunspot_test 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.travis.yml +11 -0
- data/Gemfile +3 -4
- data/README.md +106 -0
- data/Rakefile +4 -54
- data/lib/sunspot_test.rb +3 -2
- data/lib/sunspot_test/rspec.rb +3 -3
- data/spec/sunspot_test_spec.rb +67 -38
- data/sunspot_test.gemspec +17 -51
- metadata +93 -66
- data/README.rdoc +0 -87
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c96240e859a3da72c60b40347236eee759bbcc42
|
4
|
+
data.tar.gz: b3920e2ac63fbc27ab7c22daade6fd5781dd35f0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9073db9ea9fa231752fa280290c14fec67b20fa498d212f15845226ea2552085c852c0f7b39612b3c3f21026c72d77ce0a8ea05ebf416e0cdefd2eb0d5b1ceb4
|
7
|
+
data.tar.gz: 70f2fe9495eb77b04f0d903404698ece8afc6e0a3e54c4736ec34a8687219086e99083d5c33e6f49f1c23b7d49dfb99b105f5fdbfd03a6abd0858756caa5deb4
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# SunspotTest
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/sunspot_test.png)](http://badge.fury.io/rb/sunspot_test)
|
3
|
+
[![Build Status](https://travis-ci.org/collectiveidea/sunspot_test.svg?branch=master)](https://travis-ci.org/collectiveidea/sunspot_test)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/collectiveidea/sunspot_test.png)](https://codeclimate.com/github/collectiveidea/sunspot_test)
|
5
|
+
[![Coverage Status](https://codeclimate.com/github/collectiveidea/sunspot_test/coverage.png)](https://codeclimate.com/github/collectiveidea/sunspot_test/coverage.png)
|
6
|
+
[![Dependency Status](https://gemnasium.com/collectiveidea/sunspot_test.svg)](https://gemnasium.com/collectiveidea/sunspot_test)
|
7
|
+
|
8
|
+
## How to install
|
9
|
+
|
10
|
+
Install this sunspot_test from rubygems either directly:
|
11
|
+
|
12
|
+
```bash
|
13
|
+
gem install sunspot_test
|
14
|
+
```
|
15
|
+
|
16
|
+
Or through bundler
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
# in Gemfile
|
20
|
+
gem "sunspot_test"
|
21
|
+
```
|
22
|
+
|
23
|
+
Then in Cucumber's env.rb:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'sunspot_test/cucumber'
|
27
|
+
```
|
28
|
+
|
29
|
+
## What does it do?
|
30
|
+
|
31
|
+
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.
|
32
|
+
|
33
|
+
```
|
34
|
+
@search
|
35
|
+
Feature: Books
|
36
|
+
|
37
|
+
Scenario: Searching for a book
|
38
|
+
Given a book exists with a title of "Of Mice and Men"
|
39
|
+
```
|
40
|
+
|
41
|
+
If your feature is not tagged with @search the environment will use a sunspot test proxy object which will silently swallow all requests.
|
42
|
+
|
43
|
+
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.
|
44
|
+
|
45
|
+
## Can it do RSpec?
|
46
|
+
|
47
|
+
In `spec_helper.rb`
|
48
|
+
|
49
|
+
```
|
50
|
+
require 'sunspot_test/rspec'
|
51
|
+
```
|
52
|
+
|
53
|
+
Then within your specs, you'll need to tag and explicitly commit changes to solr:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
require 'spec_helper'
|
57
|
+
|
58
|
+
describe "searching", :search => true do
|
59
|
+
it 'returns book results' do
|
60
|
+
book = Factory(:book, :title => "Of Mice and Men")
|
61
|
+
Sunspot.commit
|
62
|
+
Book.search { keywords "mice"}.results.should == [book]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
## Can it do TestUnit?
|
68
|
+
|
69
|
+
Same as RSpec.
|
70
|
+
|
71
|
+
In `test_helper.rb`
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
require 'sunspot_test/test_unit'
|
75
|
+
```
|
76
|
+
|
77
|
+
Then within your test, you'll need to tag and explicitly commit changes to solr:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
test 'searching' do
|
81
|
+
book = Factory(:book, :title => "Of Mice and Men")
|
82
|
+
Sunspot.commit
|
83
|
+
assert_equal [book], Book.search { keywords "mice"}.results
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
## Configuring the timeout
|
88
|
+
|
89
|
+
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:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
SunspotTest.solr_startup_timeout = 60 # will wait 60 seconds for the solr process to start
|
93
|
+
```
|
94
|
+
|
95
|
+
## Note on Patches/Pull Requests
|
96
|
+
|
97
|
+
* Fork the project.
|
98
|
+
* Make your feature addition or bug fix.
|
99
|
+
future version unintentionally.
|
100
|
+
* Commit, do not mess with rakefile, version, or history.
|
101
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
102
|
+
* Send me a pull request. Bonus points for topic branches.
|
103
|
+
|
104
|
+
## Copyright
|
105
|
+
|
106
|
+
Copyright (c) 2011 Zach Moazeni. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,56 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require '
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
|
4
|
-
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "sunspot_test"
|
8
|
-
gem.summary = %Q{Auto-starts solr for your cucumber tests}
|
9
|
-
gem.description = %Q{Testing sunspot with cucumber can be a pain. This gem will automatically start/stop solr with cucumber scenarios tagged with @search}
|
10
|
-
gem.email = "zach@collectiveidea.com"
|
11
|
-
gem.homepage = "https://github.com/collectiveidea/sunspot_test"
|
12
|
-
gem.authors = ["Zach Moazeni"]
|
13
|
-
gem.add_dependency "sunspot_rails", ">= 1.2.1"
|
14
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
-
end
|
16
|
-
Jeweler::GemcutterTasks.new
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
-
end
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
20
5
|
|
21
|
-
|
22
|
-
# Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
-
# spec.libs << 'lib' << 'spec'
|
24
|
-
# spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
# Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
-
# spec.libs << 'lib' << 'spec'
|
29
|
-
# spec.pattern = 'spec/**/*_spec.rb'
|
30
|
-
# spec.rcov = true
|
31
|
-
# end
|
32
|
-
#
|
33
|
-
# begin
|
34
|
-
# require 'cucumber/rake/task'
|
35
|
-
# Cucumber::Rake::Task.new(:features)
|
36
|
-
#
|
37
|
-
# task :features => :check_dependencies
|
38
|
-
# rescue LoadError
|
39
|
-
# task :features do
|
40
|
-
# abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
41
|
-
# end
|
42
|
-
# end
|
43
|
-
#
|
44
|
-
# task :spec => :check_dependencies
|
45
|
-
#
|
46
|
-
# task :default => :spec
|
47
|
-
#
|
48
|
-
# require 'rake/rdoctask'
|
49
|
-
# Rake::RDocTask.new do |rdoc|
|
50
|
-
# version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
51
|
-
#
|
52
|
-
# rdoc.rdoc_dir = 'rdoc'
|
53
|
-
# rdoc.title = "sunspot_test #{version}"
|
54
|
-
# rdoc.rdoc_files.include('README*')
|
55
|
-
# rdoc.rdoc_files.include('lib/**/*.rb')
|
56
|
-
# end
|
6
|
+
task :default => :spec
|
data/lib/sunspot_test.rb
CHANGED
@@ -68,8 +68,9 @@ module SunspotTest
|
|
68
68
|
def solr_running?
|
69
69
|
begin
|
70
70
|
solr_ping_uri = URI.parse("#{Sunspot.session.config.solr.url}/ping")
|
71
|
-
Net::HTTP.
|
72
|
-
|
71
|
+
res = Net::HTTP.get_response(solr_ping_uri)
|
72
|
+
# Solr will return 503 codes when it's starting up
|
73
|
+
res.code != '503'
|
73
74
|
rescue
|
74
75
|
false # Solr Not Running
|
75
76
|
end
|
data/lib/sunspot_test/rspec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'sunspot_test'
|
2
2
|
|
3
3
|
RSpec.configure do |c|
|
4
|
-
c.before(:
|
4
|
+
c.before(:each) do
|
5
5
|
SunspotTest.stub
|
6
6
|
end
|
7
7
|
|
8
|
-
c.before(:
|
8
|
+
c.before(:each, :search => true) do
|
9
9
|
SunspotTest.setup_solr
|
10
10
|
Sunspot.remove_all!
|
11
11
|
Sunspot.commit
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
data/spec/sunspot_test_spec.rb
CHANGED
@@ -1,158 +1,187 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe SunspotTest do
|
4
4
|
describe ".solr_startup_timeout" do
|
5
5
|
after(:all) { SunspotTest.solr_startup_timeout = 15 }
|
6
|
+
|
6
7
|
it "defaults to 15" do
|
7
|
-
SunspotTest.solr_startup_timeout.
|
8
|
+
expect(SunspotTest.solr_startup_timeout).to eq(15)
|
8
9
|
end
|
9
10
|
|
10
11
|
it "can be set using .solr_startup_timeout=" do
|
11
12
|
SunspotTest.solr_startup_timeout = 20
|
12
|
-
SunspotTest.solr_startup_timeout.
|
13
|
+
expect(SunspotTest.solr_startup_timeout).to eq(20)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
17
|
describe "setup_solr" do
|
17
18
|
it "calls unstub and start_sunspot_server" do
|
18
|
-
SunspotTest.
|
19
|
-
SunspotTest.
|
19
|
+
expect(SunspotTest).to receive(:unstub)
|
20
|
+
expect(SunspotTest).to receive(:start_sunspot_server)
|
20
21
|
SunspotTest.setup_solr
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
describe "server" do
|
25
26
|
it "creates a new Sunspot Rails Server" do
|
26
|
-
Sunspot::Rails::Server.
|
27
|
+
expect(Sunspot::Rails::Server).to receive(:new)
|
27
28
|
SunspotTest.server
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
32
|
describe ".start_sunspot_server" do
|
32
33
|
context "if server is already started" do
|
33
|
-
before
|
34
|
+
before do
|
35
|
+
allow(SunspotTest).to receive(:solr_running?) { true }
|
36
|
+
end
|
34
37
|
|
35
38
|
it "does not try to spin up another server" do
|
36
|
-
Kernel.
|
39
|
+
expect(Kernel).not_to receive(:fork)
|
37
40
|
SunspotTest.start_sunspot_server
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
41
44
|
context "if the server has NOT been started" do
|
42
|
-
before
|
43
|
-
SunspotTest.
|
45
|
+
before do
|
46
|
+
allow(SunspotTest).to receive(:wait_until_solr_starts) { true }
|
44
47
|
end
|
45
48
|
|
46
|
-
before
|
49
|
+
before do
|
47
50
|
SunspotTest.server = nil
|
48
51
|
|
49
|
-
fake_server =
|
50
|
-
SunspotTest.
|
52
|
+
fake_server = double("server")
|
53
|
+
allow(SunspotTest).to receive(:server) { fake_server }
|
51
54
|
end
|
52
55
|
|
53
56
|
# was getting funky issues when the test was broken up
|
54
57
|
it "forks the process, redirects stdout/stderr, runs server, sets exit hook, waits for server" do
|
55
58
|
|
56
|
-
SunspotTest.
|
57
|
-
STDERR.
|
58
|
-
STDOUT.
|
59
|
-
SunspotTest.server.
|
59
|
+
expect(SunspotTest).to receive(:fork) do |&block|
|
60
|
+
expect(STDERR).to receive(:reopen).with("/dev/null")
|
61
|
+
expect(STDOUT).to receive(:reopen).with("/dev/null")
|
62
|
+
expect(SunspotTest.server).to receive(:run)
|
60
63
|
block.call
|
61
64
|
end
|
62
65
|
|
63
|
-
SunspotTest.
|
64
|
-
Process.
|
66
|
+
expect(SunspotTest).to receive(:at_exit) do |&block|
|
67
|
+
expect(Process).to receive(:kill)
|
65
68
|
block.call
|
66
69
|
end
|
67
70
|
|
68
|
-
SunspotTest.
|
71
|
+
expect(SunspotTest).to receive(:wait_until_solr_starts)
|
69
72
|
SunspotTest.start_sunspot_server
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
73
76
|
describe ".stub" do
|
74
77
|
context "if the session is already stubbed" do
|
75
|
-
before
|
78
|
+
before do
|
79
|
+
SunspotTest.instance_variable_set(:@session_stubbed, true)
|
80
|
+
end
|
76
81
|
|
77
82
|
it "does nothing" do
|
78
|
-
Sunspot::Rails::StubSessionProxy.
|
83
|
+
expect(Sunspot::Rails::StubSessionProxy).not_to receive(:new)
|
79
84
|
|
80
85
|
SunspotTest.stub
|
81
86
|
end
|
82
87
|
end
|
83
88
|
|
84
89
|
context "if the session is not currently stubbed" do
|
85
|
-
before
|
90
|
+
before do
|
91
|
+
SunspotTest.instance_variable_set(:@session_stubbed, false)
|
92
|
+
end
|
86
93
|
|
87
94
|
it "stubs the Sunspot session and sets @session_stubbed to true" do
|
88
|
-
Sunspot::Rails::StubSessionProxy.
|
95
|
+
expect(Sunspot::Rails::StubSessionProxy).to receive(:new)
|
89
96
|
|
90
97
|
SunspotTest.stub
|
91
98
|
end
|
92
99
|
|
93
100
|
it "sets @session_stubbed to true" do
|
94
101
|
SunspotTest.stub
|
95
|
-
SunspotTest.instance_variable_get(:@session_stubbed).
|
102
|
+
expect(SunspotTest.instance_variable_get(:@session_stubbed)).to eq(true)
|
96
103
|
end
|
97
104
|
end
|
98
105
|
end
|
99
106
|
|
100
107
|
describe ".unstub" do
|
101
108
|
context "if the session is not stubbed" do
|
102
|
-
before
|
109
|
+
before do
|
110
|
+
SunspotTest.instance_variable_set(:@session_stubbed, false)
|
111
|
+
end
|
103
112
|
it "does nothing" do
|
104
|
-
SunspotTest.
|
113
|
+
expect(SunspotTest).not_to receive(:original_sunspot_session)
|
105
114
|
SunspotTest.unstub
|
106
115
|
end
|
107
116
|
end
|
108
117
|
|
109
118
|
context "if the session is currently stubbed" do
|
110
|
-
before
|
119
|
+
before do
|
120
|
+
SunspotTest.instance_variable_set(:@session_stubbed, true)
|
121
|
+
end
|
111
122
|
|
112
123
|
it "sets the Sunspot session to the original session" do
|
113
|
-
SunspotTest.
|
124
|
+
expect(SunspotTest).to receive(:original_sunspot_session)
|
114
125
|
|
115
126
|
SunspotTest.unstub
|
116
127
|
end
|
117
128
|
|
118
129
|
it "sets @session_stubbed to true" do
|
119
130
|
SunspotTest.unstub
|
120
|
-
SunspotTest.instance_variable_get(:@session_stubbed).
|
131
|
+
expect(SunspotTest.instance_variable_get(:@session_stubbed)).to eq(false)
|
121
132
|
end
|
122
133
|
end
|
123
134
|
end
|
124
135
|
|
125
136
|
describe ".solr_running" do
|
126
137
|
context "if solr is running" do
|
127
|
-
before
|
138
|
+
before do
|
139
|
+
Net::HTTP.stub(get_response: double(code: '200'))
|
140
|
+
end
|
128
141
|
|
129
142
|
it "returns true" do
|
130
|
-
SunspotTest.send(:solr_running?).
|
143
|
+
expect(SunspotTest.send(:solr_running?)).to eq(true)
|
131
144
|
end
|
132
145
|
end
|
133
146
|
|
134
147
|
context "if solr is not running" do
|
135
148
|
it "returns false" do
|
136
|
-
SunspotTest.send(:solr_running?).
|
149
|
+
expect(SunspotTest.send(:solr_running?)).to eq(false)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context "if solr is starting up" do
|
154
|
+
before do
|
155
|
+
Net::HTTP.stub(get_response:double(code: '503'))
|
156
|
+
end
|
157
|
+
|
158
|
+
it "returns false" do
|
159
|
+
expect(SunspotTest.send(:solr_running?)).to eq(false)
|
137
160
|
end
|
138
161
|
end
|
162
|
+
|
139
163
|
end
|
164
|
+
|
140
165
|
describe ".wait_until_solr_starts" do
|
141
166
|
context "if solr never starts" do
|
142
|
-
before
|
167
|
+
before do
|
168
|
+
SunspotTest.solr_startup_timeout = 2
|
169
|
+
end
|
143
170
|
|
144
171
|
it "calls solr_running? until solr_startup_timeout raises TimeOutError" do
|
145
|
-
SunspotTest.
|
172
|
+
expect(SunspotTest).to receive(:solr_running?).exactly((SunspotTest.solr_startup_timeout * 10) + 1).times
|
146
173
|
|
147
|
-
|
174
|
+
expect { SunspotTest.send(:wait_until_solr_starts) }
|
175
|
+
.to raise_error SunspotTest::TimeOutError, "Solr failed to start after #{SunspotTest.solr_startup_timeout} seconds"
|
148
176
|
end
|
149
177
|
end
|
150
178
|
|
151
179
|
context "if solr is started" do
|
152
180
|
it "calls solr_running? and returns" do
|
153
|
-
SunspotTest.
|
181
|
+
expect(SunspotTest).to receive(:solr_running?).exactly(2).times.and_return(true)
|
154
182
|
|
155
|
-
|
183
|
+
expect { SunspotTest.send(:wait_until_solr_starts) }
|
184
|
+
.not_to raise_error
|
156
185
|
end
|
157
186
|
end
|
158
187
|
end
|
data/sunspot_test.gemspec
CHANGED
@@ -1,59 +1,25 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
6
3
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.4.
|
4
|
+
s.name = "sunspot_test"
|
5
|
+
s.version = "0.4.1"
|
9
6
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
7
|
s.authors = ["Zach Moazeni"]
|
12
|
-
s.
|
13
|
-
s.description =
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
s.
|
20
|
-
".document",
|
21
|
-
"Gemfile",
|
22
|
-
"HISTORY",
|
23
|
-
"LICENSE",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"features/support/env.rb",
|
28
|
-
"lib/sunspot_test.rb",
|
29
|
-
"lib/sunspot_test/cucumber.rb",
|
30
|
-
"lib/sunspot_test/rspec.rb",
|
31
|
-
"lib/sunspot_test/test_unit.rb",
|
32
|
-
"spec/spec_helper.rb",
|
33
|
-
"spec/sunspot_test_spec.rb",
|
34
|
-
"sunspot_test.gemspec"
|
35
|
-
]
|
36
|
-
s.homepage = %q{https://github.com/collectiveidea/sunspot_test}
|
8
|
+
s.email = "zach@collectiveidea.com"
|
9
|
+
s.description = "Testing sunspot with cucumber can be a pain. This gem will automatically start/stop solr with cucumber scenarios tagged with @search"
|
10
|
+
s.summary = "Auto-starts solr for your cucumber tests"
|
11
|
+
s.homepage = "https://github.com/collectiveidea/sunspot_test"
|
12
|
+
s.license = "MIT"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split($/)
|
15
|
+
s.test_files = s.files.grep(/^spec/)
|
37
16
|
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = %q{1.5.2}
|
39
|
-
s.summary = %q{Auto-starts solr for your cucumber tests}
|
40
17
|
|
41
|
-
|
42
|
-
|
18
|
+
s.add_runtime_dependency "sunspot_solr"
|
19
|
+
s.add_runtime_dependency "sunspot_rails", ">= 2.1.1"
|
43
20
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
s.add_runtime_dependency(%q<sunspot_rails>, [">= 1.2.1"])
|
48
|
-
else
|
49
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
50
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
51
|
-
s.add_dependency(%q<sunspot_rails>, [">= 1.2.1"])
|
52
|
-
end
|
53
|
-
else
|
54
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
55
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
56
|
-
s.add_dependency(%q<sunspot_rails>, [">= 1.2.1"])
|
57
|
-
end
|
21
|
+
s.add_development_dependency "bundler"
|
22
|
+
s.add_development_dependency "rake"
|
23
|
+
s.add_development_dependency "rspec"
|
58
24
|
end
|
59
25
|
|
metadata
CHANGED
@@ -1,66 +1,99 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot_test
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.4.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- Zach Moazeni
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
|
-
requirements:
|
11
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sunspot_solr
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
21
17
|
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sunspot_rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
24
48
|
type: :development
|
25
49
|
prerelease: false
|
26
|
-
version_requirements:
|
27
|
-
|
28
|
-
name: rspec
|
29
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
-
none: false
|
31
|
-
requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
32
52
|
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version:
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
35
62
|
type: :development
|
36
63
|
prerelease: false
|
37
|
-
version_requirements:
|
38
|
-
|
39
|
-
name: sunspot_rails
|
40
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
43
66
|
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version:
|
46
|
-
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
47
77
|
prerelease: false
|
48
|
-
version_requirements:
|
49
|
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Testing sunspot with cucumber can be a pain. This gem will automatically
|
84
|
+
start/stop solr with cucumber scenarios tagged with @search
|
50
85
|
email: zach@collectiveidea.com
|
51
86
|
executables: []
|
52
|
-
|
53
87
|
extensions: []
|
54
|
-
|
55
|
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
|
59
|
-
- .document
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".document"
|
91
|
+
- ".gitignore"
|
92
|
+
- ".travis.yml"
|
60
93
|
- Gemfile
|
61
94
|
- HISTORY
|
62
95
|
- LICENSE
|
63
|
-
- README.
|
96
|
+
- README.md
|
64
97
|
- Rakefile
|
65
98
|
- VERSION
|
66
99
|
- features/support/env.rb
|
@@ -71,36 +104,30 @@ files:
|
|
71
104
|
- spec/spec_helper.rb
|
72
105
|
- spec/sunspot_test_spec.rb
|
73
106
|
- sunspot_test.gemspec
|
74
|
-
has_rdoc: true
|
75
107
|
homepage: https://github.com/collectiveidea/sunspot_test
|
76
|
-
licenses:
|
77
|
-
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
78
111
|
post_install_message:
|
79
112
|
rdoc_options: []
|
80
|
-
|
81
|
-
require_paths:
|
113
|
+
require_paths:
|
82
114
|
- lib
|
83
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
-
|
85
|
-
requirements:
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
86
117
|
- - ">="
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
version: "0"
|
92
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
|
-
requirements:
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
95
122
|
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version:
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
98
125
|
requirements: []
|
99
|
-
|
100
126
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
127
|
+
rubygems_version: 2.6.14
|
102
128
|
signing_key:
|
103
|
-
specification_version:
|
129
|
+
specification_version: 4
|
104
130
|
summary: Auto-starts solr for your cucumber tests
|
105
|
-
test_files:
|
106
|
-
|
131
|
+
test_files:
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
- spec/sunspot_test_spec.rb
|
data/README.rdoc
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
= sunspot_test
|
2
|
-
|
3
|
-
== How to install
|
4
|
-
|
5
|
-
Install this sunspot_test from rubygems either directly:
|
6
|
-
|
7
|
-
gem install sunspot_test
|
8
|
-
|
9
|
-
Or through bundler
|
10
|
-
|
11
|
-
# in Gemfile
|
12
|
-
gem "sunspot_test"
|
13
|
-
|
14
|
-
Then in Cucumber's env.rb:
|
15
|
-
|
16
|
-
require 'sunspot_test/cucumber'
|
17
|
-
|
18
|
-
|
19
|
-
== What does it do?
|
20
|
-
|
21
|
-
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.
|
22
|
-
|
23
|
-
@search
|
24
|
-
Feature: Books
|
25
|
-
|
26
|
-
Scenario: Searching for a book
|
27
|
-
Given a book exists with a title of "Of Mice and Men"
|
28
|
-
|
29
|
-
|
30
|
-
If you feature is not tagged with @search the environment will use a sunspot test proxy object which will silently swallow all requests.
|
31
|
-
|
32
|
-
Starting solr will depend on your settings in <b>config/sunspot.yml</b> (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.
|
33
|
-
|
34
|
-
== Can it do RSpec?
|
35
|
-
|
36
|
-
In spec_helper.rb
|
37
|
-
|
38
|
-
require 'sunspot_test/rspec'
|
39
|
-
|
40
|
-
Then within your specs, you'll need to tag and explicitly commit changes to solr:
|
41
|
-
|
42
|
-
require 'spec_helper'
|
43
|
-
|
44
|
-
describe "searching", :search => true do
|
45
|
-
it 'returns book results' do
|
46
|
-
book = Factory(:book, :title => "Of Mice and Men")
|
47
|
-
Sunspot.commit
|
48
|
-
Book.search { keywords "mice"}.results.should == [book]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
== Can it do TestUnit?
|
53
|
-
|
54
|
-
Same as RSpec.
|
55
|
-
|
56
|
-
In test_helper.rb
|
57
|
-
|
58
|
-
require 'sunspot_test/test_unit'
|
59
|
-
|
60
|
-
Then within your test, you'll need to tag and explicitly commit changes to solr:
|
61
|
-
|
62
|
-
test 'searching' do
|
63
|
-
book = Factory(:book, :title => "Of Mice and Men")
|
64
|
-
Sunspot.commit
|
65
|
-
assert_equal [book], Book.search { keywords "mice"}.results
|
66
|
-
end
|
67
|
-
|
68
|
-
== Configuring the timeout
|
69
|
-
|
70
|
-
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:
|
71
|
-
|
72
|
-
|
73
|
-
SunspotTest.solr_startup_timeout = 60 # will wait 60 seconds for the solr process to start
|
74
|
-
|
75
|
-
|
76
|
-
== Note on Patches/Pull Requests
|
77
|
-
|
78
|
-
* Fork the project.
|
79
|
-
* Make your feature addition or bug fix.
|
80
|
-
future version unintentionally.
|
81
|
-
* Commit, do not mess with rakefile, version, or history.
|
82
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
83
|
-
* Send me a pull request. Bonus points for topic branches.
|
84
|
-
|
85
|
-
== Copyright
|
86
|
-
|
87
|
-
Copyright (c) 2011 Zach Moazeni. See LICENSE for details.
|