lazy-head-gen 0.3.1 → 0.3.2
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/README.md +16 -4
- data/VERSION +1 -1
- data/lazy-head-gen.gemspec +1 -1
- data/lib/lazy-head-gen.rb +1 -1
- data/lib/lazy-head-gen/admin_controller_test.rb +1 -1
- data/lib/lazy-head-gen/scaffold.rb +4 -4
- data/lib/lazy-head-gen/templates/admin_controller_test/admin_controller_test.rb.tt +2 -2
- data/lib/lazy-head-gen/templates/scaffold/blueprints.rb.tt +0 -5
- data/test/helper.rb +1 -1
- data/test/lazy-head-gen/test_bootstrapped_admin_app_generator.rb +4 -4
- data/test/lazy-head-gen/test_bootstrapped_admin_page_generator.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -123,21 +123,33 @@ padrino g scaffold [name]
|
|
123
123
|
padrino g scaffold Product title:string summary:text quantity:integer available_from:datetime display:boolean -c
|
124
124
|
```
|
125
125
|
|
126
|
-
##
|
126
|
+
## Tests
|
127
127
|
|
128
128
|
### Built in assertions and test helpers
|
129
129
|
|
130
|
-
|
130
|
+
First off you will need to add this line to your test_config.rb file, after you have required boot.rb.
|
131
|
+
|
132
|
+
```
|
133
|
+
include LazyHeadGen
|
134
|
+
```
|
135
|
+
|
136
|
+
This will allow you to access the couple of test helpers that are used in the generated tests.
|
137
|
+
|
138
|
+
TODO: list test helper methods.
|
131
139
|
|
132
140
|
### blueprints.rb
|
133
141
|
|
134
|
-
|
142
|
+
The scaffold and admin_controller_test generators are reliant on you using a blueprints.rb file.
|
143
|
+
|
144
|
+
## Known Issues (probably loads of unknown!)
|
145
|
+
|
146
|
+
* If you generate an admin_controller_test for the admin account controller you end up with 2 failing tests. Other generated admin tests pass.
|
135
147
|
|
136
148
|
## To Do List
|
137
149
|
|
138
150
|
* Finish README - Built in assertions and test helpers
|
139
|
-
* See if there is a better way to do the blueprint inserts
|
140
151
|
* Add form output to the scaffold generator
|
152
|
+
* Figure out why generated test for the Admin Account controller fails.
|
141
153
|
|
142
154
|
## Contributing to lazy-head-gen
|
143
155
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/lazy-head-gen.gemspec
CHANGED
data/lib/lazy-head-gen.rb
CHANGED
@@ -9,6 +9,7 @@ module LazyHeadGen
|
|
9
9
|
|
10
10
|
# Allows testing as a logged in admin user
|
11
11
|
#
|
12
|
+
# param [Account] account - The account to attempt login with
|
12
13
|
def login_as_admin(account)
|
13
14
|
post "/admin/sessions/create", {
|
14
15
|
:email => account.email, :password => "password"
|
@@ -60,7 +61,6 @@ module LazyHeadGen
|
|
60
61
|
last_response.ok?
|
61
62
|
end
|
62
63
|
|
63
|
-
|
64
64
|
# A factory which we can use to build objects which are a bit more complex or
|
65
65
|
# which require special setup which can't be done by Machinist without a bit of
|
66
66
|
# help.
|
@@ -19,7 +19,7 @@ module Padrino
|
|
19
19
|
|
20
20
|
desc "Description:\n\n\tpadrino g admin_controller_test - Generates basic tests for an admin controller"
|
21
21
|
|
22
|
-
argument :name, :desc => "The name of your admin controller"
|
22
|
+
argument :name, :desc => "The name of your admin controller", :type => :string
|
23
23
|
|
24
24
|
class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
|
25
25
|
|
@@ -19,7 +19,7 @@ module Padrino
|
|
19
19
|
|
20
20
|
desc "Description:\n\n\tpadrino g scaffold - Generates a fully tested Padrino resource scaffold"
|
21
21
|
|
22
|
-
argument :name, :desc => "The name of your scaffold resource"
|
22
|
+
argument :name, :desc => "The name of your scaffold resource", :type => :string
|
23
23
|
|
24
24
|
argument :properties, :desc => "The properties of the scaffold's model", :type => :array, :default => []
|
25
25
|
|
@@ -133,14 +133,14 @@ module Padrino
|
|
133
133
|
|
134
134
|
# Format the blueprint entry
|
135
135
|
model_blueprint = <<-MODEL
|
136
|
+
|
136
137
|
#{@model}.blueprint do
|
137
138
|
#{props}
|
138
139
|
end
|
139
|
-
|
140
140
|
MODEL
|
141
141
|
|
142
|
-
#
|
143
|
-
|
142
|
+
# Append blueprints.rb
|
143
|
+
append_file destination_root("test", "blueprints.rb"), model_blueprint
|
144
144
|
else
|
145
145
|
say "Blueprints entry already exists for '#{@singular}'", :yellow
|
146
146
|
end
|
@@ -127,7 +127,7 @@ describe "Admin::<%= @controller if @controller %>Controller" do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should redirect to the edit page" do
|
130
|
-
assert_equal
|
130
|
+
assert_equal 302, status
|
131
131
|
assert location.include?("/admin/<%= @pluralized %>/edit/#{<%= @model %>.last.to_param}")
|
132
132
|
end
|
133
133
|
|
@@ -162,7 +162,7 @@ describe "Admin::<%= @controller if @controller %>Controller" do
|
|
162
162
|
end
|
163
163
|
|
164
164
|
it "should redirect to the edit page" do
|
165
|
-
assert_equal
|
165
|
+
assert_equal 302, status
|
166
166
|
assert location.include?("/admin/<%= @pluralized %>/edit/#{@<%= @singular %>.to_param}")
|
167
167
|
end
|
168
168
|
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'machinist/active_record'
|
2
2
|
require 'faker'
|
3
3
|
|
4
|
-
# START blueprints
|
5
|
-
|
6
4
|
Account.blueprint do
|
7
5
|
name { Faker::Name.first_name }
|
8
6
|
surname { Faker::Name.last_name }
|
@@ -11,6 +9,3 @@ Account.blueprint do
|
|
11
9
|
password_confirmation { "password" }
|
12
10
|
role { "admin" }
|
13
11
|
end
|
14
|
-
|
15
|
-
|
16
|
-
# END blueprints
|
data/test/helper.rb
CHANGED
@@ -10,7 +10,7 @@ require 'thor/group'
|
|
10
10
|
require 'padrino-core/support_lite' unless defined?(SupportLite)
|
11
11
|
require 'padrino-admin'
|
12
12
|
require File.dirname(__FILE__) + '/../lib/lazy-head-gen.rb'
|
13
|
-
|
13
|
+
|
14
14
|
begin; require 'turn/autorun'; rescue LoadError; end
|
15
15
|
|
16
16
|
Padrino::Generators.load_components!
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'helper'
|
2
2
|
|
3
3
|
describe "BootstrappedAdminAppGenerator" do
|
4
4
|
|
@@ -76,7 +76,7 @@ describe "BootstrappedAdminAppGenerator" do
|
|
76
76
|
assert_match_in_file 'Padrino.mount("Admin").to("/admin")', "#{@apptmp}/sample_project/config/apps.rb"
|
77
77
|
assert_match_in_file 'class Admin < Padrino::Application', "#{@apptmp}/sample_project/admin/app.rb"
|
78
78
|
assert_match_in_file 'role.project_module :accounts, \'/accounts\'', "#{@apptmp}/sample_project/admin/app.rb"
|
79
|
-
assert_match_in_file '
|
79
|
+
assert_match_in_file 'link_to(\'Sign Out\', url(:sessions, :destroy), :method => :delete)', "#{@apptmp}/sample_project/admin/views/layouts/application.erb"
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'should correctly generate a new padrino admin application with a custom account model' do
|
@@ -133,7 +133,7 @@ describe "BootstrappedAdminAppGenerator" do
|
|
133
133
|
assert_match_in_file 'Padrino.mount("Admin").to("/admin")', "#{@apptmp}/sample_project/config/apps.rb"
|
134
134
|
assert_match_in_file 'class Admin < Padrino::Application', "#{@apptmp}/sample_project/admin/app.rb"
|
135
135
|
assert_match_in_file 'role.project_module :users, \'/users\'', "#{@apptmp}/sample_project/admin/app.rb"
|
136
|
-
assert_match_in_file '
|
136
|
+
assert_match_in_file 'link_to(\'Sign Out\', url(:sessions, :destroy), :method => :delete)', "#{@apptmp}/sample_project/admin/views/layouts/application.erb"
|
137
137
|
end
|
138
138
|
|
139
139
|
it 'should correctly generate a new padrino admin application with model in non-default application path' do
|
@@ -184,7 +184,7 @@ describe "BootstrappedAdminAppGenerator" do
|
|
184
184
|
assert_match_in_file 'Padrino.mount("Admin").to("/admin")', "#{@apptmp}/sample_project/config/apps.rb"
|
185
185
|
assert_match_in_file 'class Admin < Padrino::Application', "#{@apptmp}/sample_project/admin/app.rb"
|
186
186
|
assert_match_in_file 'role.project_module :accounts, \'/accounts\'', "#{@apptmp}/sample_project/admin/app.rb"
|
187
|
-
assert_match_in_file '
|
187
|
+
assert_match_in_file 'link_to(\'Sign Out\', url(:sessions, :destroy), :method => :delete)', "#{@apptmp}/sample_project/admin/views/layouts/application.erb"
|
188
188
|
end
|
189
189
|
|
190
190
|
it 'should add activerecord middleware for #activerecord' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy-head-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stuart Chinery
|