]
+ #
+ def self.handlers
+ @_template_handlers ||= []
+ end
+
+ ##
+ # Registers a new handler as available to the output helpers
+ #
+ # ==== Examples
+ #
+ # OutputHelpers.register(OutputHelpers::HamlHandler)
+ #
+ def self.register(handler)
+ handlers << handler
+ end
+
+ class AbstractHandler
+ attr_reader :template
+
+ def initialize(template)
+ @template = template
+ end
+
+ ##
+ # Returns extension of the template
+ #
+ # ==== Examples
+ #
+ # @handler.template_extension => "erb"
+ #
+ def template_extension
+ caller.find { |c| c =~ /\/views\// }[/\.([\w]*?)\:/, 1] rescue nil
+ # "/some/path/app/views/posts/foo.html.erb:3:in `evaluate_source'"
+ # => "erb"
+ end
+
+ ##
+ # Returns an array of engines used for the template
+ #
+ # ==== Examples
+ #
+ # @handler.engines => [:erb, :erubis]
+ #
+ def engines
+ # Implemented in subclass
+ end
+
+ ##
+ # Returns true if the current template type is same as this handlers; false otherwise.
+ #
+ # ==== Examples
+ #
+ # @handler.is_type? => true
+ #
+ def is_type?
+ # Implemented in subclass
+ end
+
+ ##
+ # Returns true if the block given is of the handler's template type; false otherwise.
+ #
+ # ==== Examples
+ #
+ # @handler.block_is_type?(block) => true
+ #
+ def block_is_type?(block)
+ # Implemented in subclass
+ end
+
+ ##
+ # Captures the html from a block of template code for this handler
+ #
+ # ==== Examples
+ #
+ # @handler.capture_from_template(&block) => "...html..."
+ #
+ def capture_from_template(*args, &block)
+ # Implemented in subclass
+ end
+
+ ##
+ # Outputs the given text to the templates buffer directly
+ #
+ # ==== Examples
+ #
+ # @handler.concat_to_template("This will be output to the template buffer")
+ #
+ def concat_to_template(text="")
+ # Implemented in subclass
+ end
+ end # AbstractHandler
+ end # OutputHelpers
+ end # Helpers
+end # Padrino
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/erb_handler.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/erb_handler.rb
new file mode 100644
index 00000000..bd42c73a
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/erb_handler.rb
@@ -0,0 +1,79 @@
+module Padrino
+ module Helpers
+ module OutputHelpers
+ class ErbHandler < AbstractHandler
+ attr_reader :output_buffer
+
+ def initialize(template)
+ super
+ @output_buffer = template.instance_variable_get(:@_out_buf)
+ end
+
+ ##
+ # Returns true if the current template type is same as this handlers; false otherwise.
+ #
+ # ==== Examples
+ #
+ # @handler.is_type? => true
+ #
+ def is_type?
+ !self.output_buffer.nil?
+ end
+
+ # Captures the html from a block of template code for this handler
+ #
+ # ==== Examples
+ #
+ # @handler.capture_from_template(&block) => "...html..."
+ #
+ def capture_from_template(*args, &block)
+ self.output_buffer, _buf_was = "", self.output_buffer
+ block.call(*args)
+ ret = eval("@_out_buf", block.binding)
+ self.output_buffer = _buf_was
+ ret
+ end
+
+ ##
+ # Outputs the given text to the templates buffer directly
+ #
+ # ==== Examples
+ #
+ # @handler.concat_to_template("This will be output to the template buffer")
+ #
+ def concat_to_template(text="")
+ self.output_buffer << text if is_type? && text
+ nil
+ end
+
+ ##
+ # Returns true if the block given is of the handler's template type; false otherwise.
+ #
+ # ==== Examples
+ #
+ # @handler.block_is_type?(block) => true
+ #
+ def block_is_type?(block)
+ is_type? || (block && eval('defined?(__in_erb_template)', block.binding))
+ end
+
+ ##
+ # Returns an array of engines used for the template
+ #
+ # ==== Examples
+ #
+ # @handler.engines => [:erb, :erubis]
+ #
+ def engines
+ @_engines ||= [:erb, :erubis]
+ end
+
+ protected
+ def output_buffer=(val)
+ template.instance_variable_set(:@_out_buf, val)
+ end
+ end # ErbHandler
+ OutputHelpers.register(ErbHandler)
+ end # OutputHelpers
+ end # Helpers
+end # Padrino
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/haml_handler.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/haml_handler.rb
new file mode 100644
index 00000000..4240a11f
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/haml_handler.rb
@@ -0,0 +1,64 @@
+module Padrino
+ module Helpers
+ module OutputHelpers
+ class HamlHandler < AbstractHandler
+ ##
+ # Returns true if the current template type is same as this handlers; false otherwise.
+ #
+ # ==== Examples
+ #
+ # @handler.is_type? => true
+ #
+ def is_type?
+ template.respond_to?(:is_haml?) && template.is_haml?
+ end
+
+ ##
+ # Returns true if the block given is of the handler's template type; false otherwise.
+ #
+ # ==== Examples
+ #
+ # @handler.block_is_type?(block) => true
+ #
+ def block_is_type?(block)
+ template.block_is_haml?(block)
+ end
+
+ # Captures the html from a block of template code for this handler
+ #
+ # ==== Examples
+ #
+ # @handler.capture_from_template(&block) => "...html..."
+ #
+ def capture_from_template(*args, &block)
+ eval("_hamlout ||= @haml_buffer", block.binding) # this is for rbx
+ template.capture_haml(*args, &block)
+ end
+
+ ##
+ # Outputs the given text to the templates buffer directly
+ #
+ # ==== Examples
+ #
+ # @handler.concat_to_template("This will be output to the template buffer")
+ #
+ def concat_to_template(text="")
+ template.haml_concat(text)
+ nil
+ end
+
+ ##
+ # Returns an array of engines used for the template
+ #
+ # ==== Examples
+ #
+ # @handler.engines => [:erb, :erubis]
+ #
+ def engines
+ @_engines ||= [:haml]
+ end
+ end # HamlHandler
+ OutputHelpers.register(HamlHandler)
+ end # OutputHelpers
+ end # Helpers
+end # Padrino
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/slim_handler.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/slim_handler.rb
new file mode 100644
index 00000000..924b539b
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/slim_handler.rb
@@ -0,0 +1,82 @@
+# Make slim works with sinatra/padrino
+Slim::Engine.set_default_options(:buffer => '@_out_buf', :generator => Temple::Generators::StringBuffer) if defined?(Slim)
+
+module Padrino
+ module Helpers
+ module OutputHelpers
+ class SlimHandler < AbstractHandler
+ attr_reader :output_buffer
+
+ def initialize(template)
+ super
+ @output_buffer = template.instance_variable_get(:@_out_buf)
+ end
+
+ ##
+ # Returns true if the current template type is same as this handlers; false otherwise.
+ #
+ # ==== Examples
+ #
+ # @handler.is_type? => true
+ #
+ def is_type?
+ !self.output_buffer.nil?
+ end
+
+ # Captures the html from a block of template code for this handler
+ #
+ # ==== Examples
+ #
+ # @handler.capture_from_template(&block) => "...html..."
+ #
+ def capture_from_template(*args, &block)
+ self.output_buffer, _buf_was = "", self.output_buffer
+ block.call(*args)
+ ret = eval("@_out_buf", block.binding)
+ self.output_buffer = _buf_was
+ ret
+ end
+
+ ##
+ # Outputs the given text to the templates buffer directly
+ #
+ # ==== Examples
+ #
+ # @handler.concat_to_template("This will be output to the template buffer")
+ #
+ def concat_to_template(text="")
+ self.output_buffer << text if is_type? && text
+ nil
+ end
+
+ ##
+ # Returns true if the block given is of the handler's template type; false otherwise.
+ #
+ # ==== Examples
+ #
+ # @handler.block_is_type?(block) => true
+ #
+ def block_is_type?(block)
+ is_type? || (block && eval('defined? __in_erb_template', block.binding))
+ end
+
+ ##
+ # Returns an array of engines used for the template
+ #
+ # ==== Examples
+ #
+ # @handler.engines => [:erb, :erubis]
+ #
+ def engines
+ @_engines ||= [:slim]
+ end
+
+ protected
+ def output_buffer=(val)
+ template.instance_variable_set(:@_out_buf, val)
+ end
+ end # ErbHandler
+ OutputHelpers.register(SlimHandler)
+ end # OutputHelpers
+ end # Helpers
+end # Padrino
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/render_helpers.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/render_helpers.rb
new file mode 100644
index 00000000..a91aaf62
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/render_helpers.rb
@@ -0,0 +1,40 @@
+module Padrino
+ module Helpers
+ module RenderHelpers
+ ##
+ # Partials implementation which includes collections support
+ #
+ # ==== Examples
+ #
+ # partial 'photo/item', :object => @photo
+ # partial 'photo/item', :collection => @photos
+ # partial 'photo/item', :locals => { :foo => :bar }
+ # partial 'photo/item', :engine => :erb
+ #
+ def partial(template, options={})
+ options.reverse_merge!(:locals => {}, :layout => false)
+ path = template.to_s.split(File::SEPARATOR)
+ object_name = path[-1].to_sym
+ path[-1] = "_#{path[-1]}"
+ explicit_engine = options.delete(:engine)
+ template_path = File.join(path).to_sym
+ raise 'Partial collection specified but is nil' if options.has_key?(:collection) && options[:collection].nil?
+ if collection = options.delete(:collection)
+ options.delete(:object)
+ counter = 0
+ collection.map { |member|
+ counter += 1
+ options[:locals].merge!(object_name => member, "#{object_name}_counter".to_sym => counter)
+ render(explicit_engine, template_path, options.dup)
+ }.join("\n")
+ else
+ if member = options.delete(:object)
+ options[:locals].merge!(object_name => member)
+ end
+ render(explicit_engine, template_path, options.dup)
+ end
+ end
+ alias :render_partial :partial
+ end # RenderHelpers
+ end # Helpers
+end # Padrino
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/tag_helpers.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/tag_helpers.rb
new file mode 100644
index 00000000..ca2d97d1
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/tag_helpers.rb
@@ -0,0 +1,59 @@
+module Padrino
+ module Helpers
+ module TagHelpers
+ ##
+ # Creates an html input field with given type and options
+ #
+ # ==== Examples
+ #
+ # input_tag :text, :class => "test"
+ #
+ def input_tag(type, options = {})
+ options.reverse_merge!(:type => type)
+ tag(:input, options)
+ end
+
+ ##
+ # Creates an html tag with given name, content and options
+ #
+ # ==== Examples
+ #
+ # content_tag(:p, "hello", :class => 'light')
+ # content_tag(:p, :class => 'dark') do ... end
+ # content_tag(name, content=nil, options={}, &block)
+ #
+ def content_tag(*args, &block)
+ name = args.first
+ options = args.extract_options!
+ tag_html = block_given? ? capture_html(&block) : args[1]
+ tag_result = tag(name, options.merge(:content => tag_html))
+ block_is_template?(block) ? concat_content(tag_result) : tag_result
+ end
+
+ ##
+ # Creates an html tag with the given name and options
+ #
+ # ==== Examples
+ #
+ # tag(:br, :style => 'clear:both')
+ # tag(:p, :content => "hello", :class => 'large')
+ #
+ def tag(name, options={})
+ content, open_tag = options.delete(:content), options.delete(:open)
+ content = content.join("\n") if content.respond_to?(:join)
+ identity_tag_attributes.each { |attr| options[attr] = attr.to_s if options[attr] }
+ html_attrs = options.map { |a, v| v.nil? || v == false ? nil : "#{a}=\"#{v}\"" }.compact.join(" ")
+ base_tag = (html_attrs.present? ? "<#{name} #{html_attrs}" : "<#{name}")
+ base_tag << (open_tag ? ">" : (content ? ">#{content}#{name}>" : " />"))
+ end
+
+ private
+ ##
+ # Returns a list of attributes which can only contain an identity value (i.e selected)
+ #
+ def identity_tag_attributes
+ [:checked, :disabled, :selected, :multiple]
+ end
+ end # TagHelpers
+ end # Helpers
+end # Padrino
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/translation_helpers.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/translation_helpers.rb
new file mode 100644
index 00000000..265d3aa4
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/translation_helpers.rb
@@ -0,0 +1,21 @@
+module Padrino
+ module Helpers
+ module TranslationHelpers
+ ##
+ # Delegates to I18n.translate with no additional functionality.
+ #
+ def translate(*args)
+ I18n.translate(*args)
+ end
+ alias :t :translate
+
+ ##
+ # Delegates to I18n.localize with no additional functionality.
+ #
+ def localize(*args)
+ I18n.localize(*args)
+ end
+ alias :l :localize
+ end # TranslationHelpers
+ end # Helpers
+end # Padrino
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/padrino-helpers.gemspec b/lib/middleman/vendor/padrino-helpers-0.10.0/padrino-helpers.gemspec
new file mode 100755
index 00000000..c37285f0
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/padrino-helpers.gemspec
@@ -0,0 +1,27 @@
+#!/usr/bin/env gem build
+# encoding: utf-8
+
+require File.expand_path("../../padrino-core/lib/padrino-core/version.rb", __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = "padrino-helpers"
+ s.rubyforge_project = "padrino-helpers"
+ s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
+ s.email = "padrinorb@gmail.com"
+ s.summary = "Helpers for padrino"
+ s.homepage = "http://www.padrinorb.com"
+ s.description = "Tag helpers, asset helpers, form helpers, form builders and many more helpers for padrino"
+ s.required_rubygems_version = ">= 1.3.6"
+ s.version = Padrino.version
+ s.date = Time.now.strftime("%Y-%m-%d")
+
+ s.extra_rdoc_files = Dir["*.rdoc"]
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+ s.rdoc_options = ["--charset=UTF-8"]
+
+ s.add_dependency("padrino-core", Padrino.version)
+ s.add_dependency("i18n", "~> 0.5.0")
+end
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/app.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/app.rb
new file mode 100644
index 00000000..1c43b1e7
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/app.rb
@@ -0,0 +1,73 @@
+require 'sinatra/base'
+require 'haml'
+require 'erubis'
+require 'slim'
+
+class MarkupDemo < Sinatra::Base
+ register Padrino::Helpers
+
+ configure do
+ set :root, File.dirname(__FILE__)
+ end
+
+ get '/:engine/:file' do
+ show(params[:engine], params[:file].to_sym)
+ end
+
+ helpers do
+ # show :erb, :index
+ # show :haml, :index
+ def show(kind, template)
+ send kind.to_sym, template.to_sym
+ end
+
+ def captured_content(&block)
+ content_html = capture_html(&block)
+ "#{content_html}
"
+ end
+
+ def concat_in_p(content_html)
+ concat_content "#{content_html}
"
+ end
+
+ def determine_block_is_template(name, &block)
+ concat_content "The #{name} block passed in is a template
" if block_is_template?(block)
+ end
+
+ def ruby_not_template_block
+ determine_block_is_template('ruby') do
+ content_tag(:span, "This not a template block")
+ end
+ end
+ end
+end
+
+class MarkupUser
+ def errors; { :fake => "must be valid", :second => "must be present", :third => "must be a number", :email => "must be a email"}; end
+ def session_id; 45; end
+ def gender; 'male'; end
+ def remember_me; '1'; end
+ def permission; Permission.new; end
+ def telephone; Telephone.new; end
+ def addresses; [Address.new('Greenfield', true), Address.new('Willowrun', false)]; end
+end
+
+class Telephone
+ def number; "62634576545"; end
+end
+
+class Address
+ attr_accessor :name
+ def initialize(name, existing); @name, @existing = name, existing; end
+ def new_record?; !@existing; end
+ def id; @existing ? 25 : nil; end
+end
+
+class Permission
+ def can_edit; true; end
+ def can_delete; false; end
+end
+
+module Outer
+ class UserAccount; end
+end
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.erb
new file mode 100644
index 00000000..d5471a4d
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.erb
@@ -0,0 +1,14 @@
+<% @content = captured_content do %>
+ Captured Line 1
+ Captured Line 2
+<% end %>
+<%= @content %>
+
+<% concat_in_p('Concat Line 3') %>
+
+<% determine_block_is_template('erb') do %>
+ This is erb
+ This is erb
+<% end %>
+
+<% ruby_not_template_block %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.haml
new file mode 100644
index 00000000..54831676
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.haml
@@ -0,0 +1,12 @@
+- @content = captured_content do
+ %span Captured Line 1
+ %span Captured Line 2
+= @content
+
+- concat_in_p('Concat Line 3')
+
+- determine_block_is_template('haml') do
+ %span This is haml
+ %span This is haml
+
+- ruby_not_template_block
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.slim
new file mode 100644
index 00000000..39fe7dd1
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.slim
@@ -0,0 +1,13 @@
+-@content = captured_content do
+ span Captured Line 1
+ span Captured Line 2
+
+==@content
+
+==determine_block_is_template('slim') do
+ span This is slim
+ span This is slim
+
+==concat_in_p('Concat Line 3')
+
+==ruby_not_template_block
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.erb
new file mode 100644
index 00000000..789b90b9
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.erb
@@ -0,0 +1,11 @@
+<% content_for :demo do %>
+ This is content yielded from a content_for
+<% end %>
+
+<%= yield_content :demo %>
+
+<% content_for :demo2 do |fname, lname| %>
+ This is content yielded with name <%= fname + " " + lname %>
+<% end %>
+
+<%= yield_content :demo2, "Johnny", "Smith" %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.haml
new file mode 100644
index 00000000..00656e87
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.haml
@@ -0,0 +1,9 @@
+- content_for :demo do
+ %h1 This is content yielded from a content_for
+
+.demo= yield_content :demo
+
+- content_for :demo2 do |fname, lname|
+ %h1 This is content yielded with name #{fname + " " + lname}
+
+.demo2= yield_content :demo2, "Johnny", "Smith"
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.slim
new file mode 100644
index 00000000..1eee26b2
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.slim
@@ -0,0 +1,9 @@
+- content_for :demo do
+ h1 This is content yielded from a content_for
+
+.demo== yield_content :demo
+
+- content_for :demo2 do |fname, lname|
+ h1 This is content yielded with name #{fname + " " + lname}
+
+.demo2== yield_content :demo2, "Johnny", "Smith"
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.erb
new file mode 100644
index 00000000..a73f6d3b
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.erb
@@ -0,0 +1,11 @@
+<%= content_tag :p, "Test 1", :class => 'test', :id => "test1" %>
+
+<%= content_tag :p, "Test 2" %>
+
+<% content_tag(:p, :class => 'test', :id => 'test3') do %>
+ Test 3
+<% end %>
+
+<% content_tag(:p) do %>
+ Test 4
+<% end %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.haml
new file mode 100644
index 00000000..780a2332
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.haml
@@ -0,0 +1,9 @@
+= content_tag :p, "Test 1", :class => 'test', :id => "test1"
+
+= content_tag :p, "Test 2"
+
+- content_tag(:p, :class => 'test', :id => 'test3') do
+ %span Test 3
+
+- content_tag(:p) do
+ %span Test 4
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.slim
new file mode 100644
index 00000000..84e42bf3
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.slim
@@ -0,0 +1,9 @@
+==content_tag :p, "Test 1", :class => 'test', :id => "test1"
+
+== content_tag :p, "Test 2"
+
+==content_tag(:p, :class => 'test', :id => 'test3') do
+ span Test 3
+
+==content_tag(:p) do
+ span Test 4
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.erb
new file mode 100644
index 00000000..a992c8be
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.erb
@@ -0,0 +1,5 @@
+<%= current_engine %>
+<%= haml :'partials/_haml' %>
+<%= erb :'partials/_erb' %>
+<%= slim :'partials/_slim' %>
+<%= current_engine %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.haml
new file mode 100644
index 00000000..78bfc262
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.haml
@@ -0,0 +1,5 @@
+%p.start= current_engine
+%p.haml= haml :'partials/_haml'
+%p.erb= erb :'partials/_erb'
+%p.slim= slim :'partials/_slim'
+%p.end= current_engine
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.slim
new file mode 100644
index 00000000..d7c6b4d2
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.slim
@@ -0,0 +1,5 @@
+p.start= current_engine
+p.haml= haml :'partials/_haml'
+p.erb= erb :'partials/_erb'
+p.slim= slim :'partials/_slim'
+p.end= current_engine
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.erb
new file mode 100644
index 00000000..4ddc70cb
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.erb
@@ -0,0 +1,20 @@
+<% @user = MarkupUser.new %>
+<% form_for @user , '/demo1', :id => 'demo-fields-for' do |f| %>
+ <%= f.text_field :gender %>
+ <% fields_for @user.permission do |permission| %>
+ <%= permission.check_box :can_edit %>
+ <%= permission.check_box :can_delete %>
+ <% end %>
+ <% f.fields_for :telephone do |child_form| %>
+ <%= child_form.label :number %>
+ <%= child_form.text_field :number %>
+ <% end %>
+ <% f.fields_for :addresses do |child_form| %>
+ <%= child_form.label :name %>
+ <%= child_form.text_field :name %>
+ <% unless child_form.object.new_record? %>
+ <%= child_form.check_box '_destroy' %>
+ <%= child_form.label '_destroy', :caption => 'Remove' %>
+ <% end %>
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.haml
new file mode 100644
index 00000000..115495c4
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.haml
@@ -0,0 +1,15 @@
+- @user = MarkupUser.new
+- form_for @user , '/demo1', :id => 'demo-fields-for' do |f|
+ = f.text_field :gender
+ - fields_for @user.permission do |permission|
+ = permission.check_box :can_edit
+ = permission.check_box :can_delete
+ - f.fields_for :telephone do |child_form|
+ = child_form.label :number
+ = child_form.text_field :number
+ - f.fields_for :addresses do |child_form|
+ = child_form.label :name
+ = child_form.text_field :name
+ - unless child_form.object.new_record?
+ = child_form.check_box '_destroy'
+ = child_form.label '_destroy', :caption => 'Remove'
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.slim
new file mode 100644
index 00000000..75007ba6
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.slim
@@ -0,0 +1,15 @@
+- @user = MarkupUser.new
+== form_for @user , '/demo1', :id => 'demo-fields-for' do |f|
+ == f.text_field :gender
+ == fields_for @user.permission do |permission|
+ == permission.check_box :can_edit
+ == permission.check_box :can_delete
+ == f.fields_for :telephone do |child_form|
+ == child_form.label :number
+ == child_form.text_field :number
+ == f.fields_for :addresses do |child_form|
+ == child_form.label :name
+ == child_form.text_field :name
+ - unless child_form.object.new_record?
+ == child_form.check_box '_destroy'
+ == child_form.label '_destroy', :caption => 'Remove'
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.erb
new file mode 100644
index 00000000..184e623e
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.erb
@@ -0,0 +1,56 @@
+<% form_for MarkupUser.new, '/demo', :id => 'demo' do |f| %>
+ <%= f.error_messages(:header_message => "custom MarkupUser cannot be saved!") %>
+ <%= f.hidden_field :session_id %>
+
+ <%= f.label :username, :caption => "Login: ", :class => 'user-label' %>
+ <%= f.text_field :username, :class => 'user-text', :value => "John" %>
+
+
+ <%= f.label :email, :caption => "Email", :class => 'user-email' %>
+ <%= f.text_field :email %>
+
+
+ <%= f.label :password %>
+ <%= f.password_field :password, :class => 'user-password', :value => "secret" %>
+
+
+ <%= f.label :photo %>
+ <%= f.file_field :photo, :class => 'user-photo' %>
+
+
+ <%= f.label :about, :caption => "About Me: " %>
+ <%= f.text_area :about, :class => 'user-about' %>
+
+
+ <%= f.label :gender, :caption => "Your gender: " %>
+ <%= f.radio_button :gender, :value => 'male' %>
+ <%= f.radio_button :gender, :value => 'female' %>
+
+
+ <%= f.label :country, :caption => "Your country" %>
+ <%= f.select :country, :options => ['USA', 'Canada', 'Mexico'], :selected => 'USA', :class => 'selector' %>
+
+
+ <%= f.label :remember_me %>
+ <%= f.check_box :remember_me, :value => '1' %>
+
+ <%= f.submit "Create", :class => 'success', :id => 'demo-button' %>
+ <%= f.image_submit "buttons/post.png", :class => 'success', :id => 'image-button' %>
+<% end %>
+
+<% form_for MarkupUser.new, '/another_demo', :id => 'demo2', :method => 'get' do |f| %>
+ <%= f.error_messages :header_message => "custom MarkupUser cannot be saved!" %>
+ <%= f.hidden_field :session_id %>
+ <%= f.text_field_block :username, { :class => 'input' }, { :caption => 'Nickname: ', :class => 'label' } %>
+ <%= f.password_field_block :code, { :class => 'input' } %>
+ <%= f.text_area_block :about, { :class => 'textarea' } %>
+ <%= f.file_field_block :photo, { :class => 'upload' } %>
+ <%= f.check_box_block :remember_me, { :class => 'checker' } %>
+ <%= f.select_block :state, :options => ['California', 'Texas'], :class => 'selector' %>
+ <%= f.submit_block "Create", { :class => 'button' } %>
+ <%= f.image_submit_block "buttons/ok.png", { :class => 'image' } %>
+<% end %>
+
+<% form_for :markup_user, '/third_demo', :id => 'demo3', :method => 'get' do |f| %>
+ <%= f.text_field_block :username %>
+<% end %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.haml
new file mode 100644
index 00000000..3a798bee
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.haml
@@ -0,0 +1,47 @@
+- form_for MarkupUser.new, '/demo', :id => 'demo' do |f|
+ = f.error_messages(:header_message => "custom MarkupUser cannot be saved!")
+ = f.hidden_field :session_id
+ %p
+ = f.label :username, :caption => "Login: ", :class => 'user-label'
+ = f.text_field :username, :class => 'user-text', :value => "John"
+ %p
+ = f.label :email, :caption => "Email", :class => 'user-email'
+ = f.text_field :email
+ %p
+ = f.label :password
+ = f.password_field :password, :class => 'user-password', :value => "secret"
+ %p
+ = f.label :photo
+ = f.file_field :photo, :class => 'user-photo'
+ %p
+ = f.label :about, :caption => "About Me: "
+ = f.text_area :about, :class => 'user-about'
+ %p
+ = f.label :gender, :caption => "Your gender: "
+ = f.radio_button :gender, :value => 'male'
+ = f.radio_button :gender, :value => 'female'
+ %p
+ = f.label :country, :caption => "Your country"
+ = f.select :country, :options => ['USA', 'Canada', 'Mexico'], :selected => 'USA', :class => 'selector'
+ %p
+ = f.label :remember_me
+ = f.check_box :remember_me, :value => "1"
+ %p
+ = f.submit "Create", :class => 'success', :id => 'demo-button'
+ %p
+ = f.image_submit "buttons/post.png", :class => 'success', :id => 'image-button'
+
+- form_for MarkupUser.new, '/another_demo', :id => 'demo2', :method => 'get' do |f|
+ = f.error_messages :header_message => "custom MarkupUser cannot be saved!"
+ = f.hidden_field :session_id
+ = f.text_field_block :username, { :class => 'input' }, { :caption => 'Nickname: ', :class => 'label' }
+ = f.password_field_block :code, { :class => 'input' }
+ = f.text_area_block :about, { :class => 'textarea' }
+ = f.file_field_block :photo, { :class => 'upload' }
+ = f.check_box_block :remember_me, { :class => 'checker' }
+ = f.select_block :state, :options => ['California', 'Texas'], :class => 'selector'
+ = f.submit_block "Create", { :class => 'button' }
+ = f.image_submit_block "buttons/ok.png", { :class => 'image' }
+
+- form_for :markup_user, '/third_demo', :id => 'demo3', :method => 'get' do |f|
+ = f.text_field_block :username
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.slim
new file mode 100644
index 00000000..31a711bd
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.slim
@@ -0,0 +1,47 @@
+== form_for MarkupUser.new, '/demo', :id => 'demo' do |f|
+ == f.error_messages(:header_message => "custom MarkupUser cannot be saved!")
+ == f.hidden_field :session_id
+ p
+ == f.label :username, :caption => "Login: ", :class => 'user-label'
+ == f.text_field :username, :class => 'user-text', :value => "John"
+ p
+ == f.label :email, :caption => "Email", :class => 'user-email'
+ == f.text_field :email
+ p
+ == f.label :password
+ == f.password_field :password, :class => 'user-password', :value => "secret"
+ p
+ == f.label :photo
+ == f.file_field :photo, :class => 'user-photo'
+ p
+ == f.label :about, :caption => "About Me: "
+ == f.text_area :about, :class => 'user-about'
+ p
+ == f.label :gender, :caption => "Your gender: "
+ == f.radio_button :gender, :value => 'male'
+ == f.radio_button :gender, :value => 'female'
+ p
+ == f.label :country, :caption => "Your country"
+ == f.select :country, :options => ['USA', 'Canada', 'Mexico'], :selected => 'USA', :class => 'selector'
+ p
+ == f.label :remember_me
+ == f.check_box :remember_me, :value => "1"
+ p
+ == f.submit "Create", :class => 'success', :id => 'demo-button'
+ p
+ == f.image_submit "buttons/post.png", :class => 'success', :id => 'image-button'
+
+== form_for MarkupUser.new, '/another_demo', :id => 'demo2', :method => 'get' do |f|
+ == f.error_messages :header_message => "custom MarkupUser cannot be saved!"
+ == f.hidden_field :session_id
+ == f.text_field_block :username, { :class => 'input' }, { :caption => 'Nickname: ', :class => 'label' }
+ == f.password_field_block :code, { :class => 'input' }
+ == f.text_area_block :about, { :class => 'textarea' }
+ == f.file_field_block :photo, { :class => 'upload' }
+ == f.check_box_block :remember_me, { :class => 'checker' }
+ == f.select_block :state, :options => ['California', 'Texas'], :class => 'selector'
+ == f.submit_block "Create", { :class => 'button' }
+ == f.image_submit_block "buttons/ok.png", { :class => 'image' }
+
+== form_for :markup_user, '/third_demo', :id => 'demo3', :method => 'get' do |f|
+ == f.text_field_block :username
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.erb
new file mode 100644
index 00000000..d8956a10
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.erb
@@ -0,0 +1,56 @@
+<% form_tag '/simple', :class => 'simple-form' do %>
+ <%= hidden_field_tag :session_id, :value => "__secret__" %>
+ <% field_set_tag do %>
+ <%= label_tag :username %>
+ <%= text_field_tag :username %>
+ <%= label_tag :password %>
+ <%= password_field_tag :password %>
+ <%= check_box_tag :remember_me %>
+ <%= label_tag :gender %>
+ <%= label_tag :color %>
+ <%= select_tag :color, :options => ['green', 'orange', 'purple'] %>
+ <%= radio_button_tag :gender, :value => 'male' %>
+ <%= radio_button_tag :gender, :value => 'female' %>
+ <%= submit_tag %>
+ <% end %>
+<% end %>
+
+<% form_tag '/advanced', :id => 'advanced', :class => 'advanced-form', :method => 'get' do %>
+ <%= error_messages_for MarkupUser.new, :header_message => "There are problems with saving user!" %>
+ <%= hidden_field_tag :session_id, :value => "__secret__" %>
+ <% field_set_tag "Advanced", :class => 'advanced-field-set' do %>
+
+ <%= label_tag :username, :class => 'first', :caption => "Nickname" %>
+ <%= text_field_tag :username, :value => params[:username], :id => 'the_username' %>
+
+
+ <%= label_tag :password, :class => 'first' %>
+ <%= password_field_tag :password, :value => params[:password] %>
+
+
+ <%= label_tag :about, :class => 'about', :caption => "About Me" %>
+ <%= text_area_tag :about, :class => 'large' %>
+
+
+ <%= label_tag :photo, :class => 'photo' %>
+ <%= file_field_tag :photo, :class => 'upload' %>
+
+
+ <%= label_tag :gender, :class => 'gender' %>
+ <%= radio_button_tag :gender, :value => 'male', :checked => true %>
+ <%= radio_button_tag :remember_me, :value => 'female' %>
+
+
+ <%= label_tag :fav_color %>
+ <%= select_tag :fav_color, :options => [ ['green', '1'], ['orange', '2'], ['purple', '3'] ], :selected => '2' %>
+
+
+ <%= check_box_tag :remember_me, :value => '1', :checked => true %>
+
+ <% end %>
+ <% field_set_tag(:class => 'buttons') do %>
+ <%= submit_tag "Login" %>
+ <%= button_tag "Cancel" %>
+ <%= image_submit_tag "buttons/submit.png" %>
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.haml
new file mode 100644
index 00000000..b09aedde
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.haml
@@ -0,0 +1,45 @@
+- form_tag '/simple', :class => 'simple-form' do
+ = error_messages_for nil
+ - field_set_tag do
+ = hidden_field_tag :session_id, :value => "__secret__"
+ = label_tag :username
+ = text_field_tag :username
+ = label_tag :password
+ = password_field_tag :password
+ = label_tag :color
+ = select_tag :color, :options => ['green', 'orange', 'purple']
+ = label_tag :gender
+ = radio_button_tag :gender, :value => 'male'
+ = radio_button_tag :gender, :value => 'female'
+ = check_box_tag :remember_me
+ = submit_tag
+
+- form_tag '/advanced', :id => 'advanced', :class => 'advanced-form', :method => 'get' do
+ = error_messages_for MarkupUser.new, :header_message => "There are problems with saving user!"
+ = hidden_field_tag :session_id, :value => "__secret__"
+ - field_set_tag "Advanced", :class => 'advanced-field-set' do
+ %p
+ = label_tag :username, :class => 'first', :caption => "Nickname"
+ = text_field_tag :username, :value => params[:username], :id => 'the_username'
+ %p
+ = label_tag :password, :class => 'first'
+ = password_field_tag :password, :value => params[:password]
+ %p
+ = label_tag :about, :class => 'about', :caption => "About Me"
+ = text_area_tag :about, :class => 'large'
+ %p
+ = label_tag :gender, :class => 'gender'
+ = radio_button_tag :gender, :value => 'male', :checked => true
+ = radio_button_tag :gender, :value => 'female'
+ %p
+ = label_tag :photo, :class => 'photo'
+ = file_field_tag :photo, :class => 'upload'
+ %p
+ = label_tag :fav_color
+ = select_tag :fav_color, :options => [ ['green', '1'], ['orange', '2'], ['purple', '3'] ], :selected => '2'
+ %p
+ = check_box_tag :remember_me, :value => "1", :checked => true
+ - field_set_tag(:class => 'buttons') do
+ = submit_tag "Login"
+ = button_tag "Cancel"
+ = image_submit_tag "buttons/submit.png"
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.slim
new file mode 100644
index 00000000..7966d5b4
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.slim
@@ -0,0 +1,45 @@
+== form_tag '/simple', :class => 'simple-form' do
+ == error_messages_for nil
+ == field_set_tag do
+ == hidden_field_tag :session_id, :value => "__secret__"
+ == label_tag :username
+ == text_field_tag :username
+ == label_tag :password
+ == password_field_tag :password
+ == label_tag :color
+ == select_tag :color, :options => ['green', 'orange', 'purple']
+ == label_tag :gender
+ == radio_button_tag :gender, :value => 'male'
+ == radio_button_tag :gender, :value => 'female'
+ == check_box_tag :remember_me
+ == submit_tag
+
+== form_tag '/advanced', :id => 'advanced', :class => 'advanced-form', :method => 'get' do
+ == error_messages_for MarkupUser.new, :header_message => "There are problems with saving user!"
+ == hidden_field_tag :session_id, :value => "__secret__"
+ == field_set_tag "Advanced", :class => 'advanced-field-set' do
+ p
+ == label_tag :username, :class => 'first', :caption => "Nickname"
+ == text_field_tag :username, :value => params[:username], :id => 'the_username'
+ p
+ == label_tag :password, :class => 'first'
+ == password_field_tag :password, :value => params[:password]
+ p
+ == label_tag :about, :class => 'about', :caption => "About Me"
+ == text_area_tag :about, :class => 'large'
+ p
+ == label_tag :gender, :class => 'gender'
+ == radio_button_tag :gender, :value => 'male', :checked => true
+ == radio_button_tag :gender, :value => 'female'
+ p
+ == label_tag :photo, :class => 'photo'
+ == file_field_tag :photo, :class => 'upload'
+ p
+ == label_tag :fav_color
+ == select_tag :fav_color, :options => [ ['green', '1'], ['orange', '2'], ['purple', '3'] ], :selected => '2'
+ p
+ == check_box_tag :remember_me, :value => "1", :checked => true
+ == field_set_tag(:class => 'buttons') do
+ == submit_tag "Login"
+ == button_tag "Cancel"
+ == image_submit_tag "buttons/submit.png"
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.erb
new file mode 100644
index 00000000..00479fee
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.erb
@@ -0,0 +1,5 @@
+<%= link_to "Test 1 No Block", '/test1', :class => 'test', :id => 'test1' %>
+
+<% link_to("/test2", :class => 'test', :id => 'test2') do %>
+ Test 2 With Block
+<% end %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.haml
new file mode 100644
index 00000000..02378a95
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.haml
@@ -0,0 +1,4 @@
+= link_to "Test 1 No Block", '/test1', :class => 'test', :id => 'test1'
+
+- link_to("/test2", :class => 'test', :id => 'test2') do
+ %span Test 2 With Block
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.slim
new file mode 100644
index 00000000..a09acf84
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.slim
@@ -0,0 +1,4 @@
+= link_to "Test 1 No Block", '/test1', :class => 'test', :id => 'test1'
+
+- link_to("/test2", :class => 'test', :id => 'test2') do
+ span Test 2 With Block
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.erb
new file mode 100644
index 00000000..2465ccf0
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.erb
@@ -0,0 +1,3 @@
+
<%= mail_to 'test@demo.com' %>
+
+<%= mail_to 'test@demo.com', "Click my Email" %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.haml
new file mode 100644
index 00000000..77ec2123
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.haml
@@ -0,0 +1,3 @@
+%p.simple= mail_to 'test@demo.com'
+
+%p.captioned= mail_to 'test@demo.com', "Click my Email"
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.slim
new file mode 100644
index 00000000..cd9d6e52
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.slim
@@ -0,0 +1,3 @@
+p.simple== mail_to 'test@demo.com'
+
+p.captioned== mail_to 'test@demo.com', "Click my Email"
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.erb
new file mode 100644
index 00000000..c8703a6e
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.erb
@@ -0,0 +1,3 @@
+<%= meta_tag "weblog,news", :name => "keywords" %>
+
+<%= meta_tag "text/html; charset=UTF-8", :"http-equiv" => "Content-Type" %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.haml
new file mode 100644
index 00000000..745acb12
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.haml
@@ -0,0 +1,3 @@
+= meta_tag "weblog,news", :name => "keywords"
+
+= meta_tag "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.slim
new file mode 100644
index 00000000..840a7ace
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.slim
@@ -0,0 +1,3 @@
+== meta_tag "weblog,news", :name => "keywords"
+
+== meta_tag "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_erb.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_erb.erb
new file mode 100644
index 00000000..e14d5273
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_erb.erb
@@ -0,0 +1 @@
+<%= current_engine %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_haml.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_haml.haml
new file mode 100644
index 00000000..ec99a2e9
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_haml.haml
@@ -0,0 +1 @@
+=current_engine
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_slim.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_slim.slim
new file mode 100644
index 00000000..ec99a2e9
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_slim.slim
@@ -0,0 +1 @@
+=current_engine
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.erb
new file mode 100644
index 00000000..c900c0eb
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.erb
@@ -0,0 +1 @@
+<%= partial 'partials/erb', :engine => "erb" %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.haml
new file mode 100644
index 00000000..397d24b3
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.haml
@@ -0,0 +1 @@
+%p.haml= partial 'partials/haml', :engine => "haml"
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.slim
new file mode 100644
index 00000000..ca16c418
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.slim
@@ -0,0 +1 @@
+p.slim= partial 'partials/slim', :engine => "slim"
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/app.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/app.rb
new file mode 100644
index 00000000..07c0948f
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/app.rb
@@ -0,0 +1,45 @@
+PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
+PADRINO_ENV = 'test' unless defined? PADRINO_ENV
+
+require 'padrino-core'
+require 'slim'
+
+class RenderUser
+ attr_accessor :name
+ def initialize(name); @name = name; end
+end
+
+class RenderDemo < Padrino::Application
+ register Padrino::Rendering
+ register Padrino::Helpers
+
+ configure do
+ set :logging, false
+ set :padrino_logging, false
+ end
+
+ # get current engines from partials
+ get '/current_engine' do
+ render :current_engine
+ end
+
+ # get current engines from explicit engine partials
+ get '/explicit_engine' do
+ render :explicit_engine
+ end
+
+ # partial with object
+ get '/partial/object' do
+ partial 'template/user', :object => RenderUser.new('John'), :locals => { :extra => "bar" }
+ end
+
+ # partial with collection
+ get '/partial/collection' do
+ partial 'template/user', :collection => [RenderUser.new('John'), RenderUser.new('Billy')], :locals => { :extra => "bar" }
+ end
+
+ # partial with locals
+ get '/partial/locals' do
+ partial 'template/user', :locals => { :user => RenderUser.new('John'), :extra => "bar" }
+ end
+end
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engine.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engine.haml
new file mode 100644
index 00000000..ef0b2fd5
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engine.haml
@@ -0,0 +1,5 @@
+%p.start= current_engine
+%p.haml= partial 'current_engines/haml'
+%p.erb= partial 'current_engines/erb'
+%p.slim= partial 'current_engines/slim'
+%p.end= current_engine
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_erb.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_erb.erb
new file mode 100644
index 00000000..9ea39c1c
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_erb.erb
@@ -0,0 +1 @@
+<%= current_engine %>
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_haml.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_haml.haml
new file mode 100644
index 00000000..f76f9778
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_haml.haml
@@ -0,0 +1 @@
+%span=current_engine
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_slim.slim b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_slim.slim
new file mode 100644
index 00000000..cec51751
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_slim.slim
@@ -0,0 +1 @@
+span=current_engine
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/erb/test.erb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/erb/test.erb
new file mode 100644
index 00000000..4d97c8b6
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/erb/test.erb
@@ -0,0 +1 @@
+This is a <%= @template %> template!
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/explicit_engine.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/explicit_engine.haml
new file mode 100644
index 00000000..044e090e
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/explicit_engine.haml
@@ -0,0 +1,5 @@
+%p.start= current_engine
+%p.haml= partial "current_engines/haml", :engine => :haml
+%p.erb= partial 'current_engines/erb', :engine => :erb
+%p.slim= partial 'current_engines/slim', :engine => :slim
+%p.end= current_engine
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/haml/test.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/haml/test.haml
new file mode 100644
index 00000000..795d6248
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/haml/test.haml
@@ -0,0 +1 @@
+%h1 This is a #{@template} template!
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/_user.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/_user.haml
new file mode 100644
index 00000000..f8144ccf
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/_user.haml
@@ -0,0 +1,7 @@
+%h1 User name is #{user.name}
+
+- if defined?(extra)
+ %p Extra is #{extra}
+
+- if defined?(user_counter)
+ %p My counter is #{user_counter}
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/haml_template.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/haml_template.haml
new file mode 100644
index 00000000..4ee1417f
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/haml_template.haml
@@ -0,0 +1 @@
+%h1 This is a #{@template} template sent from render_template!
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/some_template.haml b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/some_template.haml
new file mode 100644
index 00000000..fbba69eb
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/some_template.haml
@@ -0,0 +1,2 @@
+
+%h1 This is a haml template which was detected!
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/helper.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/helper.rb
new file mode 100644
index 00000000..3875a92e
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/helper.rb
@@ -0,0 +1,78 @@
+require File.expand_path('../../../load_paths', __FILE__)
+require 'test/unit'
+require 'shoulda'
+require 'mocha'
+require 'rack/test'
+require 'webrat'
+require 'padrino-helpers'
+require 'active_support/time'
+
+class Test::Unit::TestCase
+ include Padrino::Helpers::OutputHelpers
+ include Padrino::Helpers::TagHelpers
+ include Padrino::Helpers::AssetTagHelpers
+ include Rack::Test::Methods
+ include Webrat::Methods
+ include Webrat::Matchers
+
+ Webrat.configure do |config|
+ config.mode = :rack
+ end
+
+ def stop_time_for_test
+ time = Time.now
+ Time.stubs(:now).returns(time)
+ return time
+ end
+
+ # assert_has_tag(:h1, :content => "yellow") { "yellow
" }
+ # In this case, block is the html to evaluate
+ def assert_has_tag(name, attributes = {}, &block)
+ html = block && block.call
+ matcher = HaveSelector.new(name, attributes)
+ raise "Please specify a block!" if html.blank?
+ assert matcher.matches?(html), matcher.failure_message
+ end
+
+ # assert_has_no_tag, tag(:h1, :content => "yellow") { "green
" }
+ # In this case, block is the html to evaluate
+ def assert_has_no_tag(name, attributes = {}, &block)
+ html = block && block.call
+ attributes.merge!(:count => 0)
+ matcher = HaveSelector.new(name, attributes)
+ raise "Please specify a block!" if html.blank?
+ assert matcher.matches?(html), matcher.failure_message
+ end
+
+ # Silences the output by redirecting to stringIO
+ # silence_logger { ...commands... } => "...output..."
+ def silence_logger(&block)
+ orig_stdout = $stdout
+ $stdout = log_buffer = StringIO.new
+ block.call
+ $stdout = orig_stdout
+ log_buffer.rewind && log_buffer.read
+ end
+
+ # Asserts that a file matches the pattern
+ def assert_match_in_file(pattern, file)
+ assert File.exist?(file), "File '#{file}' does not exist!"
+ assert_match pattern, File.read(file)
+ end
+
+ # mock_model("Business", :new_record? => true) =>
+ def mock_model(klazz, options={})
+ options.reverse_merge!(:class => klazz, :new_record? => false, :id => 20, :errors => {})
+ record = stub(options)
+ record.stubs(:to_ary => [record])
+ record
+ end
+end
+
+module Webrat
+ module Logging
+ def logger # :nodoc:
+ @logger = nil
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_asset_tag_helpers.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_asset_tag_helpers.rb
new file mode 100644
index 00000000..1ff5ca38
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_asset_tag_helpers.rb
@@ -0,0 +1,320 @@
+require File.expand_path(File.dirname(__FILE__) + '/helper')
+require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
+
+class TestAssetTagHelpers < Test::Unit::TestCase
+ include Padrino::Helpers::AssetTagHelpers
+
+ def app
+ MarkupDemo.tap { |app| app.set :environment, :test }
+ end
+
+ def flash
+ { :notice => "Demo notice" }
+ end
+
+ context 'for #flash_tag method' do
+ should "display flash with no given attributes" do
+ assert_has_tag('div.notice', :content => "Demo notice") { flash_tag(:notice) }
+ end
+ should "display flash with given attributes" do
+ actual_html = flash_tag(:notice, :class => 'notice', :id => 'notice-area')
+ assert_has_tag('div.notice#notice-area', :content => "Demo notice") { actual_html }
+ end
+ end
+
+ context 'for #link_to method' do
+ should "display link element with no given attributes" do
+ assert_has_tag('a', :content => "Sign up", :href => '/register') { link_to('Sign up', '/register') }
+ end
+
+ should "display link element with given attributes" do
+ actual_html = link_to('Sign up', '/register', :class => 'first', :id => 'linky')
+ assert_has_tag('a#linky.first', :content => "Sign up", :href => '/register') { actual_html }
+ end
+
+ should "display link element with anchor attribute" do
+ actual_html = link_to("Anchor", "/anchor", :anchor => :foo)
+ assert_has_tag('a', :content => "Anchor", :href => '/anchor#foo') { actual_html }
+ end
+
+ should "display link element with void url and options" do
+ actual_link = link_to('Sign up', :class => "test")
+ assert_has_tag('a', :content => "Sign up", :href => 'javascript:void(0);', :class => 'test') { actual_link }
+ end
+
+ should "display link element with remote option" do
+ actual_link = link_to('Sign up', '/register', :remote => true)
+ assert_has_tag('a', :content => "Sign up", :href => '/register', 'data-remote' => 'true') { actual_link }
+ end
+
+ should "display link element with method option" do
+ actual_link = link_to('Sign up', '/register', :method => :delete)
+ assert_has_tag('a', :content => "Sign up", :href => '/register', 'data-method' => 'delete', :rel => 'nofollow') { actual_link }
+ end
+
+ should "display link element with confirm option" do
+ actual_link = link_to('Sign up', '/register', :confirm => "Are you sure?")
+ assert_has_tag('a', :content => "Sign up", :href => '/register', 'data-confirm' => 'Are you sure?') { actual_link }
+ end
+
+ should "display link element with ruby block" do
+ actual_link = link_to('/register', :class => 'first', :id => 'binky') { "Sign up" }
+ assert_has_tag('a#binky.first', :content => "Sign up", :href => '/register') { actual_link }
+ end
+
+ should "display link block element in haml" do
+ visit '/haml/link_to'
+ assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
+ assert_have_selector :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
+ end
+
+ should "display link block element in erb" do
+ visit '/erb/link_to'
+ assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
+ assert_have_selector :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
+ end
+ end
+
+ context 'for #mail_to method' do
+ should "display link element for mail to no caption" do
+ actual_html = mail_to('test@demo.com')
+ assert_has_tag(:a, :href => "mailto:test@demo.com", :content => 'test@demo.com') { actual_html }
+ end
+
+ should "display link element for mail to with caption" do
+ actual_html = mail_to('test@demo.com', "My Email", :class => 'demo')
+ assert_has_tag(:a, :href => "mailto:test@demo.com", :content => 'My Email', :class => 'demo') { actual_html }
+ end
+
+ should "display link element for mail to with caption and mail options" do
+ actual_html = mail_to('test@demo.com', "My Email", :subject => 'demo test', :class => 'demo', :cc => 'foo@test.com')
+ assert_has_tag(:a, :class => 'demo') { actual_html }
+ assert_match %r{mailto\:test\@demo.com\?}, actual_html
+ assert_match %r{cc=foo\@test\.com}, actual_html
+ assert_match %r{subject\=demo\%20test}, actual_html
+ end
+
+ should "display mail link element in haml" do
+ visit '/haml/mail_to'
+ assert_have_selector 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
+ assert_have_selector 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
+ end
+
+ should "display mail link element in erb" do
+ visit '/erb/mail_to'
+ assert_have_selector 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
+ assert_have_selector 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
+ end
+
+ should "display mail link element in slim" do
+ visit '/slim/mail_to'
+ assert_have_selector 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
+ assert_have_selector 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
+ end
+ end
+
+ context 'for #meta_tag method' do
+ should "display meta tag with given content and name" do
+ actual_html = meta_tag("weblog,news", :name => "keywords")
+ assert_has_tag("meta", :name => "keywords", "content" => "weblog,news") { actual_html }
+ end
+
+ should "display meta tag with given content and http-equiv" do
+ actual_html = meta_tag("text/html; charset=UTF-8", :"http-equiv" => "Content-Type")
+ assert_has_tag("meta", :"http-equiv" => "Content-Type", "content" => "text/html; charset=UTF-8") { actual_html }
+ end
+
+ should "display meta tag element in haml" do
+ visit '/haml/meta_tag'
+ assert_have_selector 'meta', "content" => "weblog,news", :name => "keywords"
+ assert_have_selector 'meta', "content" => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
+ end
+
+ should "display meta tag element in erb" do
+ visit '/erb/meta_tag'
+ assert_have_selector 'meta', "content" => "weblog,news", :name => "keywords"
+ assert_have_selector 'meta', "content" => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
+ end
+
+ should "display meta tag element in slim" do
+ visit '/slim/meta_tag'
+ assert_have_selector 'meta', "content" => "weblog,news", :name => "keywords"
+ assert_have_selector 'meta', "content" => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
+ end
+ end
+
+ context 'for #image_tag method' do
+ should "display image tag absolute link with no options" do
+ time = stop_time_for_test
+ assert_has_tag('img', :src => "/absolute/pic.gif?#{time.to_i}") { image_tag('/absolute/pic.gif') }
+ end
+
+ should "display image tag absolute link with specified uri root" do
+ time = stop_time_for_test
+ self.class.stubs(:uri_root).returns("/blog")
+ assert_has_tag('img', :src => "/blog/images/relative/pic.gif?#{time.to_i}") { image_tag('relative/pic.gif') }
+ end
+
+ should "display image tag relative link with options" do
+ time = stop_time_for_test
+ assert_has_tag('img.photo', :src => "/images/relative/pic.gif?#{time.to_i}") {
+ image_tag('relative/pic.gif', :class => 'photo') }
+ end
+
+ should "display image tag uri link with options" do
+ time = stop_time_for_test
+ assert_has_tag('img.photo', :src => "http://demo.org/pic.gif") { image_tag('http://demo.org/pic.gif', :class => 'photo') }
+ end
+
+ should "display image tag relative link with incorrect spacing" do
+ time = stop_time_for_test
+ assert_has_tag('img.photo', :src => "/images/%20relative/%20pic.gif%20%20?#{time.to_i}") {
+ image_tag(' relative/ pic.gif ', :class => 'photo') }
+ end
+
+ should "not use a timestamp if stamp setting is false" do
+ self.class.expects(:asset_stamp).returns(false)
+ assert_has_tag('img', :src => "/absolute/pic.gif") { image_tag('/absolute/pic.gif') }
+ end
+
+ should "have xhtml convention tag" do
+ self.class.expects(:asset_stamp).returns(false)
+ assert_equal image_tag('/absolute/pic.gif'), ''
+ end
+ end
+
+ context 'for #stylesheet_link_tag method' do
+ should "display stylesheet link item" do
+ time = stop_time_for_test
+ expected_options = { :media => "screen", :rel => "stylesheet", :type => "text/css" }
+ assert_has_tag('link', expected_options.merge(:href => "/stylesheets/style.css?#{time.to_i}")) { stylesheet_link_tag('style') }
+ end
+
+ should "display stylesheet link item for long relative path" do
+ time = stop_time_for_test
+ expected_options = { :media => "screen", :rel => "stylesheet", :type => "text/css" }
+ actual_html = stylesheet_link_tag('example/demo/style')
+ assert_has_tag('link', expected_options.merge(:href => "/stylesheets/example/demo/style.css?#{time.to_i}")) { actual_html }
+ end
+
+ should "display stylesheet link item with absolute path" do
+ time = stop_time_for_test
+ expected_options = { :media => "screen", :rel => "stylesheet", :type => "text/css" }
+ actual_html = stylesheet_link_tag('/css/style')
+ assert_has_tag('link', expected_options.merge(:href => "/css/style.css?#{time.to_i}")) { actual_html }
+ end
+
+ should "display stylesheet link item with uri root" do
+ self.class.stubs(:uri_root).returns("/blog")
+ time = stop_time_for_test
+ expected_options = { :media => "screen", :rel => "stylesheet", :type => "text/css" }
+ actual_html = stylesheet_link_tag('style')
+ assert_has_tag('link', expected_options.merge(:href => "/blog/stylesheets/style.css?#{time.to_i}")) { actual_html }
+ end
+
+ should "display stylesheet link items" do
+ time = stop_time_for_test
+ actual_html = stylesheet_link_tag('style', 'layout.css', 'http://google.com/style.css')
+ assert_has_tag('link', :media => "screen", :rel => "stylesheet", :type => "text/css", :count => 3) { actual_html }
+ assert_has_tag('link', :href => "/stylesheets/style.css?#{time.to_i}") { actual_html }
+ assert_has_tag('link', :href => "/stylesheets/layout.css?#{time.to_i}") { actual_html }
+ assert_has_tag('link', :href => "http://google.com/style.css") { actual_html }
+ assert_equal actual_html, stylesheet_link_tag(['style', 'layout.css', 'http://google.com/style.css'])
+ end
+
+ should "not use a timestamp if stamp setting is false" do
+ self.class.expects(:asset_stamp).returns(false)
+ expected_options = { :media => "screen", :rel => "stylesheet", :type => "text/css" }
+ assert_has_tag('link', expected_options.merge(:href => "/stylesheets/style.css")) { stylesheet_link_tag('style') }
+ end
+ end
+
+ context 'for #javascript_include_tag method' do
+ should "display javascript item" do
+ time = stop_time_for_test
+ actual_html = javascript_include_tag('application')
+ assert_has_tag('script', :src => "/javascripts/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
+ end
+
+ should "display javascript item for long relative path" do
+ time = stop_time_for_test
+ actual_html = javascript_include_tag('example/demo/application')
+ assert_has_tag('script', :src => "/javascripts/example/demo/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
+ end
+
+ should "display javascript item for path containing js" do
+ time = stop_time_for_test
+ actual_html = javascript_include_tag 'test/jquery.json'
+ assert_has_tag('script', :src => "/javascripts/test/jquery.json?#{time.to_i}", :type => "text/javascript") { actual_html }
+ end
+
+ should "display javascript item for path containing period" do
+ time = stop_time_for_test
+ actual_html = javascript_include_tag 'test/jquery.min'
+ assert_has_tag('script', :src => "/javascripts/test/jquery.min.js?#{time.to_i}", :type => "text/javascript") { actual_html }
+ end
+
+ should "display javascript item with absolute path" do
+ time = stop_time_for_test
+ actual_html = javascript_include_tag('/js/application')
+ assert_has_tag('script', :src => "/js/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
+ end
+
+ should "display javascript item with uri root" do
+ self.class.stubs(:uri_root).returns("/blog")
+ time = stop_time_for_test
+ actual_html = javascript_include_tag('application')
+ assert_has_tag('script', :src => "/blog/javascripts/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
+ end
+
+ should "display javascript items" do
+ time = stop_time_for_test
+ actual_html = javascript_include_tag('application', 'base.js', 'http://google.com/lib.js')
+ assert_has_tag('script', :type => "text/javascript", :count => 3) { actual_html }
+ assert_has_tag('script', :src => "/javascripts/application.js?#{time.to_i}") { actual_html }
+ assert_has_tag('script', :src => "/javascripts/base.js?#{time.to_i}") { actual_html }
+ assert_has_tag('script', :src => "http://google.com/lib.js") { actual_html }
+ assert_equal actual_html, javascript_include_tag(['application', 'base.js', 'http://google.com/lib.js'])
+ end
+
+ should "not use a timestamp if stamp setting is false" do
+ self.class.expects(:asset_stamp).returns(false)
+ actual_html = javascript_include_tag('application')
+ assert_has_tag('script', :src => "/javascripts/application.js", :type => "text/javascript") { actual_html }
+ end
+ end
+
+ context "for #favicon_tag method" do
+ should "display favicon" do
+ time = stop_time_for_test
+ actual_html = favicon_tag('icons/favicon.png')
+ assert_has_tag('link', :rel => 'icon', :type => 'image/png', :href => "/images/icons/favicon.png?#{time.to_i}") { actual_html }
+ end
+
+ should "match type with file ext" do
+ time = stop_time_for_test
+ actual_html = favicon_tag('favicon.ico')
+ assert_has_tag('link', :rel => 'icon', :type => 'image/ico', :href => "/images/favicon.ico?#{time.to_i}") { actual_html }
+ end
+
+ should "allow option overrides" do
+ time = stop_time_for_test
+ actual_html = favicon_tag('favicon.png', :type => 'image/ico')
+ assert_has_tag('link', :rel => 'icon', :type => 'image/ico', :href => "/images/favicon.png?#{time.to_i}") { actual_html }
+ end
+ end
+
+ context 'for #feed_tag method' do
+ should "generate correctly link tag for rss" do
+ assert_has_tag('link', :type => 'application/rss+xml', :rel => 'alternate', :href => "/blog/post.rss", :title => 'rss') { feed_tag :rss, "/blog/post.rss" }
+ end
+
+ should "generate correctly link tag for atom" do
+ assert_has_tag('link', :type => 'application/atom+xml', :rel => 'alternate', :href => "/blog/post.atom", :title => 'atom') { feed_tag :atom, "/blog/post.atom" }
+ end
+
+ should "override options" do
+ assert_has_tag('link', :type => 'my-type', :rel => 'my-rel', :href => "/blog/post.rss", :title => 'my-title') { feed_tag :rss, "/blog/post.rss", :type => "my-type", :rel => "my-rel", :title => "my-title" }
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_form_builder.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_form_builder.rb
new file mode 100644
index 00000000..023863ac
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_form_builder.rb
@@ -0,0 +1,998 @@
+require File.expand_path(File.dirname(__FILE__) + '/helper')
+require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
+
+class TestFormBuilder < Test::Unit::TestCase
+ include Padrino::Helpers::FormHelpers
+
+ # Dummy form builder for testing
+ module Padrino::Helpers::FormBuilder
+ class FakeFormBuilder < AbstractFormBuilder
+ def foo_field; @template.content_tag(:span, "bar"); end
+ end
+ end
+
+ def app
+ MarkupDemo.tap { |app| app.set :environment, :test }
+ end
+
+ def setup
+ role_types = [mock_model('Role', :name => "Admin", :id => 1),
+ mock_model('Role', :name => 'Moderate', :id => 2), mock_model('Role', :name => 'Limited', :id => 3)]
+ @user = mock_model("User", :first_name => "Joe", :email => '', :session_id => 54)
+ @user.stubs(:errors => {:a => "must be present", :b => "must be valid", :email => "Must be valid", :first_name => []})
+ @user.stubs(:role_types => role_types, :role => "1")
+ @user_none = mock_model("User")
+ end
+
+ def standard_builder(object=@user)
+ Padrino::Helpers::FormBuilder::StandardFormBuilder.new(self, object)
+ end
+
+ context 'for #form_for method' do
+ should "display correct form html" do
+ actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { "Demo" }
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post', :content => "Demo") { actual_html }
+ assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
+ end
+
+ should "display correct form html with fake object" do
+ actual_html = form_for(:markup_user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.text_field :username }
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post') { actual_html }
+ assert_has_tag('form input', :type => 'text', :name => 'markup_user[username]') { actual_html }
+ assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
+ end
+
+ should "display correct form html for namespaced object" do
+ actual_html = form_for(Outer::UserAccount.new, '/register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.text_field :username }
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
+ assert_has_tag('form input', :type => 'text', :name => 'outer_user_account[username]') { actual_html }
+ end
+
+ should "display form specifying default builder setting" do
+ self.expects(:settings).returns(stub(:default_builder => 'FakeFormBuilder')).once
+ actual_html = ""
+ assert_nothing_raised do
+ actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.foo_field }
+ end
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
+ assert_has_tag('span', :content => "bar") { actual_html }
+ end
+
+ should "display correct form html with remote option" do
+ actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true) { "Demo" }
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post', "data-remote" => 'true') { actual_html }
+ end
+
+ should "display correct form html with remote option and method put" do
+ actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true, :method => 'put') { "Demo" }
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :method => 'post', "data-method" => 'put', "data-remote" => 'true') { actual_html }
+ assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
+ end
+
+ should "display correct form html with method :put" do
+ actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :method => 'put') { "Demo" }
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post') { actual_html }
+ assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
+ end
+
+ should "display correct form html with method :delete" do
+ actual_html = form_for(@user, '/destroy', :"accept-charset" => "UTF-8", :method => 'delete') { "Demo" }
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/destroy', :method => 'post') { actual_html }
+ assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'delete') { actual_html }
+ end
+
+ should "display correct form html with multipart" do
+ actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8", :multipart => true) { "Demo" }
+ assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
+ end
+
+ should "support changing form builder type" do
+ form_html = proc { form_for(@user, '/register', :"accept-charset" => "UTF-8", :builder => "AbstractFormBuilder") { |f| f.text_field_block(:name) } }
+ assert_raise(NoMethodError) { form_html.call }
+ end
+
+ should "support using default standard builder" do
+ actual_html = form_for(@user, '/register') { |f| f.text_field_block(:name) }
+ assert_has_tag('form p input[type=text]') { actual_html }
+ end
+
+ should "display fail for form with nil object" do
+ assert_raises(RuntimeError) { form_for(@not_real, '/register', :id => 'register', :method => 'post') { "Demo" } }
+ end
+
+ should "display correct form in haml" do
+ visit '/haml/form_for'
+ assert_have_selector :form, :action => '/demo', :id => 'demo'
+ assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
+ assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
+ end
+
+ should "display correct form in erb" do
+ visit '/erb/form_for'
+ assert_have_selector :form, :action => '/demo', :id => 'demo'
+ assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
+ assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
+ end
+
+ should "display correct form in slim" do
+ visit '/slim/form_for'
+ assert_have_selector :form, :action => '/demo', :id => 'demo'
+ assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
+ assert_have_selector :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
+ end
+
+ should "have a class of 'invalid' for fields with errors" do
+ actual_html = form_for(@user, '/register') {|f| f.text_field(:email) }
+ assert_has_tag(:input, :type => 'text', :name => 'user[email]', :id => 'user_email', :class => 'invalid') {actual_html }
+ end
+
+ should "not have a class of 'invalid' for fields with no errors" do
+ actual_html = form_for(@user, '/register') {|f| f.text_field(:first_name) }
+ assert_has_no_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name', :class => 'invalid') {actual_html }
+ end
+ end
+
+ context 'for #fields_for method' do
+ should 'display correct fields html' do
+ actual_html = fields_for(@user) { |f| f.text_field(:first_name) }
+ assert_has_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name') { actual_html }
+ end
+
+ should 'display correct fields html with symbol object' do
+ actual_html = fields_for(:markup_user) { |f| f.text_field(:first_name) }
+ assert_has_tag(:input, :type => 'text', :name => 'markup_user[first_name]', :id => 'markup_user_first_name') { actual_html }
+ end
+
+ should "display fail for nil object" do
+ assert_raises(RuntimeError) { fields_for(@not_real) { |f| "Demo" } }
+ end
+
+ should 'display correct simple fields in haml' do
+ visit '/haml/fields_for'
+ assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
+ assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
+ assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
+ assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
+ end
+
+ should "display correct simple fields in erb" do
+ visit '/erb/fields_for'
+ assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
+ assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
+ assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
+ assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
+ end
+
+ should "display correct simple fields in slim" do
+ visit '/slim/fields_for'
+ assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
+ assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
+ assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
+ assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
+ end
+ end
+
+ # ===========================
+ # AbstractFormBuilder
+ # ===========================
+
+ context 'for #error_messages method' do
+ should "display correct form html with no record" do
+ actual_html = standard_builder(@user_none).error_messages(:header_message => "Demo form cannot be saved")
+ assert actual_html.blank?
+ end
+
+ should "display correct form html with valid record" do
+ actual_html = standard_builder.error_messages(:header_message => "Demo form cannot be saved", :style => "foo:bar", :class => "mine")
+ assert_has_tag('#field-errors h2', :content => "Demo form cannot be saved") { actual_html }
+ assert_has_tag('#field-errors ul li', :content => "B must be valid") { actual_html }
+ assert_has_tag('#field-errors ul li', :content => "A must be present") { actual_html }
+ assert_has_tag('#field-errors', :style => "foo:bar") { actual_html }
+ assert_has_tag('#field-errors', :class => "mine") { actual_html }
+ end
+
+ should "display correct form in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
+ assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
+ assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
+ assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
+ assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
+ assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
+ assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
+ assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
+ assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'invalid'
+ end
+
+ should "display correct form in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
+ assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
+ assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
+ assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
+ assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
+ assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
+ assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
+ assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
+ assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'invalid'
+ end
+
+ should "display correct form in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
+ assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
+ assert_have_selector '#demo div.field-errors ul li', :content => "Second must be present"
+ assert_have_selector '#demo div.field-errors ul li', :content => "Third must be a number"
+ assert_have_selector '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
+ assert_have_selector '#demo2 div.field-errors ul li', :content => "Fake must be valid"
+ assert_have_selector '#demo2 div.field-errors ul li', :content => "Second must be present"
+ assert_have_selector '#demo2 div.field-errors ul li', :content => "Third must be a number"
+ assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'invalid'
+ end
+ end
+
+ context 'for #error_message_on method' do
+ should "display correct form html with no record" do
+ actual_html = standard_builder(@user_none).error_message_on(:name)
+ assert actual_html.blank?
+ end
+
+ should "display error for specified invalid object" do
+ actual_html = standard_builder(@user).error_message_on(:a, :prepend => "foo", :append => "bar")
+ assert_has_tag('span.error', :content => "foo must be present bar") { actual_html }
+ end
+
+ should "display error for specified invalid object not matching class name" do
+ @bob = mock_model("User", :first_name => "Frank", :errors => { :foo => "must be bob" })
+ actual_html = standard_builder(@bob).error_message_on(:foo, :prepend => "foo", :append => "bar")
+ assert_has_tag('span.error', :content => "foo must be bob bar") { actual_html }
+ end
+ end
+
+ context 'for #label method' do
+ should "display correct label html" do
+ actual_html = standard_builder.label(:first_name, :class => 'large', :caption => "F. Name: ")
+ assert_has_tag('label', :class => 'large', :for => 'user_first_name', :content => "F. Name: ") { actual_html }
+ end
+
+ should "display correct label in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
+ assert_have_selector '#demo label', :content => "About Me: "
+ assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
+ end
+
+ should "display correct label in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
+ assert_have_selector '#demo label', :content => "About Me: "
+ assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
+ end
+
+ should "display correct label in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
+ assert_have_selector '#demo label', :content => "About Me: "
+ assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
+ end
+ end
+
+ context 'for #hidden_field method' do
+ should "display correct hidden field html" do
+ actual_html = standard_builder.hidden_field(:session_id, :class => 'hidden')
+ assert_has_tag('input.hidden[type=hidden]', :value => "54", :id => 'user_session_id', :name => 'user[session_id]') { actual_html }
+ end
+
+ should "display correct hidden field in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
+ assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
+ end
+
+ should "display correct hidden field in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
+ assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
+ end
+
+ should "display correct hidden field in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
+ assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
+ end
+ end
+
+ context 'for #text_field method' do
+ should "display correct text field html" do
+ actual_html = standard_builder.text_field(:first_name, :class => 'large')
+ assert_has_tag('input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
+ end
+
+ should "display correct text field in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
+ assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
+ end
+
+ should "display correct text field in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
+ assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
+ end
+
+ should "display correct text field in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
+ assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
+ end
+ end
+
+ context 'for #check_box method' do
+ should "display correct checkbox html" do
+ actual_html = standard_builder.check_box(:confirm_destroy, :class => 'large')
+ assert_has_tag('input.large[type=checkbox]', :id => 'user_confirm_destroy', :name => 'user[confirm_destroy]') { actual_html }
+ assert_has_tag('input[type=hidden]', :name => 'user[confirm_destroy]', :value => '0') { actual_html }
+ end
+
+ should "display correct checkbox html when checked" do
+ actual_html = standard_builder.check_box(:confirm_destroy, :checked => true)
+ assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[confirm_destroy]') { actual_html }
+ end
+
+ should "display correct checkbox html as checked when object value matches" do
+ @user.stubs(:show_favorites => 'human')
+ actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
+ assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
+ end
+
+ should "display correct checkbox html as checked when object value is true" do
+ @user.stubs(:show_favorites => true)
+ actual_html = standard_builder.check_box(:show_favorites, :value => '1')
+ assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
+ end
+
+ should "display correct checkbox html as unchecked when object value doesn't match" do
+ @user.stubs(:show_favorites => 'alien')
+ actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
+ assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
+ end
+
+ should "display correct checkbox html as unchecked when object value is false" do
+ @user.stubs(:show_favorites => false)
+ actual_html = standard_builder.check_box(:show_favorites, :value => '1')
+ assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
+ end
+
+ should "display correct unchecked hidden field when specified" do
+ actual_html = standard_builder.check_box(:show_favorites, :value => 'female', :uncheck_value => 'false')
+ assert_has_tag('input[type=hidden]', :name => 'user[show_favorites]', :value => 'false') { actual_html }
+ end
+
+ should "display correct checkbox in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
+ end
+
+ should "display correct checkbox in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
+ end
+
+ should "display correct checkbox in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
+ end
+ end
+
+ context 'for #radio_button method' do
+ should "display correct radio button html" do
+ actual_html = standard_builder.radio_button(:gender, :value => 'male', :class => 'large')
+ assert_has_tag('input.large[type=radio]', :id => 'user_gender_male', :name => 'user[gender]', :value => 'male') { actual_html }
+ end
+
+ should "display correct radio button html when checked" do
+ actual_html = standard_builder.radio_button(:gender, :checked => true)
+ assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
+ end
+
+ should "display correct radio button html as checked when object value matches" do
+ @user.stubs(:gender => 'male')
+ actual_html = standard_builder.radio_button(:gender, :value => 'male')
+ assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
+ end
+
+ should "display correct radio button html as unchecked when object value doesn't match" do
+ @user.stubs(:gender => 'male')
+ actual_html = standard_builder.radio_button(:gender, :value => 'female')
+ assert_has_no_tag('input[type=radio]', :checked => 'checked') { actual_html }
+ end
+
+ should "display correct radio button in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
+ assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
+ assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
+ end
+
+ should "display correct radio button in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
+ assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
+ assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
+ end
+
+ should "display correct radio button in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
+ assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
+ assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
+ end
+ end
+
+ context 'for #text_area method' do
+ should "display correct text_area html" do
+ actual_html = standard_builder.text_area(:about, :class => 'large')
+ assert_has_tag('textarea.large', :id => 'user_about', :name => 'user[about]', :rows => '', :cols => '') { actual_html }
+ end
+
+ should "display correct text_area html and content" do
+ actual_html = standard_builder.text_area(:about, :value => "Demo", :rows => '5', :cols => '6')
+ assert_has_tag('textarea', :id => 'user_about', :content => 'Demo', :rows => '5', :cols => '6') { actual_html }
+ end
+
+ should "display correct text_area in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
+ assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
+ end
+
+ should "display correct text_area in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
+ assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
+ end
+
+ should "display correct text_area in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
+ assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
+ end
+ end
+
+ context 'for #password_field method' do
+ should "display correct password_field html" do
+ actual_html = standard_builder.password_field(:code, :class => 'large')
+ assert_has_tag('input.large[type=password]', :id => 'user_code', :name => 'user[code]') { actual_html }
+ end
+
+ should "display correct password_field in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
+ assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
+ end
+
+ should "display correct password_field in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
+ assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
+ end
+
+ should "display correct password_field in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
+ assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
+ end
+ end
+
+ context 'for #file_field method' do
+ should "display correct file_field html" do
+ actual_html = standard_builder.file_field(:photo, :class => 'large')
+ assert_has_tag('input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
+ end
+
+ should "display correct file_field in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
+ assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
+ end
+
+ should "display correct file_field in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
+ assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
+ end
+
+ should "display correct file_field in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
+ assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
+ end
+ end
+
+ context 'for #select method' do
+ should "display correct select html" do
+ actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :class => 'selecty')
+ assert_has_tag('select.selecty', :id => 'user_state', :name => 'user[state]') { actual_html }
+ assert_has_tag('select.selecty option', :count => 3) { actual_html }
+ assert_has_tag('select.selecty option', :value => 'California', :content => 'California') { actual_html }
+ assert_has_tag('select.selecty option', :value => 'Texas', :content => 'Texas') { actual_html }
+ assert_has_tag('select.selecty option', :value => 'Wyoming', :content => 'Wyoming') { actual_html }
+ end
+
+ should "display correct select html with selected item if it matches value" do
+ @user.stubs(:state => 'California')
+ actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'])
+ assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
+ assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
+ assert_has_tag('select option', :value => 'California', :selected => 'selected') { actual_html }
+ end
+
+ should "display correct select html with selected item if it matches full value" do
+ @user.stubs(:state => 'Cali')
+ actual_html = standard_builder.select(:state, :options => ['Cali', 'California', 'Texas', 'Wyoming'])
+ assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
+ assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
+ assert_has_tag('select option', :value => 'Cali', :selected => 'selected') { actual_html }
+ assert_has_tag('select option', :value => 'California') { actual_html }
+ end
+
+ should "display correct select html with multiple selected items" do
+ @user.stubs(:pickles => ['foo', 'bar'])
+ actual_html = standard_builder.select(
+ :pickles, :options => [ ['Foo', 'foo'], ['Bar', 'bar'], ['Baz', 'baz'], ['Bar Buz', 'bar buz'] ]
+ )
+ assert_has_tag('option', :value => 'foo', :content => 'Foo', :selected => 'selected') { actual_html }
+ assert_has_tag('option', :value => 'bar', :content => 'Bar', :selected => 'selected') { actual_html }
+ assert_has_tag('option', :value => 'baz', :content => 'Baz') { actual_html }
+ assert_has_tag('option', :value => 'bar buz', :content => 'Bar Buz') { actual_html }
+ end
+
+ should "display correct select html with include_blank" do
+ actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => true)
+ assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
+ assert_has_tag('select option', :count => 4) { actual_html }
+ assert_has_tag('select option:first-child', :content => '') { actual_html }
+ assert_has_tag('select option:first-child', :value => '') { actual_html }
+ actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => 'Select')
+ assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
+ assert_has_tag('select option', :count => 4) { actual_html }
+ assert_has_tag('select option:first-child', :content => 'Select') { actual_html }
+ assert_has_tag('select option:first-child', :value => '') { actual_html }
+ end
+
+ should "display correct select html with collection passed in" do
+ actual_html = standard_builder.select(:role, :collection => @user.role_types, :fields => [:name, :id])
+ assert_has_tag('select', :id => 'user_role', :name => 'user[role]') { actual_html }
+ assert_has_tag('select option', :count => 3) { actual_html }
+ assert_has_tag('select option', :value => '1', :content => 'Admin', :selected => 'selected') { actual_html }
+ assert_has_tag('select option', :value => '2', :content => 'Moderate') { actual_html }
+ assert_has_tag('select option', :value => '3', :content => 'Limited') { actual_html }
+ end
+
+ should "display correct select in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
+ assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
+ end
+
+ should "display correct select in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
+ assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
+ end
+
+ should "display correct select in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
+ assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
+ end
+ end
+
+ context 'for #submit method' do
+ should "display correct submit button html with no options" do
+ actual_html = standard_builder.submit
+ assert_has_tag('input[type=submit]', :value => "Submit") { actual_html }
+ end
+
+ should "display correct submit button html" do
+ actual_html = standard_builder.submit("Commit", :class => 'large')
+ assert_has_tag('input.large[type=submit]', :value => "Commit") { actual_html }
+ end
+
+ should "display correct submit button in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
+ assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
+ end
+
+ should "display correct submit button in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
+ assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
+ end
+
+ should "display correct submit button in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
+ assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
+ end
+ end
+
+ context 'for #image_submit method' do
+ setup do
+ @stamp = stop_time_for_test.to_i
+ end
+
+ should "display correct image submit button html with no options" do
+ actual_html = standard_builder.image_submit('buttons/ok.png')
+ assert_has_tag('input[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
+ end
+
+ should "display correct image submit button html" do
+ actual_html = standard_builder.image_submit('/system/ok.png', :class => 'large')
+ assert_has_tag('input.large[type=image]', :src => "/system/ok.png?#{@stamp}") { actual_html }
+ end
+
+ should "display correct image submit button in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
+ assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
+ end
+
+ should "display correct image submit button in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
+ assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
+ end
+
+ should "display correct image submit button in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
+ assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
+ end
+ end
+
+ context 'for #fields_for method' do
+ setup do
+ @telephone = mock_model("Telephone", :number => "4568769876")
+ @user.stubs(:telephone).returns(@telephone)
+ @businesses = [ mock_model("Business", :name => "Silver", :new_record? => false, :id => 20) ]
+ @businesses << mock_model("Business", :name => "Gold", :new_record? => true)
+ @addresses = [ mock_model("Address", :name => "Foo", :new_record? => false, :id => 20, :businesses => @businesses) ]
+ @addresses << mock_model("Address", :name => "Bar", :new_record? => true, :businesses => @businesses)
+ @user.stubs(:addresses).returns(@addresses)
+ end
+
+ should "display nested children fields one-to-one within form" do
+ actual_html = standard_builder.fields_for :telephone do |child_form|
+ child_form.label(:number) +
+ child_form.text_field(:number) +
+ child_form.check_box('_destroy')
+ end
+ assert_has_tag('label', :for => 'user_telephone_attributes_number') { actual_html }
+ assert_has_tag('input', :type => 'text', :id => 'user_telephone_attributes_number', :name => 'user[telephone_attributes][number]', :value => "4568769876") { actual_html }
+ assert_has_tag('input', :type => 'hidden', :name => 'user[telephone_attributes][_destroy]', :value => '0') { actual_html }
+ assert_has_tag('input', :type => 'checkbox', :id => 'user_telephone_attributes__destroy', :name => 'user[telephone_attributes][_destroy]', :value => '1') { actual_html }
+ end
+
+ should "display nested children fields one-to-many within form" do
+ actual_html = standard_builder.fields_for(:addresses) do |child_form|
+ html = child_form.label(:name)
+ html << child_form.check_box('_destroy') unless child_form.object.new_record?
+ html << child_form.text_field(:name)
+ end
+ # Address 1 (Saved)
+ assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20') { actual_html }
+ assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
+ assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]') { actual_html }
+ assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]') { actual_html }
+ # Address 2 (New)
+ assert_has_no_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_1_id') { actual_html }
+ assert_has_tag('label', :for => 'user_addresses_attributes_1_name', :content => 'Name') { actual_html }
+ assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_name', :name => 'user[addresses_attributes][1][name]') { actual_html }
+ assert_has_no_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_1__destroy') { actual_html }
+ end
+
+ should "display fields for explicit instance object" do
+ address = mock_model("Address", :name => "Page", :new_record? => false, :id => 40)
+ actual_html = standard_builder.fields_for(:addresses, address) do |child_form|
+ html = child_form.label(:name)
+ html << child_form.text_field(:name)
+ html << child_form.check_box('_destroy')
+ end
+ assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '40') { actual_html }
+ assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
+ assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Page") { actual_html }
+ assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]', :value => '1') { actual_html }
+ end
+
+ should "display fields for collection object" do
+ addresses = @addresses + [mock_model("Address", :name => "Walter", :new_record? => false, :id => 50)]
+ actual_html = standard_builder.fields_for(:addresses, addresses) do |child_form|
+ child_form.label(:name) +
+ child_form.text_field(:name) +
+ child_form.check_box('_destroy')
+ end
+ # Address 1
+ assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20') { actual_html }
+ assert_has_tag('label', :for => 'user_addresses_attributes_0_name', :content => 'Name') { actual_html }
+ assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Foo") { actual_html }
+ assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]') { actual_html }
+ # Address 3
+ assert_has_tag('input', :type => 'hidden', :id => 'user_addresses_attributes_2_id', :value => '50') { actual_html }
+ assert_has_tag('label', :for => 'user_addresses_attributes_2_name', :content => 'Name') { actual_html }
+ assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_2_name', :name => 'user[addresses_attributes][2][name]', :value => "Walter") { actual_html }
+ assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_2__destroy') { actual_html }
+ end
+
+ should "display fields for arbitrarily deep nested forms" do
+ actual_html = standard_builder.fields_for :addresses do |child_form|
+ child_form.fields_for(:businesses) do |second_child_form|
+ second_child_form.label(:name) +
+ second_child_form.text_field(:name) +
+ second_child_form.check_box('_destroy')
+ end
+ end
+ assert_has_tag('label', :for => 'user_addresses_attributes_1_businesses_attributes_0_name', :content => 'Name') { actual_html }
+ assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_0_name', :name => 'user[addresses_attributes][1][businesses_attributes][0][name]') { actual_html }
+ end
+
+ should "display nested children fields in erb" do
+ visit '/erb/fields_for'
+ # Telephone
+ assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
+ assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
+ # Address 1 (Saved)
+ assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
+ assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
+ assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
+ assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
+ # Address 2 (New)
+ assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
+ assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
+ assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
+ assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
+ end
+
+ should "display nested children fields in haml" do
+ visit '/haml/fields_for'
+ # Telephone
+ assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
+ assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
+ # Address 1 (Saved)
+ assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
+ assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
+ assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
+ assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
+ # Address 2 (New)
+ assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
+ assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
+ assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
+ assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
+ end
+
+ should "display nested children fields in slim" do
+ visit '/slim/fields_for'
+ # Telephone
+ assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
+ assert_have_selector('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
+ # Address 1 (Saved)
+ assert_have_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
+ assert_have_selector('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
+ assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
+ assert_have_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
+ # Address 2 (New)
+ assert_have_no_selector('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
+ assert_have_selector('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
+ assert_have_selector('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
+ assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
+ end
+ end
+
+ # ===========================
+ # StandardFormBuilder
+ # ===========================
+
+ context 'for #text_field_block method' do
+ should "display correct text field block html" do
+ actual_html = standard_builder.text_field_block(:first_name, :class => 'large', :caption => "FName")
+ assert_has_tag('p label', :for => 'user_first_name', :content => "FName") { actual_html }
+ assert_has_tag('p input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
+ end
+
+ should "display correct text field block in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
+ assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
+ end
+
+ should "display correct text field block in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
+ assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
+ end
+
+ should "display correct text field block in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
+ assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
+ end
+ end
+
+ context 'for #text_area_block method' do
+ should "display correct text area block html" do
+ actual_html = standard_builder.text_area_block(:about, :class => 'large', :caption => "About Me")
+ assert_has_tag('p label', :for => 'user_about', :content => "About Me") { actual_html }
+ assert_has_tag('p textarea', :id => 'user_about', :name => 'user[about]') { actual_html }
+ end
+
+ should "display correct text area block in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
+ assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
+ end
+
+ should "display correct text area block in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
+ assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
+ end
+
+ should "display correct text area block in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
+ assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
+ end
+ end
+
+ context 'for #password_field_block method' do
+ should "display correct password field block html" do
+ actual_html = standard_builder.password_field_block(:keycode, :class => 'large', :caption => "Code: ")
+ assert_has_tag('p label', :for => 'user_keycode', :content => "Code: ") { actual_html }
+ assert_has_tag('p input.large[type=password]', :id => 'user_keycode', :name => 'user[keycode]') { actual_html }
+ end
+
+ should "display correct password field block in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
+ assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
+ end
+
+ should "display correct password field block in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
+ assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
+ end
+
+ should "display correct password field block in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
+ assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
+ end
+ end
+
+ context 'for #file_field_block method' do
+ should "display correct file field block html" do
+ actual_html = standard_builder.file_field_block(:photo, :class => 'large', :caption => "Photo: ")
+ assert_has_tag('p label', :for => 'user_photo', :content => "Photo: ") { actual_html }
+ assert_has_tag('p input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
+ end
+
+ should "display correct file field block in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
+ assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
+ end
+
+ should "display correct file field block in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
+ assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
+ end
+
+ should "display correct file field block in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
+ assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
+ end
+ end
+
+ context 'for #check_box_block method' do
+ should "display correct check box block html" do
+ actual_html = standard_builder.check_box_block(:remember_me, :class => 'large', :caption => "Remember session?")
+ assert_has_tag('p label', :for => 'user_remember_me', :content => "Remember session?") { actual_html }
+ assert_has_tag('p input.large[type=checkbox]', :id => 'user_remember_me', :name => 'user[remember_me]') { actual_html }
+ end
+
+ should "display correct check box block in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
+ assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
+ end
+
+ should "display correct check box block in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
+ assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
+ end
+
+ should "display correct check box block in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
+ assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
+ end
+ end
+
+ context 'for #select_block method' do
+ should "display correct select_block block html" do
+ actual_html = standard_builder.select_block(:country, :options => ['USA', 'Canada'], :class => 'large', :caption => "Your country")
+ assert_has_tag('p label', :for => 'user_country', :content => "Your country") { actual_html }
+ assert_has_tag('p select', :id => 'user_country', :name => 'user[country]') { actual_html }
+ assert_has_tag('p select option', :content => 'USA') { actual_html }
+ assert_has_tag('p select option', :content => 'Canada') { actual_html }
+ end
+
+ should "display correct select_block block in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
+ assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
+ assert_have_selector '#demo2 p select option', :content => 'California'
+ assert_have_selector '#demo2 p select option', :content => 'Texas'
+ end
+
+ should "display correct select_block block in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
+ assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
+ end
+
+ should "display correct select_block block in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
+ assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
+ end
+ end
+
+ context 'for #submit_block method' do
+ should "display correct submit block html" do
+ actual_html = standard_builder.submit_block("Update", :class => 'large')
+ assert_has_tag('p input.large[type=submit]', :value => 'Update') { actual_html }
+ end
+
+ should "display correct submit block in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
+ end
+
+ should "display correct submit block in erb" do
+ visit '/erb/form_for'
+ assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
+ end
+
+ should "display correct submit block in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
+ end
+ end
+
+ context 'for #image_submit_block method' do
+ setup do
+ @stamp = stop_time_for_test.to_i
+ end
+
+ should "display correct image submit block html" do
+ actual_html = standard_builder.image_submit_block("buttons/ok.png", :class => 'large')
+ assert_has_tag('p input.large[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
+ end
+
+ should "display correct image submit block in haml" do
+ visit '/haml/form_for'
+ assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
+ end
+
+ should "display correct image submit block in slim" do
+ visit '/slim/form_for'
+ assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
+ end
+ end
+end
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_form_helpers.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_form_helpers.rb
new file mode 100644
index 00000000..6571e364
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_form_helpers.rb
@@ -0,0 +1,645 @@
+require File.expand_path(File.dirname(__FILE__) + '/helper')
+require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
+
+class TestFormHelpers < Test::Unit::TestCase
+ include Padrino::Helpers::FormHelpers
+
+ def app
+ MarkupDemo.tap { |app| app.set :environment, :test }
+ end
+
+ context 'for #form_tag method' do
+ should "display correct forms in ruby" do
+ actual_html = form_tag('/register', :"accept-charset" => "UTF-8", :class => 'test', :method => "post") { "Demo" }
+ assert_has_tag(:form, :"accept-charset" => "UTF-8", :class => "test") { actual_html }
+ assert_has_tag('form input', :type => 'hidden', :name => '_method', :count => 0) { actual_html }
+ end
+
+ should "display correct text inputs within form_tag" do
+ actual_html = form_tag('/register', :"accept-charset" => "UTF-8", :class => 'test') { text_field_tag(:username) }
+ assert_has_tag('form input', :type => 'text', :name => "username") { actual_html }
+ end
+
+ should "display correct form with remote" do
+ actual_html = form_tag('/update', :"accept-charset" => "UTF-8", :class => 'put-form', :remote => true) { "Demo" }
+ assert_has_tag(:form, :class => "put-form", :"accept-charset" => "UTF-8", :"data-remote" => 'true') { actual_html }
+ assert_has_no_tag(:form, "data-method" => 'post') { actual_html }
+ end
+
+ should "display correct form with remote and method is put" do
+ actual_html = form_tag('/update', :"accept-charset" => "UTF-8", :method => 'put', :remote => true) { "Demo" }
+ assert_has_tag(:form, "data-remote" => 'true', :"accept-charset" => "UTF-8", :"data-method" => 'put') { actual_html }
+ assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
+ end
+
+ should "display correct form with method :put" do
+ actual_html = form_tag('/update', :"accept-charset" => "UTF-8", :class => 'put-form', :method => "put") { "Demo" }
+ assert_has_tag(:form, :class => "put-form", :"accept-charset" => "UTF-8", :method => 'post') { actual_html }
+ assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
+ end
+
+ should "display correct form with method :delete and charset" do
+ actual_html = form_tag('/remove', :"accept-charset" => "UTF-8", :class => 'delete-form', :method => "delete") { "Demo" }
+ assert_has_tag(:form, :class => "delete-form", :"accept-charset" => "UTF-8", :method => 'post') { actual_html }
+ assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'delete') { actual_html }
+ end
+
+ should "display correct form with charset" do
+ actual_html = form_tag('/charset', :"accept-charset" => "UTF-8", :class => 'charset-form') { "Demo" }
+ assert_has_tag(:form, :class => "charset-form", :"accept-charset" => "UTF-8", :method => 'post') { actual_html }
+ end
+
+ should "display correct form with multipart encoding" do
+ actual_html = form_tag('/remove', :"accept-charset" => "UTF-8", :multipart => true) { "Demo" }
+ assert_has_tag(:form, :enctype => "multipart/form-data") { actual_html }
+ end
+
+ should "display correct forms in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.simple-form', :action => '/simple'
+ assert_have_selector 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
+ end
+
+ should "display correct forms in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.simple-form', :action => '/simple'
+ assert_have_selector 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
+ end
+
+ should "display correct forms in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.simple-form', :action => '/simple'
+ assert_have_selector 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
+ end
+ end
+
+ context 'for #field_set_tag method' do
+ should "display correct field_sets in ruby" do
+ actual_html = field_set_tag("Basic", :class => 'basic') { "Demo" }
+ assert_has_tag(:fieldset, :class => 'basic') { actual_html }
+ assert_has_tag('fieldset legend', :content => "Basic") { actual_html }
+ end
+
+ should "display correct field_sets in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.simple-form fieldset', :count => 1
+ assert_have_no_selector 'form.simple-form fieldset legend'
+ assert_have_selector 'form.advanced-form fieldset', :count => 1, :class => 'advanced-field-set'
+ assert_have_selector 'form.advanced-form fieldset legend', :content => "Advanced"
+ end
+
+ should "display correct field_sets in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.simple-form fieldset', :count => 1
+ assert_have_no_selector 'form.simple-form fieldset legend'
+ assert_have_selector 'form.advanced-form fieldset', :count => 1, :class => 'advanced-field-set'
+ assert_have_selector 'form.advanced-form fieldset legend', :content => "Advanced"
+ end
+
+ should "display correct field_sets in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.simple-form fieldset', :count => 1
+ assert_have_no_selector 'form.simple-form fieldset legend'
+ assert_have_selector 'form.advanced-form fieldset', :count => 1, :class => 'advanced-field-set'
+ assert_have_selector 'form.advanced-form fieldset legend', :content => "Advanced"
+ end
+ end
+
+ context 'for #error_messages_for method' do
+ should "display correct error messages list in ruby" do
+ user = mock_model("User", :errors => { :a => "1", :b => "2" }, :blank? => false)
+ actual_html = error_messages_for(user)
+ assert_has_tag('div.field-errors') { actual_html }
+ assert_has_tag('div.field-errors h2', :content => "2 errors prohibited this User from being saved") { actual_html }
+ assert_has_tag('div.field-errors p', :content => "There were problems with the following fields:") { actual_html }
+ assert_has_tag('div.field-errors ul') { actual_html }
+ assert_has_tag('div.field-errors ul li', :count => 2) { actual_html }
+ end
+
+ should "display correct error messages list in erb" do
+ visit '/erb/form_tag'
+ assert_have_no_selector 'form.simple-form .field-errors'
+ assert_have_selector 'form.advanced-form .field-errors'
+ assert_have_selector 'form.advanced-form .field-errors h2', :content => "There are problems with saving user!"
+ assert_have_selector 'form.advanced-form .field-errors p', :content => "There were problems with the following fields:"
+ assert_have_selector 'form.advanced-form .field-errors ul'
+ assert_have_selector 'form.advanced-form .field-errors ul li', :count => 4
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Email must be a email"
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Fake must be valid"
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Second must be present"
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
+ end
+
+ should "display correct error messages list in haml" do
+ visit '/haml/form_tag'
+ assert_have_no_selector 'form.simple-form .field-errors'
+ assert_have_selector 'form.advanced-form .field-errors'
+ assert_have_selector 'form.advanced-form .field-errors h2', :content => "There are problems with saving user!"
+ assert_have_selector 'form.advanced-form .field-errors p', :content => "There were problems with the following fields:"
+ assert_have_selector 'form.advanced-form .field-errors ul'
+ assert_have_selector 'form.advanced-form .field-errors ul li', :count => 4
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Email must be a email"
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Fake must be valid"
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Second must be present"
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
+ end
+
+ should "display correct error messages list in slim" do
+ visit '/slim/form_tag'
+ assert_have_no_selector 'form.simple-form .field-errors'
+ assert_have_selector 'form.advanced-form .field-errors'
+ assert_have_selector 'form.advanced-form .field-errors h2', :content => "There are problems with saving user!"
+ assert_have_selector 'form.advanced-form .field-errors p', :content => "There were problems with the following fields:"
+ assert_have_selector 'form.advanced-form .field-errors ul'
+ assert_have_selector 'form.advanced-form .field-errors ul li', :count => 4
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Email must be a email"
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Fake must be valid"
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Second must be present"
+ assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
+ end
+ end
+
+ context 'for #error_message_on method' do
+ should "display correct error message on specified model name in ruby" do
+ @user = mock_model("User", :errors => { :a => "1", :b => "2" }, :blank? => false)
+ actual_html = error_message_on(:user, :a, :prepend => "foo", :append => "bar")
+ assert_has_tag('span.error', :content => "foo 1 bar") { actual_html }
+ end
+
+ should "display correct error message on specified object in ruby" do
+ @bob = mock_model("User", :errors => { :a => "1", :b => "2" }, :blank? => false)
+ actual_html = error_message_on(@bob, :a, :prepend => "foo", :append => "bar")
+ assert_has_tag('span.error', :content => "foo 1 bar") { actual_html }
+ end
+
+ should "display no message when error isn't present" do
+ @user = mock_model("User", :errors => { :a => "1", :b => "2" }, :blank? => false)
+ actual_html = error_message_on(:user, :fake, :prepend => "foo", :append => "bar")
+ assert actual_html.blank?
+ end
+ end
+
+ context 'for #label_tag method' do
+ should "display label tag in ruby" do
+ actual_html = label_tag(:username, :class => 'long-label', :caption => "Nickname")
+ assert_has_tag(:label, :for => 'username', :class => 'long-label', :content => "Nickname") { actual_html }
+ end
+
+ should "display label tag in ruby with required" do
+ actual_html = label_tag(:username, :caption => "Nickname", :required => true)
+ assert_has_tag(:label, :for => 'username', :content => 'Nickname') { actual_html }
+ assert_has_tag('label[for=username] span.required', :content => "*") { actual_html }
+ end
+
+ should "display label tag in erb for simple form" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.simple-form label', :count => 4
+ assert_have_selector 'form.simple-form label', :content => "Username", :for => 'username'
+ assert_have_selector 'form.simple-form label', :content => "Password", :for => 'password'
+ assert_have_selector 'form.simple-form label', :content => "Gender", :for => 'gender'
+ end
+ should "display label tag in erb for advanced form" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.advanced-form label', :count => 6
+ assert_have_selector 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
+ assert_have_selector 'form.advanced-form label.first', :content => "Password", :for => 'password'
+ assert_have_selector 'form.advanced-form label.about', :content => "About Me", :for => 'about'
+ assert_have_selector 'form.advanced-form label.photo', :content => "Photo" , :for => 'photo'
+ assert_have_selector 'form.advanced-form label.gender', :content => "Gender" , :for => 'gender'
+ end
+
+ should "display label tag in haml for simple form" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.simple-form label', :count => 4
+ assert_have_selector 'form.simple-form label', :content => "Username", :for => 'username'
+ assert_have_selector 'form.simple-form label', :content => "Password", :for => 'password'
+ assert_have_selector 'form.simple-form label', :content => "Gender", :for => 'gender'
+ end
+
+ should "display label tag in haml for advanced form" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.advanced-form label', :count => 6
+ assert_have_selector 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
+ assert_have_selector 'form.advanced-form label.first', :content => "Password", :for => 'password'
+ assert_have_selector 'form.advanced-form label.about', :content => "About Me", :for => 'about'
+ assert_have_selector 'form.advanced-form label.photo', :content => "Photo" , :for => 'photo'
+ assert_have_selector 'form.advanced-form label.gender', :content => "Gender" , :for => 'gender'
+ end
+
+ should "display label tag in slim for simple form" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.simple-form label', :count => 4
+ assert_have_selector 'form.simple-form label', :content => "Username", :for => 'username'
+ assert_have_selector 'form.simple-form label', :content => "Password", :for => 'password'
+ assert_have_selector 'form.simple-form label', :content => "Gender", :for => 'gender'
+ end
+
+ should "display label tag in slim for advanced form" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.advanced-form label', :count => 6
+ assert_have_selector 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
+ assert_have_selector 'form.advanced-form label.first', :content => "Password", :for => 'password'
+ assert_have_selector 'form.advanced-form label.about', :content => "About Me", :for => 'about'
+ assert_have_selector 'form.advanced-form label.photo', :content => "Photo" , :for => 'photo'
+ assert_have_selector 'form.advanced-form label.gender', :content => "Gender" , :for => 'gender'
+ end
+ end
+
+ context 'for #hidden_field_tag method' do
+ should "display hidden field in ruby" do
+ actual_html = hidden_field_tag(:session_key, :id => 'session_id', :value => '56768')
+ assert_has_tag(:input, :type => 'hidden', :id => "session_id", :name => 'session_key', :value => '56768') { actual_html }
+ end
+
+ should "display hidden field in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.simple-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
+ assert_have_selector 'form.advanced-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
+ end
+
+ should "display hidden field in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.simple-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
+ assert_have_selector 'form.advanced-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
+ end
+
+ should "display hidden field in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.simple-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
+ assert_have_selector 'form.advanced-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
+ end
+ end
+
+ context 'for #text_field_tag method' do
+ should "display text field in ruby" do
+ actual_html = text_field_tag(:username, :class => 'long')
+ assert_has_tag(:input, :type => 'text', :class => "long", :name => 'username') { actual_html }
+ end
+
+ should "display text field in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.simple-form input[type=text]', :count => 1, :name => 'username'
+ assert_have_selector 'form.advanced-form fieldset input[type=text]', :count => 1, :name => 'username', :id => 'the_username'
+ end
+
+ should "display text field in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.simple-form input[type=text]', :count => 1, :name => 'username'
+ assert_have_selector 'form.advanced-form fieldset input[type=text]', :count => 1, :name => 'username', :id => 'the_username'
+ end
+
+ should "display text field in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.simple-form input[type=text]', :count => 1, :name => 'username'
+ assert_have_selector 'form.advanced-form fieldset input[type=text]', :count => 1, :name => 'username', :id => 'the_username'
+ end
+ end
+
+ context 'for #text_area_tag method' do
+ should "display text area in ruby" do
+ actual_html = text_area_tag(:about, :class => 'long')
+ assert_has_tag(:textarea, :class => "long", :name => 'about', :rows => '', :cols => '') { actual_html }
+ end
+
+ should "display text area in ruby with specified content" do
+ actual_html = text_area_tag(:about, :value => "a test", :rows => 5, :cols => 6)
+ assert_has_tag(:textarea, :content => "a test", :name => 'about', :rows => "5", :cols => "6") { actual_html }
+ end
+
+ should "display text area in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.advanced-form textarea', :count => 1, :name => 'about', :class => 'large'
+ end
+
+ should "display text area in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.advanced-form textarea', :count => 1, :name => 'about', :class => 'large'
+ end
+
+ should "display text area in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.advanced-form textarea', :count => 1, :name => 'about', :class => 'large'
+ end
+ end
+
+ context 'for #password_field_tag method' do
+ should "display password field in ruby" do
+ actual_html = password_field_tag(:password, :class => 'long')
+ assert_has_tag(:input, :type => 'password', :class => "long", :name => 'password') { actual_html }
+ end
+
+ should "display password field in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.simple-form input[type=password]', :count => 1, :name => 'password'
+ assert_have_selector 'form.advanced-form input[type=password]', :count => 1, :name => 'password'
+ end
+
+ should "display password field in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.simple-form input[type=password]', :count => 1, :name => 'password'
+ assert_have_selector 'form.advanced-form input[type=password]', :count => 1, :name => 'password'
+ end
+
+ should "display password field in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.simple-form input[type=password]', :count => 1, :name => 'password'
+ assert_have_selector 'form.advanced-form input[type=password]', :count => 1, :name => 'password'
+ end
+ end
+
+ context 'for #file_field_tag method' do
+ should "display file field in ruby" do
+ actual_html = file_field_tag(:photo, :class => 'photo')
+ assert_has_tag(:input, :type => 'file', :class => "photo", :name => 'photo') { actual_html }
+ end
+
+ should "display file field in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
+ end
+
+ should "display file field in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
+ end
+
+ should "display file field in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
+ end
+ end
+
+ context "for #check_box_tag method" do
+ should "display check_box tag in ruby" do
+ actual_html = check_box_tag("clear_session")
+ assert_has_tag(:input, :type => 'checkbox', :value => '1', :name => 'clear_session') { actual_html }
+ assert_has_no_tag(:input, :type => 'hidden') { actual_html }
+ end
+
+ should "display check_box tag in ruby with extended attributes" do
+ actual_html = check_box_tag("clear_session", :disabled => true, :checked => true)
+ assert_has_tag(:input, :type => 'checkbox', :disabled => 'disabled', :checked => 'checked') { actual_html }
+ end
+
+ should "display check_box tag in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.simple-form input[type=checkbox]', :count => 1
+ assert_have_selector 'form.advanced-form input[type=checkbox]', :value => "1", :checked => 'checked'
+ end
+
+ should "display check_box tag in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.simple-form input[type=checkbox]', :count => 1
+ assert_have_selector 'form.advanced-form input[type=checkbox]', :value => "1", :checked => 'checked'
+ end
+
+ should "display check_box tag in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.simple-form input[type=checkbox]', :count => 1
+ assert_have_selector 'form.advanced-form input[type=checkbox]', :value => "1", :checked => 'checked'
+ end
+ end
+
+ context "for #radio_button_tag method" do
+ should "display radio_button tag in ruby" do
+ actual_html = radio_button_tag("gender", :value => 'male')
+ assert_has_tag(:input, :type => 'radio', :value => 'male', :name => 'gender') { actual_html }
+ end
+
+ should "display radio_button tag in ruby with extended attributes" do
+ actual_html = radio_button_tag("gender", :disabled => true, :checked => true)
+ assert_has_tag(:input, :type => 'radio', :disabled => 'disabled', :checked => 'checked') { actual_html }
+ end
+
+ should "display radio_button tag in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'male'
+ assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'female'
+ assert_have_selector 'form.advanced-form input[type=radio]', :value => "male", :checked => 'checked'
+ assert_have_selector 'form.advanced-form input[type=radio]', :value => "female"
+ end
+
+ should "display radio_button tag in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'male'
+ assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'female'
+ assert_have_selector 'form.advanced-form input[type=radio]', :value => "male", :checked => 'checked'
+ assert_have_selector 'form.advanced-form input[type=radio]', :value => "female"
+ end
+
+ should "display radio_button tag in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'male'
+ assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'female'
+ assert_have_selector 'form.advanced-form input[type=radio]', :value => "male", :checked => 'checked'
+ assert_have_selector 'form.advanced-form input[type=radio]', :value => "female"
+ end
+ end
+
+ context "for #select_tag method" do
+ should "display select tag in ruby" do
+ actual_html = select_tag(:favorite_color, :options => ['green', 'blue', 'black'], :include_blank => true)
+ assert_has_tag(:select, :name => 'favorite_color') { actual_html }
+ assert_has_tag('select option:first-child', :content => '') { actual_html }
+ assert_has_tag('select option', :content => 'green', :value => 'green') { actual_html }
+ assert_has_tag('select option', :content => 'blue', :value => 'blue') { actual_html }
+ assert_has_tag('select option', :content => 'black', :value => 'black') { actual_html }
+ end
+
+ should "display select tag in ruby with extended attributes" do
+ actual_html = select_tag(:favorite_color, :disabled => true, :options => ['only', 'option'])
+ assert_has_tag(:select, :disabled => 'disabled') { actual_html }
+ end
+
+ should "take a range as a collection for options" do
+ actual_html = select_tag(:favorite_color, :options => (1..3))
+ assert_has_tag(:select) { actual_html }
+ assert_has_tag('select option', :value => '1') { actual_html }
+ assert_has_tag('select option', :value => '2') { actual_html }
+ assert_has_tag('select option', :value => '3') { actual_html }
+ end
+
+ should "include blank for grouped options" do
+ opts = { "Red" => ["Rose","Fire"], "Blue" => ["Sky","Sea"] }
+ actual_html = select_tag( 'color', :grouped_options => opts, :include_blank => true )
+ assert_has_tag('select option:first-child', :value => "", :content => "") { actual_html }
+ end
+
+ should "return a select tag with grouped options for an nested array" do
+ opts = [
+ ["Friends",["Yoda",["Obiwan",2]]],
+ ["Enemies", ["Palpatine",['Darth Vader',3]]]
+ ]
+ actual_html = select_tag( 'name', :grouped_options => opts )
+ assert_has_tag(:select, :name => "name") { actual_html }
+ assert_has_tag(:optgroup, :label => "Friends") { actual_html }
+ assert_has_tag(:option, :value => "Yoda", :content => "Yoda") { actual_html }
+ assert_has_tag(:option, :value => "2", :content => "Obiwan") { actual_html }
+ assert_has_tag(:optgroup, :label => "Enemies") { actual_html }
+ assert_has_tag(:option, :value => "Palpatine", :content => "Palpatine") { actual_html }
+ assert_has_tag(:option, :value => "3", :content => "Darth Vader") { actual_html }
+ end
+
+ should "return a select tag with grouped options for a hash" do
+ opts = {
+ "Friends" => ["Yoda",["Obiwan",2]],
+ "Enemies" => ["Palpatine",['Darth Vader',3]]
+ }
+ actual_html = select_tag( 'name', :grouped_options => opts )
+ assert_has_tag(:select, :name => "name") { actual_html }
+ assert_has_tag(:optgroup, :label => "Friends") { actual_html }
+ assert_has_tag(:option, :value => "Yoda", :content => "Yoda") { actual_html }
+ assert_has_tag(:option, :value => "2", :content => "Obiwan") { actual_html }
+ assert_has_tag(:optgroup, :label => "Enemies") { actual_html }
+ assert_has_tag(:option, :value => "Palpatine", :content => "Palpatine") { actual_html }
+ assert_has_tag(:option, :value => "3", :content => "Darth Vader") { actual_html }
+ end
+
+ should "display select tag in ruby with multiple attribute" do
+ actual_html = select_tag(:favorite_color, :multiple => true, :options => ['only', 'option'])
+ assert_has_tag(:select, :multiple => 'multiple', :name => 'favorite_color[]') { actual_html }
+ end
+
+ should "display options with values and single selected" do
+ options = [['Green', 'green1'], ['Blue', 'blue1'], ['Black', "black1"]]
+ actual_html = select_tag(:favorite_color, :options => options, :selected => 'green1')
+ assert_has_tag(:select, :name => 'favorite_color') { actual_html }
+ assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
+ assert_has_tag('select option', :content => 'Green', :value => 'green1', :selected => 'selected') { actual_html }
+ assert_has_tag('select option', :content => 'Blue', :value => 'blue1') { actual_html }
+ assert_has_tag('select option', :content => 'Black', :value => 'black1') { actual_html }
+ end
+
+ should "display option with values and multiple selected" do
+ options = [['Green', 'green1'], ['Blue', 'blue1'], ['Black', "black1"]]
+ actual_html = select_tag(:favorite_color, :options => options, :selected => ['green1', 'Black'])
+ assert_has_tag(:select, :name => 'favorite_color') { actual_html }
+ assert_has_tag('select option', :selected => 'selected', :count => 2) { actual_html }
+ assert_has_tag('select option', :content => 'Green', :value => 'green1', :selected => 'selected') { actual_html }
+ assert_has_tag('select option', :content => 'Blue', :value => 'blue1') { actual_html }
+ assert_has_tag('select option', :content => 'Black', :value => 'black1', :selected => 'selected') { actual_html }
+ end
+
+ should "display options selected only for exact match" do
+ options = [['One', '1'], ['1', '10'], ['Two', "-1"]]
+ actual_html = select_tag(:range, :options => options, :selected => '-1')
+ assert_has_tag(:select, :name => 'range') { actual_html }
+ assert_has_tag('select option', :selected => 'selected', :count => 1) { actual_html }
+ assert_has_tag('select option', :content => 'Two', :value => '-1', :selected => 'selected') { actual_html }
+ end
+
+ should "display select tag in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.simple-form select', :count => 1, :name => 'color'
+ assert_have_selector('select option', :content => 'green', :value => 'green')
+ assert_have_selector('select option', :content => 'orange', :value => 'orange')
+ assert_have_selector('select option', :content => 'purple', :value => 'purple')
+ assert_have_selector 'form.advanced-form select', :name => 'fav_color'
+ assert_have_selector('select option', :content => 'green', :value => '1')
+ assert_have_selector('select option', :content => 'orange', :value => '2', :selected => 'selected')
+ assert_have_selector('select option', :content => 'purple', :value => '3')
+ end
+
+ should "display select tag in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.simple-form select', :count => 1, :name => 'color'
+ assert_have_selector('select option', :content => 'green', :value => 'green')
+ assert_have_selector('select option', :content => 'orange', :value => 'orange')
+ assert_have_selector('select option', :content => 'purple', :value => 'purple')
+ assert_have_selector 'form.advanced-form select', :name => 'fav_color'
+ assert_have_selector('select option', :content => 'green', :value => '1')
+ assert_have_selector('select option', :content => 'orange', :value => '2', :selected => 'selected')
+ assert_have_selector('select option', :content => 'purple', :value => '3')
+ end
+
+ should "display select tag in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.simple-form select', :count => 1, :name => 'color'
+ assert_have_selector('select option', :content => 'green', :value => 'green')
+ assert_have_selector('select option', :content => 'orange', :value => 'orange')
+ assert_have_selector('select option', :content => 'purple', :value => 'purple')
+ assert_have_selector 'form.advanced-form select', :name => 'fav_color'
+ assert_have_selector('select option', :content => 'green', :value => '1')
+ assert_have_selector('select option', :content => 'orange', :value => '2', :selected => 'selected')
+ assert_have_selector('select option', :content => 'purple', :value => '3')
+ end
+ end
+
+ context 'for #submit_tag method' do
+ should "display submit tag in ruby" do
+ actual_html = submit_tag("Update", :class => 'success')
+ assert_has_tag(:input, :type => 'submit', :class => "success", :value => 'Update') { actual_html }
+ end
+
+ should "display submit tag in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.simple-form input[type=submit]', :count => 1, :value => "Submit"
+ assert_have_selector 'form.advanced-form input[type=submit]', :count => 1, :value => "Login"
+ end
+
+ should "display submit tag in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.simple-form input[type=submit]', :count => 1, :value => "Submit"
+ assert_have_selector 'form.advanced-form input[type=submit]', :count => 1, :value => "Login"
+ end
+
+ should "display submit tag in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.simple-form input[type=submit]', :count => 1, :value => "Submit"
+ assert_have_selector 'form.advanced-form input[type=submit]', :count => 1, :value => "Login"
+ end
+ end
+
+ context 'for #button_tag method' do
+ should "display submit tag in ruby" do
+ actual_html = button_tag("Cancel", :class => 'clear')
+ assert_has_tag(:input, :type => 'button', :class => "clear", :value => 'Cancel') { actual_html }
+ end
+
+ should "display submit tag in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
+ end
+
+ should "display submit tag in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
+ end
+
+ should "display submit tag in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
+ end
+ end
+
+ context 'for #image_submit_tag method' do
+ setup do
+ @stamp = stop_time_for_test.to_i
+ end
+
+ should "display image submit tag in ruby with relative path" do
+ actual_html = image_submit_tag('buttons/ok.png', :class => 'success')
+ assert_has_tag(:input, :type => 'image', :class => "success", :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
+ end
+
+ should "display image submit tag in ruby with absolute path" do
+ actual_html = image_submit_tag('/system/ok.png', :class => 'success')
+ assert_has_tag(:input, :type => 'image', :class => "success", :src => "/system/ok.png?#{@stamp}") { actual_html }
+ end
+
+ should "display image submit tag in erb" do
+ visit '/erb/form_tag'
+ assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
+ end
+
+ should "display image submit tag in haml" do
+ visit '/haml/form_tag'
+ assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
+ end
+
+ should "display image submit tag in slim" do
+ visit '/slim/form_tag'
+ assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_format_helpers.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_format_helpers.rb
new file mode 100644
index 00000000..e203b16c
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_format_helpers.rb
@@ -0,0 +1,227 @@
+require File.expand_path(File.dirname(__FILE__) + '/helper')
+require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
+
+class TestFormatHelpers < Test::Unit::TestCase
+ def app
+ MarkupDemo.tap { |app| app.set :environment, :test }
+ end
+
+ def setup
+ Time.stubs(:now).returns(Time.utc(1983, 11, 9, 5))
+ end
+
+ include Padrino::Helpers::FormatHelpers
+
+ context 'for #simple_format method' do
+ should "format simple text into html format" do
+ actual_text = simple_format("Here is some basic text...\n...with a line break.")
+ assert_equal "Here is some basic text...\n
...with a line break.
", actual_text
+ end
+
+ should "format more text into html format" do
+ actual_text = simple_format("We want to put a paragraph...\n\n...right there.")
+ assert_equal "We want to put a paragraph...
\n\n...right there.
", actual_text
+ end
+
+ should "support defining a class for the paragraphs" do
+ actual_text = simple_format("Look me! A class!", :class => 'description')
+ assert_equal "Look me! A class!
", actual_text
+ end
+
+ context 'wrapped in a custom tag' do
+ should "format simple text into html format" do
+ actual_text = simple_format("Here is some basic text...\n...with a line break.", :tag => :div)
+ assert_equal "Here is some basic text...\n
...with a line break.
", actual_text
+ end
+
+ should "format more text into html format" do
+ actual_text = simple_format("We want to put a paragraph...\n\n...right there.", :tag => :div)
+ assert_equal "We want to put a paragraph...
\n\n...right there.
", actual_text
+ end
+
+ should "support defining a class for the paragraphs" do
+ actual_text = simple_format("Look me! A class!", :class => 'description', :tag => :div)
+ assert_equal "Look me! A class!
", actual_text
+ end
+ end
+ end
+
+ context 'for #pluralize method' do
+ should "return singular count for 1 item collections" do
+ actual_text = pluralize(1, 'person')
+ assert_equal '1 person', actual_text
+ end
+ should "return plural count for empty collections" do
+ actual_text = pluralize(0, 'person')
+ assert_equal '0 people', actual_text
+ end
+ should "return plural count for many collections" do
+ actual_text = pluralize(2, 'person')
+ assert_equal '2 people', actual_text
+ end
+ should "return pluralized word specified as argument" do
+ actual_text = pluralize(3, 'person', 'users')
+ assert_equal '3 users', actual_text
+ end
+ end
+
+ context 'for #word_wrap method' do
+ should "return proper formatting for 8 max width" do
+ actual_text = word_wrap('Once upon a time', :line_width => 8)
+ assert_equal "Once\nupon a\ntime", actual_text
+ end
+ should "return proper formatting for 1 max width" do
+ actual_text = word_wrap('Once upon a time', :line_width => 1)
+ assert_equal "Once\nupon\na\ntime", actual_text
+ end
+ should "return proper formatting for default width" do
+ actual_text = word_wrap((1..50).to_a.join(" "))
+ assert_equal (1..30).to_a.join(" ") + "\n" + (31..50).to_a.join(" "), actual_text
+ actual_text = word_wrap((1..50).to_a.join(" "), 80)
+ assert_equal (1..30).to_a.join(" ") + "\n" + (31..50).to_a.join(" "), actual_text
+ end
+ end
+
+ context 'for #highlight method' do
+ should 'highligth with defaults' do
+ actual_text = highlight('Lorem ipsum dolor sit amet', 'dolor')
+ assert_equal 'Lorem ipsum dolor sit amet', actual_text
+ end
+
+ should 'highlight with highlighter' do
+ actual_text = highlight('Lorem ipsum dolor sit amet', 'dolor', :highlighter => '\1')
+ assert_equal 'Lorem ipsum dolor sit amet', actual_text
+ end
+ end
+
+ context 'for #truncate method' do
+ should "support default truncation" do
+ actual_text = truncate("Once upon a time in a world far far away")
+ assert_equal "Once upon a time in a world...", actual_text
+ end
+ should "support specifying length" do
+ actual_text = truncate("Once upon a time in a world far far away", :length => 14)
+ assert_equal "Once upon a...", actual_text
+ end
+ should "support specifying omission text" do
+ actual_text = truncate("And they found that many people were sleeping better.", :length => 25, :omission => "(clipped)")
+ assert_equal "And they found t(clipped)", actual_text
+ end
+ end
+
+ context 'for #truncate_words method' do
+ should "support default truncation" do
+ actual_text = truncate_words("Long before books were made, people told stories. They told them to one another and to the children as they sat before the fire. Many of these stories were about interesting people, but most of them were about the ways of fairies and giants.")
+ assert_equal "Long before books were made, people told stories. They told them to one another and to the children as they sat before the fire. Many of these stories were about...", actual_text
+ end
+ should "support specifying length" do
+ actual_text = truncate_words("Once upon a time in a world far far away", :length => 8)
+ assert_equal "Once upon a time in a world far...", actual_text
+ end
+ should "support specifying omission text" do
+ actual_text = truncate_words("And they found that many people were sleeping better.", :length => 4, :omission => "(clipped)")
+ assert_equal "And they found that(clipped)", actual_text
+ end
+ end
+
+ context 'for #h and #h! method' do
+ should "escape the simple html" do
+ assert_equal '<h1>hello</h1>', h('hello
')
+ assert_equal '<h1>hello</h1>', escape_html('hello
')
+ end
+ should "escape all brackets, quotes and ampersands" do
+ assert_equal '<h1><>"&demo&"<></h1>', h('<>"&demo&"<>
')
+ end
+ should "return default text if text is empty" do
+ assert_equal 'default', h!("", "default")
+ assert_equal ' ', h!("")
+ end
+ should "return text escaped if not empty" do
+ assert_equal '<h1>hello</h1>', h!('hello
')
+ end
+ end
+
+ context 'for #time_ago_in_words method' do
+ should "less than 5 seconds" do
+ assert_equal 'less than 5 seconds', time_ago_in_words(Time.now, true)
+ end
+ should "less than 10 seconds" do
+ assert_equal 'less than 10 seconds', time_ago_in_words(Time.now-5, true)
+ end
+ should "less than 20 seconds" do
+ assert_equal 'less than 20 seconds', time_ago_in_words(Time.now-10, true)
+ end
+ should "less than a minute" do
+ assert_equal 'less than a minute', time_ago_in_words(Time.now-40, true)
+ end
+ should "2 minutes" do
+ assert_equal '2 minutes', time_ago_in_words(Time.now-120, true)
+ end
+ should "display today" do
+ assert_equal 'less than a minute', time_ago_in_words(Time.now)
+ end
+ should "display yesterday" do
+ assert_equal '1 day', time_ago_in_words(1.day.ago)
+ end
+ should "display tomorrow" do
+ assert_equal '1 day', time_ago_in_words(1.day.from_now)
+ end
+ should "return future number of days" do
+ assert_equal '4 days', time_ago_in_words(4.days.from_now)
+ end
+ should "return past days ago" do
+ assert_equal '4 days', time_ago_in_words(4.days.ago)
+ end
+ should "return formatted archived date" do
+ assert_equal '3 months', time_ago_in_words(100.days.ago)
+ end
+ should "return formatted archived year date" do
+ assert_equal 'over 1 year', time_ago_in_words(500.days.ago)
+ end
+ should 'display now as a minute ago' do
+ assert_equal '1 minute', time_ago_in_words(1.minute.ago)
+ end
+ should "display a few minutes ago" do
+ assert_equal '4 minutes', time_ago_in_words(4.minute.ago)
+ end
+ should "display an hour ago" do
+ assert_equal 'about 1 hour', time_ago_in_words(1.hour.ago + 5.minutes.ago.sec)
+ end
+ should "display a few hours ago" do
+ assert_equal 'about 3 hours', time_ago_in_words(3.hour.ago + 5.minutes.ago.sec)
+ end
+ should "display a day ago" do
+ assert_equal '1 day', time_ago_in_words(1.day.ago)
+ end
+ should "display a few days ago" do
+ assert_equal '5 days', time_ago_in_words(5.days.ago - 5.minutes.ago.sec)
+ end
+ should "display a month ago" do
+ assert_equal 'about 1 month', time_ago_in_words(32.days.ago + 5.minutes.ago.sec)
+ end
+ should "display a few months ago" do
+ assert_equal '6 months', time_ago_in_words(180.days.ago - 5.minutes.ago.sec)
+ end
+ should "display a year ago" do
+ assert_equal 'about 1 year', time_ago_in_words(365.days.ago - 5.minutes.ago.sec)
+ end
+ should "display a few years ago" do
+ assert_equal 'over 7 years', time_ago_in_words(2800.days.ago - 5.minutes.ago.sec)
+ end
+ end
+
+ context 'for #js_escape_html method' do
+ should "escape double quotes" do
+ assert_equal "\\\"hello\\\"", js_escape_html('"hello"')
+ end
+ should "escape single quotes" do
+ assert_equal "\\'hello\\'", js_escape_html("'hello'")
+ end
+ should "escape html tags and breaks" do
+ assert_equal "\\n\\nhello<\\/p>\\n", js_escape_html("\n\r
hello
\r\n")
+ end
+ should "escape data-confirm attribute" do
+ assert_equal "", js_escape_html("")
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_number_helpers.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_number_helpers.rb
new file mode 100644
index 00000000..4c411285
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_number_helpers.rb
@@ -0,0 +1,136 @@
+class TestNumberHelpers < Test::Unit::TestCase
+ include Padrino::Helpers::NumberHelpers
+
+ def kilobytes(number)
+ number * 1024
+ end
+
+ def megabytes(number)
+ kilobytes(number) * 1024
+ end
+
+ def gigabytes(number)
+ megabytes(number) * 1024
+ end
+
+ def terabytes(number)
+ gigabytes(number) * 1024
+ end
+
+ context 'for number helpers functionality' do
+
+ should 'display number_to_currency' do
+ assert_equal "$1,234,567,890.50", number_to_currency(1234567890.50)
+ assert_equal "$1,234,567,890.51", number_to_currency(1234567890.506)
+ assert_equal "$1,234,567,892", number_to_currency(1234567891.50, {:precision => 0})
+ assert_equal "$1,234,567,890.5", number_to_currency(1234567890.50, {:precision => 1})
+ assert_equal "£1234567890,50", number_to_currency(1234567890.50, {:unit => "£", :separator => ",", :delimiter => ""})
+ assert_equal "$1,234,567,890.50", number_to_currency("1234567890.50")
+ assert_equal "1,234,567,890.50 Kč", number_to_currency("1234567890.50", {:unit => "Kč", :format => "%n %u"})
+ assert_equal "$x", number_to_currency("x")
+
+ assert_nil number_to_currency(nil)
+ end
+
+ should 'display number_to_percentage' do
+ assert_equal "100.000%", number_to_percentage(100)
+ assert_equal "100%", number_to_percentage(100, {:precision => 0})
+ assert_equal "302.06%", number_to_percentage(302.0574, {:precision => 2})
+ assert_equal "100.000%", number_to_percentage("100")
+ assert_equal "1000.000%", number_to_percentage("1000")
+ assert_equal "x%", number_to_percentage("x")
+ assert_equal "1.000,000%", number_to_percentage(1000, :delimiter => '.', :separator => ',')
+
+ assert_nil number_to_percentage(nil)
+ end
+
+ should 'display number_with_delimiter' do
+ assert_equal "12,345,678", number_with_delimiter(12345678)
+ assert_equal "0", number_with_delimiter(0)
+ assert_equal "123", number_with_delimiter(123)
+ assert_equal "123,456", number_with_delimiter(123456)
+ assert_equal "123,456.78", number_with_delimiter(123456.78)
+ assert_equal "123,456.789", number_with_delimiter(123456.789)
+ assert_equal "123,456.78901", number_with_delimiter(123456.78901)
+ assert_equal "123,456,789.78901", number_with_delimiter(123456789.78901)
+ assert_equal "0.78901", number_with_delimiter(0.78901)
+ assert_equal "123,456.78", number_with_delimiter("123456.78")
+ assert_equal "x", number_with_delimiter("x")
+
+ assert_nil number_with_delimiter(nil)
+ end
+
+ should 'display number_with_delimiter with options' do
+ assert_equal '12 345 678', number_with_delimiter(12345678, :delimiter => ' ')
+ assert_equal '12,345,678-05', number_with_delimiter(12345678.05, :separator => '-')
+ assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :separator => ',', :delimiter => '.')
+ assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :delimiter => '.', :separator => ',')
+ end
+
+ should 'display number_with_precision' do
+ assert_equal "111.235", number_with_precision(111.2346)
+ assert_equal "31.83", number_with_precision(31.825, :precision => 2)
+ assert_equal "111.23", number_with_precision(111.2346, :precision => 2)
+ assert_equal "111.00", number_with_precision(111, :precision => 2)
+ assert_equal "111.235", number_with_precision("111.2346")
+ assert_equal "31.83", number_with_precision("31.825", :precision => 2)
+ assert_equal "3268", number_with_precision((32.6751 * 100.00), :precision => 0)
+ assert_equal "112", number_with_precision(111.50, :precision => 0)
+ assert_equal "1234567892", number_with_precision(1234567891.50, :precision => 0)
+
+ # Return non-numeric params unchanged.
+ assert_equal "x", number_with_precision("x")
+ assert_nil number_with_precision(nil)
+ end
+
+ should 'display number_with_precision with custom delimiter and separator' do
+ assert_equal '31,83', number_with_precision(31.825, :precision => 2, :separator => ',')
+ assert_equal '1.231,83', number_with_precision(1231.825, :precision => 2, :separator => ',', :delimiter => '.')
+ end
+
+ should 'display number_to_human_size' do
+ assert_equal '0 Bytes', number_to_human_size(0)
+ assert_equal '1 Byte', number_to_human_size(1)
+ assert_equal '3 Bytes', number_to_human_size(3.14159265)
+ assert_equal '123 Bytes', number_to_human_size(123.0)
+ assert_equal '123 Bytes', number_to_human_size(123)
+ assert_equal '1.2 KB', number_to_human_size(1234)
+ assert_equal '12.1 KB', number_to_human_size(12345)
+ assert_equal '1.2 MB', number_to_human_size(1234567)
+ assert_equal '1.1 GB', number_to_human_size(1234567890)
+ assert_equal '1.1 TB', number_to_human_size(1234567890123)
+ assert_equal '1025 TB', number_to_human_size(terabytes(1025))
+ assert_equal '444 KB', number_to_human_size(kilobytes(444))
+ assert_equal '1023 MB', number_to_human_size(megabytes(1023))
+ assert_equal '3 TB', number_to_human_size(terabytes(3))
+ assert_equal '1.18 MB', number_to_human_size(1234567, :precision => 2)
+ assert_equal '3 Bytes', number_to_human_size(3.14159265, :precision => 4)
+ assert_equal '123 Bytes', number_to_human_size("123")
+ assert_equal '1.01 KB', number_to_human_size(kilobytes(1.0123), :precision => 2)
+ assert_equal '1.01 KB', number_to_human_size(kilobytes(1.0100), :precision => 4)
+ assert_equal '10 KB', number_to_human_size(kilobytes(10.000), :precision => 4)
+ assert_equal '1 Byte', number_to_human_size(1.1)
+ assert_equal '10 Bytes', number_to_human_size(10)
+
+ assert_nil number_to_human_size(nil)
+ end
+
+ should 'display number_to_human_size with options' do
+ assert_equal '1.18 MB', number_to_human_size(1234567, :precision => 2)
+ assert_equal '3 Bytes', number_to_human_size(3.14159265, :precision => 4)
+ assert_equal '1.01 KB', number_to_human_size(kilobytes(1.0123), :precision => 2)
+ assert_equal '1.01 KB', number_to_human_size(kilobytes(1.0100), :precision => 4)
+ assert_equal '10 KB', number_to_human_size(kilobytes(10.000), :precision => 4)
+ assert_equal '1 TB', number_to_human_size(1234567890123, :precision => 0)
+ assert_equal '500 MB', number_to_human_size(524288000, :precision => 0)
+ assert_equal '40 KB', number_to_human_size(41010, :precision => 0)
+ assert_equal '40 KB', number_to_human_size(41100, :precision => 0)
+ end
+
+ should 'display number_to_human_size with custom delimiter and separator' do
+ assert_equal '1,01 KB', number_to_human_size(kilobytes(1.0123), :precision => 2, :separator => ',')
+ assert_equal '1,01 KB', number_to_human_size(kilobytes(1.0100), :precision => 4, :separator => ',')
+ assert_equal '1.000,1 TB', number_to_human_size(terabytes(1000.1), :delimiter => '.', :separator => ',')
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_output_helpers.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_output_helpers.rb
new file mode 100644
index 00000000..b2efcd82
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_output_helpers.rb
@@ -0,0 +1,133 @@
+require File.expand_path(File.dirname(__FILE__) + '/helper')
+require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
+
+class TestOutputHelpers < Test::Unit::TestCase
+ def app
+ MarkupDemo.tap { |app| app.set :environment, :test }
+ end
+
+ context 'for #content_for method' do
+ should 'work for erb templates' do
+ visit '/erb/content_for'
+ assert_have_selector '.demo h1', :content => "This is content yielded from a content_for"
+ assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith"
+ end
+
+ should "work for haml templates" do
+ visit '/haml/content_for'
+ assert_have_selector '.demo h1', :content => "This is content yielded from a content_for"
+ assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith"
+ end
+
+ should "work for slim templates" do
+ visit '/slim/content_for'
+ assert_have_selector '.demo h1', :content => "This is content yielded from a content_for"
+ assert_have_selector '.demo2 h1', :content => "This is content yielded with name Johnny Smith"
+ end
+ end
+
+ context 'for #capture_html method' do
+ should "work for erb templates" do
+ visit '/erb/capture_concat'
+ assert_have_selector 'p span', :content => "Captured Line 1"
+ assert_have_selector 'p span', :content => "Captured Line 2"
+ end
+
+ should "work for haml templates" do
+ visit '/haml/capture_concat'
+ assert_have_selector 'p span', :content => "Captured Line 1"
+ assert_have_selector 'p span', :content => "Captured Line 2"
+ end
+
+ should "work for slim templates" do
+ visit '/slim/capture_concat'
+ assert_have_selector 'p span', :content => "Captured Line 1"
+ assert_have_selector 'p span', :content => "Captured Line 2"
+ end
+ end
+
+ context 'for #concat_content method' do
+ should "work for erb templates" do
+ visit '/erb/capture_concat'
+ assert_have_selector 'p', :content => "Concat Line 3", :count => 1
+ end
+
+ should "work for haml templates" do
+ visit '/haml/capture_concat'
+ assert_have_selector 'p', :content => "Concat Line 3", :count => 1
+ end
+
+ should "work for slim templates" do
+ visit '/slim/capture_concat'
+ assert_have_selector 'p', :content => "Concat Line 3", :count => 1
+ end
+ end
+
+ context 'for #block_is_template?' do
+ should "work for erb templates" do
+ visit '/erb/capture_concat'
+ assert_have_selector 'p', :content => "The erb block passed in is a template", :class => 'is_template'
+ # TODO Get ERB template detection working (fix block_is_erb? method)
+ # assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
+ end
+
+ should "work for haml templates" do
+ visit '/haml/capture_concat'
+ assert_have_selector 'p', :content => "The haml block passed in is a template", :class => 'is_template'
+ assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
+ end
+
+ should_eventually "work for slim templates" do
+ visit '/slim/capture_concat'
+ assert_have_selector 'p', :content => "The slim block passed in is a template", :class => 'is_template'
+ # TODO Get SLIM template detection working (fix block_is_erb? method)
+ # assert_have_no_selector 'p', :content => "The ruby block passed in is a template", :class => 'is_template'
+ end
+ end
+
+ context 'for #current_engine method' do
+ should 'detect correctly current engine for erb' do
+ visit '/erb/current_engine'
+ assert_have_selector 'p.start', :content => "erb"
+ assert_have_selector 'p.haml', :content => "haml"
+ assert_have_selector 'p.erb', :content => "erb"
+ assert_have_selector 'p.slim', :content => "slim"
+ assert_have_selector 'p.end', :content => "erb"
+ end
+
+ should 'detect correctly current engine for haml' do
+ visit '/haml/current_engine'
+ assert_have_selector 'p.start', :content => "haml"
+ assert_have_selector 'p.haml', :content => "haml"
+ assert_have_selector 'p.erb', :content => "erb"
+ assert_have_selector 'p.slim', :content => "slim"
+ assert_have_selector 'p.end', :content => "haml"
+ end
+
+ should 'detect correctly current engine for slim' do
+ visit '/slim/current_engine'
+ assert_have_selector 'p.start', :content => "slim"
+ assert_have_selector 'p.haml', :content => "haml"
+ assert_have_selector 'p.erb', :content => "erb"
+ assert_have_selector 'p.slim', :content => "slim"
+ assert_have_selector 'p.end', :content => "slim"
+ end
+ end
+
+ context 'for #partial method in simple sinatra application' do
+ should 'properly output in erb' do
+ visit '/erb/simple_partial'
+ assert_have_selector 'p.erb', :content => "erb"
+ end
+
+ should 'properly output in haml' do
+ visit '/haml/simple_partial'
+ assert_have_selector 'p.haml', :content => "haml"
+ end
+
+ should 'properly output in slim' do
+ visit '/slim/simple_partial'
+ assert_have_selector 'p.slim', :content => "slim"
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_render_helpers.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_render_helpers.rb
new file mode 100644
index 00000000..53825d26
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_render_helpers.rb
@@ -0,0 +1,69 @@
+require File.expand_path(File.dirname(__FILE__) + '/helper')
+require File.expand_path(File.dirname(__FILE__) + '/fixtures/render_app/app')
+
+class TestRenderHelpers < Test::Unit::TestCase
+ def app
+ RenderDemo.tap { |app| app.set :environment, :test }
+ end
+
+ context 'for #partial method and object' do
+ setup { visit '/partial/object' }
+ should "render partial html with object" do
+ assert_have_selector "h1", :content => "User name is John"
+ end
+ should "have no counter index for single item" do
+ assert_have_no_selector "p", :content => "My counter is 1", :count => 1
+ end
+ should "include extra locals information" do
+ assert_have_selector 'p', :content => "Extra is bar"
+ end
+ end
+
+ context 'for #partial method and collection' do
+ setup { visit '/partial/collection' }
+ should "render partial html with collection" do
+ assert_have_selector "h1", :content => "User name is John"
+ assert_have_selector "h1", :content => "User name is Billy"
+ end
+ should "include counter which contains item index" do
+ assert_have_selector "p", :content => "My counter is 1"
+ assert_have_selector "p", :content => "My counter is 2"
+ end
+ should "include extra locals information" do
+ assert_have_selector 'p', :content => "Extra is bar"
+ end
+ end
+
+ context 'for #partial method and locals' do
+ setup { visit '/partial/locals' }
+ should "render partial html with locals" do
+ assert_have_selector "h1", :content => "User name is John"
+ end
+ should "have no counter index for single item" do
+ assert_have_no_selector "p", :content => "My counter is 1", :count => 1
+ end
+ should "include extra locals information" do
+ assert_have_selector 'p', :content => "Extra is bar"
+ end
+ end
+
+ context 'for #current_engine method' do
+ should 'detect correctly current engine for a padrino application' do
+ visit '/current_engine'
+ assert_have_selector 'p.start', :content => "haml"
+ assert_have_selector 'p.haml span', :content => "haml"
+ assert_have_selector 'p.erb span', :content => "erb"
+ assert_have_selector 'p.slim span', :content => "slim"
+ assert_have_selector 'p.end', :content => "haml"
+ end
+
+ should "detect correctly current engine for explicit engine on partials" do
+ visit '/explicit_engine'
+ assert_have_selector 'p.start', :content => "haml"
+ assert_have_selector 'p.haml span', :content => "haml"
+ assert_have_selector 'p.erb span', :content => "erb"
+ assert_have_selector 'p.slim span', :content => "slim"
+ assert_have_selector 'p.end', :content => "haml"
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_tag_helpers.rb b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_tag_helpers.rb
new file mode 100644
index 00000000..582a1486
--- /dev/null
+++ b/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_tag_helpers.rb
@@ -0,0 +1,100 @@
+require File.expand_path(File.dirname(__FILE__) + '/helper')
+require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
+
+class TestTagHelpers < Test::Unit::TestCase
+ def app
+ MarkupDemo.tap { |app| app.set :environment, :test }
+ end
+
+ context 'for #tag method' do
+ should("support tags with no content no attributes") do
+ assert_has_tag(:br) { tag(:br) }
+ end
+
+ should("support tags with no content with attributes") do
+ actual_html = tag(:br, :style => 'clear:both', :class => 'yellow')
+ assert_has_tag(:br, :class => 'yellow', :style=>'clear:both') { actual_html }
+ end
+
+ should "support selected attribute by using 'selected' if true" do
+ actual_html = tag(:option, :selected => true)
+ assert_has_tag('option', :selected => 'selected') { actual_html }
+ end
+
+ should "support tags with content no attributes" do
+ assert_has_tag(:p, :content => "Demo String") { tag(:p, :content => "Demo String") }
+ end
+
+ should "support tags with content and attributes" do
+ actual_html = tag(:p, :content => "Demo", :class => 'large', :id => 'intro')
+ assert_has_tag('p#intro.large', :content => "Demo") { actual_html }
+ end
+
+ should "support open tags" do
+ actual_html = tag(:p, :class => 'demo', :open => true)
+ assert_equal "", actual_html
+ end
+ end
+
+ context 'for #content_tag method' do
+ should "support tags with content as parameter" do
+ actual_html = content_tag(:p, "Demo", :class => 'large', :id => 'thing')
+ assert_has_tag('p.large#thing', :content => "Demo") { actual_html }
+ end
+
+ should "support tags with content as block" do
+ actual_html = content_tag(:p, :class => 'large', :id => 'star') { "Demo" }
+ assert_has_tag('p.large#star', :content => "Demo") { actual_html }
+ end
+
+ should "support tags with erb" do
+ visit '/erb/content_tag'
+ assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1'
+ assert_have_selector :p, :content => "Test 2"
+ assert_have_selector :p, :content => "Test 3"
+ assert_have_selector :p, :content => "Test 4"
+ end
+
+ should "support tags with haml" do
+ visit '/haml/content_tag'
+ assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1'
+ assert_have_selector :p, :content => "Test 2"
+ assert_have_selector :p, :content => "Test 3", :class => 'test', :id => 'test3'
+ assert_have_selector :p, :content => "Test 4"
+ end
+
+ should "support tags with slim" do
+ visit '/slim/content_tag'
+ assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1'
+ assert_have_selector :p, :content => "Test 2"
+ assert_have_selector :p, :content => "Test 3", :class => 'test', :id => 'test3'
+ assert_have_selector :p, :content => "Test 4"
+ end
+ end
+
+ context 'for #input_tag method' do
+ should "support field with type" do
+ assert_has_tag('input[type=text]') { input_tag(:text) }
+ end
+
+ should "support field with type and options" do
+ actual_html = input_tag(:text, :class => "first", :id => 'texter')
+ assert_has_tag('input.first#texter[type=text]') { actual_html }
+ end
+
+ should "support checked attribute by using 'checked' if true" do
+ actual_html = input_tag(:checkbox, :checked => true)
+ assert_has_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
+ end
+
+ should "remove checked attribute if false" do
+ actual_html = input_tag(:checkbox, :checked => false)
+ assert_has_no_tag('input[type=checkbox][checked=false]') { actual_html }
+ end
+
+ should "support disabled attribute by using 'disabled' if true" do
+ actual_html = input_tag(:checkbox, :disabled => true)
+ assert_has_tag('input[type=checkbox]', :disabled => 'disabled') { actual_html }
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/middleman/version.rb b/lib/middleman/version.rb
index 845d8167..ec829b21 100644
--- a/lib/middleman/version.rb
+++ b/lib/middleman/version.rb
@@ -1,3 +1,3 @@
module Middleman
- VERSION = "2.0.4"
+ VERSION = "2.0.5"
end
diff --git a/middleman.gemspec b/middleman.gemspec
index 2d63e1c3..472c94ad 100644
--- a/middleman.gemspec
+++ b/middleman.gemspec
@@ -43,8 +43,6 @@ eos
s.add_runtime_dependency("tilt", ["~> 1.3.1"])
s.add_runtime_dependency("maruku", ["~> 0.6.0"])
s.add_runtime_dependency("sinatra", ["~> 1.2.6"])
- s.add_runtime_dependency("padrino-core", ["~> 0.10.0", '< 0.10.1'])
- s.add_runtime_dependency("padrino-helpers", ["~> 0.10.0", '< 0.10.1'])
s.add_runtime_dependency("rack-test", ["~> 0.6.1"])
s.add_runtime_dependency("uglifier", ["~> 1.0.0"])
s.add_runtime_dependency("slim", ["~> 1.0.1"])
@@ -54,6 +52,12 @@ eos
s.add_runtime_dependency("coffee-script", ["~> 2.2.0"])
s.add_runtime_dependency("sprockets", ["2.0.0.beta.14"])
+ # Padrino deps
+ s.add_runtime_dependency("activesupport", "~> 3.0.0")
+
+ # Only in Padrino-helpers
+ s.add_runtime_dependency("i18n", "~> 0.5.0")
+
case Config::CONFIG['host_os'].downcase
when %r{mswin|mingw}
# s.add_runtime_dependency "windows-api", "= 0.4.0"