sander6-enygma 0.0.7 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
@@ -0,0 +1,78 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Enygma::GeoDistanceProxy do
4
+
5
+ before do
6
+ @config = Enygma::Configuration.new
7
+ @search = Enygma::Search.new(@config)
8
+ @distance = 1000
9
+ @prox = Enygma::GeoDistanceProxy.new(@search, @distance)
10
+
11
+ Enygma::Search.any_instance.stubs(:query_sphinx).returns({})
12
+ Enygma::Search.any_instance.stubs(:query_database).returns([])
13
+ end
14
+
15
+ describe "initialization" do
16
+ describe "instance variables" do
17
+ it "should set @delegate to the input Enygma::Search object" do
18
+ @prox.instance_variable_get(:@delegate).should == @search
19
+ end
20
+
21
+ it "should set @distance to the given argument" do
22
+ @prox.instance_variable_get(:@distance).should == @distance
23
+ end
24
+
25
+ it "should set @units to :meters" do
26
+ @prox.instance_variable_get(:@units).should == :meters
27
+ end
28
+ end
29
+
30
+ describe "initialization from an Enygma::Search object" do
31
+ it "should return a GeoDistanceProxy when a Search is sent .within(distance)" do
32
+ @search.within(1000).class.should == Enygma::GeoDistanceProxy
33
+ end
34
+
35
+ it "should return the original search object back when the geodistance definition is complete with .of(point)" do
36
+ @search.within(1000).of(40.747778, -73.985556).should == @search
37
+ end
38
+
39
+ it "should allow units to be set in the middle of the chain only" do
40
+ lambda { @search.within(1000).feet.of(40.747778, -73.985556) }.should_not raise_error(NoMethodError)
41
+ lambda { @search.feet.within(1000).of(40.747778, -73.985556) }.should raise_error(NoMethodError)
42
+ lambda { @search.within(1000).of(40.747778, -73.985556).feet }.should raise_error(NoMethodError)
43
+ end
44
+ end
45
+ end
46
+
47
+ describe "#of" do
48
+ it "should accept a pair of lat/lng values"
49
+
50
+ it "should accept an object that responds to both lat and lng"
51
+
52
+ it "should accept an object that responds to #coordinates, which, in turn, responds to #lat and #lng"
53
+
54
+ it "should accept an object that responds to #point, which, in turn, responds to #lat and #lng"
55
+ end
56
+
57
+ describe "unit setters" do
58
+ it "should set @units to :meters when sent .meters" do
59
+ @prox.meters.instance_variable_get(:@units).should == :meters
60
+ end
61
+
62
+ it "should set @units to :kilometers when sent .kilometers" do
63
+ @prox.kilometers.instance_variable_get(:@units).should == :kilometers
64
+ end
65
+
66
+ it "should set @units to :feet when sent .feet" do
67
+ @prox.feet.instance_variable_get(:@units).should == :feet
68
+ end
69
+
70
+ it "should set @units to :yards when sent .yards" do
71
+ @prox.yards.instance_variable_get(:@units).should == :yards
72
+ end
73
+
74
+ it "should set @units to :miles when sent .miles" do
75
+ @prox.miles.instance_variable_get(:@units).should == :miles
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Enygma::Search do
4
+
5
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/enygma')
3
+ require 'spec'
4
+ require 'mocha'
5
+
6
+ Spec::Runner.configure do |config|
7
+ config.mock_with :mocha
8
+
9
+ config.before do
10
+ Sphinx::Client.any_instance.stubs(:SetServer)
11
+ end
12
+ end
13
+
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Enygma::Version do
4
+
5
+ it "should have MAJOR, MINOR, TINY, and STRING constants" do
6
+ Enygma::Version.const_defined?(:MAJOR).should be_true
7
+ Enygma::Version.const_defined?(:MINOR).should be_true
8
+ Enygma::Version.const_defined?(:TINY).should be_true
9
+ Enygma::Version.const_defined?(:STRING).should be_true
10
+ end
11
+
12
+ it "should define STRING to be 'MAJOR.MINOR.TINY'" do
13
+ Enygma::Version::STRING.should == [ Enygma::Version::MAJOR, Enygma::Version::MINOR, Enygma::Version::TINY ].join('.')
14
+ end
15
+
16
+ it "should define Enygma.version to be Enygma::Version::STRING" do
17
+ Enygma.version.should == Enygma::Version::STRING
18
+ end
19
+
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sander6-enygma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sander Hartlage
@@ -23,13 +23,43 @@ extra_rdoc_files:
23
23
  - README.markdown
24
24
  files:
25
25
  - README.markdown
26
+ - Rakefile
27
+ - lib/enygma.rb
28
+ - lib/api/sphinx.rb
29
+ - lib/api/sphinx/client.rb
30
+ - lib/api/sphinx/request.rb
31
+ - lib/api/sphinx/response.rb
32
+ - lib/enygma/configuration.rb
33
+ - lib/enygma/geodistance_proxy.rb
34
+ - lib/enygma/resource.rb
35
+ - lib/enygma/search.rb
36
+ - lib/enygma/version.rb
37
+ - lib/enygma/adapters/abstract_adapter.rb
38
+ - lib/enygma/adapters/active_record.rb
39
+ - lib/enygma/adapters/berkeley.rb
40
+ - lib/enygma/adapters/datamapper.rb
41
+ - lib/enygma/adapters/memcache.rb
42
+ - lib/enygma/adapters/sequel.rb
43
+ - lib/enygma/adapters/tokyo_cabinet.rb
44
+ - lib/enygma/extensions/float.rb
45
+ - spec/configuration_spec.rb
46
+ - spec/enygma_spec.rb
47
+ - spec/geodistance_proxy_spec.rb
48
+ - spec/search_spec.rb
49
+ - spec/spec_helper.rb
50
+ - spec/version_spec.rb
51
+ - spec/adapters/abstract_adapter_spec.rb
52
+ - spec/adapters/active_record_spec.rb
53
+ - spec/adapters/datamapper_spec.rb
54
+ - spec/adapters/sequel_spec.rb
55
+ - spec/extensions/float_spec.rb
26
56
  has_rdoc: true
27
57
  homepage: http://github.com/sander6/enygma
28
58
  post_install_message:
29
59
  rdoc_options: []
30
60
 
31
61
  require_paths:
32
- - - lib
62
+ - lib
33
63
  required_ruby_version: !ruby/object:Gem::Requirement
34
64
  requirements:
35
65
  - - ">="
@@ -44,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
74
  version:
45
75
  requirements: []
46
76
 
47
- rubyforge_project: ""
77
+ rubyforge_project:
48
78
  rubygems_version: 1.2.0
49
79
  signing_key:
50
80
  specification_version: 2