model_2_factory-rails 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -0
- data/CONTRIBUTORS.md +1 -0
- data/README.md +42 -15
- data/exe/factory_gen +7 -5
- data/lib/model_2_factory/constants.rb +5 -0
- data/lib/model_2_factory/model_2_factory.rb +18 -2
- data/lib/model_2_factory/version.rb +1 -1
- data/lib/model_2_factory-rails.rb +1 -0
- data/model_2_factory-rails.gemspec +2 -0
- data/sideci.yml +5 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5f43b66427d2e6c0eb883bdbd2b578f74811b77
|
4
|
+
data.tar.gz: 580c64ce7b0aba84d06cc6bd54ccce9e2464bd99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7d5447354b2760ad0340ceeb751392b11c86d5f8ae6bde6270512dbffa2bf90cb480df3d9594895ce3458e0c2f0729b8bd6177f3ca114948472e3efd977c3cf
|
7
|
+
data.tar.gz: 5d76f230c083773898e4703995f20fa41830773f1833a53c747c47bd7818cdd3f685f8990c22a5e8faf9b078d7c480a59db3bb92d16be05975bf598e089e2b68
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CONTRIBUTORS.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* **Tanvir Hasan** - check for factory_girl_rails dependency - [tanvir002700](https://github.com/tanvir002700)
|
data/README.md
CHANGED
@@ -1,41 +1,68 @@
|
|
1
1
|
# model_2_factory-rails
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/model_2_factory-rails.svg)](https://
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/model_2_factory-rails.svg)](https://rubygems.org/gems/model_2_factory-rails)
|
4
|
+
[![Downloads](https://img.shields.io/gem/dt/model_2_factory-rails.svg)](https://rubygems.org/gems/model_2_factory-rails)
|
4
5
|
[![Build Status](https://travis-ci.org/eendroroy/model_2_factory-rails.svg?branch=master)](https://travis-ci.org/eendroroy/model_2_factory-rails)
|
5
6
|
[![Code Climate](https://codeclimate.com/github/eendroroy/model_2_factory-rails/badges/gpa.svg)](https://codeclimate.com/github/eendroroy/model_2_factory-rails)
|
7
|
+
[![Contributors](https://img.shields.io/github/contributors/eendroroy/model_2_factory-rails.svg)](CONTRIBUTORS.md)
|
6
8
|
|
7
|
-
|
9
|
+
|
10
|
+
Factory model class generator for rails model class.
|
11
|
+
|
12
|
+
## Description
|
13
|
+
|
14
|
+
Generate factory model class from rails active record class for rails-rspec test code.
|
15
|
+
|
16
|
+
### Prerequisites
|
17
|
+
|
18
|
+
Require following gem to be included in your gem file:
|
19
|
+
|
20
|
+
- factory_girl-rails
|
21
|
+
```
|
22
|
+
factory_girl-rails
|
23
|
+
```
|
24
|
+
|
25
|
+
### Installing
|
8
26
|
|
9
27
|
Add this line to your application's Gemfile:
|
10
28
|
|
11
|
-
```ruby
|
12
|
-
gem 'model_2_factory-rails'
|
13
29
|
```
|
30
|
+
gem 'model_2_factory-rails'
|
14
31
|
|
32
|
+
```
|
15
33
|
And then execute:
|
16
34
|
|
17
|
-
|
35
|
+
```
|
36
|
+
$ bundle
|
18
37
|
|
19
|
-
|
38
|
+
```
|
39
|
+
Or install it globally in your system:
|
20
40
|
|
21
|
-
|
41
|
+
```
|
42
|
+
$ gem install model_2_factory-rails
|
43
|
+
|
44
|
+
```
|
22
45
|
|
23
46
|
## Usage
|
24
47
|
|
25
|
-
|
48
|
+
To generate factory class for your existing model class
|
26
49
|
|
27
|
-
|
50
|
+
```
|
51
|
+
$ bundle exec factory_gen your_model_name
|
52
|
+
```
|
28
53
|
|
29
|
-
|
54
|
+
## Contributing
|
30
55
|
|
31
|
-
|
56
|
+
Bug reports and pull requests are welcome on GitHub at [model_2_factory-rails repository](https://github.com/eendroroy/model_2_factory-rails).
|
57
|
+
This project is intended to be a safe, welcoming space for collaboration,
|
58
|
+
and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
32
59
|
|
33
|
-
##
|
60
|
+
## Authors
|
34
61
|
|
35
|
-
|
62
|
+
* **Indrajit Roy** - *Initial work* - [eendroroy](https://github.com/eendroroy)
|
36
63
|
|
64
|
+
See also the list of [contributors](CONTRIBUTORS.md) who participated in this project.
|
37
65
|
|
38
66
|
## License
|
39
67
|
|
40
|
-
|
41
|
-
|
68
|
+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
|
data/exe/factory_gen
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
if File.exist? File.join(Dir.pwd, 'bin', 'rails')
|
4
|
+
require './config/environment.rb'
|
5
|
+
require 'model_2_factory-rails'
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
Model2Factory.invoke
|
8
|
+
else
|
9
|
+
puts "\n'#{`pwd`.strip}' is not a rails application root.\n\n"
|
10
|
+
end
|
@@ -13,6 +13,7 @@ module Model2Factory
|
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
def self.invoke
|
16
|
+
warnings_for_dependencies
|
16
17
|
create_factory(ARGV[0].to_s)
|
17
18
|
end
|
18
19
|
|
@@ -29,12 +30,17 @@ module Model2Factory
|
|
29
30
|
exit(1)
|
30
31
|
end
|
31
32
|
|
32
|
-
def self.
|
33
|
-
|
33
|
+
def self.create_factory_file(name)
|
34
|
+
File.open(
|
34
35
|
"#{factory_dir}/#{name.underscore.pluralize}_#{factory_suffix}.rb",
|
35
36
|
File::RDWR | File::CREAT | File::TRUNC,
|
36
37
|
0o644
|
37
38
|
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.write_to_file(name, lines)
|
42
|
+
create_factory_dir(factory_dir)
|
43
|
+
factory = create_factory_file(name)
|
38
44
|
factory.write "FactoryGirl.define do\n factory :#{name.underscore} do\n"
|
39
45
|
lines.each do |line|
|
40
46
|
factory.write line
|
@@ -72,11 +78,21 @@ module Model2Factory
|
|
72
78
|
end
|
73
79
|
end
|
74
80
|
|
81
|
+
def self.create_factory_dir(dirname)
|
82
|
+
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.warnings_for_dependencies
|
86
|
+
puts Constants::FACTORY_GIRL_RAILS_MISSING.red unless Gem.loaded_specs.key? 'factory_girl_rails'
|
87
|
+
end
|
88
|
+
|
75
89
|
class << self
|
90
|
+
private :create_factory_dir
|
76
91
|
private :create_factory
|
77
92
|
private :write_to_file
|
78
93
|
private :warn_not_found
|
79
94
|
private :factory_dir
|
80
95
|
private :factory_suffix
|
96
|
+
private :warnings_for_dependencies
|
81
97
|
end
|
82
98
|
end
|
@@ -32,6 +32,8 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_runtime_dependency :actionpack, version_string
|
33
33
|
spec.add_runtime_dependency :railties, version_string
|
34
34
|
|
35
|
+
spec.add_dependency 'colorize'
|
36
|
+
|
35
37
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
36
38
|
spec.add_development_dependency 'rake', '~> 10.0'
|
37
39
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
data/sideci.yml
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_2_factory-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- indrajit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,6 +135,7 @@ files:
|
|
121
135
|
- ".rubocop.yml"
|
122
136
|
- ".travis.yml"
|
123
137
|
- CODE_OF_CONDUCT.md
|
138
|
+
- CONTRIBUTORS.md
|
124
139
|
- Gemfile
|
125
140
|
- LICENSE
|
126
141
|
- README.md
|
@@ -129,9 +144,11 @@ files:
|
|
129
144
|
- bin/setup
|
130
145
|
- exe/factory_gen
|
131
146
|
- lib/model_2_factory-rails.rb
|
147
|
+
- lib/model_2_factory/constants.rb
|
132
148
|
- lib/model_2_factory/model_2_factory.rb
|
133
149
|
- lib/model_2_factory/version.rb
|
134
150
|
- model_2_factory-rails.gemspec
|
151
|
+
- sideci.yml
|
135
152
|
homepage: https://github.com/eendroroy/model_2_factory-rails
|
136
153
|
licenses:
|
137
154
|
- MIT
|