factory_girl-seeds 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,30 +2,35 @@
2
2
 
3
3
  # FactoryGirl Seeds
4
4
 
5
- Make your test suite run time upto 2x faster and even more! factory_girl is a very usefull gem
6
- for creating records in your DB easily but also is very sloooow. This small repo helps fix that problem.
5
+ Don't like factory_girl because it is slow? Do you know that creating records in DB through factory_girl can take up to 50% of total spec run time? And even more!
7
6
 
8
- ## Installation
7
+ This tiny gem helps fix that problem by reusing data preloaded before running test suite.
9
8
 
10
- Add this line to your application's Gemfile:
9
+ ![](seed.jpg)
11
10
 
12
- group :test do
13
- gem 'factory_girl-seeds', github: 'evrone/factory_girl-seeds'
14
- end
11
+ ## Installation
15
12
 
16
- And then execute:
13
+ Add this line to your application's Gemfile:
17
14
 
18
- $ bundle
15
+ ```ruby
16
+ group :test do
17
+ gem 'factory_girl-seeds'
18
+ end
19
+ ```
19
20
 
20
21
  ## Usage
21
22
 
22
- Create records before test suite:
23
+ ### 1. Create records before test suite
23
24
 
24
25
  ```ruby
25
26
  FactoryGirl::SeedGenerator.create(:user, name: "John Appleseed")
26
27
  ```
27
28
 
28
- And then use in other factory definitions
29
+ For example if you are using rspec then add this to ```config.before(:suite)```.
30
+
31
+ ### 2. Use in factory definitions
32
+
33
+ This is the most important step because most of time factory_girl spends on creating associations which in turn also create associations and so on recursively.
29
34
 
30
35
  ```ruby
31
36
  FactoryGirl.define do
@@ -36,12 +41,28 @@ FactoryGirl.define do
36
41
  end
37
42
  ```
38
43
 
39
- or in specs
44
+ ### 3. Use in `it` blocks.
45
+
46
+ Also if you need standard factory without overriding attributes then do not create records. Just use one from preloaded seeds.
40
47
 
41
48
  ```ruby
42
- @user = seed(:user)
49
+ it "should do something" do
50
+ user = FactoryGirl.seed(:user)
51
+
52
+ # your code here
53
+ end
43
54
  ```
44
55
 
56
+ Short DSL also available:
57
+
58
+ ```ruby
59
+ user = seed(:user)
60
+ ```
61
+
62
+ ## How it works?
63
+
64
+ ```FactoryGirl::SeedGenerator.create``` method creates record in DB before transaction begins. Then ```it``` block starts transaction so when you update record returned by ```FactoryGirl.seed``` it is wrapped in transaction. This guarantees that every ```it``` block works with clean record.
65
+
45
66
  ## Contributing
46
67
 
47
68
  1. Fork it
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["technoforest@gmail.com"]
11
11
  gem.description = %q{Preseed reusable data for factory girl}
12
12
  gem.summary = %q{Make your test suite run time upto 2x faster and even more!}
13
- gem.homepage = ""
13
+ gem.homepage = "https://github.com/evrone/factory_girl-seeds"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -1,5 +1,5 @@
1
1
  module FactoryGirl
2
2
  module Seeds
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
data/seed.jpg ADDED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_girl-seeds
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-13 00:00:00.000000000 Z
12
+ date: 2013-07-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Preseed reusable data for factory girl
15
15
  email:
@@ -27,7 +27,8 @@ files:
27
27
  - lib/factory_girl-seeds.rb
28
28
  - lib/factory_girl-seeds/seeds.rb
29
29
  - lib/factory_girl-seeds/version.rb
30
- homepage: ''
30
+ - seed.jpg
31
+ homepage: https://github.com/evrone/factory_girl-seeds
31
32
  licenses: []
32
33
  post_install_message:
33
34
  rdoc_options: []
@@ -47,9 +48,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
48
  version: '0'
48
49
  requirements: []
49
50
  rubyforge_project:
50
- rubygems_version: 1.8.10
51
+ rubygems_version: 1.8.23
51
52
  signing_key:
52
53
  specification_version: 3
53
54
  summary: Make your test suite run time upto 2x faster and even more!
54
55
  test_files: []
55
- has_rdoc: