famili 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -8,7 +8,7 @@ We meet some problems with factory-girl:
8
8
 
9
9
  * We require quite complex logic for creation of test models
10
10
  * We require use factories with running rails application for integration tests
11
- * So why don't make factory just another class in rails lib ?
11
+ * So why don't make factory just another class in rails lib, and get extensibility of factories/mothers and rails lazy loading and dependency management?
12
12
 
13
13
  == Example
14
14
 
@@ -112,8 +112,9 @@ and then
112
112
 
113
113
  == CHANGE LOG:
114
114
 
115
- 0.0.1 - created
116
- 0.0.2 - add inheritance, and mother methods [unique,sequence_number]
115
+ * 0.0.1 - created
116
+ * 0.0.2 - add inheritance, and mother methods [unique,sequence_number]
117
+ * 0.0.3 - fix Mother.create call model.save!; Mother.hash return symbolized hash
117
118
 
118
119
  == TODO
119
120
 
data/lib/famili/mother.rb CHANGED
@@ -60,7 +60,7 @@ module Famili
60
60
 
61
61
  def create(opts={})
62
62
  mother,model = _build(opts)
63
- model.save
63
+ model.save!
64
64
  mother.after_create(model)
65
65
  model
66
66
  end
@@ -70,9 +70,9 @@ module Famili
70
70
  model
71
71
  end
72
72
 
73
- def hash
74
- mother,model = _build
75
- model.attribures
73
+ def hash(opts={})
74
+ mother,model = _build(opts)
75
+ model.attributes.dup.symbolize_keys!
76
76
  end
77
77
 
78
78
 
data/lib/famili.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
2
2
  module Famili
3
- VERSION='0.0.2'
3
+ VERSION='0.0.3'
4
4
  autoload :Mother,'famili/mother'
5
5
  end
data/spec/famili_spec.rb CHANGED
@@ -11,6 +11,7 @@ describe Famili do
11
11
 
12
12
  class User < ActiveRecord::Base
13
13
  has_many :articles
14
+ validates_presence_of :login
14
15
  end
15
16
 
16
17
  class Article < ActiveRecord::Base
@@ -38,6 +39,10 @@ describe Famili do
38
39
  end
39
40
  end
40
41
 
42
+ it "should use save! model" do
43
+ lambda { Famili::User.create(:login=>nil) }.should raise_error
44
+ end
45
+
41
46
  it "should create model" do
42
47
  nicola = Famili::User.create
43
48
  nicola.class.should == User
@@ -48,6 +53,11 @@ describe Famili do
48
53
  ivan.name.should == 'ivan'
49
54
  end
50
55
 
56
+ it "mother should have #hash method returning symbolized hash" do
57
+ hash = Famili::User.hash
58
+ hash.keys.each {|key| key.should be_kind_of(Symbol) }
59
+ end
60
+
51
61
  it "should create model with asscociation" do
52
62
  article = Famili::Article.create
53
63
  article.user.should_not be_nil
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: famili
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - niquola
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-29 00:00:00 +04:00
18
+ date: 2010-08-30 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21