Skip to content

Commit

Permalink
Merge branch '90yukke-dynamic-document-matcher'
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigopinto committed Jan 29, 2015
2 parents deb3057 + 3f56583 commit a13fbad
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -200,6 +200,7 @@ end

RSpec.describe Log do
it { is_expected.to be_stored_in :logs }
it { is_expected.to be_dynamic_document }
end

RSpec.describe Article do
Expand Down
10 changes: 10 additions & 0 deletions lib/matchers/document.rb
Expand Up @@ -161,3 +161,13 @@ def have_field(*args)
"be a multiparameted Mongoid document"
end
end

RSpec::Matchers.define :be_dynamic_document do |_|
match do |doc|
doc.class.included_modules.include?(Mongoid::Attributes::Dynamic)
end

description do
'be a Mongoid document with dynamic attributes'
end
end
2 changes: 2 additions & 0 deletions spec/models/log.rb
@@ -1,6 +1,8 @@
class Log
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Attributes::Dynamic

store_in collection: "logs"

index({ created_at: 1 }, { bucket_size: 100, expire_after_seconds: 3600 } )
Expand Down
5 changes: 5 additions & 0 deletions spec/unit/document_spec.rb
Expand Up @@ -18,4 +18,9 @@
it { is_expected.to be_mongoid_document }
it { is_expected.to be_timestamped_document }
end

describe Log do
it { is_expected.to be_mongoid_document }
it { is_expected.to be_dynamic_document }
end
end

0 comments on commit a13fbad

Please sign in to comment.