koujou 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/koujou.gemspec +1 -1
- data/lib/koujou.rb +1 -1
- data/lib/koujou/builder.rb +1 -1
- data/lib/koujou/data_generator.rb +4 -2
- data/test/test_builder.rb +5 -0
- data/test/test_data_generator.rb +0 -26
- metadata +2 -2
data/README.rdoc
CHANGED
data/koujou.gemspec
CHANGED
data/lib/koujou.rb
CHANGED
data/lib/koujou/builder.rb
CHANGED
@@ -43,9 +43,9 @@ module Koujou #:nodoc:
|
|
43
43
|
|
44
44
|
set_required_attributes!(instance, attributes)
|
45
45
|
set_unique_attributes!(instance, attributes)
|
46
|
-
set_confirmation_attributes!(instance, attributes)
|
47
46
|
set_length_validated_attributes!(instance, attributes)
|
48
47
|
set_inclusion_validated_attributes!(instance, attributes)
|
48
|
+
set_confirmation_attributes!(instance, attributes)
|
49
49
|
create_associations(instance, recursed_from_model)
|
50
50
|
CustomValidation.stub_custom_validations!(instance)
|
51
51
|
|
@@ -49,8 +49,6 @@ module Koujou #:nodoc:
|
|
49
49
|
retval = format_if_sequenced(Faker::Address.us_state)
|
50
50
|
elsif @validation.name.to_s.match(/zip|postal/)
|
51
51
|
retval = format_if_sequenced(Faker::Address.zip_code)
|
52
|
-
elsif @validation.name.to_s == 'password' || @validation.name.to_s == 'password_confirmation'
|
53
|
-
retval = 'koujourama'
|
54
52
|
else
|
55
53
|
# If we don't match any standard stuff, just return a regular bs lorem string comprised of 10 words.
|
56
54
|
# 10 is sort of a "magic number" I might make a constant for that.
|
@@ -82,6 +80,10 @@ module Koujou #:nodoc:
|
|
82
80
|
DateTime.now
|
83
81
|
end
|
84
82
|
|
83
|
+
def generate_date
|
84
|
+
DateTime.now.to_date
|
85
|
+
end
|
86
|
+
|
85
87
|
def generate_boolean
|
86
88
|
true
|
87
89
|
end
|
data/test/test_builder.rb
CHANGED
@@ -41,6 +41,11 @@ class TestBuilder < Test::Unit::TestCase
|
|
41
41
|
assert_not_nil u.password_confirmation
|
42
42
|
end
|
43
43
|
|
44
|
+
should 'have the same value for password_confirmation as password' do
|
45
|
+
u = User.koujou
|
46
|
+
assert_equal u.password, u.password_confirmation
|
47
|
+
end
|
48
|
+
|
44
49
|
should 'allow me to override the model attributes' do
|
45
50
|
namae = 'One Factory to Rule them all'
|
46
51
|
p = Post.koujou(true, :name => namae)
|
data/test/test_data_generator.rb
CHANGED
@@ -52,32 +52,6 @@ class TestDataGenerator < Test::Unit::TestCase
|
|
52
52
|
assert Koujou::DataGenerator.new(false, @validation).generate_data_for_column_type
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
56
|
-
context 'on generate for attributes that are not columns' do
|
57
|
-
setup do
|
58
|
-
@validation = mock("ActiveRecord::Reflection::MacroReflection")
|
59
|
-
@validation.expects(:active_record).once.returns(User)
|
60
|
-
end
|
61
|
-
|
62
|
-
should 'always generate "koujourama" for passwords' do
|
63
|
-
@validation.expects(:name).at_least_once.returns('password')
|
64
|
-
assert_equal "koujourama", Koujou::DataGenerator.new(false, @validation).generate_data_for_column_type
|
65
|
-
end
|
66
|
-
|
67
|
-
should 'always generate "koujourama" for password confirmations' do
|
68
|
-
@validation.expects(:name).at_least_once.returns('password_confirmation')
|
69
|
-
assert_equal "koujourama", Koujou::DataGenerator.new(false, @validation).generate_data_for_column_type
|
70
|
-
end
|
71
|
-
|
72
|
-
should 'always generate the same for password and password confirmations' do
|
73
|
-
@validation.expects(:name).at_least_once.returns('password')
|
74
|
-
password = Koujou::DataGenerator.new(false, @validation).generate_data_for_column_type
|
75
|
-
@validation.expects(:active_record).once.returns(User)
|
76
|
-
@validation.expects(:name).at_least_once.returns('password_confirmation')
|
77
|
-
password_confirmation = Koujou::DataGenerator.new(false, @validation).generate_data_for_column_type
|
78
|
-
assert_equal password, password_confirmation
|
79
|
-
end
|
80
|
-
end
|
81
55
|
|
82
56
|
context 'on generate with a required length' do
|
83
57
|
setup do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koujou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Leung
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-04-14 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|