mongoid-rspec 1.5.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -118,6 +118,7 @@ Others
118
118
  describe User do
119
119
  it { should have_fields(:email, :login) }
120
120
  it { should have_field(:active).of_type(Boolean).with_default_value_of(false) }
121
+ it { should have_field(:s).with_alias(:status) }
121
122
  it { should have_fields(:birthdate, :registered_at).of_type(DateTime) }
122
123
 
123
124
  it { should be_timestamped_document } # if you're declaring `include
@@ -9,6 +9,11 @@ module Mongoid
9
9
  @type = type
10
10
  self
11
11
  end
12
+
13
+ def with_alias(field_alias)
14
+ @field_alias = field_alias
15
+ self
16
+ end
12
17
 
13
18
  def with_default_value_of(default)
14
19
  @default = default
@@ -28,6 +33,10 @@ module Mongoid
28
33
  if !@default.nil? and !@klass.fields[attr].default_val.nil? and @klass.fields[attr].default_val != @default
29
34
  error << " with default value of #{@klass.fields[attr].default_val}"
30
35
  end
36
+
37
+ if @field_alias and @klass.fields[attr].options[:as] != @field_alias
38
+ error << " with alias #{@klass.fields[attr].options[:as]}"
39
+ end
31
40
 
32
41
  @errors.push("field #{attr.inspect}" << error) unless error.blank?
33
42
  else
@@ -48,6 +57,7 @@ module Mongoid
48
57
  def description
49
58
  desc = "have #{@attributes.size > 1 ? 'fields' : 'field'} named #{@attributes.collect(&:inspect).to_sentence}"
50
59
  desc << " of type #{@type.inspect}" if @type
60
+ desc << " with alias #{@field_alias}" if @field_alias
51
61
  desc << " with default value of #{@default.inspect}" if !@default.nil?
52
62
  desc
53
63
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Rspec
3
- VERSION = "1.5.3"
3
+ VERSION = "1.5.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70177756732360 !ruby/object:Gem::Requirement
16
+ requirement: &70302138817480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70177756732360
24
+ version_requirements: *70302138817480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mongoid
27
- requirement: &70177756731080 !ruby/object:Gem::Requirement
27
+ requirement: &70302138816280 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70177756731080
35
+ version_requirements: *70302138816280
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70177756728480 !ruby/object:Gem::Requirement
38
+ requirement: &70302138813320 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '2.9'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70177756728480
46
+ version_requirements: *70302138813320
47
47
  description: RSpec matches for Mongoid models, including association and validation
48
48
  matchers
49
49
  email: evansagge@gmail.com