fabricators 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +34 -26
  3. data/lib/fabricators.rb +26 -12
  4. data/lib/fabricators/callbacks.rb +1 -1
  5. data/lib/fabricators/configuration.rb +10 -0
  6. data/lib/fabricators/definitions.rb +5 -20
  7. data/lib/fabricators/fabricator.rb +13 -4
  8. data/lib/fabricators/{reader.rb → fetcher.rb} +2 -2
  9. data/lib/fabricators/methods.rb +1 -1
  10. data/lib/fabricators/proxy.rb +12 -5
  11. data/lib/fabricators/railtie.rb +1 -1
  12. data/lib/fabricators/{attribute.rb → sequence.rb} +3 -3
  13. data/lib/fabricators/version.rb +1 -1
  14. data/test/aliases_test.rb +4 -10
  15. data/test/associations_test.rb +2 -2
  16. data/test/attributes_test.rb +6 -16
  17. data/test/callbacks_test.rb +5 -3
  18. data/test/dependent_test.rb +9 -5
  19. data/test/dummy/db/migrate/20140613221835_create_users.rb +3 -0
  20. data/test/dummy/db/migrate/20140615180954_create_posts.rb +1 -0
  21. data/test/dummy/db/schema.rb +5 -11
  22. data/test/dummy/log/development.log +15 -0
  23. data/test/dummy/log/test.log +2711 -0
  24. data/test/dummy/test/fabricators/people.rb +2 -0
  25. data/test/fabricators_test.rb +2 -2
  26. data/test/generators_test.rb +2 -2
  27. data/test/inheritance_test.rb +1 -1
  28. data/test/lists_test.rb +2 -2
  29. data/test/load_test.rb +1 -1
  30. data/test/merges_test.rb +3 -3
  31. data/test/test_helper.rb +1 -1
  32. metadata +8 -15
  33. data/test/dummy/db/migrate/20140615152257_add_age_to_users.rb +0 -5
  34. data/test/dummy/db/migrate/20140615175509_add_phone_to_users.rb +0 -5
  35. data/test/dummy/db/migrate/20140615180938_create_groups.rb +0 -9
  36. data/test/dummy/db/migrate/20140615181030_add_group_id_to_users.rb +0 -5
  37. data/test/dummy/db/migrate/20140615181051_add_user_id_to_posts.rb +0 -5
@@ -0,0 +1,2 @@
1
+ fabricator :person do
2
+ end
@@ -15,7 +15,7 @@ class FabricatorsTest < ActiveSupport::TestCase
15
15
  assert_kind_of Hash, hash
16
16
  assert_equal 'name', hash[:name]
17
17
  end
18
-
18
+
19
19
  test "build instance" do
20
20
  record = build(:user)
21
21
  assert_kind_of User, record
@@ -29,5 +29,5 @@ class FabricatorsTest < ActiveSupport::TestCase
29
29
  assert record.persisted?
30
30
  assert_equal 'name', record.name
31
31
  end
32
-
32
+
33
33
  end
@@ -5,9 +5,9 @@ require 'generators/fabricators/model/model_generator'
5
5
  class GeneratorsTest < Rails::Generators::TestCase
6
6
  tests Fabricators::Generators::ModelGenerator
7
7
  destination File.expand_path('../tmp', File.dirname(__FILE__))
8
-
8
+
9
9
  test "file generation" do
10
10
  run_generator %w(person)
11
11
  end
12
-
12
+
13
13
  end
@@ -30,7 +30,7 @@ class InheritanceTest < ActiveSupport::TestCase
30
30
  user_with_age = build(:user_with_age)
31
31
  assert_equal 'name', user_with_age.name
32
32
  assert_equal 9, user_with_age.age
33
-
33
+
34
34
  user_with_email = build(:user_with_email)
35
35
  assert_equal 'name', user_with_email.name
36
36
  assert_equal 'mail@example.com', user_with_email.email
@@ -9,7 +9,7 @@ class ListsTest < ActiveSupport::TestCase
9
9
  end
10
10
  end
11
11
  end
12
-
12
+
13
13
  test "build list" do
14
14
  list = build(:user, 3)
15
15
  assert_equal 3, list.size
@@ -19,7 +19,7 @@ class ListsTest < ActiveSupport::TestCase
19
19
  assert_equal 'name', user.name
20
20
  end
21
21
  end
22
-
22
+
23
23
  test "create list" do
24
24
  list = create(:user, 3)
25
25
  assert_equal 3, list.size
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class LoadTest < ActiveSupport::TestCase
4
4
 
5
5
  setup do
6
- Fabricators.load_files
6
+ Fabricators.load
7
7
  end
8
8
 
9
9
  test "find files" do
@@ -9,18 +9,18 @@ class MergesTest < ActiveSupport::TestCase
9
9
  end
10
10
  end
11
11
  end
12
-
12
+
13
13
  test "return attributes" do
14
14
  assert_equal 'other', attributes_for(:user, name: 'other')[:name]
15
15
  end
16
-
16
+
17
17
  test "build instance" do
18
18
  assert_equal 'other', build(:user, name: 'other').name
19
19
  build(:user, 3, name: 'other').each do |user|
20
20
  assert_equal 'other', user.name
21
21
  end
22
22
  end
23
-
23
+
24
24
  test "create instance" do
25
25
  assert_equal 'other', create(:user, name: 'other').name
26
26
  create(:user, 3, name: 'other').each do |user|
@@ -22,5 +22,5 @@ load(File.expand_path('../dummy/db/schema.rb', __FILE__))
22
22
 
23
23
  # Include methods
24
24
  class ActiveSupport::TestCase
25
- setup { Fabricators.definitions.reset }
25
+ setup { Fabricators.reset }
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabricators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Museways
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-19 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,7 +44,7 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.3'
47
- description: Minimalistic factory alternative inspired in factory_girl.
47
+ description: Minimalistic factory inspired in factory_girl for rails.
48
48
  email:
49
49
  - hello@museways.com
50
50
  executables: []
@@ -55,14 +55,15 @@ files:
55
55
  - README.rdoc
56
56
  - Rakefile
57
57
  - lib/fabricators.rb
58
- - lib/fabricators/attribute.rb
59
58
  - lib/fabricators/callbacks.rb
59
+ - lib/fabricators/configuration.rb
60
60
  - lib/fabricators/definitions.rb
61
61
  - lib/fabricators/fabricator.rb
62
+ - lib/fabricators/fetcher.rb
62
63
  - lib/fabricators/methods.rb
63
64
  - lib/fabricators/proxy.rb
64
65
  - lib/fabricators/railtie.rb
65
- - lib/fabricators/reader.rb
66
+ - lib/fabricators/sequence.rb
66
67
  - lib/fabricators/version.rb
67
68
  - lib/generators/fabricators/model/model_generator.rb
68
69
  - lib/generators/fabricators/model/templates/fabricator.rb
@@ -104,12 +105,7 @@ files:
104
105
  - test/dummy/config/routes.rb
105
106
  - test/dummy/config/secrets.yml
106
107
  - test/dummy/db/migrate/20140613221835_create_users.rb
107
- - test/dummy/db/migrate/20140615152257_add_age_to_users.rb
108
- - test/dummy/db/migrate/20140615175509_add_phone_to_users.rb
109
- - test/dummy/db/migrate/20140615180938_create_groups.rb
110
108
  - test/dummy/db/migrate/20140615180954_create_posts.rb
111
- - test/dummy/db/migrate/20140615181030_add_group_id_to_users.rb
112
- - test/dummy/db/migrate/20140615181051_add_user_id_to_posts.rb
113
109
  - test/dummy/db/schema.rb
114
110
  - test/dummy/log/development.log
115
111
  - test/dummy/log/test.log
@@ -117,6 +113,7 @@ files:
117
113
  - test/dummy/public/422.html
118
114
  - test/dummy/public/500.html
119
115
  - test/dummy/public/favicon.ico
116
+ - test/dummy/test/fabricators/people.rb
120
117
  - test/dummy/test/fabricators/users.rb
121
118
  - test/fabricators_test.rb
122
119
  - test/generators_test.rb
@@ -186,12 +183,7 @@ test_files:
186
183
  - test/dummy/config/secrets.yml
187
184
  - test/dummy/config.ru
188
185
  - test/dummy/db/migrate/20140613221835_create_users.rb
189
- - test/dummy/db/migrate/20140615152257_add_age_to_users.rb
190
- - test/dummy/db/migrate/20140615175509_add_phone_to_users.rb
191
- - test/dummy/db/migrate/20140615180938_create_groups.rb
192
186
  - test/dummy/db/migrate/20140615180954_create_posts.rb
193
- - test/dummy/db/migrate/20140615181030_add_group_id_to_users.rb
194
- - test/dummy/db/migrate/20140615181051_add_user_id_to_posts.rb
195
187
  - test/dummy/db/schema.rb
196
188
  - test/dummy/log/development.log
197
189
  - test/dummy/log/test.log
@@ -201,6 +193,7 @@ test_files:
201
193
  - test/dummy/public/favicon.ico
202
194
  - test/dummy/Rakefile
203
195
  - test/dummy/README.rdoc
196
+ - test/dummy/test/fabricators/people.rb
204
197
  - test/dummy/test/fabricators/users.rb
205
198
  - test/fabricators_test.rb
206
199
  - test/generators_test.rb
@@ -1,5 +0,0 @@
1
- class AddAgeToUsers < ActiveRecord::Migration
2
- def change
3
- add_column :users, :age, :integer
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddPhoneToUsers < ActiveRecord::Migration
2
- def change
3
- add_column :users, :phone, :integer
4
- end
5
- end
@@ -1,9 +0,0 @@
1
- class CreateGroups < ActiveRecord::Migration
2
- def change
3
- create_table :groups do |t|
4
- t.string :name
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- class AddGroupIdToUsers < ActiveRecord::Migration
2
- def change
3
- add_column :users, :group_id, :integer
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddUserIdToPosts < ActiveRecord::Migration
2
- def change
3
- add_column :posts, :user_id, :integer
4
- end
5
- end