plucky 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ require 'helper'
2
+
3
+ class PluckyTest < Test::Unit::TestCase
4
+ context "Plucky" do
5
+ context ".to_object_id" do
6
+ setup do
7
+ @id = BSON::ObjectId.new
8
+ end
9
+
10
+ should "convert nil to nil" do
11
+ Plucky.to_object_id(nil).should be_nil
12
+ end
13
+
14
+ should "convert blank to nil" do
15
+ Plucky.to_object_id('').should be_nil
16
+ end
17
+
18
+ should "leave object id alone" do
19
+ Plucky.to_object_id(@id).should equal(@id)
20
+ end
21
+
22
+ should "convert string to object id" do
23
+ Plucky.to_object_id(@id.to_s).should == @id
24
+ end
25
+
26
+ should "not convert string that is not legal object id" do
27
+ Plucky.to_object_id('foo').should == 'foo'
28
+ Plucky.to_object_id(1).should == 1
29
+ end
30
+ end
31
+
32
+ context "::Methods" do
33
+ should "return array of methods" do
34
+ Plucky::Methods.should == [
35
+ :where, :filter, :limit, :skip, :offset, :sort, :order,
36
+ :fields, :ignore, :only,
37
+ :each, :find_each,
38
+ :count, :size, :distinct,
39
+ :last, :first, :all, :paginate,
40
+ :exists?, :exist?, :empty?,
41
+ :to_a, :remove,
42
+ ]
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,11 @@
1
+ require 'helper'
2
+
3
+ class SymbolTest < Test::Unit::TestCase
4
+ context "Symbol" do
5
+ SymbolOperators.each do |operator|
6
+ should "respond to #{operator}" do
7
+ :foo.send(operator).should be_instance_of(SymbolOperator)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,49 @@
1
+ require 'helper'
2
+
3
+ class SymbolOperatorTest < Test::Unit::TestCase
4
+ context "SymbolOperator" do
5
+ setup { @operator = SymbolOperator.new(:foo, 'in') }
6
+ subject { @operator }
7
+
8
+ should "have field" do
9
+ subject.field.should == :foo
10
+ end
11
+
12
+ should "have operator" do
13
+ subject.operator.should == 'in'
14
+ end
15
+
16
+ context "==" do
17
+ should "be true if field and operator are equal" do
18
+ SymbolOperator.new(:foo, 'in').should == SymbolOperator.new(:foo, 'in')
19
+ end
20
+
21
+ should "be false if fields are equal but operators are not" do
22
+ SymbolOperator.new(:foo, 'in').should_not == SymbolOperator.new(:foo, 'all')
23
+ end
24
+
25
+ should "be false if operators are equal but fields are not" do
26
+ SymbolOperator.new(:foo, 'in').should_not == SymbolOperator.new(:bar, 'in')
27
+ end
28
+
29
+ should "be false if neither are equal" do
30
+ SymbolOperator.new(:foo, 'in').should_not == SymbolOperator.new(:bar, 'all')
31
+ end
32
+ end
33
+
34
+ context "<=>" do
35
+ should "same field, different operator" do
36
+ (SymbolOperator.new(:foo, 'in') <=> SymbolOperator.new(:foo, 'all')).should == 1
37
+ (SymbolOperator.new(:foo, 'all') <=> SymbolOperator.new(:foo, 'in')).should == -1
38
+ end
39
+
40
+ should "same field same operator" do
41
+ (SymbolOperator.new(:foo, 'in') <=> SymbolOperator.new(:foo, 'in')).should == 0
42
+ end
43
+
44
+ should "different field" do
45
+ (SymbolOperator.new(:foo, 'in') <=> SymbolOperator.new(:bar, 'in')).should == 1
46
+ end
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plucky
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Nunemaker
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-23 00:00:00 Z
18
+ date: 2011-05-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: mongo
@@ -25,11 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- hash: 9
28
+ hash: 25
29
29
  segments:
30
30
  - 1
31
31
  - 3
32
- version: "1.3"
32
+ - 1
33
+ version: 1.3.1
33
34
  type: :runtime
34
35
  version_requirements: *id001
35
36
  description:
@@ -46,14 +47,25 @@ files:
46
47
  - lib/plucky/extensions/duplicable.rb
47
48
  - lib/plucky/extensions/symbol.rb
48
49
  - lib/plucky/extensions.rb
50
+ - lib/plucky/new_relic.rb
49
51
  - lib/plucky/options_hash.rb
50
52
  - lib/plucky/pagination/decorator.rb
51
53
  - lib/plucky/pagination/paginator.rb
52
54
  - lib/plucky/query.rb
53
55
  - lib/plucky/version.rb
54
56
  - lib/plucky.rb
57
+ - test/helper.rb
58
+ - test/plucky/pagination/test_decorator.rb
59
+ - test/plucky/pagination/test_paginator.rb
60
+ - test/plucky/test_criteria_hash.rb
61
+ - test/plucky/test_options_hash.rb
62
+ - test/plucky/test_query.rb
63
+ - test/test_plucky.rb
64
+ - test/test_symbol.rb
65
+ - test/test_symbol_operator.rb
55
66
  - LICENSE
56
67
  - README.rdoc
68
+ - UPGRADES
57
69
  homepage: http://github.com/jnunemaker/plucky
58
70
  licenses: []
59
71