Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 55 lines (43 sloc) 1.624 kB
0410f37 @grosser more readme changes, and link to factory girl
authored
1 Simple validation testing.
2 assert_invalid_attributes(User, :email => [nil, 's', '@', 'asd@sdf'], :name => [nil, 'x', 'admin'])
3 User.email expected to be invalid when set to <asd@sdf>`
4
5 Additionally: ([Factory Girl](http://github.com/thoughtbot/factory_girl) can do some of these things better...):
6
7 - guard non-model tests from validation changes
7d3d524 @grosser remove this crazy install script and pretty-up the readme
authored
8 - valid attributes to test a controller :post or fill a form (integration tests / cucumber)
9 - create a valid record
10 - create edge-case records
11 - fixture replacement
51a02c9 @grosser initial
authored
12
3a1a9fd @grosser readme
authored
13 INSTALL
14 =======
7d3d524 @grosser remove this crazy install script and pretty-up the readme
authored
15 script/plugin install git://github.com/grosser/valid_attributes.git
6f5d97c @grosser docu layout...
authored
16
0410f37 @grosser more readme changes, and link to factory girl
authored
17 Fill `test/valid_attributes.yml` or `spec/valid_attributes.yml` with 1 valid set of attributes per model
3a1a9fd @grosser readme
authored
18
19 user:
20 name: Hans
21 login: hand
22 address_id: 1
95d10b4 @grosser docs
authored
23
0410f37 @grosser more readme changes, and link to factory girl
authored
24 ### Test::Unit
25
26 # test/test_helper.rb
27 include ValidAttributes
6bfce88 cleanup, no more global namespace pollution, specs and readme
grosser authored
28
0410f37 @grosser more readme changes, and link to factory girl
authored
29 ### RSpec
30 # spec/spec_helper.rb
6bfce88 cleanup, no more global namespace pollution, specs and readme
grosser authored
31 Spec::Runner.configure do |config|
32 ...
33 config.include(ValidAttributes)
34 ...
35 end
36
3a1a9fd @grosser readme
authored
37 USAGE
38 =====
ae55685 @grosser update readme, to make usage clear
authored
39 def test_validations
40 assert true, valid(User).valid?
41 assert_invalid_attributes(User, :email => [nil, 's', '@', 'asd@sdf'], :name => [nil, 'x', 'admin'])`
42 end
43
95d10b4 @grosser docs
authored
44 - set of valid attributes: `valid_attributes User`
45 - a valid Record(new): `valid User`
d3bda84 docs
grosser authored
46 - a valid Record(saved): `create_valid User`
0410f37 @grosser more readme changes, and link to factory girl
authored
47 - custom attributes: `valid User, :name=>'oh noo it is too long'`
51a02c9 @grosser initial
authored
48
d3bda84 docs
grosser authored
49 AUTHOR
50 ======
b9c831a docs
grosser authored
51 Michael Grosser
b8da09c docs
grosser authored
52 grosser.michael@gmail.com
45eb0ff docs
grosser authored
53 Hereby placed under public domain, do what you want, just do not hold me accountable...
0410f37 @grosser more readme changes, and link to factory girl
authored
54 Derived from [`assert_invalid`](http://www.railsforum.com/viewtopic.php?id=741)
Something went wrong with that request. Please try again.