veracious 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ =Introduction
2
+
3
+ Gee... it sure would be awesome if ActiveResource _actually_ allowed us to do client-side validation of our ActiveResource objects
4
+ like their documentation promises:http://apidock.com/rails/ActiveResource/Base
@@ -0,0 +1 @@
1
+ require 'veracious/veracious_activeresource_enhancement'
@@ -0,0 +1,9 @@
1
+ ActiveResource::Base.class_eval do
2
+ def valid_with_client_side?
3
+ errors.clear
4
+ validate if defined?(validate)
5
+ valid_without_client_side?
6
+ end
7
+
8
+ alias_method_chain :valid?, :client_side
9
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe "ActiveResource" do
4
+ describe "Base" do
5
+ it "should validate client side without requiring a \"create\" or \"save\" call" do
6
+ class Book < ActiveResource::Base
7
+ self.site = ''
8
+ protected
9
+ def validate
10
+ errors.add(:author, 'is required') if (author.blank? rescue false)
11
+ end
12
+ end
13
+ @book = Book.new :author => ''
14
+ @book.valid?.should == false
15
+ @book.errors.on(:author).should == "is required"
16
+ @book.errors.count.should == 1
17
+ end
18
+
19
+ it "should not fail if the user has not defined the validate method" do
20
+ class Novel < ActiveResource::Base
21
+ self.site = ''
22
+ end
23
+ @book = Novel.new :author => ''
24
+ @book.valid?.should == true
25
+ @book.errors.on(:author).should == nil
26
+ @book.errors.count.should == 0
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ $LOAD_PATH << './lib'
2
+ require 'activeresource'
3
+ require 'veracious'
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: veracious
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matt Parker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-09 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.3
24
+ version:
25
+ description: "Gee\xE2\x80\xA6 it sure would be awesome if ActiveResource actually allowed usto do client-side validation of our ActiveResource objects like theirdocumentation promises: http://apidock.com/rails/ActiveResource/Base"
26
+ email: moonmaster9000@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ files:
34
+ - README.rdoc
35
+ - lib/veracious.rb
36
+ - lib/veracious/veracious_activeresource_enhancement.rb
37
+ has_rdoc: true
38
+ homepage: http://github.com/moonmaster9000/veracious
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options:
43
+ - --charset=UTF-8
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.3.5
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Client side validation of Active Resource objects
65
+ test_files:
66
+ - spec/lib_specs/activeresource_validation_spec.rb
67
+ - spec/spec_helper.rb