Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #36 from zelig/master

latest rails compatibility issues
  • Loading branch information...
commit 31554933355dbb4aa913810d570ee93c7d513f03 2 parents 4ea4d16 + 3601aca
@alexch alexch authored
View
2  Gemfile
@@ -13,7 +13,7 @@ group :development do
gem "sass"
gem "erubis"
gem "rdoc", "~> 3.4"
- gem "wrong", ">=0.5.4"
+ gem "wrong", ">=0.6.2"
end
group :rails do
View
34 Gemfile-rails
@@ -0,0 +1,34 @@
+# to use this Gemfile: in terminal or added to .rvmrc
+# export BUNDLE_GEMFILE=Gemfile-rails
+# bundle update --gemfile=Gemfile-rails
+source "http://rubygems.org"
+
+gem "treetop", ">= 1.2.3"
+
+group :development, :test do
+ gem "activesupport", "~>3"
+ gem "rspec", "~>2"
+ gem "rubyforge"
+ gem "rr"
+ gem "nokogiri"
+ gem "jeweler"
+ gem "haml"
+ gem "sass"
+ gem "erubis"
+ gem "rdoc", "~>3.4"
+ gem "wrong", ">=0.6.2"
+end
+
+group :rails do
+ gem 'rails' # for latest stable rails
+ # gem 'rails', :git => 'git://github.com/rails/rails.git' # for edge rails
+ gem 'sqlite3', '>=1.3.4'
+
+ # Asset template engines
+ gem 'sass-rails'
+ gem 'coffee-rails'
+ gem 'uglifier'
+
+ gem 'jquery-rails'
+ gem 'turn', :require => false
+end
View
21 Gemfile-rails2
@@ -0,0 +1,21 @@
+source "http://rubygems.org"
+
+gem "treetop", ">= 1.2.3"
+
+group :development do
+ gem "rspec", "~>2"
+ gem "rubyforge"
+ gem "rr"
+ gem "nokogiri"
+ gem "jeweler"
+ gem "haml"
+ gem "sass"
+ gem "erubis"
+ gem "rdoc", "~> 3.4"
+ gem "wrong", ">=0.5.4"
+end
+
+group :rails do
+ gem 'rails', '2.3.11'
+ gem 'sqlite3', '>=1.3.4'
+end
View
4 Gemfile-rails31
@@ -17,12 +17,12 @@ group :development do
end
group :rails do
- gem 'rails', '3.1.0.rc4'
+ gem 'rails', '~> 3.1'
# gem 'rails', :git => 'git://github.com/rails/rails.git' # for edge rails
gem 'sqlite3', '>=1.3.4'
# Asset template engines
- gem 'sass-rails', "~> 3.1.0.rc"
+ gem 'sass-rails'
gem 'coffee-script'
gem 'uglifier'
View
216 Gemfile-rails31.lock
@@ -1,126 +1,154 @@
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.1.0.rc4)
- actionpack (= 3.1.0.rc4)
- mail (~> 2.3.0)
- actionpack (3.1.0.rc4)
- activemodel (= 3.1.0.rc4)
- activesupport (= 3.1.0.rc4)
+ ParseTree (3.0.9)
+ RubyInline (~> 3.9.0)
+ sexp_processor (~> 3.2.0)
+ RubyInline (3.9.0)
+ ZenTest (~> 4.3)
+ ZenTest (4.8.2)
+ actionmailer (3.2.8)
+ actionpack (= 3.2.8)
+ mail (~> 2.4.4)
+ actionpack (3.2.8)
+ activemodel (= 3.2.8)
+ activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
- i18n (~> 0.6)
- rack (~> 1.3.0)
- rack-cache (~> 1.0.1)
- rack-mount (~> 0.8.1)
- rack-test (~> 0.6.0)
- sprockets (~> 2.0.0.beta.10)
- tzinfo (~> 0.3.27)
- activemodel (3.1.0.rc4)
- activesupport (= 3.1.0.rc4)
- bcrypt-ruby (~> 2.1.4)
+ journey (~> 1.0.4)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.3)
+ activemodel (3.2.8)
+ activesupport (= 3.2.8)
builder (~> 3.0.0)
+ activerecord (3.2.8)
+ activemodel (= 3.2.8)
+ activesupport (= 3.2.8)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.8)
+ activemodel (= 3.2.8)
+ activesupport (= 3.2.8)
+ activesupport (3.2.8)
i18n (~> 0.6)
- activerecord (3.1.0.rc4)
- activemodel (= 3.1.0.rc4)
- activesupport (= 3.1.0.rc4)
- arel (~> 2.1.1)
- tzinfo (~> 0.3.27)
- activeresource (3.1.0.rc4)
- activemodel (= 3.1.0.rc4)
- activesupport (= 3.1.0.rc4)
- activesupport (3.1.0.rc4)
multi_json (~> 1.0)
- ansi (1.3.0)
- arel (2.1.3)
- bcrypt-ruby (2.1.4)
- builder (3.0.0)
+ ansi (1.4.3)
+ arel (3.0.2)
+ builder (3.0.4)
coffee-script (2.2.0)
coffee-script-source
execjs
- coffee-script-source (1.1.1)
- diff-lcs (1.1.2)
+ coffee-script-source (1.4.0)
+ diff-lcs (1.1.3)
erubis (2.7.0)
- execjs (1.2.0)
+ execjs (1.4.0)
multi_json (~> 1.0)
+ file-tail (1.0.12)
+ tins (~> 0.5)
git (1.2.5)
- haml (3.1.2)
- hike (1.1.0)
- i18n (0.6.0)
- jeweler (1.6.4)
+ haml (3.1.7)
+ hike (1.2.1)
+ i18n (0.6.1)
+ jeweler (1.8.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
- jquery-rails (1.0.12)
- railties (~> 3.0)
+ rdoc
+ journey (1.0.4)
+ jquery-rails (2.1.3)
+ railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
- json_pure (1.5.3)
- mail (2.3.0)
+ json (1.7.5)
+ json_pure (1.7.5)
+ mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.16)
- multi_json (1.0.3)
- nokogiri (1.5.0)
- polyglot (0.3.1)
- rack (1.3.1)
- rack-cache (1.0.2)
+ mime-types (1.19)
+ multi_json (1.3.7)
+ nokogiri (1.5.5)
+ polyglot (0.3.3)
+ predicated (0.2.6)
+ rack (1.4.1)
+ rack-cache (1.2)
rack (>= 0.4)
- rack-mount (0.8.1)
- rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
- rack-test (0.6.0)
+ rack-test (0.6.2)
rack (>= 1.0)
- rails (3.1.0.rc4)
- actionmailer (= 3.1.0.rc4)
- actionpack (= 3.1.0.rc4)
- activerecord (= 3.1.0.rc4)
- activeresource (= 3.1.0.rc4)
- activesupport (= 3.1.0.rc4)
+ rails (3.2.8)
+ actionmailer (= 3.2.8)
+ actionpack (= 3.2.8)
+ activerecord (= 3.2.8)
+ activeresource (= 3.2.8)
+ activesupport (= 3.2.8)
bundler (~> 1.0)
- railties (= 3.1.0.rc4)
- railties (3.1.0.rc4)
- actionpack (= 3.1.0.rc4)
- activesupport (= 3.1.0.rc4)
+ railties (= 3.2.8)
+ railties (3.2.8)
+ actionpack (= 3.2.8)
+ activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
- thor (~> 0.14.6)
- rake (0.9.2)
- rdoc (3.8)
- rr (1.0.2)
- rspec (2.6.0)
- rspec-core (~> 2.6.0)
- rspec-expectations (~> 2.6.0)
- rspec-mocks (~> 2.6.0)
- rspec-core (2.6.4)
- rspec-expectations (2.6.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.6.0)
+ thor (>= 0.14.6, < 2.0)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ rr (1.0.4)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.3)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.11.3)
+ ruby2ruby (1.3.1)
+ ruby_parser (~> 2.0)
+ sexp_processor (~> 3.0)
+ ruby_parser (2.0.6)
+ sexp_processor (~> 3.0)
rubyforge (2.0.4)
json_pure (>= 1.1.7)
- sass (3.1.4)
- sass-rails (3.1.0.rc.4)
- actionpack (~> 3.1.0.rc1)
- railties (~> 3.1.0.rc1)
- sass (>= 3.1.4)
- sprockets (>= 2.0.0.beta.9)
- sprockets (2.0.0.beta.10)
- hike (~> 1.0)
+ sass (3.2.3)
+ sass-rails (3.2.5)
+ railties (~> 3.2.0)
+ sass (>= 3.1.10)
+ tilt (~> 1.3)
+ sexp_processor (3.2.0)
+ sourcify (0.5.0)
+ file-tail (>= 1.0.5)
+ ruby2ruby (>= 1.2.5)
+ ruby_parser (>= 2.0.5)
+ sexp_processor (>= 3.0.5)
+ sprockets (2.1.3)
+ hike (~> 1.2)
rack (~> 1.0)
- tilt (!= 1.3.0, ~> 1.1)
- sqlite3 (1.3.3)
- thor (0.14.6)
- tilt (1.3.2)
- treetop (1.4.9)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.6)
+ thor (0.16.0)
+ tilt (1.3.3)
+ tins (0.6.0)
+ treetop (1.4.12)
+ polyglot
polyglot (>= 0.3.1)
- turn (0.8.2)
- ansi (>= 1.2.2)
- tzinfo (0.3.29)
- uglifier (1.0.0)
+ turn (0.9.6)
+ ansi
+ tzinfo (0.3.35)
+ uglifier (1.3.0)
execjs (>= 0.3.0)
- multi_json (>= 1.0.2)
+ multi_json (~> 1.0, >= 1.0.2)
+ wrong (0.6.0)
+ ParseTree (~> 3.0)
+ diff-lcs (~> 1.1.2)
+ file-tail (~> 1.0)
+ predicated (>= 0.2.3)
+ ruby2ruby (~> 1.2)
+ ruby_parser (~> 2.0.4)
+ sexp_processor (~> 3.0)
+ sourcify (>= 0.3.0)
PLATFORMS
ruby
@@ -133,15 +161,15 @@ DEPENDENCIES
jeweler
jquery-rails
nokogiri
- rails (= 3.1.0.rc4)
- rake
+ rails (~> 3.1)
rdoc (~> 3.4)
rr
rspec (~> 2)
rubyforge
sass
- sass-rails (~> 3.1.0.rc)
- sqlite3
- treetop
+ sass-rails
+ sqlite3 (>= 1.3.4)
+ treetop (>= 1.2.3)
turn
uglifier
+ wrong (>= 0.5.4)
View
30 Rakefile
@@ -159,26 +159,32 @@ namespace :spec do
end
- desc "Run specs for erector's Rails integration."
- RSpec::Core::RakeTask.new(:rails) do |spec|
+ desc "Run specs for erector's Rails 3 integration."
+ RSpec::Core::RakeTask.new(:integration_rails3) do |spec|
spec.pattern = 'spec/rails_root/spec/*_spec.rb'
end
- desc "Run specs for erector's Rails integration under Rails 2."
+ desc "Run specs for erector's Rails 2 integration."
+ RSpec::Core::RakeTask.new(:integration_rails2) do |spec|
+ spec.pattern = 'spec/rails2/rails_app/spec/*_spec.rb'
+ end
+
+ desc "Run specs for erector's Rails integration under Rails 2. - prepare with 'bundle install --gemfile Gemfile-rails2"
task :rails2 do
- rails_app = "#{here}/spec/rails2/rails_app"
- gemfile = "#{rails_app}/Gemfile"
- Dir.chdir(rails_app) do
- # Bundler.with_clean_env do
- sh "BUNDLE_GEMFILE='#{gemfile}' bundle exec rake rails2"
- # end
- end
+ gemfile = "#{here}/Gemfile-rails2"
+ sh "BUNDLE_GEMFILE='#{gemfile}' bundle exec rake spec:core spec:integration_rails2"
end
desc "Run all specs under Rails 3.1 - prepare with 'bundle install --gemfile Gemfile-rails31'"
task :rails31 do
gemfile = "#{here}/Gemfile-rails31"
- sh "BUNDLE_GEMFILE='#{gemfile}' bundle exec rake spec:core spec:erect spec:rails"
+ sh "BUNDLE_GEMFILE='#{gemfile}' bundle exec rake spec:core spec:erect spec:integration_rails3"
+ end
+
+ desc "Run all specs under latest Rails - prepare with 'bundle install --gemfile Gemfile-rails'"
+ task :rails do
+ gemfile = "#{here}/Gemfile-rails"
+ sh "BUNDLE_GEMFILE='#{gemfile}' bundle exec rake spec:core spec:erect spec:integration_rails3"
end
desc "Run specs for the Erector web site."
@@ -189,4 +195,4 @@ namespace :spec do
end
desc "Run most specs"
-task :spec => ['spec:core', 'spec:erect', 'spec:rails', 'spec:rails2', 'spec:web']
+task :spec => ['spec:rails', 'spec:rails2', 'spec:web']
View
10 erector.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Alex Chaffee", "Brian Takita", "Jeff Dean", "Jim Kingdon", "John Firebaugh"]
- s.date = "2012-08-15"
+ s.date = "2012-11-11"
s.description = "Erector is a Builder-like view framework, inspired by Markaby but overcoming some of its flaws. In Erector all views are objects, not template files, which allows the full power of object-oriented programming (inheritance, modular decomposition, encapsulation) in views."
s.email = "erector@googlegroups.com"
s.executables = ["erector"]
@@ -78,7 +78,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.rubygems_version = "1.8.24"
s.summary = "HTML/XML Builder library"
- s.test_files = ["Rakefile", "Gemfile", "spec/erect", "spec/erect/erect_rails_spec.rb", "spec/erect/erect_spec.rb", "spec/erect/erected_spec.rb", "spec/erect/rhtml_parser_spec.rb", "spec/erector", "spec/erector/caching_spec.rb", "spec/erector/convenience_spec.rb", "spec/erector/dependency_spec.rb", "spec/erector/externals_spec.rb", "spec/erector/hello_from_readme.rb", "spec/erector/hello_from_readme_spec.rb", "spec/erector/html_spec.rb", "spec/erector/indentation_spec.rb", "spec/erector/inline_spec.rb", "spec/erector/jquery_spec.rb", "spec/erector/mixin_spec.rb", "spec/erector/needs_spec.rb", "spec/erector/output_spec.rb", "spec/erector/promise_spec.rb", "spec/erector/sample-file.txt", "spec/erector/sass_spec.rb", "spec/erector/tag_spec.rb", "spec/erector/unicode_builder_spec.rb", "spec/erector/widget_spec.rb", "spec/erector/widgets", "spec/erector/widgets/field_table_spec.rb", "spec/erector/widgets/form_spec.rb", "spec/erector/widgets/page_spec.rb", "spec/erector/widgets/table_spec.rb", "spec/erector/xml_widget_spec.rb", "spec/rails2", "spec/rails2/erect_rails_spec.rb", "spec/rails2/rails_app", "spec/rails2/rails_app/app", "spec/rails2/rails_app/app/controllers", "spec/rails2/rails_app/app/controllers/application_controller.rb", "spec/rails2/rails_app/app/helpers", "spec/rails2/rails_app/app/helpers/application_helper.rb", "spec/rails2/rails_app/app/helpers/rails_helpers_spec_helper.rb", "spec/rails2/rails_app/app/helpers/test_helper.rb", "spec/rails2/rails_app/app/views", "spec/rails2/rails_app/app/views/test", "spec/rails2/rails_app/app/views/test/_erb.erb", "spec/rails2/rails_app/app/views/test/_erector.rb", "spec/rails2/rails_app/app/views/test/_partial_with_locals.rb", "spec/rails2/rails_app/app/views/test/bare.rb", "spec/rails2/rails_app/app/views/test/erb_from_erector.html.rb", "spec/rails2/rails_app/app/views/test/erector_from_erb.html.erb", "spec/rails2/rails_app/app/views/test/erector_with_locals_from_erb.html.erb", "spec/rails2/rails_app/app/views/test/implicit_assigns.html.rb", "spec/rails2/rails_app/app/views/test/needs.html.rb", "spec/rails2/rails_app/app/views/test/needs_subclass.html.rb", "spec/rails2/rails_app/app/views/test/protected_instance_variable.html.rb", "spec/rails2/rails_app/app/views/test/render_default.html.rb", "spec/rails2/rails_app/app/views/test/render_partial.html.rb", "spec/rails2/rails_app/config", "spec/rails2/rails_app/config/boot.rb", "spec/rails2/rails_app/config/database.yml", "spec/rails2/rails_app/config/environment.rb", "spec/rails2/rails_app/config/environments", "spec/rails2/rails_app/config/environments/development.rb", "spec/rails2/rails_app/config/environments/production.rb", "spec/rails2/rails_app/config/environments/test.rb", "spec/rails2/rails_app/config/initializers", "spec/rails2/rails_app/config/initializers/backtrace_silencers.rb", "spec/rails2/rails_app/config/initializers/cookie_verification_secret.rb", "spec/rails2/rails_app/config/initializers/inflections.rb", "spec/rails2/rails_app/config/initializers/mime_types.rb", "spec/rails2/rails_app/config/initializers/new_rails_defaults.rb", "spec/rails2/rails_app/config/initializers/session_store.rb", "spec/rails2/rails_app/config/locales", "spec/rails2/rails_app/config/locales/en.yml", "spec/rails2/rails_app/config/routes.rb", "spec/rails2/rails_app/db", "spec/rails2/rails_app/db/development.sqlite3", "spec/rails2/rails_app/db/schema.rb", "spec/rails2/rails_app/db/seeds.rb", "spec/rails2/rails_app/doc", "spec/rails2/rails_app/doc/README_FOR_APP", "spec/rails2/rails_app/Gemfile", "spec/rails2/rails_app/Gemfile.lock", "spec/rails2/rails_app/log", "spec/rails2/rails_app/log/development.log", "spec/rails2/rails_app/log/production.log", "spec/rails2/rails_app/log/server.log", "spec/rails2/rails_app/log/test.log", "spec/rails2/rails_app/public", "spec/rails2/rails_app/public/404.html", "spec/rails2/rails_app/public/422.html", "spec/rails2/rails_app/public/500.html", "spec/rails2/rails_app/public/favicon.ico", "spec/rails2/rails_app/public/images", "spec/rails2/rails_app/public/images/rails.png", "spec/rails2/rails_app/public/index.html", "spec/rails2/rails_app/public/javascripts", "spec/rails2/rails_app/public/javascripts/application.js", "spec/rails2/rails_app/public/javascripts/controls.js", "spec/rails2/rails_app/public/javascripts/dragdrop.js", "spec/rails2/rails_app/public/javascripts/effects.js", "spec/rails2/rails_app/public/javascripts/prototype.js", "spec/rails2/rails_app/public/robots.txt", "spec/rails2/rails_app/Rakefile", "spec/rails2/rails_app/README", "spec/rails2/rails_app/script", "spec/rails2/rails_app/script/about", "spec/rails2/rails_app/script/console", "spec/rails2/rails_app/script/dbconsole", "spec/rails2/rails_app/script/destroy", "spec/rails2/rails_app/script/generate", "spec/rails2/rails_app/script/performance", "spec/rails2/rails_app/script/performance/benchmarker", "spec/rails2/rails_app/script/performance/profiler", "spec/rails2/rails_app/script/plugin", "spec/rails2/rails_app/script/runner", "spec/rails2/rails_app/script/server", "spec/rails2/rails_app/spec", "spec/rails2/rails_app/spec/rails_helpers_spec.rb", "spec/rails2/rails_app/spec/rails_spec_helper.rb", "spec/rails2/rails_app/spec/rails_widget_spec.rb", "spec/rails2/rails_app/spec/render_spec.rb", "spec/rails2/rails_app/test", "spec/rails2/rails_app/test/performance", "spec/rails2/rails_app/test/performance/browsing_test.rb", "spec/rails2/rails_app/test/test_helper.rb", "spec/rails_root", "spec/rails_root/app", "spec/rails_root/app/controllers", "spec/rails_root/app/controllers/application.rb", "spec/rails_root/app/controllers/application_controller.rb", "spec/rails_root/app/helpers", "spec/rails_root/app/helpers/application_helper.rb", "spec/rails_root/app/views", "spec/rails_root/app/views/layouts", "spec/rails_root/app/views/layouts/application.html.erb", "spec/rails_root/app/views/layouts/widget_as_layout.rb", "spec/rails_root/app/views/test", "spec/rails_root/app/views/test/_erb.erb", "spec/rails_root/app/views/test/_erector.rb", "spec/rails_root/app/views/test/_partial_with_locals.rb", "spec/rails_root/app/views/test/bare.rb", "spec/rails_root/app/views/test/erb_from_erector.html.rb", "spec/rails_root/app/views/test/erector_from_erb.html.erb", "spec/rails_root/app/views/test/erector_with_locals_from_erb.html.erb", "spec/rails_root/app/views/test/implicit_assigns.html.rb", "spec/rails_root/app/views/test/needs.html.rb", "spec/rails_root/app/views/test/needs_subclass.html.rb", "spec/rails_root/app/views/test/protected_instance_variable.html.rb", "spec/rails_root/app/views/test/render_default.html.rb", "spec/rails_root/app/views/test/render_partial.html.rb", "spec/rails_root/app/views/test/render_with_widget_as_layout.rb", "spec/rails_root/app/views/test/render_with_widget_as_layout_using_content_for.rb", "spec/rails_root/config", "spec/rails_root/config/application.rb", "spec/rails_root/config/boot.rb", "spec/rails_root/config/database.yml", "spec/rails_root/config/environment.rb", "spec/rails_root/config/environments", "spec/rails_root/config/environments/development.rb", "spec/rails_root/config/environments/production.rb", "spec/rails_root/config/environments/test.rb", "spec/rails_root/config/initializers", "spec/rails_root/config/initializers/backtrace_silencers.rb", "spec/rails_root/config/initializers/inflections.rb", "spec/rails_root/config/initializers/mime_types.rb", "spec/rails_root/config/initializers/secret_token.rb", "spec/rails_root/config/initializers/session_store.rb", "spec/rails_root/config/locales", "spec/rails_root/config/locales/en.yml", "spec/rails_root/config/routes.rb", "spec/rails_root/config.ru", "spec/rails_root/db", "spec/rails_root/db/seeds.rb", "spec/rails_root/doc", "spec/rails_root/doc/README_FOR_APP", "spec/rails_root/Gemfile", "spec/rails_root/Gemfile.lock", "spec/rails_root/lib", "spec/rails_root/lib/tasks", "spec/rails_root/log", "spec/rails_root/log/test.log", "spec/rails_root/public", "spec/rails_root/public/404.html", "spec/rails_root/public/422.html", "spec/rails_root/public/500.html", "spec/rails_root/public/dispatch.cgi", "spec/rails_root/public/dispatch.fcgi", "spec/rails_root/public/dispatch.rb", "spec/rails_root/public/favicon.ico", "spec/rails_root/public/images", "spec/rails_root/public/images/rails.png", "spec/rails_root/public/index.html", "spec/rails_root/public/javascripts", "spec/rails_root/public/javascripts/application.js", "spec/rails_root/public/javascripts/controls.js", "spec/rails_root/public/javascripts/dragdrop.js", "spec/rails_root/public/javascripts/effects.js", "spec/rails_root/public/javascripts/prototype.js", "spec/rails_root/public/javascripts/rails.js", "spec/rails_root/public/robots.txt", "spec/rails_root/public/stylesheets", "spec/rails_root/Rakefile", "spec/rails_root/README", "spec/rails_root/script", "spec/rails_root/script/about", "spec/rails_root/script/console", "spec/rails_root/script/destroy", "spec/rails_root/script/generate", "spec/rails_root/script/performance", "spec/rails_root/script/performance/benchmarker", "spec/rails_root/script/performance/profiler", "spec/rails_root/script/performance/request", "spec/rails_root/script/plugin", "spec/rails_root/script/process", "spec/rails_root/script/process/inspector", "spec/rails_root/script/process/reaper", "spec/rails_root/script/process/spawner", "spec/rails_root/script/rails", "spec/rails_root/script/runner", "spec/rails_root/script/server", "spec/rails_root/spec", "spec/rails_root/spec/form_builder_spec.rb", "spec/rails_root/spec/rails_helpers_spec.rb", "spec/rails_root/spec/rails_spec_helper.rb", "spec/rails_root/spec/rails_widget_spec.rb", "spec/rails_root/spec/render_spec.rb", "spec/rails_root/test", "spec/rails_root/test/performance", "spec/rails_root/test/performance/browsing_test.rb", "spec/rails_root/test/test_helper.rb", "spec/rails_root/vendor", "spec/rails_root/vendor/plugins", "spec/spec_helper.rb", "spec/web", "spec/web/article_spec.rb"]
+ s.test_files = ["Rakefile", "Gemfile", "spec/erect", "spec/erect/erect_rails_spec.rb", "spec/erect/erect_spec.rb", "spec/erect/erected_spec.rb", "spec/erect/rhtml_parser_spec.rb", "spec/erector", "spec/erector/caching_spec.rb", "spec/erector/convenience_spec.rb", "spec/erector/dependency_spec.rb", "spec/erector/externals_spec.rb", "spec/erector/hello_from_readme.rb", "spec/erector/hello_from_readme_spec.rb", "spec/erector/html_spec.rb", "spec/erector/indentation_spec.rb", "spec/erector/inline_spec.rb", "spec/erector/jquery_spec.rb", "spec/erector/mixin_spec.rb", "spec/erector/needs_spec.rb", "spec/erector/output_spec.rb", "spec/erector/promise_spec.rb", "spec/erector/sample-file.txt", "spec/erector/sass_spec.rb", "spec/erector/tag_spec.rb", "spec/erector/unicode_builder_spec.rb", "spec/erector/widget_spec.rb", "spec/erector/widgets", "spec/erector/widgets/field_table_spec.rb", "spec/erector/widgets/form_spec.rb", "spec/erector/widgets/page_spec.rb", "spec/erector/widgets/table_spec.rb", "spec/erector/xml_widget_spec.rb", "spec/rails2", "spec/rails2/erect_rails_spec.rb", "spec/rails2/rails_app", "spec/rails2/rails_app/app", "spec/rails2/rails_app/app/controllers", "spec/rails2/rails_app/app/controllers/application_controller.rb", "spec/rails2/rails_app/app/helpers", "spec/rails2/rails_app/app/helpers/application_helper.rb", "spec/rails2/rails_app/app/helpers/rails_helpers_spec_helper.rb", "spec/rails2/rails_app/app/helpers/test_helper.rb", "spec/rails2/rails_app/app/views", "spec/rails2/rails_app/app/views/test", "spec/rails2/rails_app/app/views/test/_erb.erb", "spec/rails2/rails_app/app/views/test/_erector.rb", "spec/rails2/rails_app/app/views/test/_partial_with_locals.rb", "spec/rails2/rails_app/app/views/test/bare.rb", "spec/rails2/rails_app/app/views/test/erb_from_erector.html.rb", "spec/rails2/rails_app/app/views/test/erector_from_erb.html.erb", "spec/rails2/rails_app/app/views/test/erector_with_locals_from_erb.html.erb", "spec/rails2/rails_app/app/views/test/implicit_assigns.html.rb", "spec/rails2/rails_app/app/views/test/needs.html.rb", "spec/rails2/rails_app/app/views/test/needs_subclass.html.rb", "spec/rails2/rails_app/app/views/test/protected_instance_variable.html.rb", "spec/rails2/rails_app/app/views/test/render_default.html.rb", "spec/rails2/rails_app/app/views/test/render_partial.html.rb", "spec/rails2/rails_app/config", "spec/rails2/rails_app/config/boot.rb", "spec/rails2/rails_app/config/database.yml", "spec/rails2/rails_app/config/environment.rb", "spec/rails2/rails_app/config/environments", "spec/rails2/rails_app/config/environments/development.rb", "spec/rails2/rails_app/config/environments/production.rb", "spec/rails2/rails_app/config/environments/test.rb", "spec/rails2/rails_app/config/initializers", "spec/rails2/rails_app/config/initializers/backtrace_silencers.rb", "spec/rails2/rails_app/config/initializers/cookie_verification_secret.rb", "spec/rails2/rails_app/config/initializers/inflections.rb", "spec/rails2/rails_app/config/initializers/mime_types.rb", "spec/rails2/rails_app/config/initializers/new_rails_defaults.rb", "spec/rails2/rails_app/config/initializers/session_store.rb", "spec/rails2/rails_app/config/locales", "spec/rails2/rails_app/config/locales/en.yml", "spec/rails2/rails_app/config/routes.rb", "spec/rails2/rails_app/db", "spec/rails2/rails_app/db/development.sqlite3", "spec/rails2/rails_app/db/schema.rb", "spec/rails2/rails_app/db/seeds.rb", "spec/rails2/rails_app/doc", "spec/rails2/rails_app/doc/README_FOR_APP", "spec/rails2/rails_app/Gemfile", "spec/rails2/rails_app/Gemfile.lock", "spec/rails2/rails_app/log", "spec/rails2/rails_app/log/development.log", "spec/rails2/rails_app/log/production.log", "spec/rails2/rails_app/log/server.log", "spec/rails2/rails_app/log/test.log", "spec/rails2/rails_app/public", "spec/rails2/rails_app/public/404.html", "spec/rails2/rails_app/public/422.html", "spec/rails2/rails_app/public/500.html", "spec/rails2/rails_app/public/favicon.ico", "spec/rails2/rails_app/public/images", "spec/rails2/rails_app/public/images/rails.png", "spec/rails2/rails_app/public/index.html", "spec/rails2/rails_app/public/javascripts", "spec/rails2/rails_app/public/javascripts/application.js", "spec/rails2/rails_app/public/javascripts/controls.js", "spec/rails2/rails_app/public/javascripts/dragdrop.js", "spec/rails2/rails_app/public/javascripts/effects.js", "spec/rails2/rails_app/public/javascripts/prototype.js", "spec/rails2/rails_app/public/robots.txt", "spec/rails2/rails_app/Rakefile", "spec/rails2/rails_app/README", "spec/rails2/rails_app/script", "spec/rails2/rails_app/script/about", "spec/rails2/rails_app/script/console", "spec/rails2/rails_app/script/dbconsole", "spec/rails2/rails_app/script/destroy", "spec/rails2/rails_app/script/generate", "spec/rails2/rails_app/script/performance", "spec/rails2/rails_app/script/performance/benchmarker", "spec/rails2/rails_app/script/performance/profiler", "spec/rails2/rails_app/script/plugin", "spec/rails2/rails_app/script/runner", "spec/rails2/rails_app/script/server", "spec/rails2/rails_app/spec", "spec/rails2/rails_app/spec/rails_helpers_spec.rb", "spec/rails2/rails_app/spec/rails_spec_helper.rb", "spec/rails2/rails_app/spec/rails_widget_spec.rb", "spec/rails2/rails_app/spec/render_spec.rb", "spec/rails2/rails_app/test", "spec/rails2/rails_app/test/performance", "spec/rails2/rails_app/test/performance/browsing_test.rb", "spec/rails2/rails_app/test/test_helper.rb", "spec/rails_root", "spec/rails_root/app", "spec/rails_root/app/controllers", "spec/rails_root/app/controllers/application.rb", "spec/rails_root/app/controllers/application_controller.rb", "spec/rails_root/app/helpers", "spec/rails_root/app/helpers/application_helper.rb", "spec/rails_root/app/views", "spec/rails_root/app/views/layouts", "spec/rails_root/app/views/layouts/application.html.erb", "spec/rails_root/app/views/layouts/widget_as_layout.rb", "spec/rails_root/app/views/test", "spec/rails_root/app/views/test/_erb.erb", "spec/rails_root/app/views/test/_erector.rb", "spec/rails_root/app/views/test/_partial_with_locals.rb", "spec/rails_root/app/views/test/bare.rb", "spec/rails_root/app/views/test/erb_from_erector.html.rb", "spec/rails_root/app/views/test/erector_from_erb.html.erb", "spec/rails_root/app/views/test/erector_with_locals_from_erb.html.erb", "spec/rails_root/app/views/test/implicit_assigns.html.rb", "spec/rails_root/app/views/test/needs.html.rb", "spec/rails_root/app/views/test/needs_subclass.html.rb", "spec/rails_root/app/views/test/protected_instance_variable.html.rb", "spec/rails_root/app/views/test/render_default.html.rb", "spec/rails_root/app/views/test/render_partial.html.rb", "spec/rails_root/app/views/test/render_with_widget_as_layout.rb", "spec/rails_root/app/views/test/render_with_widget_as_layout_using_content_for.rb", "spec/rails_root/config", "spec/rails_root/config/application.rb", "spec/rails_root/config/boot.rb", "spec/rails_root/config/database.yml", "spec/rails_root/config/environment.rb", "spec/rails_root/config/environments", "spec/rails_root/config/environments/development.rb", "spec/rails_root/config/environments/production.rb", "spec/rails_root/config/environments/test.rb", "spec/rails_root/config/initializers", "spec/rails_root/config/initializers/backtrace_silencers.rb", "spec/rails_root/config/initializers/inflections.rb", "spec/rails_root/config/initializers/mime_types.rb", "spec/rails_root/config/initializers/secret_token.rb", "spec/rails_root/config/initializers/session_store.rb", "spec/rails_root/config/locales", "spec/rails_root/config/locales/en.yml", "spec/rails_root/config/routes.rb", "spec/rails_root/config.ru", "spec/rails_root/db", "spec/rails_root/db/seeds.rb", "spec/rails_root/doc", "spec/rails_root/doc/README_FOR_APP", "spec/rails_root/Gemfile", "spec/rails_root/lib", "spec/rails_root/lib/tasks", "spec/rails_root/log", "spec/rails_root/log/test.log", "spec/rails_root/public", "spec/rails_root/public/404.html", "spec/rails_root/public/422.html", "spec/rails_root/public/500.html", "spec/rails_root/public/dispatch.cgi", "spec/rails_root/public/dispatch.fcgi", "spec/rails_root/public/dispatch.rb", "spec/rails_root/public/favicon.ico", "spec/rails_root/public/images", "spec/rails_root/public/images/rails.png", "spec/rails_root/public/index.html", "spec/rails_root/public/javascripts", "spec/rails_root/public/javascripts/application.js", "spec/rails_root/public/javascripts/controls.js", "spec/rails_root/public/javascripts/dragdrop.js", "spec/rails_root/public/javascripts/effects.js", "spec/rails_root/public/javascripts/prototype.js", "spec/rails_root/public/javascripts/rails.js", "spec/rails_root/public/robots.txt", "spec/rails_root/public/stylesheets", "spec/rails_root/Rakefile", "spec/rails_root/README", "spec/rails_root/script", "spec/rails_root/script/about", "spec/rails_root/script/console", "spec/rails_root/script/destroy", "spec/rails_root/script/generate", "spec/rails_root/script/performance", "spec/rails_root/script/performance/benchmarker", "spec/rails_root/script/performance/profiler", "spec/rails_root/script/performance/request", "spec/rails_root/script/plugin", "spec/rails_root/script/process", "spec/rails_root/script/process/inspector", "spec/rails_root/script/process/reaper", "spec/rails_root/script/process/spawner", "spec/rails_root/script/rails", "spec/rails_root/script/runner", "spec/rails_root/script/server", "spec/rails_root/spec", "spec/rails_root/spec/form_builder_spec.rb", "spec/rails_root/spec/rails_helpers_spec.rb", "spec/rails_root/spec/rails_spec_helper.rb", "spec/rails_root/spec/rails_widget_spec.rb", "spec/rails_root/spec/render_spec.rb", "spec/rails_root/test", "spec/rails_root/test/performance", "spec/rails_root/test/performance/browsing_test.rb", "spec/rails_root/test/test_helper.rb", "spec/rails_root/vendor", "spec/rails_root/vendor/plugins", "spec/spec_helper.rb", "spec/web", "spec/web/article_spec.rb"]
if s.respond_to? :specification_version then
s.specification_version = 3
@@ -95,7 +95,7 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<sass>, [">= 0"])
s.add_development_dependency(%q<erubis>, [">= 0"])
s.add_development_dependency(%q<rdoc>, ["~> 3.4"])
- s.add_development_dependency(%q<wrong>, [">= 0.5.4"])
+ s.add_development_dependency(%q<wrong>, [">= 0"])
else
s.add_dependency(%q<treetop>, [">= 1.2.3"])
s.add_dependency(%q<activesupport>, ["~> 3"])
@@ -108,7 +108,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<sass>, [">= 0"])
s.add_dependency(%q<erubis>, [">= 0"])
s.add_dependency(%q<rdoc>, ["~> 3.4"])
- s.add_dependency(%q<wrong>, [">= 0.5.4"])
+ s.add_dependency(%q<wrong>, [">= 0"])
end
else
s.add_dependency(%q<treetop>, [">= 1.2.3"])
@@ -122,7 +122,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<sass>, [">= 0"])
s.add_dependency(%q<erubis>, [">= 0"])
s.add_dependency(%q<rdoc>, ["~> 3.4"])
- s.add_dependency(%q<wrong>, [">= 0.5.4"])
+ s.add_dependency(%q<wrong>, [">= 0"])
end
end
View
10 lib/erector/rails3.rb
@@ -120,6 +120,16 @@ def render(*args, &block)
rawtext(captured)
end
+ # Rails content_for is output if and only if no block given
+ def content_for(*args,&block)
+ if block
+ helpers.content_for(*args,&block)
+ else
+ rawtext(helpers.content_for(*args))
+ ''
+ end
+ end
+
# Delegate to non-markup producing helpers via method_missing,
# returning their result directly.
def method_missing(name, *args, &block)
View
4 spec/erector/hello_from_readme_spec.rb
@@ -3,9 +3,9 @@
describe "Hello World example from README" do
it "works" do
- Dir.chdir(here) do
+ Dir.chdir('/tmp') do
clear_bundler_env
- html = sys "ruby hello_from_readme.rb"
+ html = `ruby #{File.join(here,'hello_from_readme.rb')} 2>&1`
html.should == "<html><head><title>Welcome page</title></head><body><p>Hello, world</p></body></html>\n"
end
end
View
14 spec/rails_root/app/views/layouts/application.html.erb
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>RailsRoot</title>
- <%= stylesheet_link_tag :all %>
- <%= javascript_include_tag :defaults %>
- <%= csrf_meta_tag %>
-</head>
-<body>
-
-<%= yield %>
-
-</body>
-</html>
View
2  spec/rails_root/app/views/layouts/erb_as_layout.html.erb
@@ -0,0 +1,2 @@
+<%= @layout_content %>
+<%= content_for :layout %>
View
4 spec/rails_root/app/views/layouts/widget_as_layout.rb
@@ -1,8 +1,8 @@
class Views::Layouts::WidgetAsLayout < Erector::Widget
def content
- text content_for(:top) if content_for?(:top)
+ content_for(:top) if content_for?(:top)
text @before || "BEFORE"
- rawtext content_for(:layout)
+ content_for(:layout)
text @after || "AFTER"
end
end
View
1  spec/rails_root/app/views/test/render_default_erb_with_layout.html.erb
@@ -0,0 +1 @@
+<%= @erb_content %>
View
5 spec/rails_root/app/views/test/render_default_widget_with_layout.html.rb
@@ -0,0 +1,5 @@
+class Views::Test::RenderDefaultWidgetWithLayout < Erector::Widget
+ def content
+ text "#{@widget_content}"
+ end
+end
View
38 spec/rails_root/spec/rails_helpers_spec.rb
@@ -2,10 +2,10 @@
describe Erector::Rails do
before do
- @controller = ActionController::Base.new
+ @controller = ActionController::Base.new
@controller.request = ActionController::TestRequest.new
- @view = ActionView::Base.new
+ @view = ActionView::Base.new
@view.controller = @controller
def @view.protect_against_forgery?
@@ -70,26 +70,32 @@ def test_render(&block)
Rails.application.routes.draw do
root :to => "rails_helpers_spec#index"
end
+ @app_controller = ApplicationController.new
+ @app_controller.request = ActionController::TestRequest.new
+ def app_render(&block)
+ Erector::Rails.render(Erector.inline(&block), @app_controller.view_context)
+ end
+
end
it "can be called directly" do
- test_render do
+ app_render do
text root_path
end.should == "/"
end
it "can be called via parent" do
- test_render do
+ app_render do
text parent.root_path
end.should == "/"
end
it "respects default_url_options defined by the controller" do
- def @controller.default_url_options(options = nil)
+ def @app_controller.default_url_options(options = nil)
{ :host => "www.override.com" }
end
- test_render do
+ app_render do
text root_url
end.should == "http://www.override.com/"
end
@@ -151,14 +157,16 @@ def @controller.default_url_options(options = nil)
end
end
- [:sortable_element,
- :draggable_element,
- :drop_receiving_element].each do |helper|
- describe "##{helper}" do
- it "renders helper js" do
- test_render do
- send(helper, "rails", :url => "/foo")
- end.should =~ %r{<script type="text/javascript">.*</script>}m
+ if defined?(ActionView::Helpers::ScriptaculousHelper)
+ [:sortable_element,
+ :draggable_element,
+ :drop_receiving_element].each do |helper|
+ describe "##{helper}" do
+ it "renders helper js" do
+ test_render do
+ send(helper, "rails", :url => "/foo")
+ end.should =~ %r{<script type="text/javascript">.*</script>}m
+ end
end
end
end
@@ -207,7 +215,7 @@ def @controller.default_url_options(options = nil)
it "can be called from a nested widget" do
test_render do
- widget Erector.inline { form_for(:something, :url => "/test") {|form| form.text_field :my_input} }
+ widget Erector.inline { form_for(:something, :url => "/test") { |form| form.text_field :my_input } }
end.should =~ /^<form/
end
View
6 spec/rails_root/spec/rails_widget_spec.rb
@@ -65,16 +65,16 @@ def test_render(&block)
describe "escaping" do
it "escapes non-safe strings" do
- erector { text "<>&" }.should == "&lt;&gt;&amp;"
+ test_render { text "<>&" }.should == "&lt;&gt;&amp;"
end
it "does not escape safe strings" do
- erector { text "<>&".html_safe }.should == "<>&"
+ test_render { text "<>&".html_safe }.should == "<>&"
end
it "returns safe strings from capture" do
captured = nil
- erector do
+ test_render do
captured = capture {}
end
captured.should be_html_safe
View
137 spec/rails_root/spec/render_spec.rb
@@ -4,22 +4,35 @@
class TestController < ActionController::Base
# Let exceptions propagate rather than generating the usual error page.
include ActionController::TestCase::RaiseActionExceptions
-
+
# We need this, because we reference Views::Test::Needs below, and it
# doesn't auto-load otherwise.
require 'views/test/needs.html.rb'
+ # replicate deprecated use for rails <3.2
+ if (Gem::Version.new(Rails.version) < Gem::Version.new('3.2.0') rescue false)
+ def render(*args, &block)
+ options = args.extract_options!
+ if options[:template]
+ handlers = options.delete(:handlers)
+ format = '.html' unless options.delete(:bare)
+ options[:template] += "#{format}.#{handlers.first}"
+ end
+ render(*(args << options), &block)
+ end
+ end
+
def render_widget_class
@foobar = "foobar"
render :widget => TestWidget
end
-
+
def render_widget_with_ignored_controller_variables
@foo = "foo"
@baz = "baz"
render :widget => NeedsWidget
end
-
+
def render_widget_with_extra_controller_variables
with_ignoring_extra_controller_assigns(NeedsWidget, false) do
@foo = "foo"
@@ -42,29 +55,29 @@ def render_with_rails_options
def render_template_with_implicit_assigns
@foobar = "foobar"
- render :template => "test/implicit_assigns.html.rb"
+ render :template => "test/implicit_assigns", :handlers => [:rb]
end
def render_template_with_protected_instance_variable
- render :template => "test/protected_instance_variable.html.rb"
+ render :template => "test/protected_instance_variable", :handlers => [:rb]
end
-
+
def render_template_with_excess_variables
with_ignoring_extra_controller_assigns(Views::Test::Needs, false) do
@foobar = "foobar"
@barfoo = "barfoo"
- render :template => 'test/render_default.html.rb'
+ render :template => 'test/render_default', :handlers => [:rb]
end
end
-
+
def render_needs_template_with_excess_variables
with_ignoring_extra_controller_assigns(Views::Test::Needs, false) do
@foobar = "foobar"
@barfoo = "barfoo"
- render :template => 'test/needs.html.rb'
+ render :template => 'test/needs', :handlers => [:rb]
end
end
-
+
def with_ignoring_extra_controller_assigns(klass, value)
old_value = klass.ignore_extra_controller_assigns
begin
@@ -74,21 +87,21 @@ def with_ignoring_extra_controller_assigns(klass, value)
klass.ignore_extra_controller_assigns = old_value
end
end
-
+
def render_needs_template_with_excess_variables_and_ignoring_extras
@foobar = "foobar"
@barfoo = "barfoo"
- render :template => 'test/needs.html.rb'
+ render :template => 'test/needs', :handlers => [:rb]
end
-
+
def render_needs_subclass_template_with_excess_variables_and_ignoring_extras
@foobar = "foobar"
@barfoo = "barfoo"
- render :template => 'test/needs_subclass.html.rb'
+ render :template => 'test/needs_subclass', :handlers => [:rb]
end
def render_bare_rb
- render :template => "test/bare.rb"
+ render :template => "test/bare", :handlers => [:rb], :bare => true
end
def render_default
@@ -97,48 +110,48 @@ def render_default
def render_template_with_partial
@foobar = "foobar"
- render :template => "test/render_partial.html.rb"
+ render :template => "test/render_partial", :handlers => [:rb]
end
def render_erb_from_erector
@foobar = "foobar"
- render :template => "test/erb_from_erector.html.rb"
+ render :template => "test/erb_from_erector", :handlers => [:rb]
end
def render_erector_from_erb
@foobar = "foobar"
- render :template => "test/erector_from_erb.html.erb"
+ render :template => "test/erector_from_erb", :handlers => [:erb]
end
def render_erector_with_locals_from_erb
@local_foo = "hihi"
@local_bar = "byebye"
- render :template => 'test/erector_with_locals_from_erb.html.erb'
+ render :template => 'test/erector_with_locals_from_erb', :handlers => [:erb]
end
def render_erector_with_locals_from_erb_defaulted
@local_foo = "hihi"
- render :template => 'test/erector_with_locals_from_erb.html.erb'
+ render :template => 'test/erector_with_locals_from_erb', :handlers => [:erb]
end
def render_erector_with_locals_from_erb_override
- @foo = "globalfoo"
+ @foo = "globalfoo"
@local_foo = "localfoo"
- render :template => 'test/erector_with_locals_from_erb.html.erb'
+ render :template => 'test/erector_with_locals_from_erb', :handlers => [:erb]
end
def render_erector_with_locals_from_erb_not_needed
@local_foo = "localfoo"
@local_baz = "unneeded"
- render :template => 'test/erector_with_locals_from_erb.html.erb'
+ render :template => 'test/erector_with_locals_from_erb', :handlers => [:erb]
end
def render_erector_partial_with_unneeded_controller_variables
@local_foo = "localfoo"
- @baz = "unneeded"
- render :template => 'test/erector_with_locals_from_erb.html.erb'
+ @baz = "unneeded"
+ render :template => 'test/erector_with_locals_from_erb', :handlers => [:erb]
end
-
+
def with_controller_assigns_propagate_to_partials(klass, value)
old_value = klass.controller_assigns_propagate_to_partials
begin
@@ -152,8 +165,8 @@ def with_controller_assigns_propagate_to_partials(klass, value)
def render_erector_partial_without_controller_variables
with_controller_assigns_propagate_to_partials(Views::Test::PartialWithLocals, false) do
@local_foo = "localfoo"
- @bar = "barbar"
- render :template => 'test/erector_with_locals_from_erb.html.erb'
+ @bar = "barbar"
+ render :template => 'test/erector_with_locals_from_erb', :handlers => [:erb]
end
end
@@ -162,18 +175,28 @@ def render_with_needs
@bar = "bar"
render :widget => NeedsWidget
end
-
+
def render_with_widget_as_layout
render :layout => "layouts/widget_as_layout"
end
-
+
+ def render_default_widget_with_layout
+ @widget_content = "widget content"
+ @layout_content = "layout content"
+ end
+
+ def render_default_erb_with_layout
+ @erb_content = "erb content"
+ @layout_content = "layout content"
+ end
+
def render_with_widget_as_layout_and_vars
@before = "Breakfast"
@during = "Lunch"
- @after = "Dinner"
+ @after = "Dinner"
render :template => "test/render_with_widget_as_layout", :layout => "layouts/widget_as_layout"
end
-
+
def render_with_widget_as_layout_using_content_for
render :template => "test/render_with_widget_as_layout_using_content_for", :layout => "layouts/widget_as_layout"
end
@@ -188,7 +211,7 @@ def content_method
text "content_method"
end
end
-
+
class TestFormWidget < Erector::Widget
def content
form_tag('/') do
@@ -200,7 +223,7 @@ def content
class NeedsWidget < Erector::Widget
needs :foo, :bar => true
-
+
def content
text "foo #{@foo} bar #{@bar}"
end
@@ -219,11 +242,11 @@ def test_action(action)
it "should render a widget instance with explicit assigns" do
test_action(:render_widget_instance).should == "foobar"
end
-
+
it "should render a widget class with implicit assigns and ignoring extra variables" do
test_action(:render_widget_with_ignored_controller_variables).should == "foo foo bar true"
end
-
+
it "should raise when rendering a widget class with implicit assigns and too many variables" do
proc { test_action(:render_widget_with_extra_controller_variables) }.should raise_error(ArgumentError, /Excess parameters?.*: .*baz/)
end
@@ -245,7 +268,7 @@ def test_action(action)
it "should not include protected instance variables in assigns" do
test_action(:render_template_with_protected_instance_variable).should == ""
end
-
+
it "should render a template without a .html format included" do
test_action(:render_bare_rb).should == "Bare"
end
@@ -253,15 +276,15 @@ def test_action(action)
it "should render a template with excess controller variables" do
test_action(:render_template_with_excess_variables).should == "Default foobar"
end
-
+
it "should raise if rendering a #needs template with excess controller variables" do
proc { test_action(:render_needs_template_with_excess_variables) }.should raise_error(ActionView::TemplateError, /Excess parameters?.*: .*barfoo/)
end
-
+
it "should render a #needs template with excess controller variables and ignore_extra_controller_assigns" do
test_action(:render_needs_template_with_excess_variables_and_ignoring_extras).should == "Needs foobar"
end
-
+
it "should respect ignore_extra_controller_assigns in subclasses" do
test_action(:render_needs_subclass_template_with_excess_variables_and_ignoring_extras).should == "NeedsSubclass foobar"
end
@@ -277,27 +300,27 @@ def test_action(action)
it "should render an ERB template which uses an erector widget partial" do
test_action(:render_erector_from_erb).should == "Partial foobar"
end
-
+
it "should render an ERB template which uses an erector widget partial with locals" do
test_action(:render_erector_with_locals_from_erb).should == "Partial, foo hihi, bar byebye"
end
-
+
it "should render an ERB template which uses an erector widget partial with a defaulted local" do
test_action(:render_erector_with_locals_from_erb_defaulted).should == "Partial, foo hihi, bar 12345"
end
-
+
it "should override instance variables with local variables when rendering partials" do
test_action(:render_erector_with_locals_from_erb_override).should == "Partial, foo localfoo, bar 12345"
end
-
+
it "should raise if passing a local that's not needed" do
proc { test_action(:render_erector_with_locals_from_erb_not_needed) }.should raise_error(ActionView::TemplateError, /Excess parameters?.*: .*baz/)
end
-
+
it "should not pass unneeded controller variables to a partial" do
test_action(:render_erector_partial_with_unneeded_controller_variables).should == "Partial, foo localfoo, bar 12345"
end
-
+
it "should not pass controller variables to a partial at all, if requested" do
test_action(:render_erector_partial_without_controller_variables).should == "Partial, foo localfoo, bar 12345"
end
@@ -306,10 +329,30 @@ def test_action(action)
test_action(:render_default).should == "Default foobar"
end
+ it "should render a default erb template with default erb layout" do
+ TestController.layout 'erb_as_layout'
+ test_action(:render_default_erb_with_layout).should == "layout content\nerb content"
+ end
+
+ it "should render a default widget with default erb layout" do
+ TestController.layout 'erb_as_layout'
+ test_action(:render_default_widget_with_layout).should == "layout content\nwidget content"
+ end
+
+ it "should render a default erb template with default widget layout" do
+ TestController.layout 'widget_as_layout'
+ test_action(:render_default_erb_with_layout).should == "BEFOREerb contentAFTER"
+ end
+
+ it "should render a default widget with default widget layout" do
+ TestController.layout 'widget_as_layout'
+ test_action(:render_default_widget_with_layout).should == "BEFOREwidget contentAFTER"
+ end
+
it "should allow rendering widget with needs" do
proc { test_action(:render_with_needs) }.should_not raise_error
end
-
+
it "should allow using a widget as a layout" do
test_action(:render_with_widget_as_layout).should == "BEFOREDURINGAFTER"
end
Please sign in to comment.
Something went wrong with that request. Please try again.