Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added rspec tasks for pretty and easy reporting.

  • Loading branch information...
commit ecb1841f59c8e519363b4cb4205fd7b0a22264ed 1 parent eac9c77
@napcs authored
View
133 README.rdoc
@@ -0,0 +1,133 @@
+=LazyDeveloper
+Copyright (C) 2007-2008 Brian P. Hogan and Kevin Gisi
+
+Developers are lazy. I know I am. If I have to do things over and over, I want
+them to be automated. Maybe that's efficent and not lazy. However, lazy is a
+shorter word and it's funnier to call this plugin LazyDeveloper.
+
+This plugin provides some useful Rake tasks that will make your life a little
+eaiser. I use them in many of my projects and I invite you to do the same.
+
+= Usage
+== Databases
+
+=== rake db:migrate
+
+The db:migrate task has been modified slightly. Running this task now clones your
+test database, which is really useful if you run tests individually via TextMate
+or through the commandline.
+
+=== rake db:remigrate
+
+Sometimes you just need to wipe out your database tables and start over. This
+task drops your tables and starts over by dropping the tables directly and then
+re-running your migrations. This provides a great way to test to make sure you
+haven't broken migrations at some point.
+
+=== rake db:export
+
+Dump your database to fixtures. Stores them in /test/fixtures/live. You can then use this to load the data
+back into another database, even one of a different type
+
+=== rake db:import
+Load fixtures from test/fixures/live into your database. Loads fixtures dumped by using rake db:export
+
+== Subversion
+
+=== rake svn:root
+Displays the root of your repository
+
+=== rake svn:tags
+Displays all the tags. Assumes you use a tags/ folder and a /trunk folder
+
+=== rake svn:tags:last
+Displays the last tag.
+
+=== rake svn:tag TAG=rel_1-0-0
+Creates a new tag from the trunk.
+
+== Rcov
+Thanks to Kevin Gisi for these tasks that make running RCov a bit easier.
+Requires the RCov gem and the rails_rcov plugin
+
+=== rake rcov:models
+
+Runs coverage on your models
+
+=== rake rcov:controllers
+
+Runs coverage on your controllers
+
+=== rake rcov:all
+
+Runs coverage on models and controllers
+
+
+== Tests
+Based on an idea from Geoffrey Grosenbach, you can run all tests in units\user_test.rb by doing
+
+ rake test:units:user:all
+
+Or run a specific test by speficying all or part of a name. For example, if I
+wanted to run the "test_create" test case, I would use
+
+ rake test:units:user:create
+
+The same rules apply to functional tests
+
+ rake test:functionals:users:list
+
+== Specs
+
+RSpec gets some love here. If you need nice output for your specs, we overrode
+some of the built-in specs.
+
+=== Running all model specs
+
+ rake spec:models
+
+=== Running all controller specs
+
+ rake spec:controllers
+
+=== Running a specific model or controller spec
+
+ rake spec:model:user
+ rake spec:controller:sessions
+
+== Gems (Deprecated - will be removed very, very soon)
+
+Place a file called .gems in the root of your Rails project. The file should
+contain all of the gems you want to install.
+
+ tz_info
+ rcov
+ fastercsv
+ redcloth
+
+You can install all of these gems easily with
+
+ rake rails:install:gems
+
+== Plugins
+
+Create a file in your Home folder called .plugins and you can have all of your
+favorite plugins easily installed by doing
+
+ rake rails:install:plugins
+
+Just put each plugin name or repository on its own line.
+
+Windows users need to set the HOME environment variable.
+
+== Cleaning Up
+
+Run
+
+ rake rails:clear
+
+to clean up tmp, logs, and docs in one easy command.
+
+
+
+Copyright (c) 2007-2008 Brian Hogan and Kevin Gisi. Released under the MIT license
View
12 tasks/db_translate.rake
@@ -54,11 +54,7 @@ end
namespace :db do
-
-
-
-
-
+
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
task :import => :environment do
require 'active_record/fixtures'
@@ -68,7 +64,6 @@ namespace :db do
end
end
-
desc "Dump all data to fixtures/live folder"
task :export => :environment do
path = RAILS_ROOT + "/test/fixtures/live"
@@ -91,7 +86,4 @@ namespace :db do
end
-end
-
-
-
+end
View
5 tasks/rcov.rake
@@ -1,8 +1,3 @@
-# Lazy Testing
-# Kevin Gisi
-# 06/17/08
-# Copyright(c) 2008, released under MIT License
-
namespace :rcov do
# Runs all unit tests, and determines coverage
View
65 tasks/rspec.rake
@@ -1,9 +1,65 @@
-# Lazy Specs
-# Kevin Gisi
-# 06/24/08
-# Copyright(c) 2008, released under MIT License
+# Remove the tasks we're going to replace
+# Be very careful with this section and please
+# don't use this if you don't know what it
+# actually does!
+Rake::TaskManager.class_eval do
+ def delete_task(name)
+ @tasks.delete(name)
+ end
+ Rake.application.delete_task("spec:models")
+ Rake.application.delete_task("spec:controllers")
+end
namespace :spec do
+
+ desc "Run specs for models and show nice display"
+ task :models do
+ puts `ruby script/spec --format s -c spec/models/*_spec.rb`
+ end
+
+ desc "Run specs for controllers and show nice display"
+ task :controllers do
+ puts `ruby script/spec --format s -c spec/controllers/*_spec.rb`
+ end
+
+ # Provides a mechanism to run specs for the given model
+ # or controller.
+ #
+ # Example:
+ # rake spec:models:user
+ # rake spec:controllers:sessions
+ rule /^spec/ do |t|
+ root = t.name.gsub("spec:","").split(/:/)
+ if root.length >= 2
+ flag = root[0]
+ file_name = root[1]
+ #test_name = root[2]
+ test_name = "*" if test_name == "all"
+
+
+ model = (flag == "model" || flag == "m")
+ controller = (flag == "controllers" || flag == "c")
+
+
+ if (model)
+ file_path = "models/#{file_name}_spec.rb"
+ end
+
+ if (controller)
+ file_path = "controllers/#{file_name}_controller_spec.rb"
+ end
+
+ if (!File.exist?("spec/#{file_path}"))
+ raise "No file found for #{file_path}"
+ end
+
+ puts `ruby script/spec -c --format s spec/#{file_path}`
+
+ else
+ puts "invalid arguments. Specify the type of test, filename, and test name"
+ end
+ end
+
namespace :generate do
desc "Populate spec sheets for models"
@@ -41,6 +97,7 @@ namespace :spec do
"require '#{controller}'",
"",
"describe #{controller.camelize} do",
+ " integrate_views",
"",
"end"
]
Please sign in to comment.
Something went wrong with that request. Please try again.