Skip to content

Commit

Permalink
Merge commit 'brynary/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
foca committed Dec 29, 2008
2 parents a058c8e + 2562942 commit 47bc51b
Show file tree
Hide file tree
Showing 93 changed files with 1,394 additions and 12 deletions.
33 changes: 26 additions & 7 deletions Rakefile
@@ -1,4 +1,4 @@
require 'rubygems'
# require 'rubygems'
require "rake/gempackagetask"
require 'rake/rdoctask'
require "rake/clean"
Expand Down Expand Up @@ -28,7 +28,7 @@ spec = Gem::Specification.new do |s|
s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)

# Dependencies
s.add_dependency "nokogiri", ">= 1.0.6"
s.add_dependency "nokogiri", ">= 1.1.0"

s.rubyforge_project = "webrat"
end
Expand All @@ -52,13 +52,13 @@ end
desc "Run API and Core specs"
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_files = FileList['spec/public/*_spec.rb'] + FileList['spec/private/*_spec.rb']
end

desc "Run all specs in spec directory with RCov"
Spec::Rake::SpecTask.new(:rcov) do |t|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_files = FileList['spec/public/*_spec.rb'] + FileList['spec/private/*_spec.rb']
t.rcov = true
t.rcov_opts = lambda do
IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
Expand All @@ -71,8 +71,8 @@ end

desc 'Install the package as a gem.'
task :install_gem => [:clean, :package] do
gem = Dir['pkg/*.gem'].first
sh "sudo gem install --local #{gem}"
gem_filename = Dir['pkg/*.gem'].first
sh "sudo gem install --local #{gem_filename}"
end

desc "Delete generated RDoc"
Expand All @@ -99,6 +99,25 @@ task :spec_deps do
end
end

task :prepare do
system "ln -s ../../../../.. ./spec/integration/rails/vendor/plugins/webrat"
end

namespace :spec do
desc "Run the integration specs"
task :integration do
Dir.chdir "spec/integration/rails" do
result = system "rake test:integration"
raise "Tests failed" unless result
end

Dir.chdir "spec/integration/merb" do
result = system "rake spec"
raise "Tests failed" unless result
end
end
end

task :default => :spec

task :precommit => ["spec", "spec:jruby"]
task :precommit => ["spec", "spec:jruby", "spec:integration"]
21 changes: 21 additions & 0 deletions spec/integration/merb/.gitignore
@@ -0,0 +1,21 @@
.DS_Store
log/*
tmp/*
TAGS
*~
.#*
schema/schema.rb
schema/*_structure.sql
schema/*.sqlite3
schema/*.sqlite
schema/*.db
*.sqlite
*.sqlite3
*.db
src/*
.hgignore
.hg/*
.svn/*
gems/gems/*
gems/specifications/*
merb_profile_results
35 changes: 35 additions & 0 deletions spec/integration/merb/Rakefile
@@ -0,0 +1,35 @@
require 'rubygems'
require 'rake/rdoctask'

require 'merb-core'
require 'merb-core/tasks/merb'

include FileUtils

# Load the basic runtime dependencies; this will include
# any plugins and therefore plugin rake tasks.
init_env = ENV['MERB_ENV'] || 'rake'
Merb.load_dependencies(:environment => init_env)

# Get Merb plugins and dependencies
Merb::Plugins.rakefiles.each { |r| require r }

# Load any app level custom rakefile extensions from lib/tasks
tasks_path = File.join(File.dirname(__FILE__), "lib", "tasks")
rake_files = Dir["#{tasks_path}/*.rake"]
rake_files.each{|rake_file| load rake_file }

desc "Start runner environment"
task :merb_env do
Merb.start_environment(:environment => init_env, :adapter => 'runner')
end

require 'spec/rake/spectask'
require 'merb-core/test/tasks/spectasks'
desc 'Default: run spec examples'
task :default => 'spec'

##############################################################################
# ADD YOUR CUSTOM TASKS IN /lib/tasks
# NAME YOUR RAKE FILES file_name.rake
##############################################################################
2 changes: 2 additions & 0 deletions spec/integration/merb/app/controllers/application.rb
@@ -0,0 +1,2 @@
class Application < Merb::Controller
end
13 changes: 13 additions & 0 deletions spec/integration/merb/app/controllers/exceptions.rb
@@ -0,0 +1,13 @@
class Exceptions < Merb::Controller

# handle NotFound exceptions (404)
def not_found
render :format => :html
end

# handle NotAcceptable exceptions (406)
def not_acceptable
render :format => :html
end

end
10 changes: 10 additions & 0 deletions spec/integration/merb/app/controllers/testing.rb
@@ -0,0 +1,10 @@
class Testing < Application

def show_form
render
end

def submit_form
end

end
63 changes: 63 additions & 0 deletions spec/integration/merb/app/views/exceptions/not_acceptable.html.erb
@@ -0,0 +1,63 @@
<div id="container">
<div id="header-container">
<img src="/images/merb.jpg" />
<!-- <h1>Mongrel + Erb</h1> -->
<h2>pocket rocket web framework</h2>
<hr />
</div>

<div id="left-container">
<h3>Exception:</h3>
<p><%= request.exceptions.first.message %></p>
</div>

<div id="main-container">
<h3>Why am I seeing this page?</h3>
<p>Merb couldn't find an appropriate content_type to return,
based on what you said was available via provides() and
what the client requested.</p>

<h3>How to add a mime-type</h3>
<pre><code>
Merb.add_mime_type :pdf, :to_pdf, %w[application/pdf], &quot;Content-Encoding&quot; =&gt; &quot;gzip&quot;
</code></pre>
<h3>What this means is:</h3>
<ul>
<li>Add a mime-type for :pdf</li>
<li>Register the method for converting objects to PDF as <code>#to_pdf</code>.</li>
<li>Register the incoming mime-type "Accept" header as <code>application/pdf</code>.</li>
<li>Specify a new header for PDF types so it will set <code>Content-Encoding</code> to gzip.</li>
</ul>

<h3>You can then do:</h3>
<pre><code>
class Foo &lt; Application
provides :pdf
end
</code></pre>

<h3>Where can I find help?</h3>
<p>If you have any questions or if you can't figure something out, please take a
look at our <a href="http://merbivore.com/"> project page</a>,
feel free to come chat at irc.freenode.net, channel #merb,
or post to <a href="http://groups.google.com/group/merb">merb mailing list</a>
on Google Groups.</p>

<h3>What if I've found a bug?</h3>
<p>If you want to file a bug or make your own contribution to Merb,
feel free to register and create a ticket at our
<a href="http://merb.lighthouseapp.com/">project development page</a>
on Lighthouse.</p>

<h3>How do I edit this page?</h3>
<p>You can change what people see when this happens by editing <tt>app/views/exceptions/not_acceptable.html.erb</tt>.</p>

</div>

<div id="footer-container">
<hr />
<div class="left"></div>
<div class="right">&copy; 2008 the merb dev team</div>
<p>&nbsp;</p>
</div>
</div>
47 changes: 47 additions & 0 deletions spec/integration/merb/app/views/exceptions/not_found.html.erb
@@ -0,0 +1,47 @@
<div id="container">
<div id="header-container">
<img src="/images/merb.jpg" />
<!-- <h1>Mongrel + Erb</h1> -->
<h2>pocket rocket web framework</h2>
<hr />
</div>

<div id="left-container">
<h3>Exception:</h3>
<p><%= request.exceptions.first.message %></p>
</div>

<div id="main-container">
<h3>Welcome to Merb!</h3>
<p>Merb is a light-weight MVC framework written in Ruby. We hope you enjoy it.</p>

<h3>Where can I find help?</h3>
<p>If you have any questions or if you can't figure something out, please take a
look at our <a href="http://merbivore.com/"> project page</a>,
feel free to come chat at irc.freenode.net, channel #merb,
or post to <a href="http://groups.google.com/group/merb">merb mailing list</a>
on Google Groups.</p>

<h3>What if I've found a bug?</h3>
<p>If you want to file a bug or make your own contribution to Merb,
feel free to register and create a ticket at our
<a href="http://merb.lighthouseapp.com/">project development page</a>
on Lighthouse.</p>

<h3>How do I edit this page?</h3>
<p>You're seeing this page because you need to edit the following files:
<ul>
<li>config/router.rb <strong><em>(recommended)</em></strong></li>
<li>app/views/exceptions/not_found.html.erb <strong><em>(recommended)</em></strong></li>
<li>app/views/layout/application.html.erb <strong><em>(change this layout)</em></strong></li>
</ul>
</p>
</div>

<div id="footer-container">
<hr />
<div class="left"></div>
<div class="right">&copy; 2008 the merb dev team</div>
<p>&nbsp;</p>
</div>
</div>
12 changes: 12 additions & 0 deletions spec/integration/merb/app/views/layout/application.html.erb
@@ -0,0 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
<head>
<title>Fresh Merb App</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8" />
</head>
<body>
<%#= message[:notice] %>
<%= catch_content :for_layout %>
</body>
</html>
22 changes: 22 additions & 0 deletions spec/integration/merb/app/views/testing/show_form.html.erb
@@ -0,0 +1,22 @@
<h1>Webrat Form</h1>

<form action="/testing/submit_form" method="post">
<label>
Text field
<input type="text" name="text_field" />
</label>

<label>
TOS <input type="checkbox" name="tos" />
</label>

<label>
Month
<select name="month">
<option>None</option>
<option>January</option>
</select>
</label>

<input type="submit" value="Test">
</form>
15 changes: 15 additions & 0 deletions spec/integration/merb/config/environments/development.rb
@@ -0,0 +1,15 @@
Merb.logger.info("Loaded DEVELOPMENT Environment...")
Merb::Config.use { |c|
c[:exception_details] = true
c[:reload_templates] = true
c[:reload_classes] = true
c[:reload_time] = 0.5
c[:ignore_tampered_cookies] = true
c[:log_auto_flush ] = true
c[:log_level] = :debug

c[:log_stream] = STDOUT
c[:log_file] = nil
# Or redirect logging into a file:
# c[:log_file] = Merb.root / "log" / "development.log"
}
11 changes: 11 additions & 0 deletions spec/integration/merb/config/environments/rake.rb
@@ -0,0 +1,11 @@
Merb.logger.info("Loaded RAKE Environment...")
Merb::Config.use { |c|
c[:exception_details] = true
c[:reload_classes] = false
c[:log_auto_flush ] = true

c[:log_stream] = STDOUT
c[:log_file] = nil
# Or redirect logging into a file:
# c[:log_file] = Merb.root / "log" / "development.log"
}
12 changes: 12 additions & 0 deletions spec/integration/merb/config/environments/test.rb
@@ -0,0 +1,12 @@
Merb.logger.info("Loaded TEST Environment...")
Merb::Config.use { |c|
c[:testing] = true
c[:exception_details] = true
c[:log_auto_flush ] = true
# log less in testing environment
c[:log_level] = :error

#c[:log_file] = Merb.root / "log" / "test.log"
# or redirect logger using IO handle
c[:log_stream] = STDOUT
}
25 changes: 25 additions & 0 deletions spec/integration/merb/config/init.rb
@@ -0,0 +1,25 @@
# Go to http://wiki.merbivore.com/pages/init-rb

# Specify a specific version of a dependency
# dependency "RedCloth", "> 3.0"

# use_orm :none
use_test :rspec
use_template_engine :erb

Merb::Config.use do |c|
c[:use_mutex] = false
c[:session_store] = 'cookie' # can also be 'memory', 'memcache', 'container', 'datamapper

# cookie session store configuration
c[:session_secret_key] = 'adb9ea7a0e94b5513503f58623a393c5efe18851' # required for cookie session store
c[:session_id_key] = '_merb_session_id' # cookie session id key, defaults to "_session_id"
end

Merb::BootLoader.before_app_loads do
# This will get executed after dependencies have been loaded but before your app's classes have loaded.
end

Merb::BootLoader.after_app_loads do
# This will get executed after your app's classes have been loaded.
end
11 changes: 11 additions & 0 deletions spec/integration/merb/config/rack.rb
@@ -0,0 +1,11 @@
# use PathPrefix Middleware if :path_prefix is set in Merb::Config
if prefix = ::Merb::Config[:path_prefix]
use Merb::Rack::PathPrefix, prefix
end

# comment this out if you are running merb behind a load balancer
# that serves static files
use Merb::Rack::Static, Merb.dir_for(:public)

# this is our main merb application
run Merb::Rack::Application.new

0 comments on commit 47bc51b

Please sign in to comment.