freegenie-factory_girl 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTION_GUIDELINES.rdoc +9 -0
- data/Changelog +29 -0
- data/LICENSE +19 -0
- data/README.rdoc +236 -0
- data/Rakefile +81 -0
- data/lib/factory_girl/aliases.rb +50 -0
- data/lib/factory_girl/attribute/association.rb +20 -0
- data/lib/factory_girl/attribute/dynamic.rb +20 -0
- data/lib/factory_girl/attribute/static.rb +17 -0
- data/lib/factory_girl/attribute.rb +29 -0
- data/lib/factory_girl/factory.rb +412 -0
- data/lib/factory_girl/proxy/attributes_for.rb +21 -0
- data/lib/factory_girl/proxy/build.rb +29 -0
- data/lib/factory_girl/proxy/create.rb +10 -0
- data/lib/factory_girl/proxy/stub.rb +49 -0
- data/lib/factory_girl/proxy.rb +62 -0
- data/lib/factory_girl/sequence.rb +63 -0
- data/lib/factory_girl/syntax/blueprint.rb +42 -0
- data/lib/factory_girl/syntax/generate.rb +68 -0
- data/lib/factory_girl/syntax/make.rb +39 -0
- data/lib/factory_girl/syntax/sham.rb +42 -0
- data/lib/factory_girl/syntax.rb +12 -0
- data/lib/factory_girl.rb +39 -0
- data/spec/factory_girl/aliases_spec.rb +29 -0
- data/spec/factory_girl/attribute/association_spec.rb +29 -0
- data/spec/factory_girl/attribute/dynamic_spec.rb +49 -0
- data/spec/factory_girl/attribute/static_spec.rb +29 -0
- data/spec/factory_girl/attribute_spec.rb +30 -0
- data/spec/factory_girl/factory_spec.rb +525 -0
- data/spec/factory_girl/proxy/attributes_for_spec.rb +52 -0
- data/spec/factory_girl/proxy/build_spec.rb +73 -0
- data/spec/factory_girl/proxy/create_spec.rb +83 -0
- data/spec/factory_girl/proxy/stub_spec.rb +69 -0
- data/spec/factory_girl/proxy_spec.rb +28 -0
- data/spec/factory_girl/sequence_spec.rb +66 -0
- data/spec/factory_girl/syntax/blueprint_spec.rb +35 -0
- data/spec/factory_girl/syntax/generate_spec.rb +57 -0
- data/spec/factory_girl/syntax/make_spec.rb +35 -0
- data/spec/factory_girl/syntax/sham_spec.rb +35 -0
- data/spec/integration_spec.rb +265 -0
- data/spec/models.rb +43 -0
- data/spec/spec_helper.rb +18 -0
- data/test/factory_girl_test.rb +28 -0
- metadata +118 -0
data/spec/models.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
ActiveRecord::Base.establish_connection(
|
2
|
+
:adapter => 'sqlite3',
|
3
|
+
:database => File.join(File.dirname(__FILE__), 'test.db')
|
4
|
+
)
|
5
|
+
|
6
|
+
class CreateSchema < ActiveRecord::Migration
|
7
|
+
def self.up
|
8
|
+
create_table :users, :force => true do |t|
|
9
|
+
t.string :first_name
|
10
|
+
t.string :last_name
|
11
|
+
t.string :email
|
12
|
+
t.string :username
|
13
|
+
t.boolean :admin, :default => false
|
14
|
+
end
|
15
|
+
|
16
|
+
create_table :posts, :force => true do |t|
|
17
|
+
t.string :name
|
18
|
+
t.integer :author_id
|
19
|
+
end
|
20
|
+
|
21
|
+
create_table :business, :force => true do |t|
|
22
|
+
t.string :name
|
23
|
+
t.integer :owner_id
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
CreateSchema.suppress_messages { CreateSchema.migrate(:up) }
|
29
|
+
|
30
|
+
class User < ActiveRecord::Base
|
31
|
+
validates_presence_of :first_name, :last_name, :email
|
32
|
+
has_many :posts, :foreign_key => 'author_id'
|
33
|
+
end
|
34
|
+
|
35
|
+
class Business < ActiveRecord::Base
|
36
|
+
validates_presence_of :name, :owner_id
|
37
|
+
belongs_to :owner, :class_name => 'User'
|
38
|
+
end
|
39
|
+
|
40
|
+
class Post < ActiveRecord::Base
|
41
|
+
validates_presence_of :name, :author_id
|
42
|
+
belongs_to :author, :class_name => 'User'
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
$: << File.join(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
require 'activerecord'
|
7
|
+
|
8
|
+
require 'spec'
|
9
|
+
require 'spec/autorun'
|
10
|
+
require 'rr'
|
11
|
+
|
12
|
+
require 'models'
|
13
|
+
|
14
|
+
require 'factory_girl'
|
15
|
+
|
16
|
+
Spec::Runner.configure do |config|
|
17
|
+
config.mock_with RR::Adapters::Rspec
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class FactoryGirlTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_should_use_live_registry
|
6
|
+
Post.destroy_all
|
7
|
+
post1 = Factory(:a_very_special_post)
|
8
|
+
post2 = Factory(:a_very_special_post)
|
9
|
+
post3 = Factory(:a_very_special_post)
|
10
|
+
assert 1, Factory.live_registry.size
|
11
|
+
|
12
|
+
post3.destroy
|
13
|
+
|
14
|
+
assert 0, Post.count
|
15
|
+
assert 0, Factory.live_registry.size
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup
|
20
|
+
teardown
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
Post.destroy_all
|
25
|
+
User.destroy_all
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: freegenie-factory_girl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joe Ferris
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-15 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: |-
|
17
|
+
factory_girl provides a framework and DSL for defining and
|
18
|
+
using factories - less error-prone, more explicit, and
|
19
|
+
all-around easier to work with than fixtures.
|
20
|
+
email: freegenie@gmail.com
|
21
|
+
executables: []
|
22
|
+
|
23
|
+
extensions: []
|
24
|
+
|
25
|
+
extra_rdoc_files:
|
26
|
+
- README.rdoc
|
27
|
+
files:
|
28
|
+
- Changelog
|
29
|
+
- CONTRIBUTION_GUIDELINES.rdoc
|
30
|
+
- LICENSE
|
31
|
+
- Rakefile
|
32
|
+
- README.rdoc
|
33
|
+
- lib/factory_girl/aliases.rb
|
34
|
+
- lib/factory_girl/attribute/association.rb
|
35
|
+
- lib/factory_girl/attribute/dynamic.rb
|
36
|
+
- lib/factory_girl/attribute/static.rb
|
37
|
+
- lib/factory_girl/attribute.rb
|
38
|
+
- lib/factory_girl/factory.rb
|
39
|
+
- lib/factory_girl/proxy/attributes_for.rb
|
40
|
+
- lib/factory_girl/proxy/build.rb
|
41
|
+
- lib/factory_girl/proxy/create.rb
|
42
|
+
- lib/factory_girl/proxy/stub.rb
|
43
|
+
- lib/factory_girl/proxy.rb
|
44
|
+
- lib/factory_girl/sequence.rb
|
45
|
+
- lib/factory_girl/syntax/blueprint.rb
|
46
|
+
- lib/factory_girl/syntax/generate.rb
|
47
|
+
- lib/factory_girl/syntax/make.rb
|
48
|
+
- lib/factory_girl/syntax/sham.rb
|
49
|
+
- lib/factory_girl/syntax.rb
|
50
|
+
- lib/factory_girl.rb
|
51
|
+
- spec/factory_girl/aliases_spec.rb
|
52
|
+
- spec/factory_girl/attribute/association_spec.rb
|
53
|
+
- spec/factory_girl/attribute/dynamic_spec.rb
|
54
|
+
- spec/factory_girl/attribute/static_spec.rb
|
55
|
+
- spec/factory_girl/attribute_spec.rb
|
56
|
+
- spec/factory_girl/factory_spec.rb
|
57
|
+
- spec/factory_girl/proxy/attributes_for_spec.rb
|
58
|
+
- spec/factory_girl/proxy/build_spec.rb
|
59
|
+
- spec/factory_girl/proxy/create_spec.rb
|
60
|
+
- spec/factory_girl/proxy/stub_spec.rb
|
61
|
+
- spec/factory_girl/proxy_spec.rb
|
62
|
+
- spec/factory_girl/sequence_spec.rb
|
63
|
+
- spec/factory_girl/syntax/blueprint_spec.rb
|
64
|
+
- spec/factory_girl/syntax/generate_spec.rb
|
65
|
+
- spec/factory_girl/syntax/make_spec.rb
|
66
|
+
- spec/factory_girl/syntax/sham_spec.rb
|
67
|
+
- spec/integration_spec.rb
|
68
|
+
- spec/models.rb
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
has_rdoc: true
|
71
|
+
homepage: ""
|
72
|
+
licenses: []
|
73
|
+
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options:
|
76
|
+
- --line-numbers
|
77
|
+
- --main
|
78
|
+
- README.rdoc
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
version:
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.3.3
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: factory_girl provides a framework and DSL for defining and using model instance factories.
|
100
|
+
test_files:
|
101
|
+
- spec/factory_girl/aliases_spec.rb
|
102
|
+
- spec/factory_girl/attribute/association_spec.rb
|
103
|
+
- spec/factory_girl/attribute/dynamic_spec.rb
|
104
|
+
- spec/factory_girl/attribute/static_spec.rb
|
105
|
+
- spec/factory_girl/attribute_spec.rb
|
106
|
+
- spec/factory_girl/factory_spec.rb
|
107
|
+
- spec/factory_girl/proxy/attributes_for_spec.rb
|
108
|
+
- spec/factory_girl/proxy/build_spec.rb
|
109
|
+
- spec/factory_girl/proxy/create_spec.rb
|
110
|
+
- spec/factory_girl/proxy/stub_spec.rb
|
111
|
+
- spec/factory_girl/proxy_spec.rb
|
112
|
+
- spec/factory_girl/sequence_spec.rb
|
113
|
+
- spec/factory_girl/syntax/blueprint_spec.rb
|
114
|
+
- spec/factory_girl/syntax/generate_spec.rb
|
115
|
+
- spec/factory_girl/syntax/make_spec.rb
|
116
|
+
- spec/factory_girl/syntax/sham_spec.rb
|
117
|
+
- spec/integration_spec.rb
|
118
|
+
- test/factory_girl_test.rb
|