assert_db_rejects 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ == Change Log
2
+
3
+ === 0.1.0 (November 14, 2009)
4
+
5
+ * Initial release.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jack Christensen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,27 @@
1
+ AssertDbRejects
2
+ ===============
3
+
4
+ Test database level constraints with ActiveRecord.
5
+
6
+
7
+ Installation
8
+ ============
9
+
10
+ The gem is hosted on http://gemcutter.org.
11
+
12
+ config.gem 'assert_db_rejects'
13
+
14
+ Example
15
+ =======
16
+
17
+ # Assume the people table has a not null constraint on name. The assertion
18
+ # will pass if a ActiveRecord::StatementInvalid is raised when saving p.
19
+ # Validations are bypassed by assert_db_rejects as the purpose is to test
20
+ # the database and not the model
21
+ p = Person.new( :name => nil )
22
+ assert_db_rejects(p)
23
+
24
+ License
25
+ =======
26
+
27
+ Copyright (c) 2009 Jack Christensen, released under the MIT license
@@ -0,0 +1,24 @@
1
+ require 'rake'
2
+ require 'rake/gempackagetask'
3
+
4
+ $LOAD_PATH.unshift("lib")
5
+ require 'assert_db_rejects'
6
+
7
+ spec = Gem::Specification.new do |s|
8
+ s.name = "assert_db_rejects"
9
+ s.version = AssertDbRejects::VERSION
10
+ s.summary = "Test database level constraints with ActiveRecord"
11
+ s.homepage = "http://github.com/JackC/assert_db_rejects"
12
+
13
+ s.files = FileList["[A-Z]*", "{bin,lib,rails,test}/**/*"]
14
+
15
+ s.author = "Jack Christensen"
16
+ s.email = "jack@jackchristensen.com"
17
+ end
18
+
19
+ Rake::GemPackageTask.new( spec ) do |pkg|
20
+ pkg.need_tar = true
21
+ pkg.need_zip = true
22
+ end
23
+
24
+
@@ -0,0 +1,14 @@
1
+ require 'test/unit'
2
+
3
+ module AssertDbRejects
4
+ VERSION = '0.1.0'
5
+
6
+ # passes if saving r without validations raises an exception from the database
7
+ def assert_db_rejects(r, message="")
8
+ assert_raise( ActiveRecord::StatementInvalid, message ) do
9
+ r.save(false)
10
+ end
11
+ end
12
+ end
13
+
14
+ Test::Unit::TestCase.send :include, AssertDbRejects
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: assert_db_rejects
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jack Christensen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-14 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: jack@jackchristensen.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - MIT-LICENSE
26
+ - CHANGELOG
27
+ - README.markdown
28
+ - Rakefile
29
+ - lib/assert_db_rejects.rb
30
+ has_rdoc: true
31
+ homepage: http://github.com/JackC/assert_db_rejects
32
+ licenses: []
33
+
34
+ post_install_message:
35
+ rdoc_options: []
36
+
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project:
54
+ rubygems_version: 1.3.5
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Test database level constraints with ActiveRecord
58
+ test_files: []
59
+