accept_values_for 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,13 +13,15 @@ begin
13
13
  gemspec.name = "accept_values_for"
14
14
  gemspec.summary = "In order to test a complex validation for ActiveRecord models Implemented accept_values_for custom rspec matcher"
15
15
  gemspec.description = <<-EOI
16
- When you have a complex validation(e.g. regexp or custom method) on ActiveRecord model
16
+ Rspec: When you have a complex validation(e.g. regexp or custom method) on ActiveRecord model
17
17
  you have to write annoying easy specs on which values should be accepted by your validation method and which should not.
18
18
  accepts_values_for rspec matcher simplify the code. See example for more information.
19
19
  EOI
20
20
  gemspec.email = "agresso@gmail.com"
21
21
  gemspec.homepage = "http://github.com/bogdan/accept_values_for"
22
22
  gemspec.authors = ["Bogdan Gusiev"]
23
+ gemspec.add_dependency "activerecord"
24
+ gemspec.add_dependency "rspec"
23
25
  end
24
26
  rescue LoadError
25
27
  puts "Jeweler not available. Install it with: [sudo] gem install jeweler"
@@ -0,0 +1,39 @@
1
+ h1. Accept values for
2
+
3
+ h2. Description
4
+
5
+ In order to spec a complex validation for ActiveRecord models.
6
+ Implemented accept_values_for custom matcher.
7
+ With this matcher you can specify which values of model attribute should be accepted by model validation and which should not.
8
+
9
+
10
+ h2. Usage
11
+
12
+ <pre>
13
+ describe User do
14
+
15
+ subject { User.new(@valid_attributes)}
16
+
17
+
18
+
19
+ it { should accept_values_for(:email, "john@example.com", "lambda@gusiev.com") }
20
+ it { should_not accept_values_for(:email, "invalid", nil, "a@b", "john@.com") }
21
+
22
+ end
23
+ </pre>
24
+
25
+ h2. Dependencies
26
+
27
+ * ActiveRecord
28
+ * Rspec
29
+
30
+ h2. Install
31
+
32
+
33
+ h3. Command line:
34
+
35
+ <pre>[sudo] gem install accept_values_for</pre>
36
+
37
+ h3. spec_helper.rb:
38
+
39
+ <pre>require 'accept_values_for'</pre>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -38,7 +38,8 @@ class AcceptValuesFor #:nodoc:
38
38
  return false unless model.is_a?(ActiveRecord::Base)
39
39
  @values.each do |value|
40
40
  model.send("#{@attribute}=", value)
41
- unless model.valid?
41
+ model.valid?
42
+ if model.errors.on(@attribute)
42
43
  @failed_value = value
43
44
  return false
44
45
  end
@@ -49,7 +50,7 @@ class AcceptValuesFor #:nodoc:
49
50
  def failure_message_for_should
50
51
  result = "expected #{@model.inspect} to accept value #{@failed_value.inspect} for #{@attribute.inspect}, but it was not\n"
51
52
  if @model.respond_to?(:errors) && ActiveRecord::Errors === @model.errors
52
- result += "Errors: " + @model.errors.full_messages.join(", ")
53
+ result += "Errors: " + @model.errors.on(@attribute).full_messages.join(", ")
53
54
  end
54
55
  result
55
56
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 1
9
- version: 0.1.1
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bogdan Gusiev
@@ -14,12 +14,35 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-05 00:00:00 +03:00
17
+ date: 2010-05-14 00:00:00 +03:00
18
18
  default_executable:
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activerecord
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: rspec
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :runtime
43
+ version_requirements: *id002
21
44
  description: |
22
- When you have a complex validation(e.g. regexp or custom method) on ActiveRecord model
45
+ Rspec: When you have a complex validation(e.g. regexp or custom method) on ActiveRecord model
23
46
  you have to write annoying easy specs on which values should be accepted by your validation method and which should not.
24
47
  accepts_values_for rspec matcher simplify the code. See example for more information.
25
48
 
@@ -33,7 +56,7 @@ extra_rdoc_files: []
33
56
  files:
34
57
  - Gemfile
35
58
  - Rakefile
36
- - Readme.rdoc
59
+ - Readme.textile
37
60
  - VERSION
38
61
  - lib/accept_values_for.rb
39
62
  - spec/accept_values_for_spec.rb
@@ -1,23 +0,0 @@
1
- = Accept values for
2
-
3
-
4
-
5
- == DESCRIPTION
6
-
7
- In order to spec a complex validation for ActiveRecord models
8
- Implemented accept_values_for custom matcher
9
-
10
- == SYNOPSIS:
11
-
12
- describe User do
13
-
14
- subject { User.new(@valid_attributes)}
15
-
16
-
17
-
18
- it { should accept_values_for(:email, "john@example.com", "lambda@gusiev.com") }
19
- it { should_not accept_values_for(:email, "invalid", nil, "a@b", "john@.com") }
20
-
21
- end
22
-
23
-