accept_values_for 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog.textile +3 -0
- data/Readme.textile +2 -1
- data/VERSION +1 -1
- data/accept_values_for.gemspec +4 -3
- data/lib/accept_values_for.rb +1 -1
- data/spec/accept_values_for_spec.rb +10 -0
- metadata +4 -3
data/Changelog.textile
ADDED
data/Readme.textile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/accept_values_for.gemspec
CHANGED
@@ -5,18 +5,19 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{accept_values_for}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bogdan Gusiev"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-09}
|
13
13
|
s.description = %q{Rspec: When you have a complex validation(e.g. regexp or custom method) on ActiveRecord model
|
14
14
|
you have to write annoying easy specs on which values should be accepted by your validation method and which should not.
|
15
15
|
accepts_values_for rspec matcher simplify the code. See example for more information.
|
16
16
|
}
|
17
17
|
s.email = %q{agresso@gmail.com}
|
18
18
|
s.files = [
|
19
|
-
"
|
19
|
+
"Changelog.textile",
|
20
|
+
"Gemfile",
|
20
21
|
"Rakefile",
|
21
22
|
"Readme.textile",
|
22
23
|
"VERSION",
|
data/lib/accept_values_for.rb
CHANGED
@@ -63,7 +63,7 @@ class AcceptValuesFor #:nodoc:
|
|
63
63
|
def failure_message_for_should
|
64
64
|
result = "expected #{@model.inspect} to accept value #{@failed_value.inspect} for #{@attribute.inspect}, but it was not\n"
|
65
65
|
if @model.respond_to?(:errors) && ActiveRecord::Errors === @model.errors
|
66
|
-
result += "Errors: " + @model.errors.on(@attribute).
|
66
|
+
result += "Errors: " + Array(@model.errors.on(@attribute)).join(", ")
|
67
67
|
end
|
68
68
|
result
|
69
69
|
end
|
@@ -11,4 +11,14 @@ describe "AcceptValuesFor" do
|
|
11
11
|
it "should have custom condition for should_not" do
|
12
12
|
accept_values_for(:gender, "INVALID", "MALE").does_not_match?(subject).should be_false
|
13
13
|
end
|
14
|
+
|
15
|
+
describe "#matches?" do
|
16
|
+
let(:matcher) { accept_values_for(:gender, "INVALID") }
|
17
|
+
|
18
|
+
it "should return false if one of values is not accepted" do
|
19
|
+
matcher.matches?(subject).should be_false
|
20
|
+
matcher.failure_message_for_should.should == "expected #{subject.inspect} to accept value \"INVALID\" for :gender, but it was not\n" +
|
21
|
+
"Errors: is not included in the list"
|
22
|
+
end
|
23
|
+
end
|
14
24
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 1
|
9
|
+
version: 0.3.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Bogdan Gusiev
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-09-09 00:00:00 +03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -54,6 +54,7 @@ extensions: []
|
|
54
54
|
extra_rdoc_files: []
|
55
55
|
|
56
56
|
files:
|
57
|
+
- Changelog.textile
|
57
58
|
- Gemfile
|
58
59
|
- Rakefile
|
59
60
|
- Readme.textile
|