Permalink
Browse files

run "bundle exec rspec jmongo_spec.rb" for failing spec demonstrating…

… the error
  • Loading branch information...
1 parent a109fcd commit fb9281524526be3c0f60245604587371cb78dc93 @leemhenson leemhenson committed Jul 23, 2011
Showing with 75 additions and 4 deletions.
  1. +3 −0 .rvmrc
  2. +2 −0 Gemfile
  3. +34 −0 Gemfile.lock
  4. +3 −0 jmongo.gemspec
  5. +31 −2 spec/jmongo_spec.rb
  6. +2 −2 spec/spec_helper.rb
View
3 .rvmrc
@@ -0,0 +1,3 @@
+rvm jruby-1.6.3@jmongo --create
+export JRUBY_OPTS="--1.9"
+
View
@@ -0,0 +1,2 @@
+source :rubygems
+gemspec
View
@@ -0,0 +1,34 @@
+PATH
+ remote: .
+ specs:
+ jmongo (0.1.6)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ awesome_print (0.4.0)
+ bones (3.7.0)
+ little-plugger (>= 1.1.2)
+ loquacious (>= 1.7.0)
+ rake (>= 0.8.7)
+ diff-lcs (1.1.2)
+ little-plugger (1.1.2)
+ loquacious (1.8.1)
+ rake (0.9.2)
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.4)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+
+PLATFORMS
+ java
+
+DEPENDENCIES
+ awesome_print
+ bones (>= 3.4.1)
+ jmongo!
+ rspec
View
@@ -33,4 +33,7 @@ Gem::Specification.new do |s|
else
s.add_dependency(%q<bones>, [">= 3.4.1"])
end
+
+ s.add_development_dependency 'awesome_print'
+ s.add_development_dependency 'rspec'
end
View
@@ -1,6 +1,35 @@
-
require File.join(File.dirname(__FILE__), %w[spec_helper])
describe Mongo do
-end
+ let(:doc) { { :parent => { :child_1 => '1', :child_2 => 2 } } }
+
+ before do
+ connection = Mongo::Connection.new('localhost', 27017, :safe => { :fsync => true })
+ @db = connection.db('jmongo_specs')
+ @db.collections.select { |c| c.name !~ /system/ }.each { |c| @db.drop_collection c.name }
+ @db.create_collection 'docs'
+ @collection = @db.collection 'docs'
+ @collection.insert doc
+ end
+
+ context "find all" do
+ subject { @collection.find.to_a }
+ it { should have(1).item }
+ end
+ context "complex query" do
+ let(:doc2) { { :_id => { :id_1 => 'x', :id_2 => 5 }, :foo => 'bar' } }
+ let(:query) { { '_id.id_2' => 5, '_id.id_1' => 'x' } }
+ before { @collection.insert doc2 }
+
+ describe "failing find_one" do
+ subject { @collection.find_one(query) }
+ it { should_not be_nil }
+ end
+
+ describe "passing find" do
+ subject { @collection.find(query).to_a.first }
+ it { should_not be_nil }
+ end
+ end
+end
View
@@ -1,7 +1,7 @@
-
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib jmongo]))
+require 'ap'
-Spec::Runner.configure do |config|
+RSpec.configure do |config|
# == Mock Framework
#
# RSpec uses it's own mocking framework by default. If you prefer to

0 comments on commit fb92815

Please sign in to comment.