Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Major refactor, including Rails 3.0.4 support

  • Loading branch information...
commit 3df8369148b7ca3d3b342ebb9c93ec1f5b597671 1 parent adcaf5e
Andy Lindeman authored February 16, 2011

Showing 62 changed files with 159 additions and 8,772 deletions. Show diff stats Hide diff stats

  1. 8  .gitignore
  2. 4  Gemfile
  3. 3  History.rdoc
  4. 60  README
  5. 67  README.rdoc
  6. 41  Rakefile
  7. 1  VERSION
  8. 1  init.rb
  9. 1  install.rb
  10. 77  lib/no_peeping_toms.rb
  11. 3  lib/no_peeping_toms/version.rb
  12. 67  no_peeping_toms.gemspec
  13. 2  spec/host_app/.gitignore
  14. 243  spec/host_app/README
  15. 10  spec/host_app/Rakefile
  16. 1  spec/host_app/app/controllers/application.rb
  17. 2  spec/host_app/app/controllers/application_controller.rb
  18. 3  spec/host_app/app/helpers/application_helper.rb
  19. 110  spec/host_app/config/boot.rb
  20. 22  spec/host_app/config/database.yml
  21. 5  spec/host_app/config/environment.rb
  22. 17  spec/host_app/config/environments/development.rb
  23. 28  spec/host_app/config/environments/production.rb
  24. 28  spec/host_app/config/environments/test.rb
  25. 5  spec/host_app/config/locales/en.yml
  26. 43  spec/host_app/config/routes.rb
  27. 7  spec/host_app/db/seeds.rb
  28. 2  spec/host_app/doc/README_FOR_APP
  29. 144  spec/host_app/lib/tasks/rspec.rake
  30. 0  spec/host_app/log/.keep
  31. 30  spec/host_app/public/404.html
  32. 30  spec/host_app/public/422.html
  33. 30  spec/host_app/public/500.html
  34. 0  spec/host_app/public/favicon.ico
  35. BIN  spec/host_app/public/images/rails.png
  36. 275  spec/host_app/public/index.html
  37. 2  spec/host_app/public/javascripts/application.js
  38. 963  spec/host_app/public/javascripts/controls.js
  39. 973  spec/host_app/public/javascripts/dragdrop.js
  40. 1,128  spec/host_app/public/javascripts/effects.js
  41. 4,320  spec/host_app/public/javascripts/prototype.js
  42. 5  spec/host_app/public/robots.txt
  43. 4  spec/host_app/script/about
  44. 6  spec/host_app/script/autospec
  45. 3  spec/host_app/script/console
  46. 3  spec/host_app/script/dbconsole
  47. 3  spec/host_app/script/destroy
  48. 3  spec/host_app/script/generate
  49. 3  spec/host_app/script/performance/benchmarker
  50. 3  spec/host_app/script/performance/profiler
  51. 3  spec/host_app/script/plugin
  52. 3  spec/host_app/script/runner
  53. 3  spec/host_app/script/server
  54. 10  spec/host_app/script/spec
  55. 2  spec/host_app/spec/rcov.opts
  56. 4  spec/host_app/spec/spec.opts
  57. 54  spec/host_app/spec/spec_helper.rb
  58. 9  spec/host_app/test/performance/browsing_test.rb
  59. 38  spec/host_app/test/test_helper.rb
  60. 2  spec/no_peeping_toms_spec.rb
  61. 13  spec/spec_helper.rb
  62. 1  uninstall.rb
8  .gitignore
... ...
@@ -1,3 +1,5 @@
1  
-*.log
2  
-pkg
3  
-coverage
  1
+*.gem
  2
+.bundle
  3
+Gemfile.lock
  4
+pkg/*
  5
+spec/debug.log
4  Gemfile
... ...
@@ -0,0 +1,4 @@
  1
+source "http://rubygems.org"
  2
+
  3
+# Specify your gem's dependencies in no-peeping-toms.gemspec
  4
+gemspec
3  History.rdoc
Source Rendered
... ...
@@ -1,3 +1,6 @@
  1
+=== Version 2.0.1 / 2011-02-16
  2
+* Supports current Rails 3.x release.  No longer supports Rails 2.
  3
+
1 4
 === Version 1.1.0 / 2010-01-06
2 5
 
3 6
 * Explicit enable/disable API (Corey Haines & Drew Olson)
60  README
... ...
@@ -1,60 +0,0 @@
1  
-no_peeping_toms
2  
-=============
3  
-
4  
-Originally a plugin, now gemified.  'gem install no_peeping_toms'
5  
-
6  
-This plugin disables observers in your specs, so that model specs can run in complete isolation.
7  
-
8  
-To disable observers, place the following code in your test.rb, or spec_helper.rb, or wherever:
9  
-
10  
-  ActiveRecord::Observer.disable_observers
11  
-
12  
-You can easily reenable observers:
13  
-
14  
-  ActiveRecord::Observer.enable_observers
15  
-
16  
-You can choose to run some code with specific observers turned on.  This is useful when spec'ing an observer.  For example, if you write the following observer:
17  
-
18  
-    class PersonObserver < ActiveRecord::Observer
19  
-      def before_update(person)
20  
-        old_person = Person.find person.id
21  
-        if old_person.name != person.name
22  
-          NameChange.create! :person => person, :old_name => old_person.name, :new_name => person.name
23  
-        end
24  
-      end
25  
-    end
26  
-    
27  
-You can spec the Person class in complete isolation.
28  
-
29  
-    describe Person, " when changing a name" do
30  
-      before(:each) do
31  
-        @person = Person.create! :name => "Pat Maddox"
32  
-      end
33  
-  
34  
-      # By default, don't run any observers
35  
-      it "should not register a name change" do
36  
-        lambda { @person.update_attribute :name, "Don Juan Demarco" }.should_not change(NameChange, :count)
37  
-      end
38  
-  
39  
-      # Run only a portion of code with certain observers turned on
40  
-      it "should register a name change with the person observer turned on" do
41  
-        ActiveRecord::Observer.with_observers(:person_observer) do
42  
-          lambda { @person.update_attribute :name, "Don Juan Demarco" }.should change(NameChange, :count).by(1)
43  
-        end
44  
-    
45  
-        lambda { @person.update_attribute :name, "Man Without a Name" }.should_not change(NameChange, :count)
46  
-      end
47  
-    end
48  
-
49  
-Known to work against Rails versions >= 2.2.2 (run rake:multi_rails:all to test against versions installed on your machine)
50  
-
51  
-Cool people who have contributed to NoPeepingToms:
52  
-  * Brandon Keepers
53  
-  * Corey Haines
54  
-  * Drew Olson
55  
-  * Jeff Siegel
56  
-  * Zach Dennis
57  
-
58  
-If you think your name should be here, shoot me an email and I'll add it ASAP.
59  
-
60  
-Copyright (c) 2007-2010 Pat Maddox, released under the MIT license
67  README.rdoc
Source Rendered
... ...
@@ -0,0 +1,67 @@
  1
+= no_peeping_toms
  2
+
  3
+This plugin disables observers in your specs, so that model specs can run in complete isolation.
  4
+
  5
+== Installation
  6
+
  7
+Add to your Gemfile:
  8
+
  9
+  gem 'no_peeping_toms', :git => 'git://github.com/alindeman/no_peeping_toms.git'
  10
+
  11
+and run `bundle install`.
  12
+
  13
+no_peeping_toms >= 2.0.0 only supports on Rails 3.  If you need Rails 2 support, use 1.1.0: `gem install no_peeping_toms -v 1.1.0`
  14
+
  15
+== Usage
  16
+
  17
+To disable observers, place the following code in your test.rb, or spec_helper.rb, or wherever:
  18
+
  19
+  ActiveRecord::Observer.disable_observers
  20
+
  21
+You can easily reenable observers:
  22
+
  23
+  ActiveRecord::Observer.enable_observers
  24
+
  25
+You can choose to run some code with specific observers turned on.  This is useful when spec'ing an observer.  For example, if you write the following observer:
  26
+
  27
+  class PersonObserver < ActiveRecord::Observer
  28
+    def before_update(person)
  29
+      old_person = Person.find person.id
  30
+      if old_person.name != person.name
  31
+        NameChange.create! :person => person, :old_name => old_person.name, :new_name => person.name
  32
+      end
  33
+    end
  34
+  end
  35
+
  36
+You can spec the Person class in complete isolation.
  37
+
  38
+  describe Person, " when changing a name" do
  39
+    before(:each) do
  40
+      @person = Person.create! :name => "Pat Maddox"
  41
+    end
  42
+
  43
+    # By default, don't run any observers
  44
+    it "should not register a name change" do
  45
+      lambda { @person.update_attribute :name, "Don Juan Demarco" }.should_not change(NameChange, :count)
  46
+    end
  47
+
  48
+    # Run only a portion of code with certain observers turned on
  49
+    it "should register a name change with the person observer turned on" do
  50
+      ActiveRecord::Observer.with_observers(:person_observer) do
  51
+        lambda { @person.update_attribute :name, "Don Juan Demarco" }.should change(NameChange, :count).by(1)
  52
+      end
  53
+
  54
+      lambda { @person.update_attribute :name, "Man Without a Name" }.should_not change(NameChange, :count)
  55
+    end
  56
+  end
  57
+
  58
+== Credits
  59
+
  60
+* Brandon Keepers
  61
+* Corey Haines
  62
+* Drew Olson
  63
+* Jeff Siegel
  64
+* Zach Dennis
  65
+* Andy Lindeman
  66
+
  67
+Copyright (c) 2007-2011 Pat Maddox, released under the MIT license.
41  Rakefile
... ...
@@ -1,41 +0,0 @@
1  
-begin
2  
-  require 'jeweler'
3  
-rescue LoadError
4  
-  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
5  
-  exit 1
6  
-end
7  
-require 'rake/testtask'
8  
-require 'rake/rdoctask'
9  
-require 'rcov/rcovtask'
10  
-require "load_multi_rails_rake_tasks" 
11  
-
12  
-Jeweler::Tasks.new do |s|
13  
-  s.name = "no_peeping_toms"
14  
-  s.summary = "Disables observers during testing, allowing you to write model tests that are completely decoupled from the observer."
15  
-  s.description = s.summary
16  
-  s.email = "pat.maddox@gmail.com"
17  
-  s.homepage = "http://github.com/patmaddox/no-peeping-toms"
18  
-  s.authors = ["Pat Maddox", "Brandon Keepers"]
19  
-  s.add_dependency "activerecord", ['>= 1.1']
20  
-  s.files -= ['.gitignore', 'init.rb']
21  
-  s.test_files = Dir['spec/**/*']
22  
-  s.test_files -= ['spec/debug.log']
23  
-end
24  
-
25  
-Jeweler::GemcutterTasks.new
26  
-
27  
-require 'spec/rake/spectask'
28  
-Spec::Rake::SpecTask.new(:spec) do |spec|
29  
-  spec.libs << 'lib' << 'spec'
30  
-  spec.spec_files = FileList['spec/**/*_spec.rb']
31  
-end
32  
-
33  
-Spec::Rake::SpecTask.new(:rcov) do |spec|
34  
-  spec.libs << 'lib' << 'spec'
35  
-  spec.pattern = 'spec/**/*_spec.rb'
36  
-  spec.rcov = true
37  
-  spec.rcov_opts = ['--exclude', 'gems/,spec/']
38  
-end
39  
-
40  
-task :spec => :check_dependencies
41  
-task :test => :spec
1  VERSION
... ...
@@ -1 +0,0 @@
1  
-1.1.0
1  init.rb
... ...
@@ -1 +0,0 @@
1  
-require 'no_peeping_toms'
1  install.rb
... ...
@@ -1 +0,0 @@
1  
-# Install hook code here
77  lib/no_peeping_toms.rb
... ...
@@ -1,42 +1,71 @@
  1
+require 'active_record'
  2
+require 'active_support/core_ext/class/attribute_accessors'
  3
+
1 4
 module NoPeepingToms
2  
-  def self.included(base)
3  
-    unless base.included_modules.include?(NoPeepingToms::InstanceMethods)
4  
-      base.send :include, NoPeepingToms::InstanceMethods
5  
-      base.extend NoPeepingToms::ClassMethods
6  
-      base.alias_method_chain :update, :neighborhood_watch
7  
-      base.cattr_accessor :peeping_toms, :default_observers_enabled
8  
-      base.peeping_toms = [] # toms that are allowed to peep
9  
-    end
  5
+  extend ActiveSupport::Concern
10 6
 
11  
-    base.enable_observers
12  
-  end
  7
+  included do
  8
+    # Define class-level accessors
  9
+    cattr_accessor :default_observers_enabled, :observers_enabled
13 10
 
14  
-  module InstanceMethods
15  
-    def update_with_neighborhood_watch(*args)
16  
-      if self.class.default_observers_enabled || self.class.peeping_toms.include?(self)
17  
-        update_without_neighborhood_watch(*args)
18  
-      end
19  
-    end
  11
+    # By default, enable all observers
  12
+    enable_observers
  13
+    self.observers_enabled = []
  14
+
  15
+    alias_method_chain :define_callbacks, :enabled_check
20 16
   end
21  
-  
  17
+
22 18
   module ClassMethods
  19
+    # Enables all observers (default behavior)
  20
+    def enable_observers
  21
+      self.default_observers_enabled = true
  22
+    end
  23
+
  24
+    # Disables all observers
  25
+    def disable_observers
  26
+      self.default_observers_enabled = false
  27
+    end
  28
+
  29
+    # Run a block with a specific set of observers enabled
23 30
     def with_observers(*observer_syms)
24  
-      self.peeping_toms = Array(observer_syms).map do |o| 
  31
+      self.observers_enabled = Array(observer_syms).map do |o|
25 32
         o.respond_to?(:instance) ? o.instance : o.to_s.classify.constantize.instance
26 33
       end
27 34
       yield
28 35
     ensure
29  
-      self.peeping_toms.clear
  36
+      self.observers_enabled = []
30 37
     end
31 38
 
32  
-    def disable_observers
33  
-      self.default_observers_enabled = false
  39
+    # Determines whether an observer is enabled.  Either:
  40
+    # - All observers are enabled OR
  41
+    # - The observer is in the whitelist
  42
+    def observer_enabled?(observer)
  43
+      default_observers_enabled or self.observers_enabled.include?(observer)
34 44
     end
  45
+  end
35 46
 
36  
-    def enable_observers
37  
-      self.default_observers_enabled = true
  47
+  module InstanceMethods
  48
+    # Overrides ActiveRecord#define_callbacks so that observers are only called
  49
+    # when enabled.
  50
+    #
  51
+    # This is a bit yuck being a protected method, but appears to be the cleanest
  52
+    # way so far
  53
+    def define_callbacks_with_enabled_check(klass)
  54
+      observer = self
  55
+
  56
+      ActiveRecord::Callbacks::CALLBACKS.each do |callback|
  57
+        next unless respond_to?(callback)
  58
+        klass.send(callback) do |record|
  59
+          observer.send(callback, record) if observer.observer_enabled?
  60
+        end
  61
+      end
  62
+    end
  63
+
  64
+    # Determines whether this observer should be run
  65
+    def observer_enabled?
  66
+      self.class.observer_enabled?(self)
38 67
     end
39 68
   end
40 69
 end
41 70
 
42  
-ActiveRecord::Observer.send :include, NoPeepingToms
  71
+ActiveRecord::Observer.__send__ :include, NoPeepingToms
3  lib/no_peeping_toms/version.rb
... ...
@@ -0,0 +1,3 @@
  1
+module NoPeepingToms
  2
+  VERSION = "2.0.1"
  3
+end
67  no_peeping_toms.gemspec
... ...
@@ -1,58 +1,25 @@
1  
-# Generated by jeweler
2  
-# DO NOT EDIT THIS FILE DIRECTLY
3  
-# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4 1
 # -*- encoding: utf-8 -*-
  2
+$:.push File.expand_path("../lib", __FILE__)
  3
+require "no_peeping_toms/version"
5 4
 
6 5
 Gem::Specification.new do |s|
7  
-  s.name = %q{no_peeping_toms}
8  
-  s.version = "1.1.0"
9  
-
10  
-  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11  
-  s.authors = ["Pat Maddox", "Brandon Keepers"]
12  
-  s.date = %q{2010-01-06}
  6
+  s.name        = "no_peeping_toms"
  7
+  s.version     = NoPeepingToms::VERSION
  8
+  s.platform    = Gem::Platform::RUBY
  9
+  s.authors     = ["Andy Lindeman", "Pat Maddox", "Brandon Keepers"]
  10
+  s.email       = ["alindeman@gmail.com", "pat.maddox@gmail.com"]
  11
+  s.homepage    = "https://github.com/alindeman/no_peeping_toms"
  12
+  s.summary     = %q{Disables observers during testing, allowing you to write model tests that are completely decoupled from the observer.}
13 13
   s.description = %q{Disables observers during testing, allowing you to write model tests that are completely decoupled from the observer.}
14  
-  s.email = %q{pat.maddox@gmail.com}
15  
-  s.extra_rdoc_files = [
16  
-    "README"
17  
-  ]
18  
-  s.files = [
19  
-    "History.rdoc",
20  
-     "README",
21  
-     "Rakefile",
22  
-     "VERSION",
23  
-     "install.rb",
24  
-     "lib/no_peeping_toms.rb",
25  
-     "no_peeping_toms.gemspec",
26  
-     "spec/db/database.yml",
27  
-     "spec/db/schema.rb",
28  
-     "spec/no_peeping_toms_spec.rb",
29  
-     "spec/spec_helper.rb",
30  
-     "uninstall.rb"
31  
-  ]
32  
-  s.homepage = %q{http://github.com/patmaddox/no-peeping-toms}
33  
-  s.rdoc_options = ["--charset=UTF-8"]
  14
+
  15
+  s.files         = `git ls-files`.split("\n")
  16
+  s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
  17
+  s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
34 18
   s.require_paths = ["lib"]
35  
-  s.rubygems_version = %q{1.3.5}
36  
-  s.summary = %q{Disables observers during testing, allowing you to write model tests that are completely decoupled from the observer.}
37  
-  s.test_files = [
38  
-    "spec/db",
39  
-     "spec/db/database.yml",
40  
-     "spec/db/schema.rb",
41  
-     "spec/no_peeping_toms_spec.rb",
42  
-     "spec/spec_helper.rb"
43  
-  ]
44 19
 
45  
-  if s.respond_to? :specification_version then
46  
-    current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47  
-    s.specification_version = 3
  20
+  s.add_runtime_dependency 'activerecord', '>=3.0.0'
  21
+  s.add_runtime_dependency 'activesupport', '>=3.0.0'
48 22
 
49  
-    if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50  
-      s.add_runtime_dependency(%q<activerecord>, [">= 1.1"])
51  
-    else
52  
-      s.add_dependency(%q<activerecord>, [">= 1.1"])
53  
-    end
54  
-  else
55  
-    s.add_dependency(%q<activerecord>, [">= 1.1"])
56  
-  end
  23
+  s.add_development_dependency 'rspec', '~>2.5'
  24
+  s.add_development_dependency 'sqlite3'
57 25
 end
58  
-
2  spec/host_app/.gitignore
... ...
@@ -1,2 +0,0 @@
1  
-db/*.sqlite3
2  
-log/*.log
243  spec/host_app/README
... ...
@@ -1,243 +0,0 @@
1  
-== Welcome to Rails
2  
-
3  
-Rails is a web-application framework that includes everything needed to create 
4  
-database-backed web applications according to the Model-View-Control pattern. 
5  
-
6  
-This pattern splits the view (also called the presentation) into "dumb" templates
7  
-that are primarily responsible for inserting pre-built data in between HTML tags.
8  
-The model contains the "smart" domain objects (such as Account, Product, Person,
9  
-Post) that holds all the business logic and knows how to persist themselves to
10  
-a database. The controller handles the incoming requests (such as Save New Account,
11  
-Update Product, Show Post) by manipulating the model and directing data to the view.
12  
-
13  
-In Rails, the model is handled by what's called an object-relational mapping
14  
-layer entitled Active Record. This layer allows you to present the data from
15  
-database rows as objects and embellish these data objects with business logic
16  
-methods. You can read more about Active Record in
17  
-link:files/vendor/rails/activerecord/README.html.
18  
-
19  
-The controller and view are handled by the Action Pack, which handles both
20  
-layers by its two parts: Action View and Action Controller. These two layers
21  
-are bundled in a single package due to their heavy interdependence. This is
22  
-unlike the relationship between the Active Record and Action Pack that is much
23  
-more separate. Each of these packages can be used independently outside of
24  
-Rails.  You can read more about Action Pack in
25  
-link:files/vendor/rails/actionpack/README.html.
26  
-
27  
-
28  
-== Getting Started
29  
-
30  
-1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
31  
-   and your application name. Ex: rails myapp
32  
-2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
33  
-3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
34  
-4. Follow the guidelines to start developing your application
35  
-
36  
-
37  
-== Web Servers
38  
-
39  
-By default, Rails will try to use Mongrel if it's are installed when started with script/server, otherwise Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails
40  
-with a variety of other web servers.
41  
-
42  
-Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
43  
-suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
44  
-getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
45  
-More info at: http://mongrel.rubyforge.org
46  
-
47  
-Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or
48  
-Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use
49  
-FCGI or proxy to a pack of Mongrels/Thin/Ebb servers.
50  
-
51  
-== Apache .htaccess example for FCGI/CGI
52  
-
53  
-# General Apache options
54  
-AddHandler fastcgi-script .fcgi
55  
-AddHandler cgi-script .cgi
56  
-Options +FollowSymLinks +ExecCGI
57  
-
58  
-# If you don't want Rails to look in certain directories,
59  
-# use the following rewrite rules so that Apache won't rewrite certain requests
60  
-# 
61  
-# Example:
62  
-#   RewriteCond %{REQUEST_URI} ^/notrails.*
63  
-#   RewriteRule .* - [L]
64  
-
65  
-# Redirect all requests not available on the filesystem to Rails
66  
-# By default the cgi dispatcher is used which is very slow
67  
-# 
68  
-# For better performance replace the dispatcher with the fastcgi one
69  
-#
70  
-# Example:
71  
-#   RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
72  
-RewriteEngine On
73  
-
74  
-# If your Rails application is accessed via an Alias directive,
75  
-# then you MUST also set the RewriteBase in this htaccess file.
76  
-#
77  
-# Example:
78  
-#   Alias /myrailsapp /path/to/myrailsapp/public
79  
-#   RewriteBase /myrailsapp
80  
-
81  
-RewriteRule ^$ index.html [QSA]
82  
-RewriteRule ^([^.]+)$ $1.html [QSA]
83  
-RewriteCond %{REQUEST_FILENAME} !-f
84  
-RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
85  
-
86  
-# In case Rails experiences terminal errors
87  
-# Instead of displaying this message you can supply a file here which will be rendered instead
88  
-# 
89  
-# Example:
90  
-#   ErrorDocument 500 /500.html
91  
-
92  
-ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
93  
-
94  
-
95  
-== Debugging Rails
96  
-
97  
-Sometimes your application goes wrong.  Fortunately there are a lot of tools that
98  
-will help you debug it and get it back on the rails.
99  
-
100  
-First area to check is the application log files.  Have "tail -f" commands running
101  
-on the server.log and development.log. Rails will automatically display debugging
102  
-and runtime information to these files. Debugging info will also be shown in the
103  
-browser on requests from 127.0.0.1.
104  
-
105  
-You can also log your own messages directly into the log file from your code using
106  
-the Ruby logger class from inside your controllers. Example:
107  
-
108  
-  class WeblogController < ActionController::Base
109  
-    def destroy
110  
-      @weblog = Weblog.find(params[:id])
111  
-      @weblog.destroy
112  
-      logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
113  
-    end
114  
-  end
115  
-
116  
-The result will be a message in your log file along the lines of:
117  
-
118  
-  Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
119  
-
120  
-More information on how to use the logger is at http://www.ruby-doc.org/core/
121  
-
122  
-Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
123  
-
124  
-* The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
125  
-* Learn to Program: http://pine.fm/LearnToProgram/  (a beginners guide)
126  
-
127  
-These two online (and free) books will bring you up to speed on the Ruby language
128  
-and also on programming in general.
129  
-
130  
-
131  
-== Debugger
132  
-
133  
-Debugger support is available through the debugger command when you start your Mongrel or
134  
-Webrick server with --debugger. This means that you can break out of execution at any point
135  
-in the code, investigate and change the model, AND then resume execution! 
136  
-You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
137  
-Example:
138  
-
139  
-  class WeblogController < ActionController::Base
140  
-    def index
141  
-      @posts = Post.find(:all)
142  
-      debugger
143  
-    end
144  
-  end
145  
-
146  
-So the controller will accept the action, run the first line, then present you
147  
-with a IRB prompt in the server window. Here you can do things like:
148  
-
149  
-  >> @posts.inspect
150  
-  => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
151  
-       #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
152  
-  >> @posts.first.title = "hello from a debugger"
153  
-  => "hello from a debugger"
154  
-
155  
-...and even better is that you can examine how your runtime objects actually work:
156  
-
157  
-  >> f = @posts.first
158  
-  => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
159  
-  >> f.
160  
-  Display all 152 possibilities? (y or n)
161  
-
162  
-Finally, when you're ready to resume execution, you enter "cont"
163  
-
164  
-
165  
-== Console
166  
-
167  
-You can interact with the domain model by starting the console through <tt>script/console</tt>.
168  
-Here you'll have all parts of the application configured, just like it is when the
169  
-application is running. You can inspect domain models, change values, and save to the
170  
-database. Starting the script without arguments will launch it in the development environment.
171  
-Passing an argument will specify a different environment, like <tt>script/console production</tt>.
172  
-
173  
-To reload your controllers and models after launching the console run <tt>reload!</tt>
174  
-
175  
-== dbconsole
176  
-
177  
-You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
178  
-You would be connected to the database with the credentials defined in database.yml.
179  
-Starting the script without arguments will connect you to the development database. Passing an
180  
-argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
181  
-Currently works for mysql, postgresql and sqlite.
182  
-
183  
-== Description of Contents
184  
-
185  
-app
186  
-  Holds all the code that's specific to this particular application.
187  
-
188  
-app/controllers
189  
-  Holds controllers that should be named like weblogs_controller.rb for
190  
-  automated URL mapping. All controllers should descend from ApplicationController
191  
-  which itself descends from ActionController::Base.
192  
-
193  
-app/models
194  
-  Holds models that should be named like post.rb.
195  
-  Most models will descend from ActiveRecord::Base.
196  
-
197  
-app/views
198  
-  Holds the template files for the view that should be named like
199  
-  weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
200  
-  syntax.
201  
-
202  
-app/views/layouts
203  
-  Holds the template files for layouts to be used with views. This models the common
204  
-  header/footer method of wrapping views. In your views, define a layout using the
205  
-  <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
206  
-  call <% yield %> to render the view using this layout.
207  
-
208  
-app/helpers
209  
-  Holds view helpers that should be named like weblogs_helper.rb. These are generated
210  
-  for you automatically when using script/generate for controllers. Helpers can be used to
211  
-  wrap functionality for your views into methods.
212  
-
213  
-config
214  
-  Configuration files for the Rails environment, the routing map, the database, and other dependencies.
215  
-
216  
-db
217  
-  Contains the database schema in schema.rb.  db/migrate contains all
218  
-  the sequence of Migrations for your schema.
219  
-
220  
-doc
221  
-  This directory is where your application documentation will be stored when generated
222  
-  using <tt>rake doc:app</tt>
223  
-
224  
-lib
225  
-  Application specific libraries. Basically, any kind of custom code that doesn't
226  
-  belong under controllers, models, or helpers. This directory is in the load path.
227  
-
228  
-public
229  
-  The directory available for the web server. Contains subdirectories for images, stylesheets,
230  
-  and javascripts. Also contains the dispatchers and the default HTML files. This should be
231  
-  set as the DOCUMENT_ROOT of your web server.
232  
-
233  
-script
234  
-  Helper scripts for automation and generation.
235  
-
236  
-test
237  
-  Unit and functional tests along with fixtures. When using the script/generate scripts, template
238  
-  test files will be generated for you and placed in this directory.
239  
-
240  
-vendor
241  
-  External libraries that the application depends on. Also includes the plugins subdirectory.
242  
-  If the app has frozen rails, those gems also go here, under vendor/rails/.
243  
-  This directory is in the load path.
10  spec/host_app/Rakefile
... ...
@@ -1,10 +0,0 @@
1  
-# Add your own tasks in files placed in lib/tasks ending in .rake,
2  
-# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3  
-
4  
-require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5  
-
6  
-require 'rake'
7  
-require 'rake/testtask'
8  
-require 'rake/rdoctask'
9  
-
10  
-require 'tasks/rails'
1  spec/host_app/app/controllers/application.rb
... ...
@@ -1 +0,0 @@
1  
-require 'application_controller'
2  spec/host_app/app/controllers/application_controller.rb
... ...
@@ -1,2 +0,0 @@
1  
-class ApplicationController < ActionController::Base
2  
-end
3  spec/host_app/app/helpers/application_helper.rb
... ...
@@ -1,3 +0,0 @@
1  
-# Methods added to this helper will be available to all templates in the application.
2  
-module ApplicationHelper
3  
-end
110  spec/host_app/config/boot.rb
... ...
@@ -1,110 +0,0 @@
1  
-# Don't change this file!
2  
-# Configure your app in config/environment.rb and config/environments/*.rb
3  
-
4  
-RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5  
-
6  
-module Rails
7  
-  class << self
8  
-    def boot!
9  
-      unless booted?
10  
-        preinitialize
11  
-        pick_boot.run
12  
-      end
13  
-    end
14  
-
15  
-    def booted?
16  
-      defined? Rails::Initializer
17  
-    end
18  
-
19  
-    def pick_boot
20  
-      (vendor_rails? ? VendorBoot : GemBoot).new
21  
-    end
22  
-
23  
-    def vendor_rails?
24  
-      File.exist?("#{RAILS_ROOT}/vendor/rails")
25  
-    end
26  
-
27  
-    def preinitialize
28  
-      load(preinitializer_path) if File.exist?(preinitializer_path)
29  
-    end
30  
-
31  
-    def preinitializer_path
32  
-      "#{RAILS_ROOT}/config/preinitializer.rb"
33  
-    end
34  
-  end
35  
-
36  
-  class Boot
37  
-    def run
38  
-      load_initializer
39  
-      Rails::Initializer.run(:set_load_path)
40  
-    end
41  
-  end
42  
-
43  
-  class VendorBoot < Boot
44  
-    def load_initializer
45  
-      require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46  
-      Rails::Initializer.run(:install_gem_spec_stubs)
47  
-      Rails::GemDependency.add_frozen_gem_path
48  
-    end
49  
-  end
50  
-
51  
-  class GemBoot < Boot
52  
-    def load_initializer
53  
-      self.class.load_rubygems
54  
-      load_rails_gem
55  
-      require 'initializer'
56  
-    end
57  
-
58  
-    def load_rails_gem
59  
-      if version = self.class.gem_version
60  
-        gem 'rails', version
61  
-      else
62  
-        gem 'rails'
63  
-      end
64  
-    rescue Gem::LoadError => load_error
65  
-      $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66  
-      exit 1
67  
-    end
68  
-
69  
-    class << self
70  
-      def rubygems_version
71  
-        Gem::RubyGemsVersion rescue nil
72  
-      end
73  
-
74  
-      def gem_version
75  
-        if defined? RAILS_GEM_VERSION
76  
-          RAILS_GEM_VERSION
77  
-        elsif ENV.include?('RAILS_GEM_VERSION')
78  
-          ENV['RAILS_GEM_VERSION']
79  
-        else
80  
-          parse_gem_version(read_environment_rb)
81  
-        end
82  
-      end
83  
-
84  
-      def load_rubygems
85  
-        min_version = '1.3.2'
86  
-        require 'rubygems'
87  
-        unless rubygems_version >= min_version
88  
-          $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89  
-          exit 1
90  
-        end
91  
-
92  
-      rescue LoadError
93  
-        $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94  
-        exit 1
95  
-      end
96  
-
97  
-      def parse_gem_version(text)
98  
-        $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99  
-      end
100  
-
101  
-      private
102  
-        def read_environment_rb
103  
-          File.read("#{RAILS_ROOT}/config/environment.rb")
104  
-        end
105  
-    end
106  
-  end
107  
-end
108  
-
109  
-# All that for this:
110  
-Rails.boot!
22  spec/host_app/config/database.yml
... ...
@@ -1,22 +0,0 @@
1  
-# SQLite version 3.x
2  
-#   gem install sqlite3-ruby (not necessary on OS X Leopard)
3  
-development:
4  
-  adapter: sqlite3
5  
-  database: db/development.sqlite3
6  
-  pool: 5
7  
-  timeout: 5000
8  
-
9  
-# Warning: The database defined as "test" will be erased and
10  
-# re-generated from your development database when you run "rake".
11  
-# Do not set this db to the same as development or production.
12  
-test:
13  
-  adapter: sqlite3
14  
-  database: db/test.sqlite3
15  
-  pool: 5
16  
-  timeout: 5000
17  
-
18  
-production:
19  
-  adapter: sqlite3
20  
-  database: db/production.sqlite3
21  
-  pool: 5
22  
-  timeout: 5000
5  spec/host_app/config/environment.rb
... ...
@@ -1,5 +0,0 @@
1  
-require File.join(File.dirname(__FILE__), 'boot')
2  
-
3  
-Rails::Initializer.run do |config|
4  
-  config.frameworks = [:active_record]
5  
-end
17  spec/host_app/config/environments/development.rb
... ...
@@ -1,17 +0,0 @@
1  
-# Settings specified here will take precedence over those in config/environment.rb
2  
-
3  
-# In the development environment your application's code is reloaded on
4  
-# every request.  This slows down response time but is perfect for development
5  
-# since you don't have to restart the webserver when you make code changes.
6  
-config.cache_classes = false
7  
-
8  
-# Log error messages when you accidentally call methods on nil.
9  
-config.whiny_nils = true
10  
-
11  
-# Show full error reports and disable caching
12  
-config.action_controller.consider_all_requests_local = true
13  
-config.action_view.debug_rjs                         = true
14  
-config.action_controller.perform_caching             = false
15  
-
16  
-# Don't care if the mailer can't send
17  
-config.action_mailer.raise_delivery_errors = false
28  spec/host_app/config/environments/production.rb
... ...
@@ -1,28 +0,0 @@
1  
-# Settings specified here will take precedence over those in config/environment.rb
2  
-
3  
-# The production environment is meant for finished, "live" apps.
4  
-# Code is not reloaded between requests
5  
-config.cache_classes = true
6  
-
7  
-# Full error reports are disabled and caching is turned on
8  
-config.action_controller.consider_all_requests_local = false
9  
-config.action_controller.perform_caching             = true
10  
-config.action_view.cache_template_loading            = true
11  
-
12  
-# See everything in the log (default is :info)
13  
-# config.log_level = :debug
14  
-
15  
-# Use a different logger for distributed setups
16  
-# config.logger = SyslogLogger.new
17  
-
18  
-# Use a different cache store in production
19  
-# config.cache_store = :mem_cache_store
20  
-
21  
-# Enable serving of images, stylesheets, and javascripts from an asset server
22  
-# config.action_controller.asset_host = "http://assets.example.com"
23  
-
24  
-# Disable delivery errors, bad email addresses will be ignored
25  
-# config.action_mailer.raise_delivery_errors = false
26  
-
27  
-# Enable threaded mode
28  
-# config.threadsafe!
28  spec/host_app/config/environments/test.rb
... ...
@@ -1,28 +0,0 @@
1  
-# Settings specified here will take precedence over those in config/environment.rb
2  
-
3  
-# The test environment is used exclusively to run your application's
4  
-# test suite.  You never need to work with it otherwise.  Remember that
5  
-# your test database is "scratch space" for the test suite and is wiped
6  
-# and recreated between test runs.  Don't rely on the data there!
7  
-config.cache_classes = true
8  
-
9  
-# Log error messages when you accidentally call methods on nil.
10  
-config.whiny_nils = true
11  
-
12  
-# Show full error reports and disable caching
13  
-config.action_controller.consider_all_requests_local = true
14  
-config.action_controller.perform_caching             = false
15  
-config.action_view.cache_template_loading            = true
16  
-
17  
-# Disable request forgery protection in test environment
18  
-config.action_controller.allow_forgery_protection    = false
19  
-
20  
-# Tell Action Mailer not to deliver emails to the real world.
21  
-# The :test delivery method accumulates sent emails in the
22  
-# ActionMailer::Base.deliveries array.
23  
-config.action_mailer.delivery_method = :test
24  
-
25  
-# Use SQL instead of Active Record's schema dumper when creating the test database.
26  
-# This is necessary if your schema can't be completely dumped by the schema dumper,
27  
-# like if you have constraints or database-specific column types
28  
-# config.active_record.schema_format = :sql
5  spec/host_app/config/locales/en.yml
... ...
@@ -1,5 +0,0 @@
1  
-# Sample localization file for English. Add more files in this directory for other locales.
2  
-# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3  
-
4  
-en:
5  
-  hello: "Hello world"
43  spec/host_app/config/routes.rb
... ...
@@ -1,43 +0,0 @@
1  
-ActionController::Routing::Routes.draw do |map|
2  
-  # The priority is based upon order of creation: first created -> highest priority.
3  
-
4  
-  # Sample of regular route:
5  
-  #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6  
-  # Keep in mind you can assign values other than :controller and :action
7  
-
8  
-  # Sample of named route:
9  
-  #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
10  
-  # This route can be invoked with purchase_url(:id => product.id)
11  
-
12  
-  # Sample resource route (maps HTTP verbs to controller actions automatically):
13  
-  #   map.resources :products
14  
-
15  
-  # Sample resource route with options:
16  
-  #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
17  
-
18  
-  # Sample resource route with sub-resources:
19  
-  #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
20  
-  
21  
-  # Sample resource route with more complex sub-resources
22  
-  #   map.resources :products do |products|
23  
-  #     products.resources :comments
24  
-  #     products.resources :sales, :collection => { :recent => :get }
25  
-  #   end
26  
-
27  
-  # Sample resource route within a namespace:
28  
-  #   map.namespace :admin do |admin|
29  
-  #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
30  
-  #     admin.resources :products
31  
-  #   end
32  
-
33  
-  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
34  
-  # map.root :controller => "welcome"
35  
-
36  
-  # See how all your routes lay out with "rake routes"
37  
-
38  
-  # Install the default routes as the lowest priority.
39  
-  # Note: These default routes make all actions in every controller accessible via GET requests. You should
40  
-  # consider removing or commenting them out if you're using named routes and resources.
41  
-  map.connect ':controller/:action/:id'
42  
-  map.connect ':controller/:action/:id.:format'
43  
-end
7  spec/host_app/db/seeds.rb
... ...
@@ -1,7 +0,0 @@
1  
-# This file should contain all the record creation needed to seed the database with its default values.
2  
-# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3  
-#
4  
-# Examples:
5  
-#   
6  
-#   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7  
-#   Major.create(:name => 'Daley', :city => cities.first)
2  spec/host_app/doc/README_FOR_APP
... ...
@@ -1,2 +0,0 @@
1  
-Use this README file to introduce your application and point to useful places in the API for learning more.
2  
-Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
144  spec/host_app/lib/tasks/rspec.rake
... ...
@@ -1,144 +0,0 @@
1  
-gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
2  
-rspec_gem_dir = nil
3  
-Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir|
4  
-  rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
5  
-end
6  
-rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec')
7  
-
8  
-if rspec_gem_dir && (test ?d, rspec_plugin_dir)
9  
-  raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n"
10  
-end
11  
-
12  
-if rspec_gem_dir
13  
-  $LOAD_PATH.unshift("#{rspec_gem_dir}/lib")
14  
-elsif File.exist?(rspec_plugin_dir)
15  
-  $LOAD_PATH.unshift("#{rspec_plugin_dir}/lib")
16  
-end
17  
-
18  
-# Don't load rspec if running "rake gems:*"
19  
-unless ARGV.any? {|a| a =~ /^gems/}
20  
-
21  
-begin
22  
-  require 'spec/rake/spectask'
23  
-rescue MissingSourceFile
24  
-  module Spec
25  
-    module Rake
26  
-      class SpecTask
27  
-        def initialize(name)
28  
-          task name do
29  
-            # if rspec-rails is a configured gem, this will output helpful material and exit ...
30  
-            require File.expand_path(File.join(File.dirname(__FILE__),"..","..","config","environment"))
31  
-
32  
-            # ... otherwise, do this:
33  
-            raise <<-MSG
34  
-
35  
-#{"*" * 80}
36  
-*  You are trying to run an rspec rake task defined in
37  
-*  #{__FILE__},
38  
-*  but rspec can not be found in vendor/gems, vendor/plugins or system gems.
39  
-#{"*" * 80}
40  
-MSG
41  
-          end
42  
-        end
43  
-      end
44  
-    end
45  
-  end
46  
-end
47  
-
48  
-Rake.application.instance_variable_get('@tasks').delete('default')
49  
-
50  
-spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
51  
-task :noop do
52  
-end
53  
-
54  
-task :default => :spec
55  
-task :stats => "spec:statsetup"
56  
-
57  
-desc "Run all specs in spec directory (excluding plugin specs)"
58  
-Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
59  
-  t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
60  
-  t.spec_files = FileList['spec/**/*_spec.rb']
61  
-end
62  
-
63  
-namespace :spec do
64  
-  desc "Run all specs in spec directory with RCov (excluding plugin specs)"
65  
-  Spec::Rake::SpecTask.new(:rcov) do |t|
66  
-    t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
67  
-    t.spec_files = FileList['spec/**/*_spec.rb']
68  
-    t.rcov = true
69  
-    t.rcov_opts = lambda do
70  
-      IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
71  
-    end
72  
-  end
73  
-
74  
-  desc "Print Specdoc for all specs (excluding plugin specs)"
75  
-  Spec::Rake::SpecTask.new(:doc) do |t|
76  
-    t.spec_opts = ["--format", "specdoc", "--dry-run"]
77  
-    t.spec_files = FileList['spec/**/*_spec.rb']
78  
-  end
79  
-
80  
-  desc "Print Specdoc for all plugin examples"
81  
-  Spec::Rake::SpecTask.new(:plugin_doc) do |t|
82  
-    t.spec_opts = ["--format", "specdoc", "--dry-run"]
83  
-    t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
84  
-  end
85  
-
86  
-  [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub|
87  
-    desc "Run the code examples in spec/#{sub}"
88  
-    Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
89  
-      t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
90  
-      t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
91  
-    end
92  
-  end
93  
-
94  
-  desc "Run the code examples in vendor/plugins (except RSpec's own)"
95  
-  Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
96  
-    t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
97  
-    t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
98  
-  end
99  
-
100  
-  namespace :plugins do
101  
-    desc "Runs the examples for rspec_on_rails"
102  
-    Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
103  
-      t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
104  
-      t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
105  
-    end
106  
-  end
107  
-
108  
-  # Setup specs for stats
109  
-  task :statsetup do
110  
-    require 'code_statistics'
111  
-    ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
112  
-    ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
113  
-    ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
114  
-    ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
115  
-    ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
116  
-    ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
117  
-    ::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration')
118  
-    ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
119  
-    ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
120  
-    ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
121  
-    ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
122  
-    ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
123  
-    ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
124  
-    ::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration')
125  
-  end
126  
-
127  
-  namespace :db do
128  
-    namespace :fixtures do
129  
-      desc "Load fixtures (from spec/fixtures) into the current environment's database.  Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
130  
-      task :load => :environment do
131  
-        ActiveRecord::Base.establish_connection(Rails.env)
132  
-        base_dir = File.join(Rails.root, 'spec', 'fixtures')
133  
-        fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
134  
-
135  
-        require 'active_record/fixtures'
136  
-        (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
137  
-          Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
138  
-        end
139  
-      end
140  
-    end
141  
-  end
142  
-end
143  
-
144  
-end
0  spec/host_app/log/.keep
No changes.
30  spec/host_app/public/404.html
... ...
@@ -1,30 +0,0 @@
1  
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2  
-       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3  
-
4  
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5  
-
6  
-<head>
7  
-  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8  
-  <title>The page you were looking for doesn't exist (404)</title>
9  
-	<style type="text/css">
10  
-		body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11  
-		div.dialog {
12  
-			width: 25em;
13  
-			padding: 0 4em;
14  
-			margin: 4em auto 0 auto;
15  
-			border: 1px solid #ccc;
16  
-			border-right-color: #999;
17  
-			border-bottom-color: #999;
18  
-		}
19  
-		h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20  
-	</style>
21  
-</head>
22  
-
23  
-<body>
24  
-  <!-- This file lives in public/404.html -->
25  
-  <div class="dialog">
26  
-    <h1>The page you were looking for doesn't exist.</h1>
27  
-    <p>You may have mistyped the address or the page may have moved.</p>
28  
-  </div>
29  
-</body>
30  
-</html>