diff --git a/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core.rb b/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core.rb index 98719cad..635e9074 100644 --- a/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core.rb +++ b/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core.rb @@ -112,21 +112,6 @@ module Padrino nil end - ## - # Determines whether the dependencies are locked by Bundler. - # otherwise return nil - # - # @return [:locked, :unlocked, nil] - # Returns +:locked+ if the +Gemfile.lock+ file exists, or +:unlocked+ - # if only the +Gemfile+ exists. - # - # @deprecated Will be removed in 1.0.0 - # - def bundle - return :locked if File.exist?(root('Gemfile.lock')) - return :unlocked if File.exist?(root("Gemfile")) - end - ## # A Rack::Builder object that allows to add middlewares in front of all # Padrino applications. diff --git a/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/application.rb b/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/application.rb index 0bcdc1e9..d7723a57 100644 --- a/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/application.rb +++ b/middleman-core/lib/middleman-core/vendor/padrino-core-0.10.5/lib/padrino-core/application.rb @@ -22,16 +22,17 @@ module Padrino class << self def inherited(base) # @private - logger.devel "Setup #{base}" + begun_at = Time.now CALLERS_TO_IGNORE.concat(PADRINO_IGNORE_CALLERS) base.default_configuration! base.prerequisites.concat([ - File.join(base.root, "/models.rb"), - File.join(base.root, "/models/**/*.rb"), - File.join(base.root, "/lib.rb"), - File.join(base.root, "/lib/**/*.rb") + File.join(base.root, '/models.rb'), + File.join(base.root, '/models/**/*.rb'), + File.join(base.root, '/lib.rb'), + File.join(base.root, '/lib/**/*.rb') ]).uniq! Padrino.require_dependencies(base.prerequisites) + logger.devel :setup, begun_at, base super(base) # Loading the subclass inherited method end @@ -47,11 +48,10 @@ module Padrino # MyApp.reload! # def reload! - logger.devel "Reloading #{self}" - @_dependencies = nil # Reset dependencies + logger.devel "Reloading #{settings}" reset! # Reset sinatra app reset_router! # Reset all routes - Padrino.require_dependencies(self.app_file, :force => true) # Reload the app file + Padrino.require_dependencies(settings.app_file, :force => true) # Reload the app file require_dependencies # Reload dependencies default_filters! # Reload filters default_routes! # Reload default routes @@ -92,12 +92,12 @@ module Padrino # def setup_application! return if @_configured - self.require_dependencies - self.default_filters! - self.default_routes! - self.default_errors! + settings.require_dependencies + settings.default_filters! + settings.default_routes! + settings.default_errors! if defined?(I18n) - I18n.load_path << self.locale_path + I18n.load_path << settings.locale_path I18n.reload! end @_configured = true @@ -112,7 +112,7 @@ module Padrino # def run!(options={}) return unless Padrino.load! - Padrino.mount(self.to_s).to("/") + Padrino.mount(settings.to_s).to('/') Padrino.run!(options) end @@ -121,7 +121,7 @@ module Padrino # directory that need to be added to +$LOAD_PATHS+ from this application # def load_paths - @_load_paths ||= %w(models lib mailers controllers helpers).map { |path| File.join(self.root, path) } + @_load_paths ||= %w[models lib mailers controllers helpers].map { |path| File.join(settings.root, path) } end ## @@ -136,10 +136,10 @@ module Padrino # MyApp.dependencies << Padrino.root('other_app', 'controllers.rb') # def dependencies - @_dependencies ||= [ - "urls.rb", "config/urls.rb", "mailers/*.rb", "mailers.rb", - "controllers/**/*.rb", "controllers.rb", "helpers/**/*.rb", "helpers.rb" - ].map { |file| Dir[File.join(self.root, file)] }.flatten + [ + 'urls.rb', 'config/urls.rb', 'mailers/*.rb', 'mailers.rb', + 'controllers/**/*.rb', 'controllers.rb', 'helpers/**/*.rb', 'helpers.rb' + ].map { |file| Dir[File.join(settings.root, file)] }.flatten end ## @@ -161,110 +161,109 @@ module Padrino end protected - ## - # Defines default settings for Padrino application - # - def default_configuration! - # Overwriting Sinatra defaults - set :app_file, File.expand_path(caller_files.first || $0) # Assume app file is first caller - set :environment, Padrino.env - set :reload, Proc.new { development? } - set :logging, Proc.new { development? } - set :method_override, true - set :sessions, false - set :public_folder, Proc.new { Padrino.root('public', uri_root) } - set :views, Proc.new { File.join(root, "views") } - set :images_path, Proc.new { File.join(public, "images") } - set :protection, false - # Padrino specific - set :uri_root, "/" - set :app_name, self.to_s.underscore.to_sym - set :default_builder, 'StandardFormBuilder' - set :flash, defined?(Sinatra::Flash) || defined?(Rack::Flash) - set :authentication, false - # Padrino locale - set :locale_path, Proc.new { Dir[File.join(self.root, "/locale/**/*.{rb,yml}")] } - # Load the Global Configurations - class_eval(&Padrino.apps_configuration) if Padrino.apps_configuration - end + ## + # Defines default settings for Padrino application + # + def default_configuration! + # Overwriting Sinatra defaults + set :app_file, File.expand_path(caller_files.first || $0) # Assume app file is first caller + set :environment, Padrino.env + set :reload, Proc.new { development? } + set :logging, Proc.new { development? } + set :method_override, true + set :sessions, false + set :public_folder, Proc.new { Padrino.root('public', uri_root) } + set :views, Proc.new { File.join(root, "views") } + set :images_path, Proc.new { File.join(public, "images") } + set :protection, false + # Padrino specific + set :uri_root, '/' + set :app_name, settings.to_s.underscore.to_sym + set :default_builder, 'StandardFormBuilder' + set :flash, defined?(Sinatra::Flash) || defined?(Rack::Flash) + set :authentication, false + # Padrino locale + set :locale_path, Proc.new { Dir[File.join(settings.root, '/locale/**/*.{rb,yml}')] } + # Load the Global Configurations + class_eval(&Padrino.apps_configuration) if Padrino.apps_configuration + end - ## - # We need to add almost __sinatra__ images. - # - def default_routes! - configure :development do - get '*__sinatra__/:image.png' do - content_type :png - filename = File.dirname(__FILE__) + "/images/#{params[:image]}.png" - send_file filename - end + ## + # We need to add almost __sinatra__ images. + # + def default_routes! + configure :development do + get '*__sinatra__/:image.png' do + content_type :png + filename = File.dirname(__FILE__) + "/images/#{params[:image]}.png" + send_file filename end end + end - ## - # This filter it's used for know the format of the request, and automatically set the content type. - # - def default_filters! - before do - unless @_content_type - @_content_type = :html - response['Content-Type'] = 'text/html;charset=utf-8' - end + ## + # This filter it's used for know the format of the request, and automatically set the content type. + # + def default_filters! + before do + unless @_content_type + @_content_type = :html + response['Content-Type'] = 'text/html;charset=utf-8' end end + end - ## - # This log errors for production environments - # - def default_errors! - configure :production do - error ::Exception do - boom = env['sinatra.error'] - logger.error ["#{boom.class} - #{boom.message}:", *boom.backtrace].join("\n ") - response.status = 500 - content_type 'text/html' - '
+ # # => Hello World + # # =>
+ # # => Padrino + # # =>
- <%= 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 :age %> + <%= f.number_field :age, :class => 'numeric '%> +
+ <%= f.label :telephone %> + <%= f.telephone_field :telephone, :class => 'numeric' %> +
+ <%= f.label :email, :caption => 'Email Address: ' %> + <%= f.email_field :email, :class => 'string' %> +
+ <%= f.label :webpage, :caption => 'Your Web Page: ' %> + <%= f.url_field :webpage, :class => 'string' %> +
+ <%= f.label :search %> + <%= f.search_field :search, :class => 'string' %> +
<%= f.label :photo %> <%= f.file_field :photo, :class => 'user-photo' %> diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.haml b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.haml old mode 100644 new mode 100755 index 669b09a6..dfc71a00 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.haml +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.haml @@ -4,12 +4,24 @@ %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 :age + = f.number_field :age, :class => 'numeric' + %p + = f.label :telephone + = f.telephone_field :telephone, :class => 'numeric' + %p + = f.label :email, :caption => 'Email Address: ' + = f.email_field :email, :class => 'string' + %p + = f.label :webpage, :caption => 'Your Web Page: ' + = f.url_field :webpage, :class => 'string' + %p + = f.label :search + = f.search_field :search, :class => 'string' %p = f.label :photo = f.file_field :photo, :class => 'user-photo' diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.slim b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.slim old mode 100644 new mode 100755 index 7a7c3590..5b3906d6 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.slim +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.slim @@ -4,12 +4,24 @@ 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 :age + == f.number_field :age, :class => 'numeric' + p + == f.label :telephone + == f.telephone_field :telephone, :class => 'numeric' + p + == f.label :email, :caption => 'Email Address: ' + == f.email_field :email, :class => 'string' + p + == f.label :webpage, :caption => 'Your Web Page: ' + == f.url_field :webpage, :class => 'string' + p + == f.label :search + == f.search_field :search, :class => 'string' p == f.label :photo == f.file_field :photo, :class => 'user-photo' diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.erb b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.erb old mode 100644 new mode 100755 index 0872d78e..d8a96699 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.erb +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.erb @@ -5,6 +5,16 @@ <%= text_field_tag :username %> <%= label_tag :password %> <%= password_field_tag :password %> + <%= label_tag :email %> + <%= email_field_tag :email %> + <%= label_tag :age %> + <%= number_field_tag :age %> + <%= label_tag :telephone %> + <%= telephone_field_tag :telephone %> + <%= label_tag :webpage %> + <%= url_field_tag :webpage %> + <%= label_tag :search %> + <%= search_field_tag :search %> <%= check_box_tag :remember_me %> <%= label_tag :gender %> <%= label_tag :color %> @@ -27,6 +37,26 @@ <%= label_tag :password, :class => 'first' %> <%= password_field_tag :password, :value => params[:password] %>
+ <%= label_tag :email, :caption => 'Email Address' %> + <%= email_field_tag :email, :class => 'string' %> +
+ <%= label_tag :age, :class => 'age' %> + <%= number_field_tag :age, :class => 'numeric' %> +
+ <%= label_tag :telephone, :class => 'telephone' %> + <%= telephone_field_tag :telephone, :class => 'numeric' %> +
+ <%= label_tag :webpage, :caption => 'Your Home Page' %> + <%= url_field_tag :webpage, :class => 'string' %> +
+ <%= label_tag :search %> + <%= search_field_tag :search, :class => 'string' %> +
<%= label_tag :about, :class => 'about', :caption => "About Me" %> <%= text_area_tag :about, :class => 'large' %> diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.haml b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.haml old mode 100644 new mode 100755 index bf392861..e7010e32 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.haml +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.haml @@ -6,6 +6,16 @@ = text_field_tag :username = label_tag :password = password_field_tag :password + = label_tag :email + = email_field_tag :email + = label_tag :age + = number_field_tag :age + = label_tag :telephone + = telephone_field_tag :telephone + = label_tag :webpage + = url_field_tag :webpage + = label_tag :search + = search_field_tag :search = label_tag :color = select_tag :color, :options => ['green', 'orange', 'purple'] = label_tag :gender @@ -24,6 +34,21 @@ %p = label_tag :password, :class => 'first' = password_field_tag :password, :value => params[:password] + %p + = label_tag :email, :caption => 'Email Address' + = email_field_tag :email, :class => 'string' + %p + = label_tag :age, :class => 'age' + = number_field_tag :age, :class => 'numeric' + %p + = label_tag :telephone, :class => 'telephone' + = telephone_field_tag :telephone, :class => 'numeric' + %p + = label_tag :webpage, :caption => 'Your Home Page' + = url_field_tag :webpage, :class => 'string' + %p + = label_tag :search + = search_field_tag :search, :class => 'string' %p = label_tag :about, :class => 'about', :caption => "About Me" = text_area_tag :about, :class => 'large' diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.slim b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.slim old mode 100644 new mode 100755 index e71846c7..8ec5c58e --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.slim +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.slim @@ -6,6 +6,16 @@ == text_field_tag :username == label_tag :password == password_field_tag :password + == label_tag :email + == email_field_tag :email + == label_tag :age + == number_field_tag :age + == label_tag :telephone + == telephone_field_tag :telephone + == label_tag :webpage + == url_field_tag :webpage + == label_tag :search + == search_field_tag :search == label_tag :color == select_tag :color, :options => ['green', 'orange', 'purple'] == label_tag :gender @@ -24,6 +34,21 @@ p == label_tag :password, :class => 'first' == password_field_tag :password, :value => params[:password] + p + == label_tag :email, :caption => 'Email Address' + == email_field_tag :email, :class => 'string' + p + == label_tag :age, :class => 'age' + == number_field_tag :age, :class => 'numeric' + p + == label_tag :telephone, :class => 'telephone' + == telephone_field_tag :telephone, :class => 'numeric' + p + == label_tag :webpage, :caption => 'Your Home Page' + == url_field_tag :webpage, :class => 'string' + p + == label_tag :search + == search_field_tag :search, :class => 'string' p == label_tag :about, :class => 'about', :caption => "About Me" == text_area_tag :about, :class => 'large' diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_asset_tag_helpers.rb b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_asset_tag_helpers.rb index cfe532be..257e8ae4 100644 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_asset_tag_helpers.rb +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_asset_tag_helpers.rb @@ -9,7 +9,7 @@ describe "AssetTagHelpers" do end def flash - { :notice => "Demo notice" } + @_flash ||= { :notice => "Demo notice" } end context 'for #flash_tag method' do @@ -20,6 +20,14 @@ describe "AssetTagHelpers" do actual_html = flash_tag(:notice, :class => 'notice', :id => 'notice-area') assert_has_tag('div.notice#notice-area', :content => "Demo notice") { actual_html } end + should "display multiple flash tags with given attributes" do + flash[:error] = 'wrong' + flash[:success] = 'okey' + actual_html = flash_tag(:success, :error, :id => 'area') + assert_has_tag('div.success#area', :content => flash[:success]) { actual_html } + assert_has_tag('div.error#area', :content => flash[:error]) { actual_html } + assert_has_no_tag('div.notice') { actual_html } + end end context 'for #link_to method' do @@ -39,7 +47,7 @@ describe "AssetTagHelpers" do 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 } + assert_has_tag('a', :content => "Sign up", :href => '#', :class => 'test') { actual_link } end should "display link element with remote option" do @@ -146,10 +154,10 @@ describe "AssetTagHelpers" do 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') } + assert_has_tag('img', :src => "/absolute/pic.gif") { image_tag('/absolute/pic.gif') } end - should "display image tag absolute link with specified uri root" do + should "display image tag relative 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') } @@ -201,7 +209,7 @@ describe "AssetTagHelpers" 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 } + assert_has_tag('link', expected_options.merge(:href => "/css/style.css")) { actual_html } end should "display stylesheet link item with uri root" do @@ -257,7 +265,7 @@ describe "AssetTagHelpers" do 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 } + assert_has_tag('script', :src => "/js/application.js", :type => "text/javascript") { actual_html } end should "display javascript item with uri root" do diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_form_builder.rb b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_form_builder.rb index 74d35988..b3cdb744 100644 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_form_builder.rb +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_form_builder.rb @@ -63,7 +63,7 @@ describe "FormBuilder" do 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', :"accept-charset" => "UTF-8", :method => 'post', "data-remote" => 'true') { actual_html } assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html } end @@ -199,7 +199,7 @@ describe "FormBuilder" do 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' + assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid' end should "display correct form in erb" do @@ -212,7 +212,7 @@ describe "FormBuilder" do 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' + assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid' end should "display correct form in slim" do @@ -225,7 +225,7 @@ describe "FormBuilder" do 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' + assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid' end end @@ -325,6 +325,116 @@ describe "FormBuilder" do end end + context 'for #number_field method' do + should "display correct number field html" do + actual_html = standard_builder.number_field(:age, :class => 'numeric') + assert_has_tag('input.numeric[type=number]', :id => 'user_age', :name => 'user[age]') { actual_html } + end + + should "display correct number field in haml" do + visit '/haml/form_for' + assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age' + end + + should "display correct number field in erb" do + visit '/erb/form_for' + assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age' + end + + should "display correct number field in slim" do + visit '/slim/form_for' + assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age' + end + end + + context 'for #telephone_field method' do + should "display correct telephone field html" do + actual_html = standard_builder.telephone_field(:telephone, :class => 'numeric') + assert_has_tag('input.numeric[type=tel]', :id => 'user_telephone', :name => 'user[telephone]') { actual_html } + end + + should "display correct telephone field in haml" do + visit '/haml/form_for' + assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone' + end + + should "display correct telephone field in erb" do + visit '/erb/form_for' + assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone' + end + + should "display correct telephone field in slim" do + visit '/slim/form_for' + assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone' + end + end + + context 'for #search_field method' do + should "display correct search field html" do + actual_html = standard_builder.search_field(:search, :class => 'string') + assert_has_tag('input.string[type=search]', :id => 'user_search', :name => 'user[search]') { actual_html } + end + + should "display correct search field in haml" do + visit '/haml/form_for' + assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search' + end + + should "display correct search field in erb" do + visit '/erb/form_for' + assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search' + end + + should "display correct search field in slim" do + visit '/slim/form_for' + assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search' + end + end + + context 'for #email_field method' do + should "display correct email field html" do + actual_html = standard_builder.email_field(:email, :class => 'string') + assert_has_tag('input.string[type=email]', :id => 'user_email', :name => 'user[email]') { actual_html } + end + + should "display correct email field in haml" do + visit '/haml/form_for' + assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email' + end + + should "display correct email field in erb" do + visit '/erb/form_for' + assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email' + end + + should "display correct email field in slim" do + visit '/slim/form_for' + assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email' + end + end + + context 'for #url_field method' do + should "display correct url field html" do + actual_html = standard_builder.url_field(:webpage, :class => 'string') + assert_has_tag('input.string[type=url]', :id => 'user_webpage', :name => 'user[webpage]') { actual_html } + end + + should "display correct url field in haml" do + visit '/haml/form_for' + assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage' + end + + should "display correct url field in erb" do + visit '/erb/form_for' + assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage' + end + + should "display correct url field in slim" do + visit '/slim/form_for' + assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage' + end + end + context 'for #check_box method' do should "display correct checkbox html" do actual_html = standard_builder.check_box(:confirm_destroy, :class => 'large') @@ -430,7 +540,7 @@ describe "FormBuilder" do 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 } + assert_has_tag('textarea.large', :id => 'user_about', :name => 'user[about]') { actual_html } end should "display correct text_area html and content" do @@ -628,7 +738,7 @@ describe "FormBuilder" do 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 } + assert_has_tag('input.large[type=image]', :src => "/system/ok.png") { actual_html } end should "display correct image submit button in haml" do diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_form_helpers.rb b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_form_helpers.rb index ba9d2afa..3f181aac 100644 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_form_helpers.rb +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_form_helpers.rb @@ -28,7 +28,7 @@ describe "FormHelpers" do 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, "data-remote" => 'true', :"accept-charset" => "UTF-8") { actual_html } assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html } end @@ -193,14 +193,14 @@ describe "FormHelpers" do 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', :count => 9 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', :count => 11 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' @@ -210,7 +210,7 @@ describe "FormHelpers" do 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', :count => 9 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' @@ -218,7 +218,7 @@ describe "FormHelpers" do 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', :count => 11 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' @@ -228,7 +228,7 @@ describe "FormHelpers" do 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', :count => 9 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' @@ -236,7 +236,7 @@ describe "FormHelpers" do 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', :count => 11 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' @@ -295,10 +295,135 @@ describe "FormHelpers" do end end + context 'for #number_field_tag method' do + should "display number field in ruby" do + actual_html = number_field_tag(:age, :class => 'numeric') + assert_has_tag(:input, :type => 'number', :class => 'numeric', :name => 'age') { actual_html } + end + + should "display number field in erb" do + visit '/erb/form_tag' + assert_have_selector 'form.simple-form input[type=number]', :count => 1, :name => 'age' + assert_have_selector 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric' + end + + should "display number field in haml" do + visit '/haml/form_tag' + assert_have_selector 'form.simple-form input[type=number]', :count => 1, :name => 'age' + assert_have_selector 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric' + end + + should "display number field in slim" do + visit '/slim/form_tag' + assert_have_selector 'form.simple-form input[type=number]', :count => 1, :name => 'age' + assert_have_selector 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric' + end + end + + context 'for #telephone_field_tag method' do + should "display number field in ruby" do + actual_html = telephone_field_tag(:telephone, :class => 'numeric') + assert_has_tag(:input, :type => 'tel', :class => 'numeric', :name => 'telephone') { actual_html } + end + + should "display telephone field in erb" do + visit '/erb/form_tag' + assert_have_selector 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone' + assert_have_selector 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric' + end + + should "display telephone field in haml" do + visit '/haml/form_tag' + assert_have_selector 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone' + assert_have_selector 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric' + end + + should "display telephone field in slim" do + visit '/slim/form_tag' + assert_have_selector 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone' + assert_have_selector 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric' + end + end + + context 'for #search_field_tag method' do + should "display search field in ruby" do + actual_html = search_field_tag(:search, :class => 'string') + assert_has_tag(:input, :type => 'search', :class => 'string', :name => 'search') { actual_html } + end + + should "display search field in erb" do + visit '/erb/form_tag' + assert_have_selector 'form.simple-form input[type=search]', :count => 1, :name => 'search' + assert_have_selector 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string' + end + + should "display search field in haml" do + visit '/haml/form_tag' + assert_have_selector 'form.simple-form input[type=search]', :count => 1, :name => 'search' + assert_have_selector 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string' + end + + should "display search field in slim" do + visit '/slim/form_tag' + assert_have_selector 'form.simple-form input[type=search]', :count => 1, :name => 'search' + assert_have_selector 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string' + end + end + + context 'for #email_field_tag method' do + should "display email field in ruby" do + actual_html = email_field_tag(:email, :class => 'string') + assert_has_tag(:input, :type => 'email', :class => 'string', :name => 'email') { actual_html } + end + + should "display email field in erb" do + visit '/erb/form_tag' + assert_have_selector 'form.simple-form input[type=email]', :count => 1, :name => 'email' + assert_have_selector 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string' + end + + should "display email field in haml" do + visit '/haml/form_tag' + assert_have_selector 'form.simple-form input[type=email]', :count => 1, :name => 'email' + assert_have_selector 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string' + end + + should "display email field in slim" do + visit '/slim/form_tag' + assert_have_selector 'form.simple-form input[type=email]', :count => 1, :name => 'email' + assert_have_selector 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string' + end + end + + context 'for #url_field_tag method' do + should "display url field in ruby" do + actual_html = url_field_tag(:webpage, :class => 'string') + assert_has_tag(:input, :type => 'url', :class => 'string', :name => 'webpage') { actual_html } + end + + should "display url field in erb" do + visit '/erb/form_tag' + assert_have_selector 'form.simple-form input[type=url]', :count => 1, :name => 'webpage' + assert_have_selector 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string' + end + + should "display url field in haml" do + visit '/haml/form_tag' + assert_have_selector 'form.simple-form input[type=url]', :count => 1, :name => 'webpage' + assert_have_selector 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string' + end + + should "display url field in slim" do + visit '/slim/form_tag' + assert_have_selector 'form.simple-form input[type=url]', :count => 1, :name => 'webpage' + assert_have_selector 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string' + 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 } + assert_has_tag(:textarea, :class => "long", :name => 'about') { actual_html } end should "display text area in ruby with specified content" do @@ -624,7 +749,7 @@ describe "FormHelpers" do 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 } + assert_has_tag(:input, :type => 'image', :class => "success", :src => "/system/ok.png") { actual_html } end should "display image submit tag in erb" do diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_number_helpers.rb b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_number_helpers.rb index b9d1e66c..96b40b43 100644 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_number_helpers.rb +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_number_helpers.rb @@ -1,3 +1,6 @@ +require File.expand_path(File.dirname(__FILE__) + '/helper') +require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app') + describe "NumberHelpers" do include Padrino::Helpers::NumberHelpers diff --git a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_tag_helpers.rb b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_tag_helpers.rb index 7dd14a87..494d9d30 100644 --- a/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_tag_helpers.rb +++ b/middleman-core/lib/middleman-core/vendor/padrino-helpers-0.10.5/test/test_tag_helpers.rb @@ -21,17 +21,18 @@ describe "TagHelpers" do 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") } + should "support data attributes" do + actual_html = tag(:a, :data => { :remote => true, :method => 'post'}) + assert_has_tag(:a, 'data-remote' => 'true', 'data-method' => 'post') { actual_html } 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 } + should "support nested attributes" do + actual_html = tag(:div, :data => {:dojo => {:type => 'dijit.form.TextBox', :props => 'readOnly: true'}}) + assert_has_tag(:div, 'data-dojo-type' => 'dijit.form.TextBox', 'data-dojo-props' => 'readOnly: true') { actual_html } end should "support open tags" do - actual_html = tag(:p, :class => 'demo', :open => true) + actual_html = tag(:p, { :class => 'demo' }, true) assert_equal "
", actual_html end