to_factory 2.0.0 → 2.1.0
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/.travis.yml +3 -1
- data/README.md +16 -6
- data/lib/to_factory.rb +0 -9
- data/lib/to_factory/collation.rb +1 -1
- data/lib/to_factory/file_sync.rb +1 -1
- data/lib/to_factory/file_writer.rb +17 -1
- data/lib/to_factory/finders/factory.rb +8 -2
- data/lib/to_factory/finders/model.rb +11 -11
- data/lib/to_factory/generation/attribute.rb +4 -2
- data/lib/to_factory/parsing/file.rb +3 -1
- data/lib/to_factory/parsing/syntax.rb +1 -1
- data/lib/to_factory/version.rb +1 -1
- data/spec/example_factories/user_admin_root.rb +4 -3
- data/spec/integration/empty_factory_file_spec.rb +19 -0
- data/spec/integration/file_sync_spec.rb +0 -7
- data/spec/integration/multiple_to_factory_calls_spec.rb +94 -0
- data/spec/integration/to_factory_method_spec.rb +0 -2
- data/spec/spec_helper.rb +1 -10
- data/spec/support/broken_models/invalid_ruby_file.rb +1 -0
- data/spec/support/broken_models/project.rb +3 -0
- data/spec/unit/finders/model_spec.rb +34 -4
- data/spec/unit/generation/attribute_spec.rb +14 -13
- data/spec/unit/generation/factory_spec.rb +26 -0
- data/to_factory.gemspec +6 -8
- metadata +50 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b772bf1a0170e218dfc0cec7d1e18aea8183291
|
4
|
+
data.tar.gz: cf2c1036f4212a9786fc255eb8a421713c4ca8f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cded91aa7aafddf9c6812a220f5a7798397012d80352095d7bfa442b4616680827af2e2db9399c5c5f168af071ae728fc1870d82bfdcf9fde0982d3cc77a85d
|
7
|
+
data.tar.gz: 3195202d58066527509f151faf4cff787e740d534ee22268b086a0d3b363e71325bfe761e961b22494ffd69660c24008fc97d406d478f30cf9d247db84e86537
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -19,7 +19,15 @@ If you find yourself retro-fitting tests this gem will save you some of the legw
|
|
19
19
|
* display factory definition for a record
|
20
20
|
* parse and write `FactoryGirl` syntax or older `Factory.define` syntax
|
21
21
|
|
22
|
-
Tested against Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1.x, 2.2.
|
22
|
+
Tested against Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1.x, 2.2.x
|
23
|
+
|
24
|
+
## Warning :warning:
|
25
|
+
`ToFactory` writes into the `spec/factories` folder. Whilst it
|
26
|
+
is tested and avoids overwriting existing factories,
|
27
|
+
it is recommended that you execute after committing or when in a known
|
28
|
+
safe state.
|
29
|
+
|
30
|
+
|
23
31
|
|
24
32
|
|
25
33
|
## Installation :file_folder:
|
@@ -33,11 +41,13 @@ group :test, :development do
|
|
33
41
|
end
|
34
42
|
```
|
35
43
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
44
|
+
For Ruby < `2.x` and older `FactoryGirl` syntax etc
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
group :test, :development do
|
48
|
+
gem "to_factory", "~> 0.2.1"
|
49
|
+
end
|
50
|
+
```
|
41
51
|
|
42
52
|
|
43
53
|
|
data/lib/to_factory.rb
CHANGED
@@ -59,12 +59,3 @@ def ToFactory(args=nil)
|
|
59
59
|
|
60
60
|
sync.perform(exclusions)
|
61
61
|
end
|
62
|
-
|
63
|
-
if defined?(Rails)
|
64
|
-
unless Rails.respond_to?(:configuration)
|
65
|
-
#FactoryGirl 1.3.x expects this method, but it isn't defined in Rails 2.0.2
|
66
|
-
def Rails.configuration
|
67
|
-
OpenStruct.new
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
data/lib/to_factory/collation.rb
CHANGED
data/lib/to_factory/file_sync.rb
CHANGED
@@ -24,8 +24,24 @@ module ToFactory
|
|
24
24
|
|
25
25
|
def wrap_factories(definitions)
|
26
26
|
out = "FactoryGirl.define do\n"
|
27
|
-
out << definitions.join("\n\n")
|
27
|
+
out << indent(definitions).join("\n\n")
|
28
|
+
out << "\n" unless out[-1] == "\n"
|
28
29
|
out << "end"
|
30
|
+
out << "\n" unless out[-1] == "\n"
|
31
|
+
end
|
32
|
+
|
33
|
+
def indent(definitions)
|
34
|
+
definitions.map do |d|
|
35
|
+
if d[/\A\s\s/]
|
36
|
+
d
|
37
|
+
else
|
38
|
+
lines = d.split("\n").map do |l|
|
39
|
+
" #{l}"
|
40
|
+
end
|
41
|
+
|
42
|
+
lines.join("\n")
|
43
|
+
end
|
44
|
+
end
|
29
45
|
end
|
30
46
|
|
31
47
|
def mkdir(name)
|
@@ -15,8 +15,14 @@ module ToFactory
|
|
15
15
|
|
16
16
|
def parsed_files
|
17
17
|
Dir.glob(File.join(ToFactory.factories, "**/*.rb")).map do |f|
|
18
|
-
|
19
|
-
end
|
18
|
+
parse_file(f)
|
19
|
+
end.compact
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse_file(f)
|
23
|
+
ToFactory::Parsing::File.parse(f)
|
24
|
+
rescue ToFactory::Parsing::File::EmptyFileException => e
|
25
|
+
#ignore empty files
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module ToFactory
|
2
2
|
module Finders
|
3
3
|
class Model
|
4
|
-
def call(exclusions
|
4
|
+
def call(exclusions: [], klasses: nil)
|
5
5
|
instances = []
|
6
|
+
klasses ||= find_klasses(exclusions)
|
6
7
|
|
7
|
-
|
8
|
+
klasses.each do |klass|
|
8
9
|
if instance = get_active_record_instance(klass)
|
9
10
|
instances << instance
|
10
11
|
end
|
@@ -15,14 +16,17 @@ module ToFactory
|
|
15
16
|
|
16
17
|
private
|
17
18
|
|
18
|
-
def
|
19
|
+
def find_klasses(exclusions)
|
20
|
+
klasses = []
|
19
21
|
models.each do |file|
|
20
22
|
matching_lines(file) do |match|
|
21
23
|
klass = rescuing_require(file, match)
|
22
24
|
|
23
|
-
|
25
|
+
klasses << klass unless exclusions.include?(klass)
|
24
26
|
end
|
25
27
|
end
|
28
|
+
|
29
|
+
klasses
|
26
30
|
end
|
27
31
|
|
28
32
|
def models
|
@@ -49,14 +53,10 @@ module ToFactory
|
|
49
53
|
|
50
54
|
def get_active_record_instance(klass)
|
51
55
|
if klass && klass.ancestors.include?(ActiveRecord::Base)
|
52
|
-
|
53
|
-
klass.first
|
54
|
-
rescue
|
55
|
-
klass.find(:first)
|
56
|
-
end
|
56
|
+
klass.first
|
57
57
|
end
|
58
|
-
rescue
|
59
|
-
warn "Failed to get record from #{klass} #{e.message}"
|
58
|
+
rescue StandardError => e
|
59
|
+
warn "Failed to get record from #{klass} #{e.message.inspect}"
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module ToFactory
|
2
2
|
module Generation
|
3
3
|
class Attribute
|
4
|
+
attr_writer :parser
|
5
|
+
|
4
6
|
def initialize(attribute, value)
|
5
7
|
@attribute = attribute
|
6
8
|
@value = value
|
@@ -28,7 +30,7 @@ module ToFactory
|
|
28
30
|
when Date
|
29
31
|
value.to_s.inspect
|
30
32
|
when BigDecimal
|
31
|
-
value.
|
33
|
+
"BigDecimal.new(#{value.to_s.inspect})"
|
32
34
|
when Hash
|
33
35
|
inspect_hash(value, nested)
|
34
36
|
when Array
|
@@ -45,7 +47,7 @@ module ToFactory
|
|
45
47
|
def validate_parseable!(value)
|
46
48
|
return value if parse(value)
|
47
49
|
|
48
|
-
"ToFactory: RubyParser exception parsing this attribute
|
50
|
+
"ToFactory: RubyParser exception parsing this attribute"
|
49
51
|
end
|
50
52
|
|
51
53
|
def parse(value)
|
@@ -6,6 +6,8 @@ require 'to_factory/parsing/syntax'
|
|
6
6
|
module ToFactory
|
7
7
|
module Parsing
|
8
8
|
class File
|
9
|
+
EmptyFileException = Class.new ArgumentError
|
10
|
+
|
9
11
|
delegate :multiple_factories?, :header?, :parse, :to => :parser
|
10
12
|
attr_reader :contents
|
11
13
|
|
@@ -15,7 +17,7 @@ module ToFactory
|
|
15
17
|
|
16
18
|
def self.from_file(filename)
|
17
19
|
contents = ::File.read filename rescue nil
|
18
|
-
raise
|
20
|
+
raise EmptyFileException.new "Invalid file #{filename}" if contents.to_s.strip.length == 0
|
19
21
|
|
20
22
|
new(contents)
|
21
23
|
end
|
@@ -28,7 +28,7 @@ module ToFactory
|
|
28
28
|
end
|
29
29
|
|
30
30
|
rescue Racc::ParseError, StringScanner::Error => e
|
31
|
-
raise ParseException.new("Original exception: #{e.message}\n #{e.backtrace}\nToFactory Error parsing \n#{@contents}\n o")
|
31
|
+
raise ParseException.new("Original exception: #{e.message}\n #{e.backtrace.join("\n")}\nToFactory Error parsing \n#{@contents}\n o")
|
32
32
|
end
|
33
33
|
|
34
34
|
|
data/lib/to_factory/version.rb
CHANGED
@@ -3,6 +3,10 @@ FactoryGirl.define do
|
|
3
3
|
name("User")
|
4
4
|
end
|
5
5
|
|
6
|
+
factory(:admin, :parent => :"to_factory/user") do
|
7
|
+
name("Admin")
|
8
|
+
end
|
9
|
+
|
6
10
|
factory(:root, :parent => :"to_factory/user") do
|
7
11
|
birthday "2014-07-08T15:30 UTC"
|
8
12
|
email "test@example.com"
|
@@ -11,9 +15,6 @@ FactoryGirl.define do
|
|
11
15
|
some_id 8
|
12
16
|
end
|
13
17
|
|
14
|
-
factory(:admin, :parent => :"to_factory/user") do
|
15
|
-
name("Admin")
|
16
|
-
end
|
17
18
|
|
18
19
|
factory(:super_admin, :parent => :admin) do
|
19
20
|
name("Super Admin")
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe "Empty File spec" do
|
2
|
+
let(:user) { create_user! }
|
3
|
+
|
4
|
+
context "with an empty factory file" do
|
5
|
+
before do
|
6
|
+
user
|
7
|
+
FileUtils.mkdir_p "./tmp/factories/to_factory"
|
8
|
+
|
9
|
+
File.open("./tmp/factories/to_factory/empty.rb", "w") do |f|
|
10
|
+
f << " "
|
11
|
+
f << "\n "
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "doesn't blow up" do
|
16
|
+
ToFactory(:empty => OpenStruct.new({attributes: {}}), :user => user)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -2,18 +2,12 @@ describe "FileSync" do
|
|
2
2
|
let(:user) { create_user! }
|
3
3
|
let(:admin) { create_admin! }
|
4
4
|
let(:project) { create_project! }
|
5
|
-
let(:version) { "new" }
|
6
5
|
let(:expected_user_file) { File.read("./spec/example_factories/user.rb") }
|
7
6
|
let(:expected_user_with_header_file) { File.read("./spec/example_factories/user_with_header.rb") }
|
8
7
|
let(:expected_admin_file) { File.read("./spec/example_factories/admin.rb") }
|
9
8
|
let(:user_with_header) { File.read("./spec/example_factories/user_with_header.rb") }
|
10
9
|
let(:user_admin_with_header) { File.read("./spec/example_factories/user_admin_with_header.rb") }
|
11
10
|
|
12
|
-
|
13
|
-
before do
|
14
|
-
FileUtils.rm_rf "./tmp/factories"
|
15
|
-
end
|
16
|
-
|
17
11
|
def user_file
|
18
12
|
File.read("./tmp/factories/to_factory/user.rb") rescue nil
|
19
13
|
end
|
@@ -22,7 +16,6 @@ describe "FileSync" do
|
|
22
16
|
File.read("./tmp/factories/to_factory/project.rb") rescue nil
|
23
17
|
end
|
24
18
|
|
25
|
-
|
26
19
|
context "with no arguments" do
|
27
20
|
before do
|
28
21
|
user
|
@@ -0,0 +1,94 @@
|
|
1
|
+
describe ToFactory do
|
2
|
+
let!(:user) { create_user! }
|
3
|
+
|
4
|
+
def user_file
|
5
|
+
File.read("./tmp/factories/to_factory/user.rb") rescue nil
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:expected_user_file) { File.read "./spec/example_factories/user_with_header.rb"}
|
9
|
+
|
10
|
+
context "single call" do
|
11
|
+
before do
|
12
|
+
ToFactory()
|
13
|
+
end
|
14
|
+
it "renders a single factory correctly" do
|
15
|
+
expect(user_file).to match_sexp expected_user_file
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "two calls" do
|
20
|
+
before do
|
21
|
+
ToFactory()
|
22
|
+
ToFactory(user_2: ToFactory::User.first)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "renders two factories correctly" do
|
26
|
+
expect(user_file).to eq <<-FACTORY.strip_heredoc
|
27
|
+
FactoryGirl.define do
|
28
|
+
factory(:"to_factory/user") do
|
29
|
+
birthday("2014-07-08T15:30 UTC")
|
30
|
+
email("test@example.com")
|
31
|
+
name("Jeff")
|
32
|
+
some_attributes(:a => 1)
|
33
|
+
some_id(8)
|
34
|
+
end
|
35
|
+
|
36
|
+
factory(:user_2, :parent => :"to_factory/user") do
|
37
|
+
birthday "2014-07-08T15:30 UTC"
|
38
|
+
email "test@example.com"
|
39
|
+
name "Jeff"
|
40
|
+
some_attributes({:a => 1})
|
41
|
+
some_id 8
|
42
|
+
end
|
43
|
+
end
|
44
|
+
FACTORY
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "multiple calls" do
|
49
|
+
before do
|
50
|
+
ToFactory()
|
51
|
+
ToFactory(user_2: ToFactory::User.first)
|
52
|
+
ToFactory(user_3: ToFactory::User.first)
|
53
|
+
ToFactory(user_4: ToFactory::User.first)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "renders multiple factories correctly" do
|
57
|
+
expect(user_file).to match_sexp <<-FACTORY
|
58
|
+
FactoryGirl.define do
|
59
|
+
factory(:"to_factory/user") do
|
60
|
+
birthday("2014-07-08T15:30 UTC")
|
61
|
+
email("test@example.com")
|
62
|
+
name("Jeff")
|
63
|
+
some_attributes(:a => 1)
|
64
|
+
some_id(8)
|
65
|
+
end
|
66
|
+
|
67
|
+
factory(:user_2, :parent => :"to_factory/user") do
|
68
|
+
birthday("2014-07-08T15:30 UTC")
|
69
|
+
email("test@example.com")
|
70
|
+
name("Jeff")
|
71
|
+
some_attributes(:a => 1)
|
72
|
+
some_id(8)
|
73
|
+
end
|
74
|
+
|
75
|
+
factory(:user_3, :parent => :"to_factory/user") do
|
76
|
+
birthday("2014-07-08T15:30 UTC")
|
77
|
+
email("test@example.com")
|
78
|
+
name("Jeff")
|
79
|
+
some_attributes(:a => 1)
|
80
|
+
some_id(8)
|
81
|
+
end
|
82
|
+
|
83
|
+
factory(:user_4, :parent => :"to_factory/user") do
|
84
|
+
birthday "2014-07-08T15:30 UTC"
|
85
|
+
email "test@example.com"
|
86
|
+
name "Jeff"
|
87
|
+
some_attributes({:a => 1})
|
88
|
+
some_id 8
|
89
|
+
end
|
90
|
+
end
|
91
|
+
FACTORY
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,16 +11,7 @@ require 'active_support/core_ext/hash'
|
|
11
11
|
require "sqlite3"
|
12
12
|
require "database_cleaner"
|
13
13
|
|
14
|
-
|
15
|
-
require "pry-byebug"
|
16
|
-
rescue LoadError
|
17
|
-
begin
|
18
|
-
require "ruby-debug"
|
19
|
-
rescue LoadError
|
20
|
-
$stderr.puts "No debugger available for #{RUBY_VERSION}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
14
|
+
require "byebug"
|
24
15
|
require "to_factory"
|
25
16
|
|
26
17
|
require "./spec/support/models/user"
|
@@ -0,0 +1 @@
|
|
1
|
+
class Egg < ActiveRecord::Base
|
@@ -4,21 +4,51 @@ describe ToFactory::Finders::Model do
|
|
4
4
|
end
|
5
5
|
|
6
6
|
let(:finder) { ToFactory::Finders::Model.new }
|
7
|
+
let(:path) { "./spec/support/models" }
|
7
8
|
|
8
9
|
describe "#call" do
|
9
10
|
let!(:user) { ToFactory::User.create! :name => "a user"}
|
10
11
|
let!(:project) { ToFactory::Project.create! :name => "a project"}
|
11
12
|
|
13
|
+
context "with a match" do
|
14
|
+
it do
|
15
|
+
expect(finder.call).to match_array [user, project]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
12
19
|
context "no match"do
|
13
20
|
let(:path) { "./tmp/doesnt_exist" }
|
14
21
|
it do
|
15
22
|
expect(finder.call).to eq []
|
16
23
|
end
|
17
24
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
25
|
+
|
26
|
+
context "with an invalid model file" do
|
27
|
+
let(:path) { "./spec/support/broken_models" }
|
28
|
+
before do
|
29
|
+
allow(finder).to receive(:warn)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "displays a warning" do
|
33
|
+
expect(finder.call).to eq [project]
|
34
|
+
|
35
|
+
expect(finder).to have_received(:warn).
|
36
|
+
with( "Failed to eval ./spec/support/broken_models/invalid_ruby_file.rb")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "with an invalid class" do
|
41
|
+
before do
|
42
|
+
allow(finder).to receive(:warn)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "displays a warning" do
|
46
|
+
klass = double("BrokenClass", inspect: "BrokenClass")
|
47
|
+
expect(klass).to receive(:ancestors).and_raise("Some error")
|
48
|
+
finder.call(klasses: [klass])
|
49
|
+
|
50
|
+
expect(finder).to have_received(:warn).
|
51
|
+
with( "Failed to get record from BrokenClass \"Some error\"")
|
22
52
|
end
|
23
53
|
end
|
24
54
|
end
|
@@ -21,6 +21,20 @@ describe ToFactory::Generation::Attribute do
|
|
21
21
|
expect(attribute.format(123)) .to eq "123"
|
22
22
|
expect(attribute.format(123.0)).to eq "123.0"
|
23
23
|
end
|
24
|
+
|
25
|
+
it "formats BigDecimal"do
|
26
|
+
expect(attribute.format(BigDecimal.new "123456789012345678900.0")).to eq "BigDecimal.new(\"123456789012345678900.0\")"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "handles unparseable strings" do
|
30
|
+
#NB this spec may only have been relevant for ruby 1.8 i.e. older RubyParser versions
|
31
|
+
#see https://github.com/markburns/to_factory/issues/4
|
32
|
+
parser = double "RubyParser"
|
33
|
+
expect(parser).to receive(:parse).and_raise "some error"
|
34
|
+
attribute.parser = parser
|
35
|
+
|
36
|
+
expect(attribute.format("anything")).to eq "ToFactory: RubyParser exception parsing this attribute".inspect
|
37
|
+
end
|
24
38
|
end
|
25
39
|
|
26
40
|
|
@@ -46,17 +60,4 @@ describe ToFactory::Generation::Attribute do
|
|
46
60
|
expect(attribute.format(input, false)).to eq expected
|
47
61
|
end
|
48
62
|
end
|
49
|
-
|
50
|
-
if RUBY_VERSION =~ /\A1\.8/
|
51
|
-
it "alters attributes that are unparseable by RubyParser" do
|
52
|
-
#when reparsing the generated files, we don't want the parser itself
|
53
|
-
#to raise an exception, rather than fix RubyParser now, a hotfix is to
|
54
|
-
#warn about these attributes and replace them with something parseable
|
55
|
-
value = File.read("./spec/support/ruby_parser_exception_causing_string.rb")
|
56
|
-
expect(lambda{RubyParser.new.parse(value)}).to raise_error StringScanner::Error
|
57
|
-
result = attribute.inspect_value(value)
|
58
|
-
expect(lambda{RubyParser.new.parse(result)}).not_to raise_error
|
59
|
-
expect(result).to match /ToFactory: RubyParser exception/
|
60
|
-
end
|
61
|
-
end
|
62
63
|
end
|
@@ -13,6 +13,32 @@ describe ToFactory::Generation::Factory do
|
|
13
13
|
let(:representation) { ToFactory::Representation.from(user) }
|
14
14
|
let(:generator) { ToFactory::Generation::Factory.new representation }
|
15
15
|
|
16
|
+
describe "#name" do
|
17
|
+
context "with a simple name" do
|
18
|
+
let(:representation) { double "Representation", name: "some_name" }
|
19
|
+
|
20
|
+
it "adds just displays the name" do
|
21
|
+
expect(generator.name).to eq "some_name"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with a namespace" do
|
26
|
+
let(:representation) { double "Representation", name: "some_namespace/some_name" }
|
27
|
+
|
28
|
+
it "adds quotes to the name" do
|
29
|
+
expect(generator.name).to eq "some_namespace/some_name".inspect
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with a an already quoted name in a namespace" do
|
34
|
+
let(:representation) { double "Representation", name: "some_namespace/some_name".inspect }
|
35
|
+
|
36
|
+
it "doesn't add extra adds quotes to the name" do
|
37
|
+
expect(generator.name).to eq "some_namespace/some_name".inspect
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
16
42
|
|
17
43
|
|
18
44
|
describe "#header" do
|
data/to_factory.gemspec
CHANGED
@@ -18,17 +18,15 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "factory_girl", "~> 4.5"
|
22
|
+
spec.add_dependency "ruby2ruby"
|
23
|
+
spec.add_dependency "activerecord", "> 4.0"
|
24
|
+
|
21
25
|
spec.add_development_dependency "sqlite3" , "~> 1.3.6"
|
22
|
-
spec.add_development_dependency "database_cleaner", "~> 1.
|
26
|
+
spec.add_development_dependency "database_cleaner", "~> 1.5.1"
|
23
27
|
|
24
|
-
|
25
|
-
spec.add_development_dependency "pry-byebug"
|
26
|
-
end
|
28
|
+
spec.add_development_dependency "byebug"
|
27
29
|
|
28
|
-
spec.add_development_dependency "factory_girl", "~> 4.5"
|
29
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
31
|
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
-
|
32
|
-
spec.add_dependency "ruby2ruby"
|
33
|
-
spec.add_dependency "activerecord", "> 4.0"
|
34
32
|
end
|
metadata
CHANGED
@@ -1,127 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: to_factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Burns
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: factory_girl
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
19
|
+
version: '4.5'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '4.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: ruby2ruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
type: :
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activerecord
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :
|
47
|
+
version: '4.0'
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '4.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.3.6
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.3.6
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: database_cleaner
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.5.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.5.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: byebug
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
110
|
+
version: '3.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
118
|
-
type: :
|
117
|
+
version: '10.0'
|
118
|
+
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '10.0'
|
125
125
|
description: Autogenerate and append/create factory_girl definitions from the console
|
126
126
|
email:
|
127
127
|
- markthedeveloper@gmail.com
|
@@ -168,11 +168,15 @@ files:
|
|
168
168
|
- spec/example_factories/user_admin_with_header.rb
|
169
169
|
- spec/example_factories/user_with_header.rb
|
170
170
|
- spec/integration/config_spec.rb
|
171
|
+
- spec/integration/empty_factory_file_spec.rb
|
171
172
|
- spec/integration/file_sync_spec.rb
|
172
173
|
- spec/integration/file_writer_spec.rb
|
173
174
|
- spec/integration/lint_spec.rb
|
175
|
+
- spec/integration/multiple_to_factory_calls_spec.rb
|
174
176
|
- spec/integration/to_factory_method_spec.rb
|
175
177
|
- spec/spec_helper.rb
|
178
|
+
- spec/support/broken_models/invalid_ruby_file.rb
|
179
|
+
- spec/support/broken_models/project.rb
|
176
180
|
- spec/support/data_creation.rb
|
177
181
|
- spec/support/match_sexp.rb
|
178
182
|
- spec/support/models/not_active_record.rb
|
@@ -209,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
213
|
version: '0'
|
210
214
|
requirements: []
|
211
215
|
rubyforge_project:
|
212
|
-
rubygems_version: 2.4.5
|
216
|
+
rubygems_version: 2.4.5.1
|
213
217
|
signing_key:
|
214
218
|
specification_version: 4
|
215
219
|
summary: Turn ActiveRecord instances into factories
|
@@ -229,11 +233,15 @@ test_files:
|
|
229
233
|
- spec/example_factories/user_admin_with_header.rb
|
230
234
|
- spec/example_factories/user_with_header.rb
|
231
235
|
- spec/integration/config_spec.rb
|
236
|
+
- spec/integration/empty_factory_file_spec.rb
|
232
237
|
- spec/integration/file_sync_spec.rb
|
233
238
|
- spec/integration/file_writer_spec.rb
|
234
239
|
- spec/integration/lint_spec.rb
|
240
|
+
- spec/integration/multiple_to_factory_calls_spec.rb
|
235
241
|
- spec/integration/to_factory_method_spec.rb
|
236
242
|
- spec/spec_helper.rb
|
243
|
+
- spec/support/broken_models/invalid_ruby_file.rb
|
244
|
+
- spec/support/broken_models/project.rb
|
237
245
|
- spec/support/data_creation.rb
|
238
246
|
- spec/support/match_sexp.rb
|
239
247
|
- spec/support/models/not_active_record.rb
|
@@ -248,4 +256,3 @@ test_files:
|
|
248
256
|
- spec/unit/generation/factory_spec.rb
|
249
257
|
- spec/unit/parsing/file_spec.rb
|
250
258
|
- spec/unit/parsing/klass_inference_spec.rb
|
251
|
-
has_rdoc:
|