lazy-head-gen 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
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
- ## Extras
126
+ ## Tests
127
127
 
128
128
  ### Built in assertions and test helpers
129
129
 
130
- TODO: Write about these
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
- If you already have a blueprints.rb file, the scaffold generator looks for *# END blueprints* as a marker to insert the generated models blueprint. This is a bit... well crap... but I currently haven't thought of another way to do it.
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
1
+ 0.3.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "lazy-head-gen"
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Stuart Chinery"]
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
- # Insert into blueprints.rb
143
- insert_into_file destination_root("test", "blueprints.rb"), model_blueprint, :before => "# END blueprints"
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 status, 302
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 status, 302
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
- require 'debugger'
13
+
14
14
  begin; require 'turn/autorun'; rescue LoadError; end
15
15
 
16
16
  Padrino::Generators.load_components!
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../helper')
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 'button_to pat(:logout)', "#{@apptmp}/sample_project/admin/views/layouts/application.erb"
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 'button_to pat(:logout)', "#{@apptmp}/sample_project/admin/views/layouts/application.erb"
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 'button_to pat(:logout)', "#{@apptmp}/sample_project/admin/views/layouts/application.erb"
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
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../helper')
1
+ require 'helper'
2
2
 
3
3
  class Person
4
4
  def self.columns
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: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stuart Chinery