makers 0.2.0 → 4.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -29
- data/lib/generators/makers/{install_generator.rb → install/install_generator.rb} +1 -1
- data/lib/generators/makers/{templates → install/templates}/definitions.rb +0 -0
- data/lib/makers.rb +0 -1
- data/lib/makers/dsl/maker.rb +2 -2
- data/lib/makers/extensions/active_support/test_case.rb +1 -0
- data/lib/makers/proxy.rb +1 -1
- data/lib/makers/railtie.rb +10 -2
- data/lib/makers/version.rb +1 -1
- data/test/dummy/app/assets/javascripts/application.js +2 -2
- data/test/dummy/app/assets/stylesheets/application.css +1 -1
- data/test/dummy/app/models/post.rb +2 -0
- data/test/dummy/app/models/user.rb +2 -0
- data/test/dummy/bin/bundle +0 -0
- data/test/dummy/bin/rails +1 -1
- data/test/dummy/bin/rake +0 -0
- data/test/dummy/bin/setup +1 -1
- data/test/dummy/config.ru +1 -1
- data/test/dummy/config/initializers/cookies_serializer.rb +1 -1
- data/test/dummy/config/initializers/mime_types.rb +1 -1
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/dummy/config/secrets.yml +2 -2
- data/test/dummy/db/migrate/20140613221835_create_users.rb +2 -0
- data/test/dummy/db/migrate/20140615180954_create_posts.rb +2 -0
- data/test/dummy/public/404.html +57 -63
- data/test/dummy/public/422.html +57 -63
- data/test/dummy/public/500.html +56 -62
- data/test/generator_test.rb +1 -1
- data/test/{makers_test.rb → maker_test.rb} +1 -1
- metadata +6 -14
- data/test/dummy/app/models/group.rb +0 -2
- data/test/dummy/db/schema.rb +0 -57
- data/test/dummy/log/development.log +0 -176
- data/test/dummy/log/test.log +0 -1529
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e78fc8b34311d64cff23b79b1232d24cf4d230e6
|
4
|
+
data.tar.gz: 11ade66cbe89b1cf259c6f27e750b2f099ed7d3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4482615e34ef62932354bf9d665705705ed5411b84bfe143c23edf724cd98476640906e083ab16327ba6813351e098d69b83ee19f941b237515f6554513d1e70
|
7
|
+
data.tar.gz: a60586dea2e74e1a30853d5dbb1c3e7982e3c7a60ad178578a5cca1fe8eb91211c1ec86b081d73fd097c251697ad5fec1a25db1fb050d10ba194e30665a3a584
|
data/README.md
CHANGED
@@ -9,10 +9,10 @@ Minimalistic factories to replace fixtures in rails.
|
|
9
9
|
|
10
10
|
## Why
|
11
11
|
|
12
|
-
I did this gem to
|
12
|
+
I did this gem to:
|
13
13
|
|
14
14
|
- Enforce better practices removing unnecessary options.
|
15
|
-
- Avoid the need to use another method to create lists.
|
15
|
+
- Avoid the need to use another method to build/create lists.
|
16
16
|
- Quicker syntax to handle associations.
|
17
17
|
|
18
18
|
## Install
|
@@ -29,53 +29,33 @@ $ bundle
|
|
29
29
|
|
30
30
|
## Configuration
|
31
31
|
|
32
|
-
Generate
|
32
|
+
Generate de definitions file:
|
33
33
|
```
|
34
|
-
bundle exec rails g makers:install
|
34
|
+
$ bundle exec rails g makers:install
|
35
35
|
```
|
36
36
|
|
37
|
-
|
37
|
+
The file will be put in test/makers.rb or spec/makers.rb depending on your test framework:
|
38
38
|
```ruby
|
39
39
|
Makers.define do
|
40
|
-
maker :user do
|
41
|
-
name 'example'
|
42
|
-
end
|
43
40
|
end
|
44
41
|
```
|
45
42
|
|
46
43
|
## Usage
|
47
44
|
|
48
|
-
### Methods
|
49
|
-
|
50
|
-
There are two methods available:
|
51
|
-
```ruby
|
52
|
-
build
|
53
|
-
create
|
54
|
-
```
|
55
|
-
|
56
|
-
Is possible to override the defaults passing a hash:
|
57
|
-
```ruby
|
58
|
-
build :user, name: 'other'
|
59
|
-
create :category, title: 'other'
|
60
|
-
```
|
61
|
-
|
62
|
-
To create lists just pass the desired size as second parameter:
|
63
|
-
```ruby
|
64
|
-
build :user, 2, name: 'other'
|
65
|
-
create :category, 5, title: 'other'
|
66
|
-
```
|
67
|
-
|
68
45
|
### Inheritance
|
69
46
|
|
70
47
|
Just concatenate makers:
|
71
48
|
```ruby
|
72
49
|
Makers.define do
|
50
|
+
|
73
51
|
maker :user do
|
74
52
|
name 'example'
|
53
|
+
|
75
54
|
maker :user_with_email do
|
76
55
|
email 'example@mail.com'
|
77
56
|
end
|
78
57
|
end
|
58
|
+
|
79
59
|
end
|
80
60
|
```
|
81
61
|
|
@@ -84,10 +64,12 @@ end
|
|
84
64
|
Generates an unique sequence of numbers for an attribute:
|
85
65
|
```ruby
|
86
66
|
Makers.define do
|
67
|
+
|
87
68
|
maker :user do
|
88
69
|
sequence(:email) { |n| "example#{n}@mail.com" }
|
89
70
|
sequence(:phone)
|
90
71
|
end
|
72
|
+
|
91
73
|
end
|
92
74
|
```
|
93
75
|
|
@@ -96,16 +78,20 @@ end
|
|
96
78
|
Associations are defined by name or by the association method:
|
97
79
|
```ruby
|
98
80
|
Makers.define do
|
81
|
+
|
99
82
|
maker :user do
|
100
83
|
posts
|
101
84
|
comments 4, strategy: :create
|
102
85
|
end
|
86
|
+
|
103
87
|
maker :comment do
|
104
88
|
association :user
|
105
89
|
end
|
90
|
+
|
106
91
|
maker :post do
|
107
92
|
user
|
108
93
|
end
|
94
|
+
|
109
95
|
end
|
110
96
|
```
|
111
97
|
|
@@ -114,13 +100,16 @@ end
|
|
114
100
|
Aliases can be assigned in the initialization:
|
115
101
|
```ruby
|
116
102
|
Makers.define do
|
103
|
+
|
117
104
|
maker :user, aliases: :author do
|
118
105
|
comments
|
119
106
|
end
|
120
|
-
|
107
|
+
|
108
|
+
maker :post, aliases: %i(comment article) do
|
121
109
|
title
|
122
110
|
author
|
123
111
|
end
|
112
|
+
|
124
113
|
end
|
125
114
|
```
|
126
115
|
|
@@ -129,14 +118,36 @@ end
|
|
129
118
|
If you need to use some logic that depends of another attribute you can use a block:
|
130
119
|
```ruby
|
131
120
|
Makers.define do
|
121
|
+
|
132
122
|
maker :user do
|
133
123
|
name 'example'
|
134
124
|
email { "#{name}@mail.com" }
|
135
125
|
sequence(:username) { |n| "#{name}-#{n}" }
|
136
126
|
end
|
127
|
+
|
137
128
|
end
|
138
129
|
```
|
139
130
|
|
131
|
+
### Methods
|
132
|
+
|
133
|
+
There are two new methods available in tests:
|
134
|
+
```ruby
|
135
|
+
build
|
136
|
+
create
|
137
|
+
```
|
138
|
+
|
139
|
+
Is possible to override the defaults passing a hash:
|
140
|
+
```ruby
|
141
|
+
build :user, name: 'other'
|
142
|
+
create :category, title: 'other'
|
143
|
+
```
|
144
|
+
|
145
|
+
To create lists just pass the desired size as second parameter:
|
146
|
+
```ruby
|
147
|
+
build :user, 2, name: 'other'
|
148
|
+
create :category, 5, title: 'other'
|
149
|
+
```
|
150
|
+
|
140
151
|
## Credits
|
141
152
|
|
142
153
|
This gem is maintained and funded by [mmontossi](https://github.com/mmontossi).
|
File without changes
|
data/lib/makers.rb
CHANGED
data/lib/makers/dsl/maker.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Makers
|
2
|
-
module
|
2
|
+
module Dsl
|
3
3
|
class Maker
|
4
4
|
|
5
5
|
def initialize(name, options={}, &block)
|
@@ -22,7 +22,7 @@ module Makers
|
|
22
22
|
options.delete :aliases
|
23
23
|
options.merge! overrides
|
24
24
|
options.merge! parent: @name
|
25
|
-
|
25
|
+
Dsl::Maker.new name, options, &block
|
26
26
|
end
|
27
27
|
|
28
28
|
def sequence(name, &block)
|
data/lib/makers/proxy.rb
CHANGED
data/lib/makers/railtie.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
module Makers
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
|
4
|
-
initializer
|
4
|
+
initializer 'makers.extensions' do
|
5
|
+
ActiveSupport::TestCase.include(
|
6
|
+
Makers::Extensions::ActiveSupport::TestCase
|
7
|
+
)
|
8
|
+
end
|
9
|
+
|
10
|
+
initializer 'makers.replace_fixtures' do
|
5
11
|
config.app_generators.test_framework(
|
6
12
|
config.app_generators.options[:rails][:test_framework],
|
7
13
|
fixture: false
|
8
14
|
)
|
15
|
+
end
|
16
|
+
|
17
|
+
config.after_initialize do
|
9
18
|
if Dir.exist?(Rails.root.join('spec'))
|
10
19
|
directory = 'spec'
|
11
20
|
else
|
@@ -15,7 +24,6 @@ module Makers
|
|
15
24
|
if File.exist?(path)
|
16
25
|
load path
|
17
26
|
end
|
18
|
-
ActiveSupport::TestCase.include Makers::Extensions::ActiveSupport::TestCase
|
19
27
|
end
|
20
28
|
|
21
29
|
end
|
data/lib/makers/version.rb
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
// listed below.
|
3
3
|
//
|
4
4
|
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or vendor/assets/javascripts
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
6
|
//
|
7
7
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
8
|
// compiled file.
|
9
9
|
//
|
10
|
-
// Read Sprockets README (https://github.com/
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
11
|
// about supported directives.
|
12
12
|
//
|
13
13
|
//= require_tree .
|
@@ -3,7 +3,7 @@
|
|
3
3
|
* listed below.
|
4
4
|
*
|
5
5
|
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
7
|
*
|
8
8
|
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
9
|
* compiled file so the styles you add here take precedence over styles defined in any styles
|
data/test/dummy/bin/bundle
CHANGED
File without changes
|
data/test/dummy/bin/rails
CHANGED
data/test/dummy/bin/rake
CHANGED
File without changes
|
data/test/dummy/bin/setup
CHANGED
@@ -9,7 +9,7 @@ Dir.chdir APP_ROOT do
|
|
9
9
|
# This script is a starting point to setup your application.
|
10
10
|
# Add necessary setup steps to this file:
|
11
11
|
|
12
|
-
puts
|
12
|
+
puts '== Installing dependencies =='
|
13
13
|
system 'gem install bundler --conservative'
|
14
14
|
system 'bundle check || bundle install'
|
15
15
|
|
data/test/dummy/config.ru
CHANGED
@@ -11,10 +11,10 @@
|
|
11
11
|
# if you're sharing your code publicly.
|
12
12
|
|
13
13
|
development:
|
14
|
-
secret_key_base:
|
14
|
+
secret_key_base: 2c1c8d4cbaa726b21aa6483b7d556125f4897508e2b94f8b3ddaec675168382c9b3b6eb5a9359d2fade03f539c16ac1ef905891c2410f2fd00b83b76c1666feb
|
15
15
|
|
16
16
|
test:
|
17
|
-
secret_key_base:
|
17
|
+
secret_key_base: 9dd531171128e7c3d11dd2c5c18c84ba43d29b677043002634a6f4d58bf2687a283b7b6dc6af741d63c3824f11fa1f858010d7c2509a932023f2ece0d3bfe6cf
|
18
18
|
|
19
19
|
# Do not keep production secrets in the repository,
|
20
20
|
# instead read values from the environment.
|
data/test/dummy/public/404.html
CHANGED
@@ -1,67 +1,61 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
div.dialog {
|
15
|
+
width: 95%;
|
16
|
+
max-width: 33em;
|
17
|
+
margin: 4em auto 0;
|
18
|
+
}
|
19
|
+
div.dialog > div {
|
20
|
+
border: 1px solid #CCC;
|
21
|
+
border-right-color: #999;
|
22
|
+
border-left-color: #999;
|
23
|
+
border-bottom-color: #BBB;
|
24
|
+
border-top: #B00100 solid 4px;
|
25
|
+
border-top-left-radius: 9px;
|
26
|
+
border-top-right-radius: 9px;
|
27
|
+
background-color: white;
|
28
|
+
padding: 7px 12% 0;
|
29
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
30
|
+
}
|
31
|
+
h1 {
|
32
|
+
font-size: 100%;
|
33
|
+
color: #730E15;
|
34
|
+
line-height: 1.5em;
|
35
|
+
}
|
36
|
+
div.dialog > p {
|
37
|
+
margin: 0 0 1em;
|
38
|
+
padding: 1em;
|
39
|
+
background-color: #F7F7F7;
|
40
|
+
border: 1px solid #CCC;
|
41
|
+
border-right-color: #999;
|
42
|
+
border-left-color: #999;
|
43
|
+
border-bottom-color: #999;
|
44
|
+
border-bottom-left-radius: 4px;
|
45
|
+
border-bottom-right-radius: 4px;
|
46
|
+
border-top-color: #DADADA;
|
47
|
+
color: #666;
|
48
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
49
|
+
}
|
50
|
+
</style>
|
51
|
+
</head>
|
52
|
+
<body>
|
53
|
+
<div class="dialog">
|
54
|
+
<div>
|
55
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
56
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
57
|
+
</div>
|
58
|
+
<p>If you are the application owner check the logs for more information.</p>
|
63
59
|
</div>
|
64
|
-
|
65
|
-
</div>
|
66
|
-
</body>
|
60
|
+
</body>
|
67
61
|
</html>
|