mongoid-rspec 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.bundle/config CHANGED
@@ -1,2 +1,3 @@
1
1
  ---
2
2
  BUNDLE_WITHOUT: ""
3
+ BUNDLE_DISABLE_SHARED_GEMS: "1"
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm 1.9.2-head
1
+ rvm 1.9.2-rc2
data/Gemfile CHANGED
@@ -1,11 +1,11 @@
1
1
  # A sample Gemfile
2
2
  source :gemcutter
3
3
 
4
- gem "rails", "3.0.0.beta3"
4
+ gem "rails", "3.0.0.rc"
5
5
 
6
- gem "mongoid", ">= 2.0.0.beta4"
7
- gem "bson_ext", ">= 0.20.1"
6
+ gem "mongoid", :git => 'git://github.com/durran/mongoid.git'
7
+ gem 'bson_ext', '>= 1.0.4'
8
8
 
9
9
  gem 'redgreen'
10
10
 
11
- gem 'rspec-rails', ">= 2.0.0.beta.7"
11
+ gem 'rspec-rails', ">= 2.0.0.beta.19"
data/Gemfile.lock ADDED
@@ -0,0 +1,109 @@
1
+ GIT
2
+ remote: git://github.com/durran/mongoid.git
3
+ revision: 93bd79e
4
+ specs:
5
+ mongoid (2.0.0.beta.15)
6
+ activemodel (= 3.0.0.rc)
7
+ bson (= 1.0.4)
8
+ mongo (= 1.0.6)
9
+ tzinfo (= 0.3.22)
10
+ will_paginate (~> 3.0.pre)
11
+
12
+ GEM
13
+ remote: http://rubygems.org/
14
+ specs:
15
+ abstract (1.0.0)
16
+ actionmailer (3.0.0.rc)
17
+ actionpack (= 3.0.0.rc)
18
+ mail (~> 2.2.5)
19
+ actionpack (3.0.0.rc)
20
+ activemodel (= 3.0.0.rc)
21
+ activesupport (= 3.0.0.rc)
22
+ builder (~> 2.1.2)
23
+ erubis (~> 2.6.6)
24
+ i18n (~> 0.4.1)
25
+ rack (~> 1.2.1)
26
+ rack-mount (~> 0.6.9)
27
+ rack-test (~> 0.5.4)
28
+ tzinfo (~> 0.3.22)
29
+ activemodel (3.0.0.rc)
30
+ activesupport (= 3.0.0.rc)
31
+ builder (~> 2.1.2)
32
+ i18n (~> 0.4.1)
33
+ activerecord (3.0.0.rc)
34
+ activemodel (= 3.0.0.rc)
35
+ activesupport (= 3.0.0.rc)
36
+ arel (~> 0.4.0)
37
+ tzinfo (~> 0.3.22)
38
+ activeresource (3.0.0.rc)
39
+ activemodel (= 3.0.0.rc)
40
+ activesupport (= 3.0.0.rc)
41
+ activesupport (3.0.0.rc)
42
+ arel (0.4.0)
43
+ activesupport (>= 3.0.0.beta)
44
+ bson (1.0.4)
45
+ bson_ext (1.0.4)
46
+ builder (2.1.2)
47
+ diff-lcs (1.1.2)
48
+ erubis (2.6.6)
49
+ abstract (>= 1.0.0)
50
+ i18n (0.4.1)
51
+ mail (2.2.5)
52
+ activesupport (>= 2.3.6)
53
+ mime-types
54
+ treetop (>= 1.4.5)
55
+ mime-types (1.16)
56
+ mongo (1.0.6)
57
+ bson (>= 1.0.4)
58
+ nokogiri (1.4.3.1)
59
+ polyglot (0.3.1)
60
+ rack (1.2.1)
61
+ rack-mount (0.6.9)
62
+ rack (>= 1.0.0)
63
+ rack-test (0.5.4)
64
+ rack (>= 1.0)
65
+ rails (3.0.0.rc)
66
+ actionmailer (= 3.0.0.rc)
67
+ actionpack (= 3.0.0.rc)
68
+ activerecord (= 3.0.0.rc)
69
+ activeresource (= 3.0.0.rc)
70
+ activesupport (= 3.0.0.rc)
71
+ bundler (>= 1.0.0.rc.1)
72
+ railties (= 3.0.0.rc)
73
+ railties (3.0.0.rc)
74
+ actionpack (= 3.0.0.rc)
75
+ activesupport (= 3.0.0.rc)
76
+ rake (>= 0.8.3)
77
+ thor (~> 0.14.0)
78
+ rake (0.8.7)
79
+ redgreen (1.2.2)
80
+ rspec (2.0.0.beta.19)
81
+ rspec-core (= 2.0.0.beta.19)
82
+ rspec-expectations (= 2.0.0.beta.19)
83
+ rspec-mocks (= 2.0.0.beta.19)
84
+ rspec-core (2.0.0.beta.19)
85
+ rspec-expectations (2.0.0.beta.19)
86
+ diff-lcs (>= 1.1.2)
87
+ rspec-mocks (2.0.0.beta.19)
88
+ rspec-rails (2.0.0.beta.19)
89
+ rspec (= 2.0.0.beta.19)
90
+ webrat (>= 0.7.2.beta.1)
91
+ thor (0.14.0)
92
+ treetop (1.4.8)
93
+ polyglot (>= 0.3.1)
94
+ tzinfo (0.3.22)
95
+ webrat (0.7.2.beta.1)
96
+ nokogiri (>= 1.2.0)
97
+ rack (>= 1.0)
98
+ rack-test (>= 0.5.3)
99
+ will_paginate (3.0.pre2)
100
+
101
+ PLATFORMS
102
+ ruby
103
+
104
+ DEPENDENCIES
105
+ bson_ext (>= 1.0.4)
106
+ mongoid!
107
+ rails (= 3.0.0.rc)
108
+ redgreen
109
+ rspec-rails (>= 2.0.0.beta.19)
data/Rakefile CHANGED
@@ -10,9 +10,9 @@ begin
10
10
  gem.email = "evansagge@gmail.com"
11
11
  gem.homepage = "http://github.com/evansagge/mongoid-rspec"
12
12
  gem.authors = ["Evan Sagge"]
13
- gem.add_dependency "mongoid", ">= 2.0.0.beta3"
14
- gem.add_dependency "bson_ext", ">= 0.20.1"
15
- gem.add_dependency "rspec-rails", ">= 2.0.0.beta.7"
13
+ gem.add_dependency "mongoid", ">= 2.0.0.beta.15"
14
+ gem.add_dependency "bson_ext", ">= 1.0.4"
15
+ gem.add_dependency "rspec-rails", ">= 2.0.0.beta.19"
16
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
17
  end
18
18
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.2.0
@@ -16,12 +16,12 @@ module Mongoid
16
16
  @association = {}
17
17
  @association[:name] = name.to_s
18
18
  @association[:type] = association_type
19
- begin
20
- @association[:class] = name.to_s.classify.constantize
21
- rescue
22
- end
19
+ # begin
20
+ # @association[:class] = name.to_s.classify.constantize
21
+ # rescue
22
+ # end
23
23
  @expectation_message = "#{type_description} #{@association[:name].inspect}"
24
- @expectation_message << " of type #{@association[:class].inspect}"
24
+ @expectation_message << " of type #{@association[:class].inspect}" unless @association[:class].nil?
25
25
  end
26
26
 
27
27
  def of_type(klass)
@@ -56,7 +56,7 @@ module Mongoid
56
56
  @positive_result_message = "#{@actual.inspect} #{type_description(association.association, false)} #{@association[:name]}"
57
57
  end
58
58
 
59
- if @association[:class] != association.klass
59
+ if !@association[:class].nil? and @association[:class] != association.klass
60
60
  @negative_result_message = "#{@positive_result_message} of type #{association.klass.inspect}"
61
61
  return false
62
62
  else
@@ -97,11 +97,11 @@ module Mongoid
97
97
  when EMBEDDED_IN.name
98
98
  (passive ? 'be' : 'is') << ' embedded in'
99
99
  when HAS_ONE.name
100
- (passive ? 'have' : 'has') << ' one related'
100
+ (passive ? 'reference' : 'references') << ' one'
101
101
  when HAS_MANY.name
102
- (passive ? 'have' : 'has') << ' many related'
102
+ (passive ? 'reference' : 'references') << ' many'
103
103
  when BELONGS_TO.name
104
- (passive ? 'belong' : 'belongs') << ' to related'
104
+ (passive ? 'be referenced in' : 'referenced in')
105
105
  else
106
106
  raise "Unknown association type"
107
107
  end
@@ -123,14 +123,17 @@ module Mongoid
123
123
  def have_one_related(association_name)
124
124
  HaveAssociationMatcher.new(association_name, HAS_ONE)
125
125
  end
126
+ alias :reference_one :have_one_related
126
127
 
127
128
  def have_many_related(association_name)
128
129
  HaveAssociationMatcher.new(association_name, HAS_MANY)
129
- end
130
+ end
131
+ alias :reference_many :have_many_related
130
132
 
131
133
  def belong_to_related(association_name)
132
134
  HaveAssociationMatcher.new(association_name, BELONGS_TO)
133
- end
135
+ end
136
+ alias :be_referenced_in :belong_to_related
134
137
  end
135
138
  end
136
139
  end
@@ -6,15 +6,15 @@ module Mongoid
6
6
  end
7
7
 
8
8
  def of_type(type)
9
- @type = type
9
+ @type = type
10
10
  self
11
11
  end
12
-
12
+
13
13
  def with_default_value_of(default)
14
14
  @default = default
15
15
  self
16
16
  end
17
-
17
+
18
18
  def matches?(klass)
19
19
  @klass = klass.is_a?(Class) ? klass : klass.class
20
20
  @errors = []
@@ -24,11 +24,11 @@ module Mongoid
24
24
  if @type and @klass.fields[attr].type != @type
25
25
  error << " of type #{@klass.fields[attr].type}"
26
26
  end
27
-
27
+
28
28
  if @default and @klass.fields[attr].default != @default
29
29
  error << " with default value of #{@klass.fields[attr].default}"
30
30
  end
31
-
31
+
32
32
  @errors.push("field #{attr.inspect}" << error) unless error.blank?
33
33
  else
34
34
  @errors.push "no field named #{attr.inspect}"
@@ -52,51 +52,51 @@ module Mongoid
52
52
  desc
53
53
  end
54
54
  end
55
-
55
+
56
56
  def have_field(*args)
57
57
  HaveFieldMatcher.new(*args)
58
58
  end
59
59
  alias_method :have_fields, :have_field
60
-
60
+
61
61
  class SaveMatcher
62
62
  def initialize(attributes = {})
63
63
  @attributes = attributes
64
64
  end
65
-
65
+
66
66
  def matches?(actual)
67
- @actual = actual.is_a?(Class) ?
67
+ @actual = actual.is_a?(Class) ?
68
68
  ( defined?(::Factory) ? ::Factory.build(actual.name.underscore, @attributes) : actual.new(@attributes)) :
69
69
  actual
70
70
  @actual.valid? and @actual.save
71
71
  end
72
-
72
+
73
73
  def failure_message_for_should
74
74
  "Expected #{@actual.inspect} to save properly, got #{@actual.errors.full_messages.to_sentence}"
75
75
  end
76
-
76
+
77
77
  def failure_message_for_should_not
78
78
  "Expected #{@actual.inspect} to not save, got saved instead"
79
79
  end
80
-
80
+
81
81
  def description
82
82
  "save properly"
83
83
  end
84
84
  end
85
-
85
+
86
86
  def save(attributes = {})
87
87
  SaveMatcher.new(attributes)
88
88
  end
89
- alias_method :save_properly, :save
90
-
89
+ alias_method :save_properly, :save
90
+
91
91
  end
92
92
  end
93
93
 
94
- Rspec::Matchers.define :have_instance_method do |name|
94
+ RSpec::Matchers.define :have_instance_method do |name|
95
95
  match do |klass|
96
96
  klass.instance_methods.include?(name.to_sym)
97
97
  end
98
-
98
+
99
99
  description do
100
100
  "have instance method #{name.to_s}"
101
101
  end
102
- end
102
+ end
@@ -38,4 +38,4 @@ module Mongoid
38
38
  end
39
39
  end
40
40
  end
41
- end
41
+ end
data/lib/mongoid-rspec.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
 
3
3
  require 'mongoid'
4
+ require 'rspec'
4
5
  require 'matchers/document'
5
6
  require 'matchers/associations'
6
7
  require 'matchers/validations'
@@ -16,4 +17,4 @@ module Mongoid
16
17
  include Mongoid::Matchers::Associations
17
18
  include Mongoid::Matchers::Validations
18
19
  end
19
- end
20
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid-rspec}
8
- s.version = "1.1.2"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Evan Sagge"]
12
- s.date = %q{2010-06-08}
12
+ s.date = %q{2010-08-03}
13
13
  s.description = %q{RSpec matches for Mongoid models, including association and validation matchers}
14
14
  s.email = %q{evansagge@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  ".gitignore",
23
23
  ".rvmrc",
24
24
  "Gemfile",
25
+ "Gemfile.lock",
25
26
  "LICENSE",
26
27
  "README.rdoc",
27
28
  "Rakefile",
@@ -49,7 +50,7 @@ Gem::Specification.new do |s|
49
50
  s.homepage = %q{http://github.com/evansagge/mongoid-rspec}
50
51
  s.rdoc_options = ["--charset=UTF-8"]
51
52
  s.require_paths = ["lib"]
52
- s.rubygems_version = %q{1.3.6}
53
+ s.rubygems_version = %q{1.3.7}
53
54
  s.summary = %q{RSpec matchers for Mongoid}
54
55
  s.test_files = [
55
56
  "spec/models/article.rb",
@@ -66,19 +67,19 @@ Gem::Specification.new do |s|
66
67
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
67
68
  s.specification_version = 3
68
69
 
69
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
70
- s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.beta3"])
71
- s.add_runtime_dependency(%q<bson_ext>, [">= 0.20.1"])
72
- s.add_runtime_dependency(%q<rspec-rails>, [">= 2.0.0.beta.7"])
70
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
71
+ s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.beta.15"])
72
+ s.add_runtime_dependency(%q<bson_ext>, [">= 1.0.4"])
73
+ s.add_runtime_dependency(%q<rspec-rails>, [">= 2.0.0.beta.19"])
73
74
  else
74
- s.add_dependency(%q<mongoid>, [">= 2.0.0.beta3"])
75
- s.add_dependency(%q<bson_ext>, [">= 0.20.1"])
76
- s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta.7"])
75
+ s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.15"])
76
+ s.add_dependency(%q<bson_ext>, [">= 1.0.4"])
77
+ s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta.19"])
77
78
  end
78
79
  else
79
- s.add_dependency(%q<mongoid>, [">= 2.0.0.beta3"])
80
- s.add_dependency(%q<bson_ext>, [">= 0.20.1"])
81
- s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta.7"])
80
+ s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.15"])
81
+ s.add_dependency(%q<bson_ext>, [">= 1.0.4"])
82
+ s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta.19"])
82
83
  end
83
84
  end
84
85
 
@@ -6,7 +6,7 @@ class Article
6
6
  field :published, :type => Boolean, :default => false
7
7
 
8
8
  embeds_many :comments
9
- belongs_to_related :user, :inverse_of => :articles
9
+ referenced_in :user, :inverse_of => :articles
10
10
 
11
11
  validates :title, :presence => true
12
12
  end
@@ -2,5 +2,5 @@ class Comment
2
2
  include Mongoid::Document
3
3
 
4
4
  embedded_in :article, :inverse_of => :comments
5
- belongs_to_related :user, :inverse_of => :comments
5
+ referenced_in :user, :inverse_of => :comments
6
6
  end
data/spec/models/user.rb CHANGED
@@ -5,8 +5,8 @@ class User
5
5
  field :email
6
6
  field :role
7
7
 
8
- has_many_related :articles
9
- has_many_related :comments
8
+ references_many :articles
9
+ references_many :comments
10
10
 
11
11
  embeds_one :profile
12
12
 
data/spec/spec_helper.rb CHANGED
@@ -22,11 +22,11 @@ Dir[ File.join(MODELS, "*.rb") ].sort.each { |file| require File.basename(file)
22
22
 
23
23
  require 'mongoid-rspec'
24
24
 
25
- Rspec.configure do |config|
26
- config.include Rspec::Matchers
25
+ RSpec.configure do |config|
26
+ config.include RSpec::Matchers
27
27
  config.include Mongoid::Matchers
28
28
  config.mock_with :rspec
29
29
  config.after :all do
30
30
  Mongoid.master.collections.each(&:drop)
31
31
  end
32
- end
32
+ end
@@ -1,31 +1,31 @@
1
- require 'spec_helper'
2
-
3
- describe "Associations" do
4
- describe User do
5
- subject { User }
6
-
7
- it { should have_many_related :articles }
8
- it { should have_many_related :comments }
9
- it { should embed_one :profile }
10
- end
11
-
12
- describe Profile do
13
- subject { Profile }
14
-
15
- it { should be_embedded_in(:user).as_inverse_of(:profile) }
16
- end
17
-
18
- describe Article do
19
- subject { Article }
20
-
21
- it { should belong_to_related(:user).as_inverse_of(:articles) }
22
- it { should embed_many(:comments) }
23
- end
24
-
25
- describe Comment do
26
- subject { Comment }
27
-
28
- it { should be_embedded_in(:article).as_inverse_of(:comments) }
29
- it { should belong_to_related(:user).as_inverse_of(:comments) }
30
- end
31
- end
1
+ # require 'spec_helper'
2
+ #
3
+ # describe "Associations" do
4
+ # describe User do
5
+ # subject { User }
6
+ #
7
+ # it { should reference_many :articles }
8
+ # it { should reference_many :comments }
9
+ # it { should embed_one :profile }
10
+ # end
11
+ #
12
+ # describe Profile do
13
+ # subject { Profile }
14
+ #
15
+ # it { should be_embedded_in(:user).as_inverse_of(:profile) }
16
+ # end
17
+ #
18
+ # describe Article do
19
+ # subject { Article }
20
+ #
21
+ # it { should be_referenced_in(:user).as_inverse_of(:articles) }
22
+ # it { should embed_many(:comments) }
23
+ # end
24
+ #
25
+ # describe Comment do
26
+ # subject { Comment }
27
+ #
28
+ # it { should be_embedded_in(:article).as_inverse_of(:comments) }
29
+ # it { should be_referenced_in(:user).as_inverse_of(:comments) }
30
+ # end
31
+ # end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
8
7
  - 2
9
- version: 1.1.2
8
+ - 0
9
+ version: 1.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Evan Sagge
@@ -14,13 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-08 00:00:00 +08:00
17
+ date: 2010-08-03 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: mongoid
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
@@ -28,28 +29,31 @@ dependencies:
28
29
  - 2
29
30
  - 0
30
31
  - 0
31
- - beta3
32
- version: 2.0.0.beta3
32
+ - beta
33
+ - 15
34
+ version: 2.0.0.beta.15
33
35
  type: :runtime
34
36
  version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency
36
38
  name: bson_ext
37
39
  prerelease: false
38
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
39
42
  requirements:
40
43
  - - ">="
41
44
  - !ruby/object:Gem::Version
42
45
  segments:
43
- - 0
44
- - 20
45
46
  - 1
46
- version: 0.20.1
47
+ - 0
48
+ - 4
49
+ version: 1.0.4
47
50
  type: :runtime
48
51
  version_requirements: *id002
49
52
  - !ruby/object:Gem::Dependency
50
53
  name: rspec-rails
51
54
  prerelease: false
52
55
  requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
53
57
  requirements:
54
58
  - - ">="
55
59
  - !ruby/object:Gem::Version
@@ -58,8 +62,8 @@ dependencies:
58
62
  - 0
59
63
  - 0
60
64
  - beta
61
- - 7
62
- version: 2.0.0.beta.7
65
+ - 19
66
+ version: 2.0.0.beta.19
63
67
  type: :runtime
64
68
  version_requirements: *id003
65
69
  description: RSpec matches for Mongoid models, including association and validation matchers
@@ -77,6 +81,7 @@ files:
77
81
  - .gitignore
78
82
  - .rvmrc
79
83
  - Gemfile
84
+ - Gemfile.lock
80
85
  - LICENSE
81
86
  - README.rdoc
82
87
  - Rakefile
@@ -110,6 +115,7 @@ rdoc_options:
110
115
  require_paths:
111
116
  - lib
112
117
  required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
113
119
  requirements:
114
120
  - - ">="
115
121
  - !ruby/object:Gem::Version
@@ -117,6 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
123
  - 0
118
124
  version: "0"
119
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
120
127
  requirements:
121
128
  - - ">="
122
129
  - !ruby/object:Gem::Version
@@ -126,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
133
  requirements: []
127
134
 
128
135
  rubyforge_project:
129
- rubygems_version: 1.3.6
136
+ rubygems_version: 1.3.7
130
137
  signing_key:
131
138
  specification_version: 3
132
139
  summary: RSpec matchers for Mongoid