Permalink
Browse files

Add compatibility to mongo_mapper 0.7.x

  • Loading branch information...
1 parent 6577d15 commit 0105a176d32efbe8ebba7d47d6ad582f184544a5 @shingara shingara committed with nmerouze Jun 3, 2010
View
@@ -10,9 +10,9 @@ begin
gem.email = "nicolas.merouze@gmail.com"
gem.homepage = "http://github.com/nmerouze/remarkable_mongo"
gem.authors = ["Nicolas Mérouze"]
-
- gem.add_dependency('remarkable', '~> 3.1.8')
- gem.add_dependency('mongo_mapper', '~> 0.6.1')
+
+ gem.add_dependency('remarkable')
+ gem.add_dependency('mongo_mapper', '~>0.7.6')
end
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
@@ -25,4 +25,4 @@ desc 'Run all the specs for the machinist plugin.'
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.rcov = false
-end
+end
@@ -2,23 +2,23 @@ module Remarkable
module MongoMapper
module Matchers
class HaveKeyMatcher < Remarkable::MongoMapper::Base
-
+
arguments :type, :collection => :attributes, :as => :attribute
-
+
collection_assertions :has_key?
-
+
# before_assert do
# @type = @options[:type]
# end
protected
def has_key?
- @subject.respond_to?(@attribute) && @subject.class.keys[@attribute] == ::MongoMapper::Key.new(@attribute, @type)
+ @subject.respond_to?(@attribute) && @subject.class.keys[@attribute] == ::MongoMapper::Plugins::Keys::Key.new(@attribute, @type)
end
end
-
+
# Ensures that a key of the database actually exists.
#
# == Examples
@@ -35,4 +35,4 @@ def have_key(*args, &block)
end
end
-end
+end
@@ -7,12 +7,11 @@ class ValidateLengthOfMatcher < Remarkable::MongoMapper::Base #:nodoc:
optional :within, :minimum, :maximum, :is
optional :allow_nil, :allow_blank, :default => true
optional :message
-
+
default_options :message => "is invalid"
- collection_assertions :less_than_min_length?, :exactly_min_length?,
- :more_than_max_length?, :exactly_max_length?,
- :allow_nil?, :allow_blank?
+ collection_assertions :allow_nil?, :allow_blank?, :less_than_min_length?, :exactly_min_length?,
+ :more_than_max_length?, :exactly_max_length?
before_assert do
if @options[:is]
View
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Nicolas M\303\251rouze"]
- s.date = %q{2010-01-11}
+ s.date = %q{2010-06-03}
s.email = %q{nicolas.merouze@gmail.com}
s.extra_rdoc_files = [
"LICENSE",
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
"lib/remarkable/mongo_mapper/matchers/validate_length_of_matcher.rb",
"lib/remarkable/mongo_mapper/matchers/validate_presence_of_matcher.rb",
"locales/en.yml",
+ "remarkable_mongo.gemspec",
"spec/matchers/allow_values_for_matcher_spec.rb",
"spec/matchers/association_matcher_spec.rb",
"spec/matchers/have_key_matcher_spec.rb",
@@ -46,7 +47,7 @@ Gem::Specification.new do |s|
s.homepage = %q{http://github.com/nmerouze/remarkable_mongo}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
+ s.rubygems_version = %q{1.3.7}
s.summary = %q{Remarkable Matchers for MongoDB ORMs}
s.test_files = [
"spec/matchers/allow_values_for_matcher_spec.rb",
@@ -64,16 +65,16 @@ Gem::Specification.new do |s|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<remarkable>, ["~> 3.1.8"])
- s.add_runtime_dependency(%q<mongo_mapper>, ["~> 0.6.1"])
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<remarkable>, [">= 0"])
+ s.add_runtime_dependency(%q<mongo_mapper>, ["~> 0.7.6"])
else
- s.add_dependency(%q<remarkable>, ["~> 3.1.8"])
- s.add_dependency(%q<mongo_mapper>, ["~> 0.6.1"])
+ s.add_dependency(%q<remarkable>, [">= 0"])
+ s.add_dependency(%q<mongo_mapper>, ["~> 0.7.6"])
end
else
- s.add_dependency(%q<remarkable>, ["~> 3.1.8"])
- s.add_dependency(%q<mongo_mapper>, ["~> 0.6.1"])
+ s.add_dependency(%q<remarkable>, [">= 0"])
+ s.add_dependency(%q<mongo_mapper>, ["~> 0.7.6"])
end
end
@@ -9,10 +9,10 @@ def define_and_validate(options={})
@model = define_model :product do
include MongoMapper::Document
-
+
key :size, String
key :category, String
-
+
validates_length_of :size, options
end
@@ -21,7 +21,7 @@ def define_and_validate(options={})
describe 'messages' do
before(:each){ @matcher = define_and_validate }
-
+
it 'should contain a description' do
@matcher.within(3..5)
@matcher.description.should == 'ensure length of size is within 3..5 characters'
View
@@ -1,27 +1,28 @@
class Article
include MongoMapper::Document
-
+
key :title, String, :required => true
key :body, String
-
+
many :comments
many :unknowns
many :ratings, :class_name => "Rate"
many :assets
+
belongs_to :user
belongs_to :unknown
belongs_to :site, :class_name => 'Site'
end
class Comment
include MongoMapper::EmbeddedDocument
-
+
key :body, String
end
class User
include MongoMapper::Document
-
+
key :login, String
end
@@ -39,4 +40,12 @@ class Site
class Webiste
include MongoMapper::EmbeddedDocument
-end
+end
+
+class Unknown
+ include MongoMapper::Document
+end
+
+class Asset
+ include MongoMapper::Document
+end

0 comments on commit 0105a17

Please sign in to comment.