rack-environmental 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 1.0.3 (December 3, 2009)
2
+ * Refactored to use rack-plastic gem.
3
+
1
4
  1.0.2 (November 17, 2009)
2
5
  * BUGFIX: Another minor configuration tweak to get the gem to work properly.
3
6
 
File without changes
data/Rakefile CHANGED
@@ -1,26 +1,28 @@
1
1
  require 'rake'
2
2
  require 'rake/gempackagetask'
3
3
  require 'rubygems'
4
-
5
- gem_spec = Gem::Specification.new do |s|
6
- s.name = "rack-environmental"
7
- s.version = "1.0.2"
8
- s.add_dependency 'rack', '>= 1.0.0'
9
- s.add_dependency 'nokogiri', '>= 1.4.0'
10
- s.author = "Wyatt Greene"
11
- s.email = "techiferous@gmail.com"
12
- s.summary = "Rack middleware that adds an indicator of your application environment"
13
- s.description = %Q{
14
- Rack::Environmental indicates which environment your web application is running
15
- in (staging, test, etc.).
16
- }
17
- s.require_path = "lib"
18
- s.files = ["lib/rack-environmental.rb", "LICENSE", "Rakefile", "README",
19
- "CHANGELOG"]
20
- s.homepage = "http://github.com/techiferous/rack-environmental"
21
- s.requirements << "none"
22
- s.has_rdoc = false
23
- end
24
4
 
25
- Rake::GemPackageTask.new(gem_spec) do |pkg|
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |s|
8
+ s.name = "rack-environmental"
9
+ s.version = "1.0.3"
10
+ s.add_dependency 'plastic', '>= 0.0.0'
11
+ s.author = "Wyatt Greene"
12
+ s.email = "techiferous@gmail.com"
13
+ s.summary = "Rack middleware that adds an indicator of your application environment"
14
+ s.description = %Q{
15
+ Rack::Environmental indicates which environment your web application is running
16
+ in (staging, test, etc.).
17
+ }
18
+ s.require_path = "lib"
19
+ s.files = ["lib/rack-environmental.rb", "LICENSE", "Rakefile", "README.rdoc",
20
+ "CHANGELOG"]
21
+ s.homepage = "http://github.com/techiferous/rack-environmental"
22
+ s.requirements << "none"
23
+ s.has_rdoc = false
24
+ end
25
+ Jeweler::GemcutterTasks.new
26
+ rescue LoadError
27
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
26
28
  end
@@ -1,57 +1,32 @@
1
- require 'nokogiri'
2
-
1
+ require 'rack-plastic'
2
+
3
3
  module Rack
4
- class Environmental
5
-
6
- def initialize(app, options = {})
7
- @app = app
8
- @options = options
9
- end
10
-
11
- def call(env)
12
- @doc = nil # clear out the doc object so we don't accidentally keep the last
13
- # request's HTML around
14
- @request = Rack::Request.new(env)
15
- status, @headers, @body = @app.call(env)
16
- if html?
17
- add_to_top_of_web_page(create_sticker)
18
- update_content_length
19
- end
20
- [status, @headers, @body]
21
- end
22
-
23
- private
4
+ class Environmental < Plastic
24
5
 
25
- def html?
26
- @headers["Content-Type"] && @headers["Content-Type"].include?("text/html")
6
+ def change_nokogiri_doc(doc)
7
+ add_to_top_of_web_page(doc, create_sticker(doc))
8
+ doc
27
9
  end
28
10
 
29
- def add_to_top_of_web_page(node)
11
+ private
12
+
13
+ def add_to_top_of_web_page(doc, node)
30
14
  if node
31
- doc.at_css("body").children.first.add_previous_sibling(node)
32
- end
33
- new_body_string = doc.to_html
34
- # If we're dealing with a Rails response, we don't want to throw the
35
- # response object away, we just want to update the response string.
36
- if @body.class.name == "ActionController::Response"
37
- @body.body = new_body_string
38
- else
39
- @body = [new_body_string]
15
+ add_first_child(doc.at_css("body"), node)
40
16
  end
41
17
  end
42
18
 
43
- def create_sticker
44
- environment_name = environment(@request.url)
19
+ def create_sticker(doc)
20
+ environment_name = environment(request.url)
45
21
  return nil if environment_name.nil?
46
- div = Nokogiri::XML::Node.new("div", doc)
47
- div['style'] = style(@options[environment_name])
48
- div.content = environment_name.to_s
22
+ div = create_node(doc, "div", environment_name.to_s)
23
+ div['style'] = style(options[environment_name])
49
24
  div
50
25
  end
51
26
 
52
27
  def environment(url)
53
28
  url = url.split('//').last # remove http://
54
- @options.each do |environment_name, options|
29
+ options.each do |environment_name, options|
55
30
  if options[:url] && options[:url] =~ url
56
31
  return environment_name
57
32
  end
@@ -59,16 +34,6 @@ module Rack
59
34
  return nil
60
35
  end
61
36
 
62
- def doc
63
- @doc ||= Nokogiri::HTML(body_to_string)
64
- end
65
-
66
- def body_to_string
67
- s = ""
68
- @body.each { |x| s << x }
69
- s
70
- end
71
-
72
37
  def style(options)
73
38
  style = ""
74
39
  style << "font-family: Verdana, Arial, sans-serif;"
@@ -100,14 +65,5 @@ module Rack
100
65
  end
101
66
  end
102
67
 
103
- def update_content_length
104
- length = 0
105
- @body.each do |s| # we can't use inject because @body may not respond to it
106
- length += Rack::Utils.bytesize(s) # we use Rack::Utils.bytesize to avoid
107
- # incompatibilities between Ruby 1.8 and 1.9
108
- end
109
- @headers['Content-Length'] = length.to_s
110
- end
111
-
112
68
  end
113
69
  end
@@ -0,0 +1,105 @@
1
+ class App
2
+
3
+ def call(env)
4
+ response = Rack::Response.new
5
+ request = Rack::Request.new(env)
6
+ response['Content-Type'] = 'text/html'
7
+ if request.path =~ /more/
8
+ response.write more
9
+ else
10
+ response.write front_page
11
+ end
12
+ response.finish
13
+ end
14
+
15
+ def front_page
16
+ %Q{
17
+ <!DOCTYPE html
18
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
19
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
20
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
21
+ <head>
22
+ <title>The Greatest Movie of All Time</title>
23
+ </head>
24
+ <body>
25
+ <div id="container">
26
+ <p>
27
+ What my associate is trying to say is that our new brake pads are really cool.
28
+ You're not even gonna believe it.
29
+ </p>
30
+ <p>
31
+ Like, um, let's say you're driving along
32
+ the road, with your family.<br />
33
+ And you're driving along...la de da...woo...<br />
34
+ And then all of a sudden
35
+ there's a truck tire
36
+ in the middle of the road
37
+ and you hit the brakes.<br />
38
+ Screeeee!
39
+ </p>
40
+ <p>
41
+ Woah, that was close.
42
+ </p>
43
+ <p>
44
+ Now let's see what happens when you're
45
+ driving with "the other guy's brake pads".
46
+ </p>
47
+ <p>
48
+ You're driving along,<br />
49
+ you're driving along,<br />
50
+ and all of a sudden your kids are
51
+ yelling from the back seat:<br />
52
+ "I gotta go to the bathroom, daddy!"<br />
53
+ "Not now, dammit!"<br />
54
+ "Truck tire! I can't stop! Aaaaa! Help!"<br />
55
+ "There's a cliff! Aaaaa!"<br />
56
+ And your family screaming:<br />
57
+ "Oh my God, we're burning alive!"<br />
58
+ "No! I can't feel my legs!"<br />
59
+ Here comes the meat-wagon! Woo woo woo!<br />
60
+ And the medic gets out and says:<br />
61
+ "Oh! My! God!"<br />
62
+ New guy's in the corner puking his guts out:<br />
63
+ Blllleeeeeeeaaaaaaaaaaah!<br />
64
+ Blllleeeeeeeaaaaaaaaaaah!<br />
65
+ </p>
66
+ <p>
67
+ All because you wanna save a coupla extra pennies.
68
+ </p>
69
+ <a href="/more">&laquo; inflict me with more &raquo;</a>
70
+ </div>
71
+ </body>
72
+ </html>
73
+ }
74
+ end
75
+
76
+ def more
77
+ %Q{
78
+ <!DOCTYPE html
79
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
80
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
81
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
82
+ <head>
83
+ <title>More of the Greatest Movie of All Time</title>
84
+ </head>
85
+ <body>
86
+ <div id="container">
87
+ <p>
88
+ D+? Oh my God! I passed! I passed! Oh, man i got a D+! I'm gonna graduate!
89
+ I'm gonna graduate! D+!
90
+ </p>
91
+ <p>
92
+ Hey guys, do i look different now that i'm a college grad?
93
+ </p>
94
+ <p>
95
+ Apparently they give a lot fewer D+'s than D-'s.
96
+ It's not a grade they like to give out, i'll tell ya that right now.
97
+ </p>
98
+ <a href="/">&laquo; take me back &raquo;</a>
99
+ </div>
100
+ </body>
101
+ </html>
102
+ }
103
+ end
104
+
105
+ end
@@ -0,0 +1,10 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
+
8
+ # Scrub sensitive parameters from your log
9
+ # filter_parameter_logging :password
10
+ end
@@ -0,0 +1,9 @@
1
+ class TommyBoyController < ApplicationController
2
+
3
+ def index
4
+ end
5
+
6
+ def more
7
+ end
8
+
9
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,2 @@
1
+ module TommyBoyHelper
2
+ end
@@ -0,0 +1,110 @@
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!
@@ -0,0 +1,52 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Specifies gem version of Rails to use when vendor/rails is not present
4
+ RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
5
+
6
+ # Bootstrap the Rails environment, frameworks, and default configuration
7
+ require File.join(File.dirname(__FILE__), 'boot')
8
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'rack-environmental')
9
+
10
+ Rails::Initializer.run do |config|
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ config.middleware.use Rack::Environmental, :staging => { :url => /^staging.+$/ },
16
+ :test => { :url => /^test.+$/ },
17
+ :development => { :url => /^localhost.+$/,
18
+ :style => :badge,
19
+ :color => 'red',
20
+ :size => :large,
21
+ :opacity => 1,
22
+ :top => 100,
23
+ :left => 100 }
24
+
25
+ # Add additional load paths for your own custom dirs
26
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
27
+
28
+ # Specify gems that this application depends on and have them installed with rake gems:install
29
+ # config.gem "bj"
30
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
31
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
32
+ # config.gem "aws-s3", :lib => "aws/s3"
33
+
34
+ # Only load the plugins named here, in the order given (default is alphabetical).
35
+ # :all can be used as a placeholder for all plugins not explicitly named
36
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
37
+
38
+ # Skip frameworks you're not going to use. To use Rails without a database,
39
+ # you must remove the Active Record framework.
40
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
41
+
42
+ # Activate observers that should always be running
43
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
44
+
45
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
46
+ # Run "rake -D time" for a list of tasks for finding time zone names.
47
+ config.time_zone = 'UTC'
48
+
49
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
50
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
51
+ # config.i18n.default_locale = :de
52
+ end
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,28 @@
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!
@@ -0,0 +1,28 @@
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
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,21 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # These settings change the behavior of Rails 2 apps and will be defaults
4
+ # for Rails 3. You can remove this initializer when Rails 3 is released.
5
+
6
+ if defined?(ActiveRecord)
7
+ # Include Active Record class name as root for JSON serialized output.
8
+ ActiveRecord::Base.include_root_in_json = true
9
+
10
+ # Store the full class name (including module namespace) in STI type column.
11
+ ActiveRecord::Base.store_full_sti_class = true
12
+ end
13
+
14
+ ActionController::Routing.generate_best_match = false
15
+
16
+ # Use ISO 8601 format for JSON serialized times and dates.
17
+ ActiveSupport.use_standard_json_time_format = true
18
+
19
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
20
+ # if you're including raw json in an HTML page.
21
+ ActiveSupport.escape_html_entities_in_json = false
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying cookie session data integrity.
4
+ # If you change this key, all old sessions will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ ActionController::Base.session = {
8
+ :key => '_railsapp_session',
9
+ :secret => '6d70a9e57e167a4699d60a921751576300e78c50f23bbc3276f511090577c2757cf9bf2d93218b2163c84e9275f7d8be7577f8e58290c5904d4ad74118c4542b'
10
+ }
11
+
12
+ # Use the database for sessions instead of the cookie-based default,
13
+ # which shouldn't be used to store highly confidential information
14
+ # (create the session table with "rake db:sessions:create")
15
+ # ActionController::Base.session_store = :active_record_store
@@ -0,0 +1,4 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.root :controller => "tommy_boy", :action => "index"
3
+ map.connect 'more', :controller => "tommy_boy", :action => "more"
4
+ end
@@ -0,0 +1,7 @@
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)
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class TommyBoyControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+ require 'performance_test_help'
3
+
4
+ # Profiling results for each test method are written to tmp/performance.
5
+ class BrowsingTest < ActionController::PerformanceTest
6
+ def test_homepage
7
+ get '/'
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
+ require 'test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Transactional fixtures accelerate your tests by wrapping each test method
7
+ # in a transaction that's rolled back on completion. This ensures that the
8
+ # test database remains unchanged so your fixtures don't have to be reloaded
9
+ # between every test method. Fewer database queries means faster tests.
10
+ #
11
+ # Read Mike Clark's excellent walkthrough at
12
+ # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
13
+ #
14
+ # Every Active Record database supports transactions except MyISAM tables
15
+ # in MySQL. Turn off transactional fixtures in this case; however, if you
16
+ # don't care one way or the other, switching from MyISAM to InnoDB tables
17
+ # is recommended.
18
+ #
19
+ # The only drawback to using transactional fixtures is when you actually
20
+ # need to test transactions. Since your test is bracketed by a transaction,
21
+ # any transactions started in your code will be automatically rolled back.
22
+ self.use_transactional_fixtures = true
23
+
24
+ # Instantiated fixtures are slow, but give you @david where otherwise you
25
+ # would need people(:david). If you don't want to migrate your existing
26
+ # test cases which use the @david style and don't mind the speed hit (each
27
+ # instantiated fixtures translates to a database query per test method),
28
+ # then set this back to true.
29
+ self.use_instantiated_fixtures = false
30
+
31
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
32
+ #
33
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
34
+ # -- they do not yet inherit this setting
35
+ fixtures :all
36
+
37
+ # Add more helper methods to be used by all tests here...
38
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class TommyBoyHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,98 @@
1
+ require 'rubygems'
2
+ require 'sinatra'
3
+ require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rack-environmental')
4
+
5
+ use Rack::Environmental, :staging => { :url => /^staging.+$/ },
6
+ :test => { :url => /^test.+$/ },
7
+ :development => { :url => /^localhost.+$/,
8
+ :style => :badge }
9
+
10
+ get '/' do
11
+ %Q{
12
+ <!DOCTYPE html
13
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
14
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
15
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
16
+ <head>
17
+ <title>The Greatest Movie of All Time</title>
18
+ </head>
19
+ <body>
20
+ <div id="container">
21
+ <p>
22
+ What my associate is trying to say is that our new brake pads are really cool.
23
+ You're not even gonna believe it.
24
+ </p>
25
+ <p>
26
+ Like, um, let's say you're driving along
27
+ the road, with your family.<br />
28
+ And you're driving along...la de da...woo...<br />
29
+ And then all of a sudden
30
+ there's a truck tire
31
+ in the middle of the road
32
+ and you hit the brakes.<br />
33
+ Screeeee!
34
+ </p>
35
+ <p>
36
+ Woah, that was close.
37
+ </p>
38
+ <p>
39
+ Now let's see what happens when you're
40
+ driving with "the other guy's brake pads".
41
+ </p>
42
+ <p>
43
+ You're driving along,<br />
44
+ you're driving along,<br />
45
+ and all of a sudden your kids are
46
+ yelling from the back seat:<br />
47
+ "I gotta go to the bathroom, daddy!"<br />
48
+ "Not now, dammit!"<br />
49
+ "Truck tire! I can't stop! Aaaaa! Help!"<br />
50
+ "There's a cliff! Aaaaa!"<br />
51
+ And your family screaming:<br />
52
+ "Oh my God, we're burning alive!"<br />
53
+ "No! I can't feel my legs!"<br />
54
+ Here comes the meat-wagon! Woo woo woo!<br />
55
+ And the medic gets out and says:<br />
56
+ "Oh! My! God!"<br />
57
+ New guy's in the corner puking his guts out:<br />
58
+ Blllleeeeeeeaaaaaaaaaaah!<br />
59
+ Blllleeeeeeeaaaaaaaaaaah!<br />
60
+ </p>
61
+ <p>
62
+ All because you wanna save a coupla extra pennies.
63
+ </p>
64
+ <a href="/more">&laquo; inflict me with more &raquo;</a>
65
+ </div>
66
+ </body>
67
+ </html>
68
+ }
69
+ end
70
+
71
+ get '/more' do
72
+ %Q{
73
+ <!DOCTYPE html
74
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
75
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
76
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
77
+ <head>
78
+ <title>More of the Greatest Movie of All Time</title>
79
+ </head>
80
+ <body>
81
+ <div id="container">
82
+ <p>
83
+ D+? Oh my God! I passed! I passed! Oh, man i got a D+! I'm gonna graduate!
84
+ I'm gonna graduate! D+!
85
+ </p>
86
+ <p>
87
+ Hey guys, do i look different now that i'm a college grad?
88
+ </p>
89
+ <p>
90
+ Apparently they give a lot fewer D+'s than D-'s.
91
+ It's not a grade they like to give out, i'll tell ya that right now.
92
+ </p>
93
+ <a href="/">&laquo; take me back &raquo;</a>
94
+ </div>
95
+ </body>
96
+ </html>
97
+ }
98
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-environmental
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wyatt Greene
@@ -9,50 +9,41 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-17 00:00:00 -05:00
12
+ date: 2009-12-03 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: rack
16
+ name: plastic
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.0.0
23
+ version: 0.0.0
24
24
  version:
25
- - !ruby/object:Gem::Dependency
26
- name: nokogiri
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.4.0
34
- version:
35
- description: "\n Rack::Environmental indicates which environment your web application is running\n in (staging, test, etc.).\n "
25
+ description: "\n Rack::Environmental indicates which environment your web application is running\n in (staging, test, etc.).\n "
36
26
  email: techiferous@gmail.com
37
27
  executables: []
38
28
 
39
29
  extensions: []
40
30
 
41
- extra_rdoc_files: []
42
-
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
43
34
  files:
44
- - lib/rack-environmental.rb
35
+ - CHANGELOG
45
36
  - LICENSE
37
+ - README.rdoc
46
38
  - Rakefile
47
- - README
48
- - CHANGELOG
39
+ - lib/rack-environmental.rb
49
40
  has_rdoc: true
50
41
  homepage: http://github.com/techiferous/rack-environmental
51
42
  licenses: []
52
43
 
53
44
  post_install_message:
54
- rdoc_options: []
55
-
45
+ rdoc_options:
46
+ - --charset=UTF-8
56
47
  require_paths:
57
48
  - lib
58
49
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -74,5 +65,26 @@ rubygems_version: 1.3.5
74
65
  signing_key:
75
66
  specification_version: 3
76
67
  summary: Rack middleware that adds an indicator of your application environment
77
- test_files: []
78
-
68
+ test_files:
69
+ - test/rackapp/app.rb
70
+ - test/railsapp/app/controllers/application_controller.rb
71
+ - test/railsapp/app/controllers/tommy_boy_controller.rb
72
+ - test/railsapp/app/helpers/application_helper.rb
73
+ - test/railsapp/app/helpers/tommy_boy_helper.rb
74
+ - test/railsapp/config/boot.rb
75
+ - test/railsapp/config/environment.rb
76
+ - test/railsapp/config/environments/development.rb
77
+ - test/railsapp/config/environments/production.rb
78
+ - test/railsapp/config/environments/test.rb
79
+ - test/railsapp/config/initializers/backtrace_silencers.rb
80
+ - test/railsapp/config/initializers/inflections.rb
81
+ - test/railsapp/config/initializers/mime_types.rb
82
+ - test/railsapp/config/initializers/new_rails_defaults.rb
83
+ - test/railsapp/config/initializers/session_store.rb
84
+ - test/railsapp/config/routes.rb
85
+ - test/railsapp/db/seeds.rb
86
+ - test/railsapp/test/functional/tommy_boy_controller_test.rb
87
+ - test/railsapp/test/performance/browsing_test.rb
88
+ - test/railsapp/test/test_helper.rb
89
+ - test/railsapp/test/unit/helpers/tommy_boy_helper_test.rb
90
+ - test/sinatraapp/app.rb