mongoid_monkey 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,12 @@
1
+ require "spec_helper"
2
+
3
+ if defined?(Moped) && Moped::VERSION =~ /\A1\./
4
+
5
+ describe Moped::Node do
6
+ let(:node){ Moped::Node.new("127.0.0.1:27017") }
7
+
8
+ it { expect(described_class.included_modules).to include(Moped::Instrumentable) }
9
+ it { expect(node.instrumenter).to eq Moped::Instrumentable::Noop }
10
+ it { expect(node).to respond_to(:instrument) }
11
+ end
12
+ end
@@ -0,0 +1,62 @@
1
+ require "spec_helper"
2
+
3
+ if defined?(Moped)
4
+
5
+ describe Moped::Database do
6
+
7
+ describe "#collection_names" do
8
+
9
+ let(:session) do
10
+ Moped::Session.new([ "127.0.0.1:27017" ], database: "moped_test")
11
+ end
12
+
13
+ let(:database) do
14
+ described_class.new(session, :moped_test)
15
+ end
16
+
17
+ let(:collection_names) do
18
+ database.collection_names
19
+ end
20
+
21
+ before do
22
+ session.drop
23
+ names.map do |name|
24
+ session.command(create: name)
25
+ end
26
+ end
27
+
28
+ context "when name doesn't include system" do
29
+
30
+ let(:names) do
31
+ %w[ users comments ]
32
+ end
33
+
34
+ it "returns the name of all non system collections" do
35
+ expect(collection_names.sort).to eq([ "comments", "users" ])
36
+ end
37
+ end
38
+
39
+ context "when name includes system not at the beginning" do
40
+
41
+ let(:names) do
42
+ %w[ users comments_system_fu ]
43
+ end
44
+
45
+ it "returns the name of all non system collections" do
46
+ expect(collection_names.sort).to eq([ "comments_system_fu", "users" ])
47
+ end
48
+ end
49
+
50
+ context "when name includes system at the beginning" do
51
+
52
+ let(:names) do
53
+ %w[ users system_comments_fu ]
54
+ end
55
+
56
+ it "returns the name of all non system collections" do
57
+ expect(collection_names.sort).to eq([ "system_comments_fu", "users" ])
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ if Mongoid::VERSION =~ /\A3\./
4
+
5
+ class Origin::Query
6
+ include Origin::Queryable
7
+ end
8
+
9
+ describe Origin::Optional do
10
+
11
+ let(:query) do
12
+ Origin::Query.new
13
+ end
14
+
15
+ describe "#reoder" do
16
+
17
+ let(:selection) do
18
+ query.order_by(field_one: 1, field_two: -1)
19
+ end
20
+
21
+ let(:reordered) do
22
+ selection.reorder(field_three: 1)
23
+ end
24
+
25
+ it "replaces all order options with the new options" do
26
+ expect(reordered.options).to eq(sort: { "field_three" => 1 })
27
+ end
28
+ end
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid_monkey
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - johnnyshields
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mongoid
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ description: A collection of monkey patches for Mongoid containing feature backports,
56
+ fixes, and forward compatibility.
57
+ email:
58
+ - johnny.shields@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - LICENSE
64
+ - README.md
65
+ - lib/mongoid_monkey.rb
66
+ - lib/patches/atomic.rb
67
+ - lib/patches/big_decimal.rb
68
+ - lib/patches/instrument.rb
69
+ - lib/patches/list_collections.rb
70
+ - lib/patches/reorder.rb
71
+ - lib/version.rb
72
+ - spec/config/mongodb-mmapv1.conf
73
+ - spec/config/mongodb-wiredtiger.conf
74
+ - spec/gemfile/mongoid3.gemfile
75
+ - spec/gemfile/mongoid4.gemfile
76
+ - spec/gemfile/mongoid5.gemfile
77
+ - spec/spec_helper.rb
78
+ - spec/unit/atomic_spec.rb
79
+ - spec/unit/big_decimal_spec.rb
80
+ - spec/unit/instrument_spec.rb
81
+ - spec/unit/list_collections_spec.rb
82
+ - spec/unit/reorder_spec.rb
83
+ homepage: https://github.com/johnnyshields/mongoid_monkey
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.4.7
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Monkey patches for Mongoid
107
+ test_files:
108
+ - spec/config/mongodb-mmapv1.conf
109
+ - spec/config/mongodb-wiredtiger.conf
110
+ - spec/gemfile/mongoid3.gemfile
111
+ - spec/gemfile/mongoid4.gemfile
112
+ - spec/gemfile/mongoid5.gemfile
113
+ - spec/spec_helper.rb
114
+ - spec/unit/atomic_spec.rb
115
+ - spec/unit/big_decimal_spec.rb
116
+ - spec/unit/instrument_spec.rb
117
+ - spec/unit/list_collections_spec.rb
118
+ - spec/unit/reorder_spec.rb
119
+ has_rdoc: