Permalink
Browse files

small enhancements: added rcov task and table indexes

Squashed commit of the following:

commit cbc5265e4349246026b1bbf4468b4df22ff02cf6
Author: Alexander Dreher <alexdreher@lxmedia.net>
Date:   Tue Jan 18 14:24:38 2011 +0100

    added indexes to messages table

commit 04a00e7c790a8f24a0746388ed386029537fa6f1
Author: Alexander Dreher <alexdreher@lxmedia.net>
Date:   Tue Jan 18 14:21:52 2011 +0100

    small fix and clean up

commit 8801b25cd2b82828dcd12932eb7a6e18dd22f12a
Author: Alexander Dreher <alexdreher@lxmedia.net>
Date:   Tue Jan 18 14:18:30 2011 +0100

    added rcov rake task; gitignored results
  • Loading branch information...
1 parent 9a33085 commit 79a735e00f2775c46e944084e58be9e8a5ddf7f8 @alexdreher committed Jan 18, 2011
View
@@ -3,4 +3,6 @@ db/*.sqlite3
log/*.log
tmp/**/*
.DS_Store
-public/stylesheets/compiled/
+public/stylesheets/compiled/
+coverage.data
+coverage/
@@ -1,2 +0,0 @@
-module Admin::MessagesHelper
-end
@@ -1,2 +0,0 @@
-module Admin::UsersHelper
-end
@@ -1,2 +0,0 @@
-module MessagesHelper
-end
@@ -1,2 +0,0 @@
-module WelcomeHelper
-end
@@ -0,0 +1,13 @@
+class AddIndexes < ActiveRecord::Migration
+ def self.up
+ add_index :messages, :sender_id
+ add_index :messages, :recipient_id
+ add_index :messages, :subject
+ end
+
+ def self.down
+ remove_index :messages, :subject
+ remove_index :messages, :recipient_id
+ remove_index :messages, :sender_id
+ end
+end
View
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110118110237) do
+ActiveRecord::Schema.define(:version => 20110118132248) do
create_table "messages", :force => true do |t|
t.integer "sender_id"
@@ -21,6 +21,10 @@
t.datetime "updated_at"
end
+ add_index "messages", ["recipient_id"], :name => "index_messages_on_recipient_id"
+ add_index "messages", ["sender_id"], :name => "index_messages_on_sender_id"
+ add_index "messages", ["subject"], :name => "index_messages_on_subject"
+
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
View
@@ -0,0 +1,47 @@
+# https://gist.github.com/670111
+#
+# Forked to get it working with Rails 3 and RSpec 2
+#
+# From http://github.com/jaymcgavren
+#
+# Save this as rcov.rake in lib/tasks and use rcov:all =>
+# to get accurate spec/feature coverage data
+#
+# Use rcov:rspec or rcov:cucumber
+# to get non-aggregated coverage reports for rspec or cucumber separately
+
+require 'cucumber/rake/task'
+require "rspec/core/rake_task"
+
+namespace :rcov do
+ Cucumber::Rake::Task.new(:cucumber_run) do |t|
+ t.rcov = true
+ t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data}
+ t.rcov_opts << %[-o "coverage"]
+ end
+
+ RSpec::Core::RakeTask.new(:rspec_run) do |t|
+ t.pattern = 'spec/**/*_spec.rb'
+ t.rcov = true
+ t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/}
+ end
+
+ desc "Run both specs and features to generate aggregated coverage"
+ task :all do |t|
+ rm "coverage.data" if File.exist?("coverage.data")
+ Rake::Task["rcov:cucumber_run"].invoke
+ Rake::Task["rcov:rspec_run"].invoke
+ end
+
+ desc "Run only rspecs"
+ task :rspec do |t|
+ rm "coverage.data" if File.exist?("coverage.data")
+ Rake::Task["rcov:rspec_run"].invoke
+ end
+
+ desc "Run only cucumber"
+ task :cucumber do |t|
+ rm "coverage.data" if File.exist?("coverage.data")
+ Rake::Task["rcov:cucumber_run"].invoke
+ end
+end
@@ -1,15 +0,0 @@
-require 'spec_helper'
-
-# Specs in this file have access to a helper object that includes
-# the Admin::MessagesHelper. For example:
-#
-# describe Admin::MessagesHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
-describe Admin::MessagesHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
@@ -1,11 +0,0 @@
-require 'spec_helper'
-
-describe "Admin::Messages" do
- describe "GET /admin_messages" do
- it "works! (now write some real specs)" do
- # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
- get admin_messages_path
- response.status.should be(200)
- end
- end
-end

0 comments on commit 79a735e

Please sign in to comment.