enhanced_date_select 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.2-p290@enhanced_date_select --create
data/Gemfile ADDED
@@ -0,0 +1,26 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development, :test do
9
+ gem 'rspec-rails'
10
+ gem 'capybara'
11
+ gem 'spork', "> 0.9.0.rc"
12
+ gem 'active_reload'
13
+ gem "shoulda"
14
+ gem "rdoc"
15
+ gem 'rspec'
16
+ gem 'rake'
17
+ gem 'rspec-mocks'
18
+ gem "bundler"
19
+ gem "jeweler"
20
+ gem "simplecov"
21
+ gem 'simplecov', :require => false
22
+ gem 'simplecov-rcov', :require => false
23
+ gem 'webmock'
24
+ gem 'mocha'
25
+ end
26
+
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 bogdanRada
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,90 @@
1
+ = enhanced_date_select
2
+
3
+ = Overview
4
+
5
+
6
+ An enhanced date select form helper that allows you to use the full {HTML spec}[http://www.w3.org/TR/html5] for date_select helper methods from rails. This is more than what you get with the
7
+ default Rails date select helper because it can allow values to persist in dropdowns even if you submit a invalid value.
8
+
9
+ = Features
10
+
11
+ * Fully customizable HTML5 attributes for date_select .
12
+
13
+ = Requirements
14
+
15
+ 1. {Ruby 1.9.x}[http://www.ruby-lang.org]
16
+ 2. {Ruby on Rails}[http://rubyonrails.org].
17
+
18
+ = Setup
19
+
20
+ Type the following from the command line to install:
21
+
22
+ gem install enhanced_date_select
23
+
24
+ Add the following to your Gemfile:
25
+
26
+ gem "enhanced_date_select"
27
+
28
+ = Usage
29
+
30
+ Use the +enhanced_date_select+ instead of +date_select+ helper
31
+ methods in your views. Example:
32
+
33
+ <%= form_for @post do |form| %>
34
+ <div >
35
+ <%= form.enhanced_date_select :birthday, { :prompt => {
36
+ :day => "please select one",
37
+ :month => "please select one",
38
+ :year => "please select one" },
39
+ :value => {:year => @year, :month => @month, :day => @day},
40
+ :order => [:day, :month, :year],
41
+ :start_year => Time.now.year,
42
+ :end_year => 1940 }, { :class => "input_3cols" } %>
43
+ </div>
44
+ <% end %>
45
+
46
+ ...or alternatively:
47
+
48
+ <%= form_for @post do |form| %>
49
+ <div >
50
+ <%= form.date_select :birthday, { :prompt => {
51
+ :day => "please select one",
52
+ :month => "please select one",
53
+ :year => "please select one" },
54
+ :value => Date.new(2011,02,01),
55
+ :order => [:day, :month, :year],
56
+ :start_year => Time.now.year,
57
+ :end_year => 1940 }, { :class => "input_3cols" } %>
58
+ </div>
59
+ <% end %>
60
+
61
+ The +enhanced_date_select+ takes all the standard options as the default Rails date_select
62
+ method. The only difference is that it expects an hash with values for year, month and day instead of an date object.
63
+
64
+ = Testing
65
+
66
+ To test, do the following:
67
+
68
+ 1. cd to the gem root.
69
+ 2. bundle install
70
+ 3. bundle exec rspec spec
71
+
72
+ = Contributions
73
+
74
+ Please log all feedback/issues via {GitHub Issues}[http://github.com/bogdanRada/enhanced_date_select/issues]. Thanks.
75
+
76
+
77
+ == Contributing to enhanced_date_select
78
+
79
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
80
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
81
+ * Fork the project.
82
+ * Start a feature/bugfix branch.
83
+ * Commit and push until you are happy with your contribution.
84
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
85
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
86
+
87
+ == Copyright
88
+
89
+ Copyright (c) 2012 bogdanRada. See LICENSE.txt for
90
+ further details.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "enhanced_date_select"
18
+ gem.homepage = "http://github.com/bogdanRada/enhanced_date_select"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{"enhanced date select"}
21
+ gem.description = %Q{"Enhances ActionView with a customizable date select form helper where any valid HTML attribute can be applied."}
22
+ gem.email = "raoul_ice@yahoo.com"
23
+ gem.authors = ["bogdanRada"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+
29
+
30
+ task :default => :test
31
+
32
+ require 'rdoc/task'
33
+ Rake::RDocTask.new do |rdoc|
34
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
35
+
36
+ rdoc.rdoc_dir = 'rdoc'
37
+ rdoc.title = "enhanced_date_select #{version}"
38
+ rdoc.rdoc_files.include('README*')
39
+ rdoc.rdoc_files.include('lib/**/*.rb')
40
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
@@ -0,0 +1,96 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "enhanced_date_select"
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["bogdanRada"]
12
+ s.date = "2012-10-16"
13
+ s.description = "\"Enhances ActionView with a customizable date select form helper where any valid HTML attribute can be applied.\""
14
+ s.email = "raoul_ice@yahoo.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".rspec",
21
+ ".rvmrc",
22
+ "Gemfile",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "enhanced_date_select-0.3.0.gem",
28
+ "enhanced_date_select.gemspec",
29
+ "lib/enhanced_date_select.rb",
30
+ "spec/enhanced_date_select_spec.rb",
31
+ "spec/spec_helper.rb"
32
+ ]
33
+ s.homepage = "http://github.com/bogdanRada/enhanced_date_select"
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = "1.8.24"
37
+ s.summary = "\"enhanced date select\""
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_development_dependency(%q<rspec-rails>, [">= 0"])
44
+ s.add_development_dependency(%q<capybara>, [">= 0"])
45
+ s.add_development_dependency(%q<spork>, ["> 0.9.0.rc"])
46
+ s.add_development_dependency(%q<active_reload>, [">= 0"])
47
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
48
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
49
+ s.add_development_dependency(%q<rspec>, [">= 0"])
50
+ s.add_development_dependency(%q<rake>, [">= 0"])
51
+ s.add_development_dependency(%q<rspec-mocks>, [">= 0"])
52
+ s.add_development_dependency(%q<bundler>, [">= 0"])
53
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
54
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
55
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
56
+ s.add_development_dependency(%q<simplecov-rcov>, [">= 0"])
57
+ s.add_development_dependency(%q<webmock>, [">= 0"])
58
+ s.add_development_dependency(%q<mocha>, [">= 0"])
59
+ else
60
+ s.add_dependency(%q<rspec-rails>, [">= 0"])
61
+ s.add_dependency(%q<capybara>, [">= 0"])
62
+ s.add_dependency(%q<spork>, ["> 0.9.0.rc"])
63
+ s.add_dependency(%q<active_reload>, [">= 0"])
64
+ s.add_dependency(%q<shoulda>, [">= 0"])
65
+ s.add_dependency(%q<rdoc>, [">= 0"])
66
+ s.add_dependency(%q<rspec>, [">= 0"])
67
+ s.add_dependency(%q<rake>, [">= 0"])
68
+ s.add_dependency(%q<rspec-mocks>, [">= 0"])
69
+ s.add_dependency(%q<bundler>, [">= 0"])
70
+ s.add_dependency(%q<jeweler>, [">= 0"])
71
+ s.add_dependency(%q<simplecov>, [">= 0"])
72
+ s.add_dependency(%q<simplecov>, [">= 0"])
73
+ s.add_dependency(%q<simplecov-rcov>, [">= 0"])
74
+ s.add_dependency(%q<webmock>, [">= 0"])
75
+ s.add_dependency(%q<mocha>, [">= 0"])
76
+ end
77
+ else
78
+ s.add_dependency(%q<rspec-rails>, [">= 0"])
79
+ s.add_dependency(%q<capybara>, [">= 0"])
80
+ s.add_dependency(%q<spork>, ["> 0.9.0.rc"])
81
+ s.add_dependency(%q<active_reload>, [">= 0"])
82
+ s.add_dependency(%q<shoulda>, [">= 0"])
83
+ s.add_dependency(%q<rdoc>, [">= 0"])
84
+ s.add_dependency(%q<rspec>, [">= 0"])
85
+ s.add_dependency(%q<rake>, [">= 0"])
86
+ s.add_dependency(%q<rspec-mocks>, [">= 0"])
87
+ s.add_dependency(%q<bundler>, [">= 0"])
88
+ s.add_dependency(%q<jeweler>, [">= 0"])
89
+ s.add_dependency(%q<simplecov>, [">= 0"])
90
+ s.add_dependency(%q<simplecov>, [">= 0"])
91
+ s.add_dependency(%q<simplecov-rcov>, [">= 0"])
92
+ s.add_dependency(%q<webmock>, [">= 0"])
93
+ s.add_dependency(%q<mocha>, [">= 0"])
94
+ end
95
+ end
96
+
@@ -0,0 +1,88 @@
1
+ #EnhancedDateSelect
2
+ if defined?(Rails) && defined?(ActionView)
3
+ module ActionView
4
+ module Helpers
5
+ module FormOptionsHelper
6
+ def enhanced_date_select object, method, options = {}, html_options = {}
7
+ InstanceTag.new(object, method, self, options.delete(:object)).to_enhanced_date_select_tag(options, html_options)
8
+ end
9
+ end
10
+
11
+
12
+ class InstanceTag
13
+ def to_enhanced_date_select_tag options, html_options
14
+ enhanced_datetime_selector(options, html_options).enhanced_select_date.html_safe
15
+ end
16
+
17
+ private
18
+ def enhanced_datetime_selector(options, html_options)
19
+ datetime = options[:value] || value(object) || default_datetime(options)
20
+
21
+ @auto_index ||= nil
22
+
23
+ options = options.dup
24
+ options[:field_name] = @method_name
25
+ options[:include_position] = true
26
+ options[:prefix] ||= @object_name
27
+ options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
28
+
29
+ EnhancedDateTimeSelector.new(datetime, options, html_options)
30
+ end
31
+
32
+ end
33
+
34
+
35
+ class EnhancedDateTimeSelector < DateTimeSelector
36
+
37
+ def enhanced_select_date
38
+ order = date_order.dup
39
+
40
+ @options[:discard_hour] = true
41
+ @options[:discard_minute] = true
42
+ @options[:discard_second] = true
43
+
44
+ @options[:discard_year] ||= true unless order.include?(:year)
45
+ @options[:discard_month] ||= true unless order.include?(:month)
46
+ @options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day)
47
+
48
+ # If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are valid (otherwise it could be 31 and February wouldn't be a valid date)
49
+ if @datetime && @options[:discard_day] && !@options[:discard_month]
50
+ if @datetime.is_a?(Hash)
51
+ @datetime[:day] = 1
52
+ else
53
+ @datetime = @datetime.change(:day => 1)
54
+ end
55
+ end
56
+
57
+ [:day, :month, :year].each { |o| order.unshift(o) unless order.include?(o) }
58
+
59
+ build_selects_from_types(order)
60
+ end
61
+
62
+ private
63
+ %w( sec min hour day month year ).each do |method|
64
+ define_method(method) do
65
+ if @datetime
66
+ if @datetime.kind_of?(Fixnum)
67
+ @datetime
68
+ elsif @datetime.is_a?(Hash)
69
+ @datetime[method.to_sym]
70
+ else
71
+ @datetime.send(method)
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+
78
+
79
+ end
80
+
81
+ class FormBuilder
82
+ def enhanced_date_select method, options = {}, html_options = {}
83
+ @template.enhanced_date_select(@object_name, method, objectify_options(options), html_options)
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,86 @@
1
+ require "spec_helper"
2
+
3
+ describe "Enhanced DateSelect" do
4
+ include ActionView::Helpers::FormOptionsHelper
5
+ let(:student) {Object.new}
6
+ let(:form_builder){ ActionView::Helpers::FormBuilder.new(:birthday, student, self, {}, nil)}
7
+
8
+ let(:instance_tag) { ActionView::Helpers::InstanceTag.new(student.class, 'birthday', self, student )}
9
+ let(:datetime){{:year => 2001, :month => 2, :day => 3}}
10
+ let(:html_options){{}}
11
+ let(:options) {{ :discard_day =>true,
12
+ :value => {:year => 2001, :month => 2, :day => 3},
13
+ :order => [:day, :month, :year],
14
+ :start_year => Time.now.year,
15
+ :end_year => 1940 }}
16
+ let(:expected_result) {"<input id=\"birthday_birthday_3i\" name=\"birthday[birthday(3i)]\" type=\"hidden\" value=\"1\" />\n<select id=\"birthday_birthday_2i\" name=\"birthday[birthday(2i)]\">\n<option value=\"1\">January</option>\n<option selected=\"selected\" value=\"2\">February</option>\n<option value=\"3\">March</option>\n<option value=\"4\">April</option>\n<option value=\"5\">May</option>\n<option value=\"6\">June</option>\n<option value=\"7\">July</option>\n<option value=\"8\">August</option>\n<option value=\"9\">September</option>\n<option value=\"10\">October</option>\n<option value=\"11\">November</option>\n<option value=\"12\">December</option>\n</select>\n<select id=\"birthday_birthday_1i\" name=\"birthday[birthday(1i)]\">\n<option value=\"2012\">2012</option>\n<option value=\"2011\">2011</option>\n<option value=\"2010\">2010</option>\n<option value=\"2009\">2009</option>\n<option value=\"2008\">2008</option>\n<option value=\"2007\">2007</option>\n<option value=\"2006\">2006</option>\n<option value=\"2005\">2005</option>\n<option value=\"2004\">2004</option>\n<option value=\"2003\">2003</option>\n<option value=\"2002\">2002</option>\n<option selected=\"selected\" value=\"2001\">2001</option>\n<option value=\"2000\">2000</option>\n<option value=\"1999\">1999</option>\n<option value=\"1998\">1998</option>\n<option value=\"1997\">1997</option>\n<option value=\"1996\">1996</option>\n<option value=\"1995\">1995</option>\n<option value=\"1994\">1994</option>\n<option value=\"1993\">1993</option>\n<option value=\"1992\">1992</option>\n<option value=\"1991\">1991</option>\n<option value=\"1990\">1990</option>\n<option value=\"1989\">1989</option>\n<option value=\"1988\">1988</option>\n<option value=\"1987\">1987</option>\n<option value=\"1986\">1986</option>\n<option value=\"1985\">1985</option>\n<option value=\"1984\">1984</option>\n<option value=\"1983\">1983</option>\n<option value=\"1982\">1982</option>\n<option value=\"1981\">1981</option>\n<option value=\"1980\">1980</option>\n<option value=\"1979\">1979</option>\n<option value=\"1978\">1978</option>\n<option value=\"1977\">1977</option>\n<option value=\"1976\">1976</option>\n<option value=\"1975\">1975</option>\n<option value=\"1974\">1974</option>\n<option value=\"1973\">1973</option>\n<option value=\"1972\">1972</option>\n<option value=\"1971\">1971</option>\n<option value=\"1970\">1970</option>\n<option value=\"1969\">1969</option>\n<option value=\"1968\">1968</option>\n<option value=\"1967\">1967</option>\n<option value=\"1966\">1966</option>\n<option value=\"1965\">1965</option>\n<option value=\"1964\">1964</option>\n<option value=\"1963\">1963</option>\n<option value=\"1962\">1962</option>\n<option value=\"1961\">1961</option>\n<option value=\"1960\">1960</option>\n<option value=\"1959\">1959</option>\n<option value=\"1958\">1958</option>\n<option value=\"1957\">1957</option>\n<option value=\"1956\">1956</option>\n<option value=\"1955\">1955</option>\n<option value=\"1954\">1954</option>\n<option value=\"1953\">1953</option>\n<option value=\"1952\">1952</option>\n<option value=\"1951\">1951</option>\n<option value=\"1950\">1950</option>\n<option value=\"1949\">1949</option>\n<option value=\"1948\">1948</option>\n<option value=\"1947\">1947</option>\n<option value=\"1946\">1946</option>\n<option value=\"1945\">1945</option>\n<option value=\"1944\">1944</option>\n<option value=\"1943\">1943</option>\n<option value=\"1942\">1942</option>\n<option value=\"1941\">1941</option>\n<option value=\"1940\">1940</option>\n</select>\n"}
17
+ before(:each) do
18
+ @instance_tag =ActionView::Helpers::InstanceTag.new(student.class, 'birthday', self, student )
19
+ @enhanced_datetime_selector = ActionView::Helpers::EnhancedDateTimeSelector.new(datetime, options, {})
20
+ end
21
+
22
+
23
+ describe ".enhanced_date_select" do
24
+ it "constructs 3 selectboxes" do
25
+ form_builder.enhanced_date_select(:birthday,{ :prompt => {
26
+ :day => "please select one",
27
+ :month => "please select one",
28
+ :year => "please select one" },
29
+ :value => {:year => 2001, :month => 2, :day => 3},
30
+ :order => [:day, :month, :year],
31
+ :start_year => Time.now.year,
32
+ :end_year => 1940 } ).should == "<select id=\"birthday_birthday_3i\" name=\"birthday[birthday(3i)]\">\n<option value=\"\">please select one</option>\n<option value=\"1\">1</option>\n<option value=\"2\">2</option>\n<option selected=\"selected\" value=\"3\">3</option>\n<option value=\"4\">4</option>\n<option value=\"5\">5</option>\n<option value=\"6\">6</option>\n<option value=\"7\">7</option>\n<option value=\"8\">8</option>\n<option value=\"9\">9</option>\n<option value=\"10\">10</option>\n<option value=\"11\">11</option>\n<option value=\"12\">12</option>\n<option value=\"13\">13</option>\n<option value=\"14\">14</option>\n<option value=\"15\">15</option>\n<option value=\"16\">16</option>\n<option value=\"17\">17</option>\n<option value=\"18\">18</option>\n<option value=\"19\">19</option>\n<option value=\"20\">20</option>\n<option value=\"21\">21</option>\n<option value=\"22\">22</option>\n<option value=\"23\">23</option>\n<option value=\"24\">24</option>\n<option value=\"25\">25</option>\n<option value=\"26\">26</option>\n<option value=\"27\">27</option>\n<option value=\"28\">28</option>\n<option value=\"29\">29</option>\n<option value=\"30\">30</option>\n<option value=\"31\">31</option>\n</select>\n<select id=\"birthday_birthday_2i\" name=\"birthday[birthday(2i)]\">\n<option value=\"\">please select one</option>\n<option value=\"1\">January</option>\n<option selected=\"selected\" value=\"2\">February</option>\n<option value=\"3\">March</option>\n<option value=\"4\">April</option>\n<option value=\"5\">May</option>\n<option value=\"6\">June</option>\n<option value=\"7\">July</option>\n<option value=\"8\">August</option>\n<option value=\"9\">September</option>\n<option value=\"10\">October</option>\n<option value=\"11\">November</option>\n<option value=\"12\">December</option>\n</select>\n<select id=\"birthday_birthday_1i\" name=\"birthday[birthday(1i)]\">\n<option value=\"\">please select one</option>\n<option value=\"2012\">2012</option>\n<option value=\"2011\">2011</option>\n<option value=\"2010\">2010</option>\n<option value=\"2009\">2009</option>\n<option value=\"2008\">2008</option>\n<option value=\"2007\">2007</option>\n<option value=\"2006\">2006</option>\n<option value=\"2005\">2005</option>\n<option value=\"2004\">2004</option>\n<option value=\"2003\">2003</option>\n<option value=\"2002\">2002</option>\n<option selected=\"selected\" value=\"2001\">2001</option>\n<option value=\"2000\">2000</option>\n<option value=\"1999\">1999</option>\n<option value=\"1998\">1998</option>\n<option value=\"1997\">1997</option>\n<option value=\"1996\">1996</option>\n<option value=\"1995\">1995</option>\n<option value=\"1994\">1994</option>\n<option value=\"1993\">1993</option>\n<option value=\"1992\">1992</option>\n<option value=\"1991\">1991</option>\n<option value=\"1990\">1990</option>\n<option value=\"1989\">1989</option>\n<option value=\"1988\">1988</option>\n<option value=\"1987\">1987</option>\n<option value=\"1986\">1986</option>\n<option value=\"1985\">1985</option>\n<option value=\"1984\">1984</option>\n<option value=\"1983\">1983</option>\n<option value=\"1982\">1982</option>\n<option value=\"1981\">1981</option>\n<option value=\"1980\">1980</option>\n<option value=\"1979\">1979</option>\n<option value=\"1978\">1978</option>\n<option value=\"1977\">1977</option>\n<option value=\"1976\">1976</option>\n<option value=\"1975\">1975</option>\n<option value=\"1974\">1974</option>\n<option value=\"1973\">1973</option>\n<option value=\"1972\">1972</option>\n<option value=\"1971\">1971</option>\n<option value=\"1970\">1970</option>\n<option value=\"1969\">1969</option>\n<option value=\"1968\">1968</option>\n<option value=\"1967\">1967</option>\n<option value=\"1966\">1966</option>\n<option value=\"1965\">1965</option>\n<option value=\"1964\">1964</option>\n<option value=\"1963\">1963</option>\n<option value=\"1962\">1962</option>\n<option value=\"1961\">1961</option>\n<option value=\"1960\">1960</option>\n<option value=\"1959\">1959</option>\n<option value=\"1958\">1958</option>\n<option value=\"1957\">1957</option>\n<option value=\"1956\">1956</option>\n<option value=\"1955\">1955</option>\n<option value=\"1954\">1954</option>\n<option value=\"1953\">1953</option>\n<option value=\"1952\">1952</option>\n<option value=\"1951\">1951</option>\n<option value=\"1950\">1950</option>\n<option value=\"1949\">1949</option>\n<option value=\"1948\">1948</option>\n<option value=\"1947\">1947</option>\n<option value=\"1946\">1946</option>\n<option value=\"1945\">1945</option>\n<option value=\"1944\">1944</option>\n<option value=\"1943\">1943</option>\n<option value=\"1942\">1942</option>\n<option value=\"1941\">1941</option>\n<option value=\"1940\">1940</option>\n</select>\n"
33
+ end
34
+
35
+ it "construct withoud the day dropdown" do
36
+ form_builder.enhanced_date_select(:birthday,{ :discard_day =>true,
37
+ :value => {:year => 2001, :month => 2, :day => 3},
38
+ :order => [:day, :month, :year],
39
+ :start_year => Time.now.year,
40
+ :end_year => 1940 } ).should =="<input id=\"birthday_birthday_3i\" name=\"birthday[birthday(3i)]\" type=\"hidden\" value=\"1\" />\n<select id=\"birthday_birthday_2i\" name=\"birthday[birthday(2i)]\">\n<option value=\"1\">January</option>\n<option selected=\"selected\" value=\"2\">February</option>\n<option value=\"3\">March</option>\n<option value=\"4\">April</option>\n<option value=\"5\">May</option>\n<option value=\"6\">June</option>\n<option value=\"7\">July</option>\n<option value=\"8\">August</option>\n<option value=\"9\">September</option>\n<option value=\"10\">October</option>\n<option value=\"11\">November</option>\n<option value=\"12\">December</option>\n</select>\n<select id=\"birthday_birthday_1i\" name=\"birthday[birthday(1i)]\">\n<option value=\"2012\">2012</option>\n<option value=\"2011\">2011</option>\n<option value=\"2010\">2010</option>\n<option value=\"2009\">2009</option>\n<option value=\"2008\">2008</option>\n<option value=\"2007\">2007</option>\n<option value=\"2006\">2006</option>\n<option value=\"2005\">2005</option>\n<option value=\"2004\">2004</option>\n<option value=\"2003\">2003</option>\n<option value=\"2002\">2002</option>\n<option selected=\"selected\" value=\"2001\">2001</option>\n<option value=\"2000\">2000</option>\n<option value=\"1999\">1999</option>\n<option value=\"1998\">1998</option>\n<option value=\"1997\">1997</option>\n<option value=\"1996\">1996</option>\n<option value=\"1995\">1995</option>\n<option value=\"1994\">1994</option>\n<option value=\"1993\">1993</option>\n<option value=\"1992\">1992</option>\n<option value=\"1991\">1991</option>\n<option value=\"1990\">1990</option>\n<option value=\"1989\">1989</option>\n<option value=\"1988\">1988</option>\n<option value=\"1987\">1987</option>\n<option value=\"1986\">1986</option>\n<option value=\"1985\">1985</option>\n<option value=\"1984\">1984</option>\n<option value=\"1983\">1983</option>\n<option value=\"1982\">1982</option>\n<option value=\"1981\">1981</option>\n<option value=\"1980\">1980</option>\n<option value=\"1979\">1979</option>\n<option value=\"1978\">1978</option>\n<option value=\"1977\">1977</option>\n<option value=\"1976\">1976</option>\n<option value=\"1975\">1975</option>\n<option value=\"1974\">1974</option>\n<option value=\"1973\">1973</option>\n<option value=\"1972\">1972</option>\n<option value=\"1971\">1971</option>\n<option value=\"1970\">1970</option>\n<option value=\"1969\">1969</option>\n<option value=\"1968\">1968</option>\n<option value=\"1967\">1967</option>\n<option value=\"1966\">1966</option>\n<option value=\"1965\">1965</option>\n<option value=\"1964\">1964</option>\n<option value=\"1963\">1963</option>\n<option value=\"1962\">1962</option>\n<option value=\"1961\">1961</option>\n<option value=\"1960\">1960</option>\n<option value=\"1959\">1959</option>\n<option value=\"1958\">1958</option>\n<option value=\"1957\">1957</option>\n<option value=\"1956\">1956</option>\n<option value=\"1955\">1955</option>\n<option value=\"1954\">1954</option>\n<option value=\"1953\">1953</option>\n<option value=\"1952\">1952</option>\n<option value=\"1951\">1951</option>\n<option value=\"1950\">1950</option>\n<option value=\"1949\">1949</option>\n<option value=\"1948\">1948</option>\n<option value=\"1947\">1947</option>\n<option value=\"1946\">1946</option>\n<option value=\"1945\">1945</option>\n<option value=\"1944\">1944</option>\n<option value=\"1943\">1943</option>\n<option value=\"1942\">1942</option>\n<option value=\"1941\">1941</option>\n<option value=\"1940\">1940</option>\n</select>\n"
41
+ end
42
+ end
43
+
44
+
45
+ describe ActionView::Helpers::FormOptionsHelper do
46
+
47
+
48
+ before(:each) do
49
+ ActionView::Helpers::InstanceTag.stub(:new).and_return(@instance_tag)
50
+ end
51
+
52
+ it "should call the instance tag with argument" do
53
+ ActionView::Helpers::InstanceTag.should_receive(:new).with(student, 'birthday', self, options.delete(:object)).and_return(@instance_tag)
54
+ enhanced_date_select(student,'birthday',options )
55
+ end
56
+ it "should call the tp date_select_tag method" do
57
+ @instance_tag.should_receive(:to_enhanced_date_select_tag).with(options, {})
58
+ enhanced_date_select(student,'birthday',options )
59
+ end
60
+
61
+ end
62
+
63
+
64
+ describe ActionView::Helpers::InstanceTag do
65
+
66
+ before(:each) do
67
+ @instance_tag.stub(:enhanced_datetime_selector).and_return(@enhanced_datetime_selector)
68
+ end
69
+
70
+
71
+ it "should call the datetimeselector" do
72
+ @instance_tag.should_receive(:enhanced_datetime_selector).with(options, html_options).and_return(@enhanced_datetime_selector)
73
+ @instance_tag.to_enhanced_date_select_tag(options, html_options)
74
+ end
75
+
76
+ it "should call the datetimeselector" do
77
+ @enhanced_datetime_selector.should_receive(:enhanced_select_date).and_return(expected_result)
78
+ @instance_tag.to_enhanced_date_select_tag(options, html_options)
79
+ end
80
+
81
+
82
+
83
+ end
84
+
85
+
86
+ end
@@ -0,0 +1,7 @@
1
+ require "bundler/setup"
2
+ require "rails"
3
+ require "action_view"
4
+ require "enhanced_date_select"
5
+
6
+ RSpec.configure do |config|
7
+ end
metadata ADDED
@@ -0,0 +1,319 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: enhanced_date_select
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - bogdanRada
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec-rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: capybara
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: spork
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>'
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.0.rc
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>'
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.0.rc
62
+ - !ruby/object:Gem::Dependency
63
+ name: active_reload
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: shoulda
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rdoc
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rake
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: rspec-mocks
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: bundler
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: jeweler
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: simplecov
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: simplecov
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ - !ruby/object:Gem::Dependency
223
+ name: simplecov-rcov
224
+ requirement: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ! '>='
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ - !ruby/object:Gem::Dependency
239
+ name: webmock
240
+ requirement: !ruby/object:Gem::Requirement
241
+ none: false
242
+ requirements:
243
+ - - ! '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ type: :development
247
+ prerelease: false
248
+ version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ! '>='
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
254
+ - !ruby/object:Gem::Dependency
255
+ name: mocha
256
+ requirement: !ruby/object:Gem::Requirement
257
+ none: false
258
+ requirements:
259
+ - - ! '>='
260
+ - !ruby/object:Gem::Version
261
+ version: '0'
262
+ type: :development
263
+ prerelease: false
264
+ version_requirements: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ! '>='
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
270
+ description: ! '"Enhances ActionView with a customizable date select form helper where
271
+ any valid HTML attribute can be applied."'
272
+ email: raoul_ice@yahoo.com
273
+ executables: []
274
+ extensions: []
275
+ extra_rdoc_files:
276
+ - LICENSE.txt
277
+ - README.rdoc
278
+ files:
279
+ - .rspec
280
+ - .rvmrc
281
+ - Gemfile
282
+ - LICENSE.txt
283
+ - README.rdoc
284
+ - Rakefile
285
+ - VERSION
286
+ - enhanced_date_select-0.3.0.gem
287
+ - enhanced_date_select.gemspec
288
+ - lib/enhanced_date_select.rb
289
+ - spec/enhanced_date_select_spec.rb
290
+ - spec/spec_helper.rb
291
+ homepage: http://github.com/bogdanRada/enhanced_date_select
292
+ licenses:
293
+ - MIT
294
+ post_install_message:
295
+ rdoc_options: []
296
+ require_paths:
297
+ - lib
298
+ required_ruby_version: !ruby/object:Gem::Requirement
299
+ none: false
300
+ requirements:
301
+ - - ! '>='
302
+ - !ruby/object:Gem::Version
303
+ version: '0'
304
+ segments:
305
+ - 0
306
+ hash: 136929645
307
+ required_rubygems_version: !ruby/object:Gem::Requirement
308
+ none: false
309
+ requirements:
310
+ - - ! '>='
311
+ - !ruby/object:Gem::Version
312
+ version: '0'
313
+ requirements: []
314
+ rubyforge_project:
315
+ rubygems_version: 1.8.24
316
+ signing_key:
317
+ specification_version: 3
318
+ summary: ! '"enhanced date select"'
319
+ test_files: []