README.md in lazy-head-gen-0.1.3 vs README.md in lazy-head-gen-0.2.0
- old
+ new
@@ -1,35 +1,31 @@
-lazy-head-gen
-=============
+# lazy-head-gen
-Lazy Head Gen is simply a couple of extra generators for the excellent [Padrino](https://github.com/padrino/padrino-framework) framework.
+Lazy Head Gen provides a couple of extra generators for the excellent [Padrino](https://github.com/padrino/padrino-framework) framework.
-It is currently tied into assuming that you are using ActiveRecord and MiniTest, as that is what I normally use when developing at Head.
+It is assuming that you are using ActiveRecord and MiniTest, as that is the options we normally use when developing at [Head](http://www.headlondon.com).
-Installation:
--------------
+## Installation
```
gem install lazy-head-gen
```
In a Gemfile:
```ruby
-gem 'lazy-head-gen'
+gem 'lazy-head-gen', :group => [:development, :test]
```
Padrino gotcha: You'll need to put the `gem 'lazy-head-gen'` requirement *after* `gem 'padrino'` in your Gemfile.
-Lazy Head Gen needs Padrino loaded before it can show up in a Gemfile.
+Lazy Head Gen needs Padrino loaded before it can work.
-Usage
------
+## Usage
There are currently 2 extra generators, scaffold and admin_controller_tests.
-Scaffold
-========
+### Scaffold Generator
To generate a new scaffold:
```
padrino g scaffold ModelName property:type
@@ -51,14 +47,12 @@
It will also add:
* A reference to blueprints.rb to test_config.rb if required
* Add a Product blueprint and it's properties to the blueprints.rb file
+### Admin Controller Tests Generator
-Admin Controller Tests
-======================
-
To generate a new admin controller test:
```
padrino g admin_controller_tests ControllerName
```
@@ -69,158 +63,36 @@
```
padrino g admin_controller_tests products
```
-This will generate a fully tested admin controller test for the 7 CRUD routes.
+This will generate a fully tested admin controller test for the 6 CRUD routes of a standard Padrino admin controller.
-Other requirements
-------------------
+## Extras
-test_config.rb
-==============
+### Built in assertions and test helpers
-You will need to add the following code to your test_config.rb for the generated tests to work correctly.
+TODO: Write about these
-```
-# Allows testing as a logged in admin user
-#
-def login_as_admin(account)
- post "/admin/sessions/create", {
- :email => account.email, :password => "password"
- }
- follow_redirect!
-end
+### blueprints.rb
-# Standard assertions to test when a user is not logged in
-# and trys to view an admin page
-#
-def assert_not_logged_in
- assert !ok?
- assert_equal 302, status
- assert_equal "http://example.org/admin/sessions/new", location
-end
+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.
-# Assertions to test when a user is not logged in
-# and trys to call a destroy action
-#
-def assert_destroy_not_logged_in
- assert !ok?
- assert_equal 405, status
- assert_nil location
-end
+## To Do List
-# Standard assertions to test when a user is logged in
-# and trys to view an admin page using GET
-#
-def assert_logged_in
- assert ok?
- assert_equal 200, status
-end
+* Finish README
+* See if there is a better way to do the blueprint inserts
-# Returns a key and new value which is set depending
-# on the old values class.
-#
-def get_key_and_value(instance)
- # Discount PK and Timestamps
- keys = instance.attributes.keys.delete_if do |k|
- ["id", "created_at", "updated_at"].include?(k) or instance.attributes[k].nil?
- end
+## Contributing to lazy-head-gen
- key = old_value = new_value = nil
-
- if keys.length > 0
- # Pick a key at random
- key = keys[rand(keys.length)]
- old_value = instance.attributes[key]
-
- case old_value.class.name
- when "Integer"
- new_value = old_value + 1
- when "Time"
- new_value = old_value + 36000
- when "String"
- new_value = "This is a modified string"
- when "TrueClass"
- new_value = false
- when "FalseClass"
- new_value = true
- else
- puts old_value.class.name
- end
- end
-
- return [key, new_value]
-end
-
-# Some shorthands for last_request and last_response varibles
-#
-def path
- last_request.path
-end
-
-def session
- last_request.env['rack.session']
-end
-
-def body
- last_response.body
-end
-
-def status
- last_response.status
-end
-
-def location
- last_response.original_headers["Location"]
-end
-
-def ok?
- last_response.ok?
-end
-```
-
-blueprints.rb
-=============
-
-If you already have a blueprints.rb file in your current Padrino project then you will need to add the following for some of the tests to work:
-
-```
-module Factory
- class << self
-
- def make_admin
- account = Account.make(:admin)
- account.save!
- account
- end
-
- end
-end
-```
-
-Also 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.
-
-To Do List
-----------
-
-* Finish writing up the Read Me
-* Get generators to check the test_config.rb to make sure that the test helpers have been added
-* Tighten up some of the other requirements, certainly the blueprint inserts
-
-
-Contributing to lazy-head-gen
------------------------------
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
-Copyright
----------
+## Copyright
-Copyright (c) 2012 Stuart Chinery, http://www.headlondon.com
+Copyright (c) 2012 [Stuart Chinery](http://www.headlondon.com/who-we-are#stuart-chinery), [headlondon.com](http://www.headlondon.com)
See LICENSE.txt for further details.
\ No newline at end of file