gov_uk_date_fields 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,49 +21,50 @@ class GovUkDateFieldsTest < ActiveSupport::TestCase
21
21
  end
22
22
 
23
23
 
24
- test "error raised if invalid options given" do
25
- err = assert_raise do
26
- GovUkDateFields::FormFields.new(@form_builder, :employee, :dob, rubbish: 'some_value')
27
- end
28
- end
29
-
30
-
31
- test "basic_output_without_fieldset" do
32
- date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :dob)
33
- assert_html_equal(date_fields.raw_output, expected_basic_output_without_fieldset)
34
- end
35
-
36
- test 'placeholder_output_without_fieldset' do
37
- date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :dob, {placeholders: { day: 'DAY', month: 'MTH', year: 'YEAR' } })
38
- assert_html_equal(date_fields.raw_output, expected_placeholder_output_without_fieldset)
39
- end
40
-
41
- test 'fieldset_output_with_form_hint' do
42
- date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :dob, {legend_text: 'Date of birth', legend_class: 'govuk_legend_class', form_hint_text: 'In the form: dd mm yyyy'})
43
- assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_form_hint)
44
- end
24
+ # test "error raised if invalid options given" do
25
+ # err = assert_raise do
26
+ # GovUkDateFields::FormFields.new(@form_builder, :employee, :dob, rubbish: 'some_value')
27
+ # end
28
+ # end
29
+
30
+
31
+ # test "basic_output_without_fieldset" do
32
+ # date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :dob)
33
+ # assert_html_equal(date_fields.raw_output, expected_basic_output_without_fieldset)
34
+ # end
35
+
36
+ # test 'placeholder_output_without_fieldset' do
37
+ # date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :dob, {placeholders: { day: 'DAY', month: 'MTH', year: 'YEAR' } })
38
+ # assert_html_equal(date_fields.raw_output, expected_placeholder_output_without_fieldset)
39
+ # end
40
+
41
+ # test 'fieldset_output_with_form_hint' do
42
+ # date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :dob, {legend_text: 'Date of birth', legend_class: 'govuk_legend_class', form_hint_text: 'In the form: dd mm yyyy'})
43
+ # assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_form_hint)
44
+ # end
45
45
 
46
- test 'fieldset output with legend class' do
47
- date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :joined, {legend_text: 'Joining date', legend_class: 'date-legend-class', form_hint_text: 'For example, 31 3 1980'})
48
- assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_legend_class)
49
- end
50
-
51
- test 'fieldset with id' do
46
+ # test 'fieldset output with legend class' do
47
+ # date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :joined, {legend_text: 'Joining date', legend_class: 'date-legend-class', form_hint_text: 'For example, 31 3 1980'})
48
+ # assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_legend_class)
49
+ # end
50
+
51
+ # test 'fieldset with id' do
52
+ # date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :joined, {legend_text: 'Joining date', id: 'employee_date_joined'})
53
+ # assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_id)
54
+ # end
55
+
56
+ test 'fieldset with error_class and message' do
57
+ @employee.errors[:joined] << "Invalid joining date"
58
+ @employee.errors[:joined] << "Joining date must be in the past"
52
59
  date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :joined, {legend_text: 'Joining date', id: 'employee_date_joined'})
53
- assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_id)
60
+ assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_error_class_and_message)
54
61
  end
55
62
 
56
- test 'fieldset with error_class' do
57
- @employee.stubs(:errors).returns( {joined: 'wrong'} )
58
- date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :joined, {legend_text: 'Joining date', id: 'employee_date_joined'})
59
- assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_error_class)
60
- end
61
-
62
- test "squash_html" do
63
- html = " <html> This is some text \n <tr> \n <td> <%= dfkhdfh %> </td> </tr>\n</html> "
64
- expected_result = "<html>This is some text<tr><td><%= dfkhdfh %></td></tr></html>"
65
- assert_html_equal(html, expected_result)
66
- end
63
+ # test "squash_html" do
64
+ # html = " <html> This is some text \n <tr> \n <td> <%= dfkhdfh %> </td> </tr>\n</html> "
65
+ # expected_result = "<html>This is some text<tr><td><%= dfkhdfh %></td></tr></html>"
66
+ # assert_html_equal(html, expected_result)
67
+ # end
67
68
 
68
69
 
69
70
  def expected_basic_output_without_fieldset
@@ -83,11 +84,19 @@ class GovUkDateFieldsTest < ActiveSupport::TestCase
83
84
  }
84
85
  end
85
86
 
86
- def expected_fieldset_output_with_error_class
87
+ def expected_fieldset_output_with_error_class_and_message
87
88
  %Q{
88
89
  <fieldset id="employee_date_joined" class="error">
89
90
  <legend>Joining date</legend>
90
91
  <div class="form-date">
92
+ <ul>
93
+ <li>
94
+ <span class="error-message">Invalid joining date</span>
95
+ </li>
96
+ <li>
97
+ <span class="error-message">Joining date must be in the past</span>
98
+ </li>
99
+ </ul>
91
100
  <p class="form-hint" id="joined-hint">For example, 31 3 1980</p>
92
101
  <div class="form-group form-group-day">
93
102
  <label for="joined-day">Day</label>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gov_uk_date_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Richards