formtastic 3.1.1 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +1 -0
  3. data/.gitignore +3 -2
  4. data/.travis.yml +29 -24
  5. data/CHANGELOG.md +49 -0
  6. data/DEPRECATIONS +4 -1
  7. data/Gemfile.lock +104 -0
  8. data/{README.textile → README.md} +178 -166
  9. data/Rakefile +20 -1
  10. data/app/assets/stylesheets/formtastic.css +1 -1
  11. data/bin/appraisal +8 -0
  12. data/formtastic.gemspec +9 -15
  13. data/gemfiles/rails_5.2/Gemfile +5 -0
  14. data/gemfiles/rails_6.0/Gemfile +5 -0
  15. data/gemfiles/rails_edge/Gemfile +13 -0
  16. data/lib/formtastic.rb +9 -11
  17. data/lib/formtastic/actions.rb +6 -3
  18. data/lib/formtastic/deprecation.rb +1 -38
  19. data/lib/formtastic/engine.rb +3 -1
  20. data/lib/formtastic/form_builder.rb +11 -24
  21. data/lib/formtastic/helpers.rb +1 -1
  22. data/lib/formtastic/helpers/action_helper.rb +1 -48
  23. data/lib/formtastic/helpers/enum.rb +13 -0
  24. data/lib/formtastic/helpers/errors_helper.rb +2 -2
  25. data/lib/formtastic/helpers/fieldset_wrapper.rb +13 -9
  26. data/lib/formtastic/helpers/form_helper.rb +1 -1
  27. data/lib/formtastic/helpers/input_helper.rb +23 -77
  28. data/lib/formtastic/helpers/inputs_helper.rb +27 -22
  29. data/lib/formtastic/i18n.rb +1 -1
  30. data/lib/formtastic/inputs.rb +32 -29
  31. data/lib/formtastic/inputs/base/choices.rb +1 -1
  32. data/lib/formtastic/inputs/base/collections.rb +43 -10
  33. data/lib/formtastic/inputs/base/database.rb +7 -2
  34. data/lib/formtastic/inputs/base/errors.rb +4 -4
  35. data/lib/formtastic/inputs/base/hints.rb +1 -1
  36. data/lib/formtastic/inputs/base/html.rb +7 -6
  37. data/lib/formtastic/inputs/base/naming.rb +4 -4
  38. data/lib/formtastic/inputs/base/options.rb +2 -3
  39. data/lib/formtastic/inputs/base/timeish.rb +5 -1
  40. data/lib/formtastic/inputs/base/validations.rb +38 -12
  41. data/lib/formtastic/inputs/check_boxes_input.rb +13 -5
  42. data/lib/formtastic/inputs/color_input.rb +0 -1
  43. data/lib/formtastic/inputs/country_input.rb +3 -1
  44. data/lib/formtastic/inputs/radio_input.rb +20 -0
  45. data/lib/formtastic/inputs/select_input.rb +29 -1
  46. data/lib/formtastic/inputs/time_zone_input.rb +16 -6
  47. data/lib/formtastic/localizer.rb +20 -22
  48. data/lib/formtastic/namespaced_class_finder.rb +1 -1
  49. data/lib/formtastic/version.rb +1 -1
  50. data/lib/generators/formtastic/form/form_generator.rb +1 -1
  51. data/lib/generators/formtastic/input/input_generator.rb +46 -0
  52. data/lib/generators/templates/formtastic.rb +14 -13
  53. data/lib/generators/templates/input.rb +19 -0
  54. data/script/integration-template.rb +71 -0
  55. data/script/integration.sh +19 -0
  56. data/spec/action_class_finder_spec.rb +1 -1
  57. data/spec/actions/button_action_spec.rb +8 -8
  58. data/spec/actions/generic_action_spec.rb +60 -60
  59. data/spec/actions/input_action_spec.rb +7 -7
  60. data/spec/actions/link_action_spec.rb +10 -10
  61. data/spec/builder/custom_builder_spec.rb +36 -20
  62. data/spec/builder/error_proc_spec.rb +4 -4
  63. data/spec/builder/semantic_fields_for_spec.rb +27 -27
  64. data/spec/fast_spec_helper.rb +12 -0
  65. data/spec/generators/formtastic/form/form_generator_spec.rb +25 -25
  66. data/spec/generators/formtastic/input/input_generator_spec.rb +124 -0
  67. data/spec/generators/formtastic/install/install_generator_spec.rb +9 -9
  68. data/spec/helpers/action_helper_spec.rb +328 -10
  69. data/spec/helpers/actions_helper_spec.rb +17 -17
  70. data/spec/helpers/form_helper_spec.rb +37 -37
  71. data/spec/helpers/input_helper_spec.rb +975 -2
  72. data/spec/helpers/inputs_helper_spec.rb +120 -105
  73. data/spec/helpers/reflection_helper_spec.rb +3 -3
  74. data/spec/helpers/semantic_errors_helper_spec.rb +22 -22
  75. data/spec/i18n_spec.rb +26 -26
  76. data/spec/input_class_finder_spec.rb +1 -1
  77. data/spec/inputs/base/collections_spec.rb +76 -0
  78. data/spec/inputs/base/validations_spec.rb +480 -0
  79. data/spec/inputs/boolean_input_spec.rb +55 -55
  80. data/spec/inputs/check_boxes_input_spec.rb +155 -108
  81. data/spec/inputs/color_input_spec.rb +51 -63
  82. data/spec/inputs/country_input_spec.rb +20 -20
  83. data/spec/inputs/custom_input_spec.rb +2 -6
  84. data/spec/inputs/datalist_input_spec.rb +1 -1
  85. data/spec/inputs/date_picker_input_spec.rb +42 -42
  86. data/spec/inputs/date_select_input_spec.rb +51 -37
  87. data/spec/inputs/datetime_picker_input_spec.rb +46 -46
  88. data/spec/inputs/datetime_select_input_spec.rb +53 -37
  89. data/spec/inputs/email_input_spec.rb +5 -5
  90. data/spec/inputs/file_input_spec.rb +6 -6
  91. data/spec/inputs/hidden_input_spec.rb +18 -18
  92. data/spec/inputs/include_blank_spec.rb +8 -8
  93. data/spec/inputs/label_spec.rb +20 -20
  94. data/spec/inputs/number_input_spec.rb +112 -112
  95. data/spec/inputs/password_input_spec.rb +5 -5
  96. data/spec/inputs/phone_input_spec.rb +5 -5
  97. data/spec/inputs/placeholder_spec.rb +5 -5
  98. data/spec/inputs/radio_input_spec.rb +84 -58
  99. data/spec/inputs/range_input_spec.rb +66 -66
  100. data/spec/inputs/readonly_spec.rb +50 -0
  101. data/spec/inputs/search_input_spec.rb +5 -5
  102. data/spec/inputs/select_input_spec.rb +149 -93
  103. data/spec/inputs/string_input_spec.rb +23 -23
  104. data/spec/inputs/text_input_spec.rb +16 -16
  105. data/spec/inputs/time_picker_input_spec.rb +43 -43
  106. data/spec/inputs/time_select_input_spec.rb +67 -54
  107. data/spec/inputs/time_zone_input_spec.rb +54 -28
  108. data/spec/inputs/url_input_spec.rb +5 -5
  109. data/spec/inputs/with_options_spec.rb +7 -7
  110. data/spec/localizer_spec.rb +17 -17
  111. data/spec/namespaced_class_finder_spec.rb +2 -2
  112. data/spec/schema.rb +21 -0
  113. data/spec/spec_helper.rb +165 -253
  114. data/spec/support/custom_macros.rb +72 -75
  115. data/spec/support/shared_examples.rb +0 -1232
  116. data/spec/support/test_environment.rb +23 -9
  117. metadata +67 -174
  118. data/Appraisals +0 -29
  119. data/CHANGELOG +0 -31
  120. data/gemfiles/rails_3.2.gemfile +0 -7
  121. data/gemfiles/rails_4.0.4.gemfile +0 -7
  122. data/gemfiles/rails_4.1.gemfile +0 -7
  123. data/gemfiles/rails_4.2.gemfile +0 -7
  124. data/gemfiles/rails_4.gemfile +0 -7
  125. data/gemfiles/rails_edge.gemfile +0 -10
  126. data/lib/formtastic/util.rb +0 -53
  127. data/spec/helpers/namespaced_action_helper_spec.rb +0 -43
  128. data/spec/helpers/namespaced_input_helper_spec.rb +0 -36
  129. data/spec/support/deferred_garbage_collection.rb +0 -21
  130. data/spec/util_spec.rb +0 -66
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'color input' do
4
+ RSpec.describe 'color input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -10,85 +10,73 @@ describe 'color input' do
10
10
  mock_everything
11
11
  end
12
12
 
13
- if Formtastic::Util.rails3?
14
- describe "attempting to use color input with Rails 3" do
15
- it "raises an error" do
16
- expect {
17
- concat(semantic_form_for(@new_post) do |builder|
18
- concat(builder.input(:color))
19
- end)
20
- }.to raise_error "The :color input requires the color_field form helper, which is only available in Rails 4+"
21
- end
13
+ describe "when object is provided" do
14
+ before do
15
+ concat(semantic_form_for(@new_post) do |builder|
16
+ concat(builder.input(:color))
17
+ end)
22
18
  end
23
- else
24
- describe "when object is provided" do
25
- before do
26
- concat(semantic_form_for(@new_post) do |builder|
27
- concat(builder.input(:color))
28
- end)
29
- end
30
19
 
31
- it_should_have_input_wrapper_with_class(:color)
32
- it_should_have_input_wrapper_with_class(:input)
33
- it_should_have_input_wrapper_with_class(:stringish)
34
- it_should_have_input_wrapper_with_id("post_color_input")
35
- it_should_have_label_with_text(/Color/)
36
- it_should_have_label_for("post_color")
37
- it_should_have_input_with_id("post_color")
38
- it_should_have_input_with_type(:color)
39
- it_should_have_input_with_name("post[color]")
20
+ it_should_have_input_wrapper_with_class(:color)
21
+ it_should_have_input_wrapper_with_class(:input)
22
+ it_should_have_input_wrapper_with_class(:stringish)
23
+ it_should_have_input_wrapper_with_id("post_color_input")
24
+ it_should_have_label_with_text(/Color/)
25
+ it_should_have_label_for("post_color")
26
+ it_should_have_input_with_id("post_color")
27
+ it_should_have_input_with_type(:color)
28
+ it_should_have_input_with_name("post[color]")
40
29
 
41
- end
30
+ end
42
31
 
43
- describe "when namespace is provided" do
32
+ describe "when namespace is provided" do
44
33
 
45
- before do
46
- concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
47
- concat(builder.input(:color))
48
- end)
49
- end
34
+ before do
35
+ concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
36
+ concat(builder.input(:color))
37
+ end)
38
+ end
50
39
 
51
- it_should_have_input_wrapper_with_id("context2_post_color_input")
52
- it_should_have_label_and_input_with_id("context2_post_color")
40
+ it_should_have_input_wrapper_with_id("context2_post_color_input")
41
+ it_should_have_label_and_input_with_id("context2_post_color")
53
42
 
54
- end
43
+ end
55
44
 
56
- describe "when index is provided" do
45
+ describe "when index is provided" do
57
46
 
58
- before do
59
- @output_buffer = ''
60
- mock_everything
47
+ before do
48
+ @output_buffer = ''
49
+ mock_everything
61
50
 
62
- concat(semantic_form_for(@new_post) do |builder|
63
- concat(builder.fields_for(:author, :index => 3) do |author|
64
- concat(author.input(:name, :as => :color))
65
- end)
51
+ concat(semantic_form_for(@new_post) do |builder|
52
+ concat(builder.fields_for(:author, :index => 3) do |author|
53
+ concat(author.input(:name, :as => :color))
66
54
  end)
67
- end
68
-
69
- it 'should index the id of the wrapper' do
70
- output_buffer.should have_tag("li#post_author_attributes_3_name_input")
71
- end
55
+ end)
56
+ end
72
57
 
73
- it 'should index the id of the select tag' do
74
- output_buffer.should have_tag("input#post_author_attributes_3_name")
75
- end
58
+ it 'should index the id of the wrapper' do
59
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
60
+ end
76
61
 
77
- it 'should index the name of the select tag' do
78
- output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
79
- end
62
+ it 'should index the id of the select tag' do
63
+ expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
64
+ end
80
65
 
66
+ it 'should index the name of the select tag' do
67
+ expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
81
68
  end
82
69
 
70
+ end
71
+
83
72
 
84
- describe "when required" do
85
- it "should add the required attribute to the input's html options" do
86
- with_config :use_required_attribute, true do
87
- concat(semantic_form_for(@new_post) do |builder|
88
- concat(builder.input(:title, :as => :color, :required => true))
89
- end)
90
- output_buffer.should have_tag("input[@required]")
91
- end
73
+ describe "when required" do
74
+ it "should add the required attribute to the input's html options" do
75
+ with_config :use_required_attribute, true do
76
+ concat(semantic_form_for(@new_post) do |builder|
77
+ concat(builder.input(:title, :as => :color, :required => true))
78
+ end)
79
+ expect(output_buffer).to have_tag("input[@required]")
92
80
  end
93
81
  end
94
82
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'country input' do
4
+ RSpec.describe 'country input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -13,11 +13,11 @@ describe 'country input' do
13
13
  describe "when country_select is not available as a helper from a plugin" do
14
14
 
15
15
  it "should raise an error, sugesting the author installs a plugin" do
16
- lambda {
16
+ expect {
17
17
  semantic_form_for(@new_post) do |builder|
18
18
  concat(builder.input(:country, :as => :country))
19
19
  end
20
- }.should raise_error
20
+ }.to raise_error(Formtastic::Inputs::CountryInput::CountrySelectPluginMissing)
21
21
  end
22
22
 
23
23
  end
@@ -26,7 +26,7 @@ describe 'country input' do
26
26
 
27
27
  before do
28
28
  concat(semantic_form_for(@new_post) do |builder|
29
- builder.stub(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
29
+ allow(builder).to receive(:country_select).and_return("<select><option>...</option></select>".html_safe)
30
30
  concat(builder.input(:country, :as => :country))
31
31
  end)
32
32
  end
@@ -39,13 +39,13 @@ describe 'country input' do
39
39
  #it_should_apply_error_logic_for_input_type(:country)
40
40
 
41
41
  it 'should generate a label for the input' do
42
- output_buffer.should have_tag('form li label')
43
- output_buffer.should have_tag('form li label[@for="post_country"]')
44
- output_buffer.should have_tag('form li label', /Country/)
42
+ expect(output_buffer).to have_tag('form li label')
43
+ expect(output_buffer).to have_tag('form li label[@for="post_country"]')
44
+ expect(output_buffer).to have_tag('form li label', :text => /Country/)
45
45
  end
46
46
 
47
47
  it "should generate a select" do
48
- output_buffer.should have_tag("form li select")
48
+ expect(output_buffer).to have_tag("form li select")
49
49
  end
50
50
 
51
51
  end
@@ -55,8 +55,8 @@ describe 'country input' do
55
55
  it "should be passed down to the country_select helper when provided" do
56
56
  priority_countries = ["Foo", "Bah"]
57
57
  semantic_form_for(@new_post) do |builder|
58
- builder.stub(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
59
- builder.should_receive(:country_select).with(:country, priority_countries, {}, {:id => "post_country", :required => false, :autofocus => false}).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
58
+ allow(builder).to receive(:country_select).and_return("<select><option>...</option></select>".html_safe)
59
+ expect(builder).to receive(:country_select).with(:country, priority_countries, {}, {:id => "post_country", :required => false, :autofocus => false, :readonly => false}).and_return("<select><option>...</option></select>".html_safe)
60
60
 
61
61
  concat(builder.input(:country, :as => :country, :priority_countries => priority_countries))
62
62
  end
@@ -64,12 +64,12 @@ describe 'country input' do
64
64
 
65
65
  it "should default to the @@priority_countries config when absent" do
66
66
  priority_countries = Formtastic::FormBuilder.priority_countries
67
- priority_countries.should_not be_empty
68
- priority_countries.should_not be_nil
67
+ expect(priority_countries).not_to be_empty
68
+ expect(priority_countries).not_to be_nil
69
69
 
70
70
  semantic_form_for(@new_post) do |builder|
71
- builder.stub(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
72
- builder.should_receive(:country_select).with(:country, priority_countries, {}, {:id => "post_country", :required => false, :autofocus => false}).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
71
+ allow(builder).to receive(:country_select).and_return("<select><option>...</option></select>".html_safe)
72
+ expect(builder).to receive(:country_select).with(:country, priority_countries, {}, {:id => "post_country", :required => false, :autofocus => false, :readonly => false}).and_return("<select><option>...</option></select>".html_safe)
73
73
 
74
74
  concat(builder.input(:country, :as => :country))
75
75
  end
@@ -84,8 +84,8 @@ describe 'country input' do
84
84
  mock_everything
85
85
 
86
86
  concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
87
- builder.stub(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
88
- builder.should_receive(:country_select).with(:country, [], {}, {:id => "context2_post_country", :required => false, :autofocus => false}).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
87
+ allow(builder).to receive(:country_select).and_return("<select><option>...</option></select>".html_safe)
88
+ expect(builder).to receive(:country_select).with(:country, [], {}, {:id => "context2_post_country", :required => false, :autofocus => false, :readonly => false}).and_return("<select><option>...</option></select>".html_safe)
89
89
  concat(builder.input(:country, :priority_countries => []))
90
90
  end)
91
91
  end
@@ -101,13 +101,13 @@ describe 'country input' do
101
101
 
102
102
  before do
103
103
  concat(semantic_form_for(@new_post) do |builder|
104
- builder.stub(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
104
+ allow(builder).to receive(:country_select).and_return("<select><option>...</option></select>".html_safe)
105
105
  concat(builder.input(:country))
106
106
  end)
107
107
  end
108
108
 
109
109
  it "should render a country input" do
110
- output_buffer.should have_tag "form li.country"
110
+ expect(output_buffer).to have_tag "form li.country"
111
111
  end
112
112
  end
113
113
 
@@ -121,8 +121,8 @@ describe 'country input' do
121
121
  end
122
122
 
123
123
  it "should render a country input" do
124
- output_buffer.should_not have_tag "form li.country"
125
- output_buffer.should have_tag "form li.string", :count => 2
124
+ expect(output_buffer).not_to have_tag "form li.country"
125
+ expect(output_buffer).to have_tag "form li.string", :count => 2
126
126
  end
127
127
 
128
128
  end
@@ -11,11 +11,7 @@ module TestInputs
11
11
  @method = :title
12
12
  @options = {}
13
13
  @proc = Proc.new {}
14
- if Rails::VERSION::MAJOR == 4
15
- @builder = Formtastic::FormBuilder.new(@object_name, @object, @template, @options)
16
- else
17
- @builder = Formtastic::FormBuilder.new(@object_name, @object, @template, @options, @proc)
18
- end
14
+ @builder = Formtastic::FormBuilder.new(@object_name, @object, @template, @options)
19
15
  [@builder, @template, @object, @object_name, @method, @options]
20
16
  end
21
17
 
@@ -31,7 +27,7 @@ module TestInputs
31
27
 
32
28
  end
33
29
 
34
- describe 'AnyCustomInput' do
30
+ RSpec.describe 'AnyCustomInput' do
35
31
 
36
32
  include TestInputs
37
33
 
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe "datalist inputs" do
4
+ RSpec.describe "datalist inputs" do
5
5
  include FormtasticSpecHelper
6
6
 
7
7
  before do
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'date_picker input' do
4
+ RSpec.describe 'date_picker input' do
5
5
 
6
6
  include FormtasticSpecHelper
7
7
 
@@ -40,7 +40,7 @@ describe 'date_picker input' do
40
40
  concat(f.input(:publish_at, :as => :date_picker))
41
41
  end
42
42
  )
43
- output_buffer.should have_tag "input[size='10']"
43
+ expect(output_buffer).to have_tag "input[size='10']"
44
44
  end
45
45
 
46
46
  it "can be set from :input_html options" do
@@ -49,7 +49,7 @@ describe 'date_picker input' do
49
49
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :size => "11" }))
50
50
  end
51
51
  )
52
- output_buffer.should have_tag "input[size='11']"
52
+ expect(output_buffer).to have_tag "input[size='11']"
53
53
  end
54
54
 
55
55
  it "can be set from options (ignoring input_html)" do
@@ -58,7 +58,7 @@ describe 'date_picker input' do
58
58
  concat(f.input(:publish_at, :as => :date_picker, :size => '12', :input_html => { :size => "11" }))
59
59
  end
60
60
  )
61
- output_buffer.should have_tag "input[size='12']"
61
+ expect(output_buffer).to have_tag "input[size='12']"
62
62
  end
63
63
 
64
64
  end
@@ -71,7 +71,7 @@ describe 'date_picker input' do
71
71
  concat(f.input(:publish_at, :as => :date_picker))
72
72
  end
73
73
  )
74
- output_buffer.should have_tag "input[maxlength='10']"
74
+ expect(output_buffer).to have_tag "input[maxlength='10']"
75
75
  end
76
76
 
77
77
  it "can be set from :input_html options" do
@@ -80,7 +80,7 @@ describe 'date_picker input' do
80
80
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :maxlength => "11" }))
81
81
  end
82
82
  )
83
- output_buffer.should have_tag "input[maxlength='11']"
83
+ expect(output_buffer).to have_tag "input[maxlength='11']"
84
84
  end
85
85
 
86
86
  it "can be set from options (ignoring input_html)" do
@@ -89,7 +89,7 @@ describe 'date_picker input' do
89
89
  concat(f.input(:publish_at, :as => :date_picker, :maxlength => 12, :input_html => { :maxlength => "11" }))
90
90
  end
91
91
  )
92
- output_buffer.should have_tag "input[maxlength='12']"
92
+ expect(output_buffer).to have_tag "input[maxlength='12']"
93
93
  end
94
94
 
95
95
  end
@@ -104,7 +104,7 @@ describe 'date_picker input' do
104
104
  concat(f.input(:publish_at, :as => :date_picker ))
105
105
  end
106
106
  )
107
- output_buffer.should_not have_tag "li input[value]"
107
+ expect(output_buffer).not_to have_tag "li input[value]"
108
108
  end
109
109
 
110
110
  it "can be set from :input_html options" do
@@ -113,7 +113,7 @@ describe 'date_picker input' do
113
113
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
114
114
  end
115
115
  )
116
- output_buffer.should have_tag "input[value='1111-11-11']"
116
+ expect(output_buffer).to have_tag "input[value='1111-11-11']"
117
117
  end
118
118
 
119
119
  end
@@ -122,7 +122,7 @@ describe 'date_picker input' do
122
122
 
123
123
  before do
124
124
  @date = Date.new(2000, 11, 11)
125
- @new_post.stub(:publish_at).and_return(@date)
125
+ allow(@new_post).to receive(:publish_at).and_return(@date)
126
126
  end
127
127
 
128
128
  it "renders the date as YYYY-MM-DD" do
@@ -131,7 +131,7 @@ describe 'date_picker input' do
131
131
  concat(f.input(:publish_at, :as => :date_picker ))
132
132
  end
133
133
  )
134
- output_buffer.should have_tag "input[value='#{@date.to_s}']"
134
+ expect(output_buffer).to have_tag "input[value='#{@date.to_s}']"
135
135
  end
136
136
 
137
137
  it "can be set from :input_html options" do
@@ -140,7 +140,7 @@ describe 'date_picker input' do
140
140
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
141
141
  end
142
142
  )
143
- output_buffer.should have_tag "input[value='1111-11-11']"
143
+ expect(output_buffer).to have_tag "input[value='1111-11-11']"
144
144
  end
145
145
 
146
146
  end
@@ -149,7 +149,7 @@ describe 'date_picker input' do
149
149
 
150
150
  before do
151
151
  @time = Time.utc(2000,11,11,11,11,11)
152
- @new_post.stub(:publish_at).and_return(@time)
152
+ allow(@new_post).to receive(:publish_at).and_return(@time)
153
153
  end
154
154
 
155
155
  it "renders the time as a YYYY-MM-DD" do
@@ -158,7 +158,7 @@ describe 'date_picker input' do
158
158
  concat(f.input(:publish_at, :as => :date_picker ))
159
159
  end
160
160
  )
161
- output_buffer.should have_tag "input[value='2000-11-11']"
161
+ expect(output_buffer).to have_tag "input[value='2000-11-11']"
162
162
  end
163
163
 
164
164
  it "can be set from :input_html options" do
@@ -167,7 +167,7 @@ describe 'date_picker input' do
167
167
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
168
168
  end
169
169
  )
170
- output_buffer.should have_tag "input[value='1111-11-11']"
170
+ expect(output_buffer).to have_tag "input[value='1111-11-11']"
171
171
  end
172
172
 
173
173
  end
@@ -175,7 +175,7 @@ describe 'date_picker input' do
175
175
  context "when method returns an empty String" do
176
176
 
177
177
  before do
178
- @new_post.stub(:publish_at).and_return("")
178
+ allow(@new_post).to receive(:publish_at).and_return("")
179
179
  end
180
180
 
181
181
  it "will be empty" do
@@ -184,7 +184,7 @@ describe 'date_picker input' do
184
184
  concat(f.input(:publish_at, :as => :date_picker ))
185
185
  end
186
186
  )
187
- output_buffer.should have_tag "input[value='']"
187
+ expect(output_buffer).to have_tag "input[value='']"
188
188
  end
189
189
 
190
190
  it "can be set from :input_html options" do
@@ -193,7 +193,7 @@ describe 'date_picker input' do
193
193
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
194
194
  end
195
195
  )
196
- output_buffer.should have_tag "input[value='1111-11-11']"
196
+ expect(output_buffer).to have_tag "input[value='1111-11-11']"
197
197
  end
198
198
 
199
199
  end
@@ -201,7 +201,7 @@ describe 'date_picker input' do
201
201
  context "when method returns a String" do
202
202
 
203
203
  before do
204
- @new_post.stub(:publish_at).and_return("yeah")
204
+ allow(@new_post).to receive(:publish_at).and_return("yeah")
205
205
  end
206
206
 
207
207
  it "will be the string" do
@@ -210,7 +210,7 @@ describe 'date_picker input' do
210
210
  concat(f.input(:publish_at, :as => :date_picker ))
211
211
  end
212
212
  )
213
- output_buffer.should have_tag "input[value='yeah']"
213
+ expect(output_buffer).to have_tag "input[value='yeah']"
214
214
  end
215
215
 
216
216
  it "can be set from :input_html options" do
@@ -219,7 +219,7 @@ describe 'date_picker input' do
219
219
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
220
220
  end
221
221
  )
222
- output_buffer.should have_tag "input[value='1111-11-11']"
222
+ expect(output_buffer).to have_tag "input[value='1111-11-11']"
223
223
  end
224
224
 
225
225
  end
@@ -234,7 +234,7 @@ describe 'date_picker input' do
234
234
  concat(f.input(:publish_at, :as => :date_picker))
235
235
  end
236
236
  )
237
- output_buffer.should_not have_tag "input[min]"
237
+ expect(output_buffer).not_to have_tag "input[min]"
238
238
  end
239
239
 
240
240
  it "can be set from :input_html options" do
@@ -243,7 +243,7 @@ describe 'date_picker input' do
243
243
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :min => "1970-01-01" }))
244
244
  end
245
245
  )
246
- output_buffer.should have_tag "input[min='1970-01-01']"
246
+ expect(output_buffer).to have_tag "input[min='1970-01-01']"
247
247
  end
248
248
 
249
249
  end
@@ -256,7 +256,7 @@ describe 'date_picker input' do
256
256
  concat(f.input(:publish_at, :as => :date_picker))
257
257
  end
258
258
  )
259
- output_buffer.should_not have_tag "input[max]"
259
+ expect(output_buffer).not_to have_tag "input[max]"
260
260
  end
261
261
 
262
262
  it "can be set from :input_html options" do
@@ -265,7 +265,7 @@ describe 'date_picker input' do
265
265
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :max => "1970-01-01" }))
266
266
  end
267
267
  )
268
- output_buffer.should have_tag "input[max='1970-01-01']"
268
+ expect(output_buffer).to have_tag "input[max='1970-01-01']"
269
269
  end
270
270
 
271
271
  end
@@ -278,7 +278,7 @@ describe 'date_picker input' do
278
278
  concat(f.input(:publish_at, :as => :date_picker))
279
279
  end
280
280
  )
281
- output_buffer.should have_tag "input[step='1']"
281
+ expect(output_buffer).to have_tag "input[step='1']"
282
282
  end
283
283
 
284
284
  it "can be set from :input_html options" do
@@ -287,7 +287,7 @@ describe 'date_picker input' do
287
287
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :step => "5" }))
288
288
  end
289
289
  )
290
- output_buffer.should have_tag "input[step='5']"
290
+ expect(output_buffer).to have_tag "input[step='5']"
291
291
  end
292
292
 
293
293
  describe "macros" do
@@ -303,49 +303,49 @@ describe 'date_picker input' do
303
303
  context ":day" do
304
304
  let(:step) { :day }
305
305
  it "uses 1" do
306
- output_buffer.should have_tag "input[step='1']"
306
+ expect(output_buffer).to have_tag "input[step='1']"
307
307
  end
308
308
  end
309
309
 
310
310
  context ":seven_days" do
311
311
  let(:step) { :seven_days }
312
312
  it "uses 7" do
313
- output_buffer.should have_tag "input[step='7']"
313
+ expect(output_buffer).to have_tag "input[step='7']"
314
314
  end
315
315
  end
316
316
 
317
317
  context ":week" do
318
318
  let(:step) { :week }
319
319
  it "uses 7" do
320
- output_buffer.should have_tag "input[step='7']"
320
+ expect(output_buffer).to have_tag "input[step='7']"
321
321
  end
322
322
  end
323
323
 
324
324
  context ":fortnight" do
325
325
  let(:step) { :fortnight }
326
326
  it "uses 14" do
327
- output_buffer.should have_tag "input[step='14']"
327
+ expect(output_buffer).to have_tag "input[step='14']"
328
328
  end
329
329
  end
330
330
 
331
331
  context ":two_weeks" do
332
332
  let(:step) { :two_weeks }
333
333
  it "uses 14" do
334
- output_buffer.should have_tag "input[step='14']"
334
+ expect(output_buffer).to have_tag "input[step='14']"
335
335
  end
336
336
  end
337
337
 
338
338
  context ":four_weeks" do
339
339
  let(:step) { :four_weeks }
340
340
  it "uses 28" do
341
- output_buffer.should have_tag "input[step='28']"
341
+ expect(output_buffer).to have_tag "input[step='28']"
342
342
  end
343
343
  end
344
344
 
345
345
  context ":thirty_days" do
346
346
  let(:step) { :thirty_days }
347
347
  it "uses 30" do
348
- output_buffer.should have_tag "input[step='30']"
348
+ expect(output_buffer).to have_tag "input[step='30']"
349
349
  end
350
350
  end
351
351
 
@@ -361,7 +361,7 @@ describe 'date_picker input' do
361
361
  concat(f.input(:publish_at, :as => :date_picker))
362
362
  end
363
363
  )
364
- output_buffer.should_not have_tag "input[placeholder]"
364
+ expect(output_buffer).not_to have_tag "input[placeholder]"
365
365
  end
366
366
 
367
367
  it "can be set from :input_html options" do
@@ -370,7 +370,7 @@ describe 'date_picker input' do
370
370
  concat(f.input(:publish_at, :as => :date_picker, :input_html => { :placeholder => "1970-01-01" }))
371
371
  end
372
372
  )
373
- output_buffer.should have_tag "input[placeholder='1970-01-01']"
373
+ expect(output_buffer).to have_tag "input[placeholder='1970-01-01']"
374
374
  end
375
375
 
376
376
  context "with i18n set" do
@@ -383,7 +383,7 @@ describe 'date_picker input' do
383
383
  concat(semantic_form_for(@new_post) do |builder|
384
384
  concat(builder.input(:publish_at, :as => :date_picker))
385
385
  end)
386
- output_buffer.should have_tag('input[@placeholder="YYYY-MM-DD"]')
386
+ expect(output_buffer).to have_tag('input[@placeholder="YYYY-MM-DD"]')
387
387
  end
388
388
  end
389
389
 
@@ -392,7 +392,7 @@ describe 'date_picker input' do
392
392
  concat(semantic_form_for(@new_post) do |builder|
393
393
  concat(builder.input(:publish_at, :as => :date_picker, :input_html => { :placeholder => "Something" }))
394
394
  end)
395
- output_buffer.should have_tag('input[@placeholder="Something"]')
395
+ expect(output_buffer).to have_tag('input[@placeholder="Something"]')
396
396
  end
397
397
  end
398
398
  end
@@ -423,15 +423,15 @@ describe 'date_picker input' do
423
423
  end
424
424
 
425
425
  it 'should index the id of the wrapper' do
426
- output_buffer.should have_tag("li#post_author_attributes_3_created_at_input")
426
+ expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
427
427
  end
428
428
 
429
429
  it 'should index the id of the select tag' do
430
- output_buffer.should have_tag("input#post_author_attributes_3_created_at")
430
+ expect(output_buffer).to have_tag("input#post_author_attributes_3_created_at")
431
431
  end
432
432
 
433
433
  it 'should index the name of the select tag' do
434
- output_buffer.should have_tag("input[@name='post[author_attributes][3][created_at]']")
434
+ expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][created_at]']")
435
435
  end
436
436
  end
437
437
 
@@ -441,7 +441,7 @@ describe 'date_picker input' do
441
441
  concat(semantic_form_for(@new_post) do |builder|
442
442
  concat(builder.input(:publish_at, :as => :date_picker, :required => true))
443
443
  end)
444
- output_buffer.should have_tag("input[@required]")
444
+ expect(output_buffer).to have_tag("input[@required]")
445
445
  end
446
446
  end
447
447
  end