sunspot_test 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +10 -0
- data/README.rdoc +16 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/sunspot_test.rb +0 -43
- data/lib/sunspot_test/cucumber.rb +54 -0
- data/sunspot_test.gemspec +17 -21
- metadata +11 -11
- data/.gitignore +0 -21
data/HISTORY
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
0.2.0 - May 26, 2011
|
2
|
+
* Moved requires from "sunspot_test" to "sunspot_test/cucumber" so we didn't conflict with bundler's autorequire.
|
3
|
+
* Added non-@search functionality which stubs out the session and consequently speeds up the non-searching tests.
|
4
|
+
* Added a configurable startup_timeout which defaults to 15 seconds.
|
5
|
+
0.1.2 - May 25, 2011
|
6
|
+
* Wrote a more descriptive Readme for new users.
|
7
|
+
0.1.1 - May 18, 2011
|
8
|
+
* Moved the repo to collectiveidea.
|
9
|
+
0.1.0 - May 18, 2011
|
10
|
+
* Initial codebase to github.
|
data/README.rdoc
CHANGED
@@ -10,6 +10,11 @@ Or through bundler
|
|
10
10
|
|
11
11
|
# in Gemfile
|
12
12
|
gem "sunspot_test"
|
13
|
+
|
14
|
+
Then in Cucumber's env.rb:
|
15
|
+
|
16
|
+
require 'sunspot_test/cucumber'
|
17
|
+
|
13
18
|
|
14
19
|
== What does it do?
|
15
20
|
|
@@ -22,13 +27,22 @@ This gem will automatically start and stop solr for cucumber tests when using th
|
|
22
27
|
Given a book exists with a title of "Of Mice and Men"
|
23
28
|
|
24
29
|
|
25
|
-
|
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
|
+
== Configuring the timeout
|
35
|
+
|
36
|
+
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:
|
37
|
+
|
38
|
+
|
39
|
+
SunspotTestHelper.startup_timeout = 60 # will wait 60 seconds for the solr process to start
|
40
|
+
|
26
41
|
|
27
42
|
== Note on Patches/Pull Requests
|
28
43
|
|
29
44
|
* Fork the project.
|
30
45
|
* Make your feature addition or bug fix.
|
31
|
-
* Add tests for it. This is important so I don't break it in a
|
32
46
|
future version unintentionally.
|
33
47
|
* Commit, do not mess with rakefile, version, or history.
|
34
48
|
(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)
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ begin
|
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "sunspot_test"
|
8
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 @
|
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
10
|
gem.email = "zach@collectiveidea.com"
|
11
11
|
gem.homepage = "https://github.com/collectiveidea/sunspot_test"
|
12
12
|
gem.authors = ["Zach Moazeni"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/sunspot_test.rb
CHANGED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
|
3
|
-
Before("@searchrunning") do
|
4
|
-
$sunspot = true
|
5
|
-
end
|
6
|
-
|
7
|
-
Before("@search") do
|
8
|
-
unless $sunspot
|
9
|
-
$sunspot = Sunspot::Rails::Server.new
|
10
|
-
pid = fork do
|
11
|
-
STDERR.reopen('/dev/null')
|
12
|
-
STDOUT.reopen('/dev/null')
|
13
|
-
$sunspot.run
|
14
|
-
end
|
15
|
-
# shut down the Solr server
|
16
|
-
at_exit { Process.kill('TERM', pid) }
|
17
|
-
SunspotHelpers.wait_until_solr_starts
|
18
|
-
end
|
19
|
-
|
20
|
-
Sunspot.remove_all!
|
21
|
-
Sunspot.commit
|
22
|
-
end
|
23
|
-
|
24
|
-
AfterStep('@search') do
|
25
|
-
Sunspot.commit
|
26
|
-
end
|
27
|
-
|
28
|
-
module SunspotHelpers
|
29
|
-
def self.wait_until_solr_starts
|
30
|
-
solr_started = false
|
31
|
-
ping_uri = URI.parse("#{Sunspot.session.config.solr.url}/ping")
|
32
|
-
150.times do
|
33
|
-
begin
|
34
|
-
Net::HTTP.get(ping_uri)
|
35
|
-
solr_started = true
|
36
|
-
break
|
37
|
-
rescue
|
38
|
-
sleep(0.1)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
raise "Solr failed to start after 15 seconds" unless solr_started
|
42
|
-
end
|
43
|
-
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
$original_sunspot_session = Sunspot.session
|
4
|
+
|
5
|
+
Before("@searchrunning") do
|
6
|
+
$sunspot = true
|
7
|
+
end
|
8
|
+
|
9
|
+
Before("~@search") do
|
10
|
+
Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session)
|
11
|
+
end
|
12
|
+
|
13
|
+
Before("@search") do
|
14
|
+
unless $sunspot
|
15
|
+
$sunspot = Sunspot::Rails::Server.new
|
16
|
+
pid = fork do
|
17
|
+
STDERR.reopen('/dev/null')
|
18
|
+
STDOUT.reopen('/dev/null')
|
19
|
+
$sunspot.run
|
20
|
+
end
|
21
|
+
# shut down the Solr server
|
22
|
+
at_exit { Process.kill('TERM', pid) }
|
23
|
+
SunspotTestHelper.wait_until_solr_starts
|
24
|
+
end
|
25
|
+
|
26
|
+
Sunspot.session = $original_sunspot_session
|
27
|
+
Sunspot.remove_all!
|
28
|
+
Sunspot.commit
|
29
|
+
end
|
30
|
+
|
31
|
+
AfterStep('@search') do
|
32
|
+
Sunspot.commit
|
33
|
+
end
|
34
|
+
|
35
|
+
module SunspotTestHelper
|
36
|
+
@@startup_timeout = 15
|
37
|
+
def self.startup_timeout; @@startup_timeout; end
|
38
|
+
def self.startup_timeout=(seconds); @@startup_timeout = seconds; end
|
39
|
+
|
40
|
+
def self.wait_until_solr_starts
|
41
|
+
solr_started = false
|
42
|
+
ping_uri = URI.parse("#{Sunspot.session.config.solr.url}/ping")
|
43
|
+
(@@startup_timeout * 10).times do
|
44
|
+
begin
|
45
|
+
Net::HTTP.get(ping_uri)
|
46
|
+
solr_started = true
|
47
|
+
break
|
48
|
+
rescue
|
49
|
+
sleep(0.1)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
raise "Solr failed to start after 15 seconds" unless solr_started
|
53
|
+
end
|
54
|
+
end
|
data/sunspot_test.gemspec
CHANGED
@@ -1,44 +1,40 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sunspot_test}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Zach Moazeni"]
|
12
|
-
s.date = %q{2011-05-
|
13
|
-
s.description = %q{Testing sunspot with cucumber can be a pain. This gem will automatically start/stop solr with cucumber scenarios tagged with @
|
12
|
+
s.date = %q{2011-05-26}
|
13
|
+
s.description = %q{Testing sunspot with cucumber can be a pain. This gem will automatically start/stop solr with cucumber scenarios tagged with @search}
|
14
14
|
s.email = %q{zach@collectiveidea.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
21
|
+
"HISTORY",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"features/support/env.rb",
|
27
|
+
"lib/sunspot_test.rb",
|
28
|
+
"lib/sunspot_test/cucumber.rb",
|
29
|
+
"spec/spec.opts",
|
30
|
+
"spec/spec_helper.rb",
|
31
|
+
"spec/sunspot_test_spec.rb",
|
32
|
+
"sunspot_test.gemspec"
|
32
33
|
]
|
33
34
|
s.homepage = %q{https://github.com/collectiveidea/sunspot_test}
|
34
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
35
35
|
s.require_paths = ["lib"]
|
36
36
|
s.rubygems_version = %q{1.4.2}
|
37
37
|
s.summary = %q{Auto-starts solr for your cucumber tests}
|
38
|
-
s.test_files = [
|
39
|
-
"spec/spec_helper.rb",
|
40
|
-
"spec/sunspot_test_spec.rb"
|
41
|
-
]
|
42
38
|
|
43
39
|
if s.respond_to? :specification_version then
|
44
40
|
s.specification_version = 3
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zach Moazeni
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-26 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
version: 1.2.9
|
51
51
|
type: :development
|
52
52
|
version_requirements: *id002
|
53
|
-
description: Testing sunspot with cucumber can be a pain. This gem will automatically start/stop solr with cucumber scenarios tagged with @
|
53
|
+
description: Testing sunspot with cucumber can be a pain. This gem will automatically start/stop solr with cucumber scenarios tagged with @search
|
54
54
|
email: zach@collectiveidea.com
|
55
55
|
executables: []
|
56
56
|
|
@@ -61,13 +61,14 @@ extra_rdoc_files:
|
|
61
61
|
- README.rdoc
|
62
62
|
files:
|
63
63
|
- .document
|
64
|
-
-
|
64
|
+
- HISTORY
|
65
65
|
- LICENSE
|
66
66
|
- README.rdoc
|
67
67
|
- Rakefile
|
68
68
|
- VERSION
|
69
69
|
- features/support/env.rb
|
70
70
|
- lib/sunspot_test.rb
|
71
|
+
- lib/sunspot_test/cucumber.rb
|
71
72
|
- spec/spec.opts
|
72
73
|
- spec/spec_helper.rb
|
73
74
|
- spec/sunspot_test_spec.rb
|
@@ -77,8 +78,8 @@ homepage: https://github.com/collectiveidea/sunspot_test
|
|
77
78
|
licenses: []
|
78
79
|
|
79
80
|
post_install_message:
|
80
|
-
rdoc_options:
|
81
|
-
|
81
|
+
rdoc_options: []
|
82
|
+
|
82
83
|
require_paths:
|
83
84
|
- lib
|
84
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -106,6 +107,5 @@ rubygems_version: 1.4.2
|
|
106
107
|
signing_key:
|
107
108
|
specification_version: 3
|
108
109
|
summary: Auto-starts solr for your cucumber tests
|
109
|
-
test_files:
|
110
|
-
|
111
|
-
- spec/sunspot_test_spec.rb
|
110
|
+
test_files: []
|
111
|
+
|