my_enginery 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +18 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +12 -0
- data/LICENSE +19 -0
- data/README.md +957 -0
- data/Rakefile +48 -0
- data/app/base/.pryrc +1 -0
- data/app/base/Gemfile +25 -0
- data/app/base/Rakefile +4 -0
- data/app/base/app.rb +8 -0
- data/app/base/base/boot.rb +45 -0
- data/app/base/base/config.rb +127 -0
- data/app/base/base/controllers/rear-controllers/.gitkeep +0 -0
- data/app/base/base/database.rb +3 -0
- data/app/base/base/helpers/application_helpers.rb +3 -0
- data/app/base/base/migrations/.gitkeep +0 -0
- data/app/base/base/models/.gitkeep +0 -0
- data/app/base/base/specs/.gitkeep +0 -0
- data/app/base/base/views/.gitkeep +0 -0
- data/app/base/config.ru +4 -0
- data/app/base/config/config.yml +17 -0
- data/app/base/public/assets/Enginery.png +0 -0
- data/app/base/public/assets/Espresso.png +0 -0
- data/app/base/public/assets/application.css +13 -0
- data/app/base/public/assets/application.js +2 -0
- data/app/base/public/assets/bootstrap/css/bootstrap-responsive.min.css +9 -0
- data/app/base/public/assets/bootstrap/css/bootstrap.min.css +9 -0
- data/app/base/public/assets/bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/app/base/public/assets/bootstrap/img/glyphicons-halflings.png +0 -0
- data/app/base/public/assets/bootstrap/js/bootstrap.min.js +6 -0
- data/app/base/public/assets/jquery.js +6 -0
- data/app/base/var/db/.gitkeep +0 -0
- data/app/base/var/log/.gitkeep +0 -0
- data/app/base/var/pid/.gitkeep +0 -0
- data/app/database/ActiveRecord.rb +11 -0
- data/app/database/DataMapper.rb +11 -0
- data/app/database/Sequel.rb +11 -0
- data/app/database/mysql.yml +24 -0
- data/app/database/postgres.yml +24 -0
- data/app/database/sqlite.yml +24 -0
- data/app/gemfiles/ActiveRecord.rb +1 -0
- data/app/gemfiles/BlueCloth.rb +1 -0
- data/app/gemfiles/DataMapper.rb +1 -0
- data/app/gemfiles/FastCGI.rb +1 -0
- data/app/gemfiles/Puma.rb +1 -0
- data/app/gemfiles/RDiscount.rb +1 -0
- data/app/gemfiles/RDoc.rb +1 -0
- data/app/gemfiles/RedCloth.rb +1 -0
- data/app/gemfiles/WEBrick.rb +1 -0
- data/app/gemfiles/WikiCloth.rb +1 -0
- data/app/gemfiles/mysql/ActiveRecord.rb +1 -0
- data/app/gemfiles/mysql/DataMapper.rb +1 -0
- data/app/gemfiles/mysql/Sequel.rb +1 -0
- data/app/gemfiles/postgres/ActiveRecord.rb +1 -0
- data/app/gemfiles/postgres/DataMapper.rb +1 -0
- data/app/gemfiles/postgres/Sequel.rb +1 -0
- data/app/gemfiles/sqlite/ActiveRecord.rb +1 -0
- data/app/gemfiles/sqlite/DataMapper.rb +1 -0
- data/app/gemfiles/sqlite/Sequel.rb +1 -0
- data/app/layouts/ERB/layout.erb +56 -0
- data/app/layouts/Erubis/layout.erb +56 -0
- data/app/layouts/Haml/layout.haml +38 -0
- data/app/layouts/Slim/layout.slim +38 -0
- data/app/migrations/ActiveRecord.erb +51 -0
- data/app/migrations/DataMapper.erb +61 -0
- data/app/migrations/Sequel.erb +54 -0
- data/app/migrations/tracking_table/ActiveRecord.rb +19 -0
- data/app/migrations/tracking_table/DataMapper.rb +26 -0
- data/app/migrations/tracking_table/Sequel.rb +18 -0
- data/app/rakefiles/ActiveRecord.rb +0 -0
- data/app/rakefiles/DataMapper.rb +1 -0
- data/app/rakefiles/Sequel.rb +0 -0
- data/app/rakefiles/Specular.rb +1 -0
- data/app/specfiles/Specular.erb +7 -0
- data/bin/my_enginery +235 -0
- data/lib/enginery.rb +23 -0
- data/lib/enginery/cli.rb +44 -0
- data/lib/enginery/configurator.rb +139 -0
- data/lib/enginery/delete.rb +116 -0
- data/lib/enginery/enginery.rb +41 -0
- data/lib/enginery/generator.rb +325 -0
- data/lib/enginery/helpers/app.rb +83 -0
- data/lib/enginery/helpers/generic.rb +145 -0
- data/lib/enginery/helpers/input.rb +123 -0
- data/lib/enginery/helpers/orm.rb +86 -0
- data/lib/enginery/helpers/validations.rb +101 -0
- data/lib/enginery/migrator.rb +371 -0
- data/lib/enginery/rake-tasks/data_mapper.rb +49 -0
- data/lib/enginery/rake-tasks/specular.rb +41 -0
- data/lib/enginery/registry.rb +101 -0
- data/lib/enginery/usage.rb +66 -0
- data/lib/enginery/version.rb +7 -0
- data/logo.png +0 -0
- data/my_enginery.gemspec +37 -0
- data/test/delete/test__admin.rb +49 -0
- data/test/delete/test__controller.rb +37 -0
- data/test/delete/test__helper.rb +49 -0
- data/test/delete/test__migration.rb +27 -0
- data/test/delete/test__model.rb +35 -0
- data/test/delete/test__route.rb +35 -0
- data/test/delete/test__spec.rb +59 -0
- data/test/delete/test__view.rb +51 -0
- data/test/generator/test__admin.rb +39 -0
- data/test/generator/test__controller.rb +123 -0
- data/test/generator/test__helper.rb +56 -0
- data/test/generator/test__model.rb +206 -0
- data/test/generator/test__project.rb +81 -0
- data/test/generator/test__route.rb +110 -0
- data/test/generator/test__spec.rb +56 -0
- data/test/generator/test__view.rb +85 -0
- data/test/migrator/test__auto_generation.rb +41 -0
- data/test/migrator/test__manual_generation.rb +59 -0
- data/test/migrator/test__migrations.rb +139 -0
- data/test/sandbox/.gitkeep +0 -0
- data/test/setup.rb +29 -0
- data/test/support/spec_helpers.rb +151 -0
- metadata +392 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Enginery
|
|
2
|
+
module Test
|
|
3
|
+
module DeleteSpec
|
|
4
|
+
Spec.new self do
|
|
5
|
+
|
|
6
|
+
Dir.chdir DST_ROOT do
|
|
7
|
+
|
|
8
|
+
is(new_app 'App').ok?
|
|
9
|
+
|
|
10
|
+
Dir.chdir 'App' do
|
|
11
|
+
|
|
12
|
+
entries = [
|
|
13
|
+
'base/specs/foo/bar' + Enginery::SPEC_SUFFIX
|
|
14
|
+
]
|
|
15
|
+
Should 'be deleted alongside controller' do
|
|
16
|
+
is(new_controller 'Foo').ok?
|
|
17
|
+
is(new_route 'Foo bar').ok?
|
|
18
|
+
entries.each do |e|
|
|
19
|
+
does(File).exists? e
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
is(delete_controller 'Foo').ok?
|
|
23
|
+
entries.each do |e|
|
|
24
|
+
refute(File).exists? e
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
Should 'be deleted alongside route' do
|
|
28
|
+
is(new_controller 'Foo').ok?
|
|
29
|
+
is(new_route 'Foo bar').ok?
|
|
30
|
+
entries.each do |e|
|
|
31
|
+
does(File).exists? e
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
is(delete_route 'Foo bar').ok?
|
|
35
|
+
entries.each do |e|
|
|
36
|
+
refute(File).exists? e
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
Should 'be deleted manually' do
|
|
40
|
+
delete_controller 'Foo'
|
|
41
|
+
is(new_controller 'Foo').ok?
|
|
42
|
+
is(new_route 'Foo bar').ok?
|
|
43
|
+
entries.each do |e|
|
|
44
|
+
does(File).exists? e
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
is(delete_spec 'Foo bar').ok?
|
|
48
|
+
entries.each do |e|
|
|
49
|
+
refute(File).exists? e
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Enginery
|
|
2
|
+
module Test
|
|
3
|
+
module DeleteView
|
|
4
|
+
Spec.new self do
|
|
5
|
+
Dir.chdir DST_ROOT do
|
|
6
|
+
|
|
7
|
+
is(new_app 'App').ok?
|
|
8
|
+
|
|
9
|
+
Dir.chdir 'App' do
|
|
10
|
+
|
|
11
|
+
Testing 'with default engine' do
|
|
12
|
+
entries = [
|
|
13
|
+
'base/views/foo/bar.erb',
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
is(new_controller 'Foo').ok?
|
|
17
|
+
is(new_route 'Foo bar').ok?
|
|
18
|
+
entries.each do |e|
|
|
19
|
+
does(File).exists? e
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
is(delete_view 'Foo bar').ok?
|
|
23
|
+
entries.each do |e|
|
|
24
|
+
refute(File).exists? e
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Testing 'with custom engine' do
|
|
29
|
+
entries = [
|
|
30
|
+
'base/views/baz/bar.slim',
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
is(new_controller 'Baz e:Slim').ok?
|
|
34
|
+
is(new_route 'Baz bar').ok?
|
|
35
|
+
entries.each do |e|
|
|
36
|
+
does(File).exists? e
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
is(delete_view 'Baz bar').ok?
|
|
40
|
+
entries.each do |e|
|
|
41
|
+
refute(File).exists? e
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Enginery
|
|
2
|
+
module Test
|
|
3
|
+
module AdminGenerator
|
|
4
|
+
|
|
5
|
+
Spec.new self do
|
|
6
|
+
base_path = 'base/controllers/rear-controllers/'
|
|
7
|
+
|
|
8
|
+
Dir.chdir DST_ROOT do
|
|
9
|
+
is(new_app 'App').ok?
|
|
10
|
+
|
|
11
|
+
Dir.chdir 'App' do
|
|
12
|
+
is(new_model 'A').ok?
|
|
13
|
+
is(File).file? base_path + 'a' + ADMIN_SUFFIX
|
|
14
|
+
|
|
15
|
+
Should 'play well with namespaced models' do
|
|
16
|
+
is(new_model 'X::Y::Z').ok?
|
|
17
|
+
is(File).file? base_path + 'x/y/z' + ADMIN_SUFFIX
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
Testing 'manual generation' do
|
|
21
|
+
is(new_model 'B').ok?
|
|
22
|
+
|
|
23
|
+
file = base_path + 'b' + ADMIN_SUFFIX
|
|
24
|
+
is(File).file? file
|
|
25
|
+
# accidentally removing controller file...
|
|
26
|
+
FileUtils.rm file
|
|
27
|
+
refute(File).file? file
|
|
28
|
+
|
|
29
|
+
is(new_admin_controller 'B').ok?
|
|
30
|
+
is(File).file? file
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
module Enginery
|
|
2
|
+
module Test
|
|
3
|
+
module ControllerGenerator
|
|
4
|
+
Spec.new self do
|
|
5
|
+
|
|
6
|
+
Should 'fail cause not inside Espresso application' do
|
|
7
|
+
does(new_controller 'Foo').fail_with? /not.*Espresso.*application/im
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
Dir.chdir DST_ROOT do
|
|
11
|
+
Testing do
|
|
12
|
+
|
|
13
|
+
is(new_app 'App').ok?
|
|
14
|
+
|
|
15
|
+
Dir.chdir 'App' do
|
|
16
|
+
Context 'creating controllers' do
|
|
17
|
+
|
|
18
|
+
Should 'create an unmapped controller' do
|
|
19
|
+
is(new_controller 'Foo').ok?
|
|
20
|
+
|
|
21
|
+
dir = 'base/controllers/foo'
|
|
22
|
+
is(File).directory? dir
|
|
23
|
+
file = dir + '_controller.rb'
|
|
24
|
+
is(File).file? file
|
|
25
|
+
expect(File.read file) =~ /class\s+Foo\s+<\s+E\n/
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Should 'create a mapped controller' do
|
|
29
|
+
is(new_controller 'Bar r:bar').ok?
|
|
30
|
+
|
|
31
|
+
dir = 'base/controllers/bar'
|
|
32
|
+
is(File).directory? dir
|
|
33
|
+
file = dir + '_controller.rb'
|
|
34
|
+
is(File).file? file
|
|
35
|
+
expect(File.read file) =~ /map\s+\Wbar/m
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
Should 'create a controller with setups' do
|
|
39
|
+
is(new_controller 'Baz engine:Slim format:html').ok?
|
|
40
|
+
|
|
41
|
+
dir = 'base/controllers/baz'
|
|
42
|
+
is(File).directory? dir
|
|
43
|
+
file = dir + '_controller.rb'
|
|
44
|
+
is(File).file? file
|
|
45
|
+
code = File.read(file)
|
|
46
|
+
expect(code) =~ /format\s+\Whtml/m
|
|
47
|
+
expect(code) =~ /engine\s+:Slim/m
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Should 'fail with "controller already exists"' do
|
|
51
|
+
does(new_controller 'Baz').fail_with? /controller already exists/i
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
Should 'correctly handle namespaces' do
|
|
55
|
+
is(new_controller 'A::B::C').ok?
|
|
56
|
+
|
|
57
|
+
dir = 'base/controllers/a/b/c'
|
|
58
|
+
is(File).directory? dir
|
|
59
|
+
file = dir + '_controller.rb'
|
|
60
|
+
is(File).file? file
|
|
61
|
+
code = File.read(file)
|
|
62
|
+
expect(code) =~ /module A/
|
|
63
|
+
expect(code) =~ /module B/
|
|
64
|
+
expect(code) =~ /class C < E/
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
cleanup
|
|
71
|
+
|
|
72
|
+
Should 'inherit engine defined at project generation' do
|
|
73
|
+
is(new_app 'App e:Slim').ok?
|
|
74
|
+
|
|
75
|
+
Dir.chdir 'App' do
|
|
76
|
+
is(new_controller 'Foo').ok?
|
|
77
|
+
|
|
78
|
+
is(File).file? 'base/views/foo/index.slim'
|
|
79
|
+
|
|
80
|
+
Should 'include modules provided via include: option' do
|
|
81
|
+
is(new_controller 'Bar i:Rack::Utils').ok?
|
|
82
|
+
|
|
83
|
+
file = 'base/controllers/bar_controller.rb'
|
|
84
|
+
is(File).file? file
|
|
85
|
+
does(File.read file) =~ /include Rack::Utils/
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
cleanup
|
|
90
|
+
|
|
91
|
+
Should 'create multiple controllers at once' do
|
|
92
|
+
is(new_app 'App').ok?
|
|
93
|
+
|
|
94
|
+
Dir.chdir 'App' do
|
|
95
|
+
are(new_controllers 'A B C X::Y::Z e:Slim').ok?
|
|
96
|
+
|
|
97
|
+
%w[a b c].each do |c|
|
|
98
|
+
dir = "base/controllers/#{c}"
|
|
99
|
+
is(File).directory? dir
|
|
100
|
+
file = dir + "_controller.rb"
|
|
101
|
+
is(File).file? file
|
|
102
|
+
expect {File.read file} =~ /class #{c} < E/i
|
|
103
|
+
is(File).file? "base/views/#{c}/index.slim"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
And 'yet behave well with namespaces' do
|
|
107
|
+
dir = "base/controllers/x/y/z"
|
|
108
|
+
is(File).directory? dir
|
|
109
|
+
file = dir + "_controller.rb"
|
|
110
|
+
is(File).file? file
|
|
111
|
+
is(File).file? "base/views/x/y/z/index.slim"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
cleanup
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Enginery
|
|
2
|
+
module Test
|
|
3
|
+
module HelperGenerator
|
|
4
|
+
|
|
5
|
+
Spec.new self do
|
|
6
|
+
|
|
7
|
+
Dir.chdir DST_ROOT do
|
|
8
|
+
is(new_app 'App').ok?
|
|
9
|
+
Dir.chdir 'App' do
|
|
10
|
+
Should 'be auto-generated alongside controller' do
|
|
11
|
+
is(new_controller 'A').ok?
|
|
12
|
+
controller_file = 'base/controllers/a_controller.rb'
|
|
13
|
+
is(File).file? controller_file
|
|
14
|
+
|
|
15
|
+
Ensure 'it generated a helper file for A controller' do
|
|
16
|
+
helper_file = 'base/helpers/a.rb'
|
|
17
|
+
is(File).file? helper_file
|
|
18
|
+
|
|
19
|
+
Ensure 'generated helper include application helpers' do
|
|
20
|
+
does(File.read(helper_file)) =~ /include\s+Helpers/
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Ensure 'controller include generated helper' do
|
|
24
|
+
does(File.read(controller_file)) =~ /include\s+AHelpers/
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Should 'play well with namespaced controllers' do
|
|
29
|
+
is(new_controller 'X::Y::Z').ok?
|
|
30
|
+
is(File).file? 'base/helpers/x/y/z.rb'
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Testing 'manual generation' do
|
|
35
|
+
is(new_controller 'B').ok?
|
|
36
|
+
|
|
37
|
+
helper_file = 'base/helpers/b.rb'
|
|
38
|
+
is(File).file? helper_file
|
|
39
|
+
FileUtils.rm helper_file
|
|
40
|
+
refute(File).file? helper_file
|
|
41
|
+
|
|
42
|
+
is(new_helper 'B').ok?
|
|
43
|
+
is(File).file? helper_file
|
|
44
|
+
|
|
45
|
+
Ensure 'generated helper include application helpers' do
|
|
46
|
+
does(File.read(helper_file)) =~ /include\s+Helpers/
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
module Enginery
|
|
2
|
+
module Test
|
|
3
|
+
module ModelGenerator
|
|
4
|
+
Spec.new self do
|
|
5
|
+
|
|
6
|
+
Dir.chdir DST_ROOT do
|
|
7
|
+
Should 'generate a plain class cause no setups given' do
|
|
8
|
+
is(new_app 'App').ok?
|
|
9
|
+
|
|
10
|
+
Dir.chdir 'App' do
|
|
11
|
+
is(new_model 'Foo').ok?
|
|
12
|
+
|
|
13
|
+
file = 'base/models/foo.rb'
|
|
14
|
+
is(File).file? file
|
|
15
|
+
expect(File.read file) =~ /class\s+Foo\n/
|
|
16
|
+
|
|
17
|
+
Should 'correctly handle namespaces' do
|
|
18
|
+
is(new_model 'A::B::C').ok?
|
|
19
|
+
|
|
20
|
+
file = 'base/models/a/b/c.rb'
|
|
21
|
+
is(File).file? file
|
|
22
|
+
code = File.read(file)
|
|
23
|
+
expect(code) =~ /module A/
|
|
24
|
+
expect(code) =~ /module B/
|
|
25
|
+
expect(code) =~ /class C/
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
cleanup
|
|
31
|
+
|
|
32
|
+
Should 'use ORM defined at project generation' do
|
|
33
|
+
is(new_app 'App orm:DataMapper').ok?
|
|
34
|
+
|
|
35
|
+
Dir.chdir 'App' do
|
|
36
|
+
is(new_model 'Foo').ok?
|
|
37
|
+
|
|
38
|
+
file = 'base/models/foo.rb'
|
|
39
|
+
is(File).file? file
|
|
40
|
+
source_code = File.read file
|
|
41
|
+
does(source_code) =~ /class\s+Foo/
|
|
42
|
+
does(source_code) =~ /include\s+DataMapper/
|
|
43
|
+
|
|
44
|
+
Should 'generate multiple models' do
|
|
45
|
+
|
|
46
|
+
are(new_models 'Bar Baz X::Y::Z').ok?
|
|
47
|
+
|
|
48
|
+
%w[Bar Baz].each do |c|
|
|
49
|
+
file = "base/models/#{c.downcase}.rb"
|
|
50
|
+
is(File).file? file
|
|
51
|
+
expect {File.read file} =~ /class #{c}/i
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
And 'yet behave well with namespaces' do
|
|
55
|
+
file = "base/models/x/y/z.rb"
|
|
56
|
+
is(File).file? file
|
|
57
|
+
expect {File.read file} =~ /class Z/i
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
Should 'include modules provided via include: option' do
|
|
63
|
+
is(new_model 'BarBaz i:Rack::Utils').ok?
|
|
64
|
+
|
|
65
|
+
file = 'base/models/bar_baz.rb'
|
|
66
|
+
is(File).file? file
|
|
67
|
+
does(File.read file) =~ /include Rack::Utils/
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
cleanup
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
Spec.new self do
|
|
77
|
+
Dir.chdir DST_ROOT do
|
|
78
|
+
|
|
79
|
+
Should 'correctly handle ActiveRecord associations' do
|
|
80
|
+
is(new_app 'App orm:ar').ok?
|
|
81
|
+
|
|
82
|
+
Dir.chdir 'App' do
|
|
83
|
+
model_file = "base/models/foo.rb"
|
|
84
|
+
|
|
85
|
+
is(new_model 'Foo belongs_to:bar').ok?
|
|
86
|
+
does(model_file).contain? /belongs_to\W+bar/
|
|
87
|
+
is(delete_model 'Foo').ok?
|
|
88
|
+
|
|
89
|
+
is(new_model 'Foo has_one:bar').ok?
|
|
90
|
+
does(model_file).contain? /has_one\W+bar/i
|
|
91
|
+
is(delete_model 'Foo').ok?
|
|
92
|
+
|
|
93
|
+
is(new_model 'Foo has_one:bar:through:baz').ok?
|
|
94
|
+
does(model_file).contain? /has_one\W+bar\W+through\W+baz/i
|
|
95
|
+
is(delete_model 'Foo').ok?
|
|
96
|
+
|
|
97
|
+
is(new_model 'Foo has_many:bars').ok?
|
|
98
|
+
does(model_file).contain? /has_many\W+bars/i
|
|
99
|
+
is(delete_model 'Foo').ok?
|
|
100
|
+
|
|
101
|
+
is(new_model 'Foo has_many:bars:through:baz').ok?
|
|
102
|
+
does(model_file).contain? /has_many\W+bars\W+through\W+baz/i
|
|
103
|
+
is(delete_model 'Foo').ok?
|
|
104
|
+
|
|
105
|
+
is(new_model 'Foo has_and_belongs_to_many:bars').ok?
|
|
106
|
+
does(model_file).contain? /has_and_belongs_to_many\W+bars/i
|
|
107
|
+
is(delete_model 'Foo').ok?
|
|
108
|
+
|
|
109
|
+
Should 'handle multiple associations' do
|
|
110
|
+
is(new_model 'Foo belongs_to:bar belongs_to:baz has_many:related_bars').ok?
|
|
111
|
+
does(model_file).contain? /belongs_to\W+bar/
|
|
112
|
+
does(model_file).contain? /belongs_to\W+baz/
|
|
113
|
+
does(model_file).contain? /has_many\W+related_bars/
|
|
114
|
+
is(delete_model 'Foo').ok?
|
|
115
|
+
|
|
116
|
+
is(new_model 'Foo has_and_belongs_to_many:bars has_many:barz:through:baz').ok?
|
|
117
|
+
does(model_file).contain? /has_and_belongs_to_many\W+bars/i
|
|
118
|
+
does(model_file).contain? /has_many\W+barz\W+through\W+baz/i
|
|
119
|
+
is(delete_model 'Foo').ok?
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
cleanup
|
|
124
|
+
|
|
125
|
+
Should 'correctly handle DataMapper associations' do
|
|
126
|
+
is(new_app 'App orm:dm').ok?
|
|
127
|
+
|
|
128
|
+
Dir.chdir 'App' do
|
|
129
|
+
model_file = "base/models/foo.rb"
|
|
130
|
+
|
|
131
|
+
is(new_model 'Foo belongs_to:bar').ok?
|
|
132
|
+
does(model_file).contain? /belongs_to\W+bar/
|
|
133
|
+
is(delete_model 'Foo').ok?
|
|
134
|
+
|
|
135
|
+
is(new_model 'Foo has_one:bar').ok?
|
|
136
|
+
does(model_file).contain? /has\s+1\W+bar/i
|
|
137
|
+
is(delete_model 'Foo').ok?
|
|
138
|
+
|
|
139
|
+
is(new_model 'Foo has_one:bar:through:baz').ok?
|
|
140
|
+
does(model_file).contain? /has\s+1\W+bar\W+through\W+baz/i
|
|
141
|
+
is(delete_model 'Foo').ok?
|
|
142
|
+
|
|
143
|
+
is(new_model 'Foo has_many:bars').ok?
|
|
144
|
+
does(model_file).contain? /has\s+n\W+bars/i
|
|
145
|
+
is(delete_model 'Foo').ok?
|
|
146
|
+
|
|
147
|
+
is(new_model 'Foo has_many:bars:through:baz').ok?
|
|
148
|
+
does(model_file).contain? /has\s+n\W+bars\W+through\W+baz/i
|
|
149
|
+
is(delete_model 'Foo').ok?
|
|
150
|
+
|
|
151
|
+
is(new_model 'Foo has_and_belongs_to_many:bars').ok?
|
|
152
|
+
does(model_file).contain? /has\s+n\W+bars/i
|
|
153
|
+
is(delete_model 'Foo').ok?
|
|
154
|
+
|
|
155
|
+
Should 'handle multiple associations' do
|
|
156
|
+
is(new_model 'Foo belongs_to:bar has_many:related_bars').ok?
|
|
157
|
+
does(model_file).contain? /belongs_to\W+bar/
|
|
158
|
+
does(model_file).contain? /has\s+n\W+related_bars/
|
|
159
|
+
is(delete_model 'Foo').ok?
|
|
160
|
+
|
|
161
|
+
is(new_model 'Foo has_many:related_bars has_many:bars:through:related_bars').ok?
|
|
162
|
+
does(model_file).contain? /has\s+n\W+related_bars/
|
|
163
|
+
does(model_file).contain? /has\s+n\W+bars\W+through\W+related_bars/
|
|
164
|
+
is(delete_model 'Foo').ok?
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
cleanup
|
|
169
|
+
|
|
170
|
+
Should 'correctly handle Sequel associations' do
|
|
171
|
+
is(new_app 'App orm:sq').ok?
|
|
172
|
+
|
|
173
|
+
Dir.chdir 'App' do
|
|
174
|
+
model_file = "base/models/foo.rb"
|
|
175
|
+
|
|
176
|
+
is(new_model 'Foo belongs_to:bar').ok?
|
|
177
|
+
does(model_file).contain? /many_to_one\W+bar/
|
|
178
|
+
is(delete_model 'Foo').ok?
|
|
179
|
+
|
|
180
|
+
is(new_model 'Foo has_one:bar').ok?
|
|
181
|
+
does(model_file).contain? /one_to_one\W+bar/i
|
|
182
|
+
is(delete_model 'Foo').ok?
|
|
183
|
+
|
|
184
|
+
is(new_model 'Foo has_many:bars').ok?
|
|
185
|
+
does(model_file).contain? /one_to_many\W+bars/i
|
|
186
|
+
is(delete_model 'Foo').ok?
|
|
187
|
+
|
|
188
|
+
is(new_model 'Foo has_and_belongs_to_many:bars').ok?
|
|
189
|
+
does(model_file).contain? /many_to_many\W+bars/i
|
|
190
|
+
is(delete_model 'Foo').ok?
|
|
191
|
+
|
|
192
|
+
Should 'handle multiple associations' do
|
|
193
|
+
is(new_model 'Foo belongs_to:bar has_many:related_bars').ok?
|
|
194
|
+
does(model_file).contain? /many_to_one\W+bar/
|
|
195
|
+
does(model_file).contain? /one_to_many\W+related_bars/
|
|
196
|
+
is(delete_model 'Foo').ok?
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
cleanup
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|