Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Type is mandatory.

  • Loading branch information...
commit 8c80da3c4c9c3697a8dab8dea9d1d975034392ec 1 parent 8504512
@nmerouze nmerouze authored
View
4 README.md
@@ -5,8 +5,8 @@ Remarkable matchers for [MongoMapper](http://github.com/jnunemaker/mongomapper).
## Matchers
<pre><code>
-it { should have_key(:name, :type => String) }
-it { should have_keys(:name, :phone_number, :type => String) }
+it { should have_key(:name, String) }
+it { should have_keys(:name, :phone_number, String) }
it { should validate_presence_of(:name, :phone_number, :message => "not there!") }
it { should belong_to(:user, :class_name => 'Person') }
it { should have_many(:users, :class_name => 'Person', :polymorphic => true) }
View
21 lib/remarkable_mongomapper/matchers/have_key_matcher.rb
@@ -3,17 +3,13 @@ module MongoMapper
module Matchers
class HaveKeyMatcher < Remarkable::MongoMapper::Base
- arguments :collection => :attributes, :as => :attribute
-
- optional :type
-
- default_options :type => nil
+ arguments :type, :collection => :attributes, :as => :attribute
collection_assertions :has_key?
- before_assert do
- @type = @options[:type]
- end
+ # before_assert do
+ # @type = @options[:type]
+ # end
protected
@@ -27,14 +23,13 @@ def has_key?
#
# == Examples
#
- # should_have_key :name, :type => String
+ # should_have_key :name, String
#
- # it { should have_key(:name, :type => String) }
- # it { should have_keys(:name, :phone_number, :type => String) }
- # it { should have_key(:name).type(String) }
+ # it { should have_key(:name, String) }
+ # it { should have_keys(:name, :phone_number, String) }
#
def have_key(*args, &block)
- HaveKeyMatcher.new(*args, &block).spec(self)
+ HaveKeyMatcher.new(args.pop, *args, &block).spec(self)
end
alias :have_keys :have_key
View
12 spec/matchers/have_key_matcher_spec.rb
@@ -8,12 +8,12 @@
describe 'messages' do
it 'should contain a description' do
- matcher = have_key(:title, :type => String)
+ matcher = have_key(:title, String)
matcher.description.should == 'have key(s) title'
end
it 'should set has_key? message' do
- matcher = have_key(:owner, :type => String)
+ matcher = have_key(:owner, String)
matcher.matches?(subject)
matcher.failure_message.should == 'Expected Article to have key named owner with type String'
end
@@ -21,12 +21,12 @@
end
describe 'matchers' do
- it { should have_key(:title, :type => String) }
- it { should have_keys(:title, :body, :type => String) }
+ it { should have_key(:title, String) }
+ it { should have_keys(:title, :body, String) }
end
describe 'macros' do
- should_have_key :title, :type => String
- should_have_keys :title, :body, :type => String
+ should_have_key :title, String
+ should_have_keys :title, :body, String
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.