Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
run "bundle exec rspec jmongo_spec.rb" for failing spec demonstrating…
Browse files Browse the repository at this point in the history
… the error
  • Loading branch information
leemhenson committed Jul 23, 2011
1 parent a109fcd commit fb92815
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .rvmrc
@@ -0,0 +1,3 @@
rvm jruby-1.6.3@jmongo --create
export JRUBY_OPTS="--1.9"

2 changes: 2 additions & 0 deletions Gemfile
@@ -0,0 +1,2 @@
source :rubygems
gemspec
34 changes: 34 additions & 0 deletions Gemfile.lock
@@ -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
3 changes: 3 additions & 0 deletions jmongo.gemspec
Expand Up @@ -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
33 changes: 31 additions & 2 deletions spec/jmongo_spec.rb
@@ -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
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
@@ -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
Expand Down

0 comments on commit fb92815

Please sign in to comment.