formtastic 3.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitattributes +1 -0
- data/.github/workflows/test.yml +61 -0
- data/.gitignore +3 -2
- data/CHANGELOG.md +61 -0
- data/Gemfile.lock +140 -0
- data/MIT-LICENSE +1 -1
- data/{README.textile → README.md} +191 -168
- data/RELEASE_PROCESS +3 -1
- data/Rakefile +24 -8
- data/app/assets/stylesheets/formtastic.css +1 -1
- data/bin/appraisal +8 -0
- data/formtastic.gemspec +13 -17
- data/gemfiles/rails_6.0/Gemfile +5 -0
- data/gemfiles/rails_6.1/Gemfile +5 -0
- data/gemfiles/rails_7.0/Gemfile +5 -0
- data/gemfiles/rails_7.1/Gemfile +5 -0
- data/gemfiles/rails_edge/Gemfile +13 -0
- data/lib/formtastic/action_class_finder.rb +19 -0
- data/lib/formtastic/actions/base.rb +1 -0
- data/lib/formtastic/actions/button_action.rb +56 -53
- data/lib/formtastic/actions/buttonish.rb +1 -0
- data/lib/formtastic/actions/input_action.rb +60 -57
- data/lib/formtastic/actions/link_action.rb +69 -67
- data/lib/formtastic/actions.rb +7 -3
- data/lib/formtastic/deprecation.rb +6 -0
- data/lib/formtastic/engine.rb +4 -1
- data/lib/formtastic/form_builder.rb +32 -25
- data/lib/formtastic/helpers/action_helper.rb +22 -31
- data/lib/formtastic/helpers/actions_helper.rb +1 -0
- data/lib/formtastic/helpers/enum.rb +14 -0
- data/lib/formtastic/helpers/errors_helper.rb +3 -2
- data/lib/formtastic/helpers/fieldset_wrapper.rb +16 -11
- data/lib/formtastic/helpers/file_column_detection.rb +1 -0
- data/lib/formtastic/helpers/form_helper.rb +4 -3
- data/lib/formtastic/helpers/input_helper.rb +59 -80
- data/lib/formtastic/helpers/inputs_helper.rb +33 -27
- data/lib/formtastic/helpers/reflection.rb +5 -4
- data/lib/formtastic/helpers.rb +2 -2
- data/lib/formtastic/html_attributes.rb +13 -1
- data/lib/formtastic/i18n.rb +2 -1
- data/lib/formtastic/input_class_finder.rb +19 -0
- data/lib/formtastic/inputs/base/associations.rb +1 -0
- data/lib/formtastic/inputs/base/choices.rb +4 -3
- data/lib/formtastic/inputs/base/collections.rb +47 -11
- data/lib/formtastic/inputs/base/database.rb +8 -5
- data/lib/formtastic/inputs/base/datetime_pickerish.rb +1 -0
- data/lib/formtastic/inputs/base/errors.rb +7 -6
- data/lib/formtastic/inputs/base/fileish.rb +1 -0
- data/lib/formtastic/inputs/base/hints.rb +2 -1
- data/lib/formtastic/inputs/base/html.rb +12 -10
- data/lib/formtastic/inputs/base/labelling.rb +3 -2
- data/lib/formtastic/inputs/base/naming.rb +5 -4
- data/lib/formtastic/inputs/base/numeric.rb +1 -0
- data/lib/formtastic/inputs/base/options.rb +3 -3
- data/lib/formtastic/inputs/base/placeholder.rb +1 -0
- data/lib/formtastic/inputs/base/stringish.rb +1 -0
- data/lib/formtastic/inputs/base/timeish.rb +9 -4
- data/lib/formtastic/inputs/base/validations.rb +39 -12
- data/lib/formtastic/inputs/base/wrapping.rb +2 -3
- data/lib/formtastic/inputs/base.rb +17 -12
- data/lib/formtastic/inputs/boolean_input.rb +2 -1
- data/lib/formtastic/inputs/check_boxes_input.rb +16 -24
- data/lib/formtastic/inputs/color_input.rb +1 -1
- data/lib/formtastic/inputs/country_input.rb +4 -1
- data/lib/formtastic/inputs/datalist_input.rb +42 -0
- data/lib/formtastic/inputs/date_picker_input.rb +1 -0
- data/lib/formtastic/inputs/date_select_input.rb +1 -0
- data/lib/formtastic/inputs/datetime_picker_input.rb +1 -0
- data/lib/formtastic/inputs/datetime_select_input.rb +1 -0
- data/lib/formtastic/inputs/email_input.rb +1 -0
- data/lib/formtastic/inputs/file_input.rb +3 -2
- data/lib/formtastic/inputs/hidden_input.rb +3 -2
- data/lib/formtastic/inputs/number_input.rb +1 -0
- data/lib/formtastic/inputs/password_input.rb +1 -0
- data/lib/formtastic/inputs/phone_input.rb +1 -0
- data/lib/formtastic/inputs/radio_input.rb +26 -21
- data/lib/formtastic/inputs/range_input.rb +1 -0
- data/lib/formtastic/inputs/search_input.rb +1 -0
- data/lib/formtastic/inputs/select_input.rb +32 -10
- data/lib/formtastic/inputs/string_input.rb +1 -0
- data/lib/formtastic/inputs/text_input.rb +1 -0
- data/lib/formtastic/inputs/time_picker_input.rb +1 -0
- data/lib/formtastic/inputs/time_select_input.rb +1 -0
- data/lib/formtastic/inputs/time_zone_input.rb +17 -6
- data/lib/formtastic/inputs/url_input.rb +1 -0
- data/lib/formtastic/inputs.rb +33 -28
- data/lib/formtastic/localized_string.rb +2 -1
- data/lib/formtastic/localizer.rb +23 -24
- data/lib/formtastic/namespaced_class_finder.rb +98 -0
- data/lib/formtastic/version.rb +2 -1
- data/lib/formtastic.rb +19 -14
- data/lib/generators/formtastic/form/form_generator.rb +8 -2
- data/lib/generators/formtastic/input/input_generator.rb +47 -0
- data/lib/generators/formtastic/install/install_generator.rb +2 -0
- data/lib/generators/templates/formtastic.rb +29 -7
- data/lib/generators/templates/input.rb +19 -0
- data/sample/basic_inputs.html +1 -1
- data/script/integration-template.rb +73 -0
- data/script/integration.sh +19 -0
- data/spec/action_class_finder_spec.rb +13 -0
- data/spec/actions/button_action_spec.rb +21 -20
- data/spec/actions/generic_action_spec.rb +134 -133
- data/spec/actions/input_action_spec.rb +20 -19
- data/spec/actions/link_action_spec.rb +30 -29
- data/spec/builder/custom_builder_spec.rb +39 -22
- data/spec/builder/error_proc_spec.rb +6 -5
- data/spec/builder/semantic_fields_for_spec.rb +46 -45
- data/spec/fast_spec_helper.rb +13 -0
- data/spec/generators/formtastic/form/form_generator_spec.rb +33 -32
- data/spec/generators/formtastic/input/input_generator_spec.rb +125 -0
- data/spec/generators/formtastic/install/install_generator_spec.rb +10 -9
- data/spec/helpers/action_helper_spec.rb +70 -97
- data/spec/helpers/actions_helper_spec.rb +43 -42
- data/spec/helpers/form_helper_spec.rb +56 -39
- data/spec/helpers/input_helper_spec.rb +314 -255
- data/spec/helpers/inputs_helper_spec.rb +217 -202
- data/spec/helpers/reflection_helper_spec.rb +7 -6
- data/spec/helpers/semantic_errors_helper_spec.rb +26 -25
- data/spec/i18n_spec.rb +30 -29
- data/spec/input_class_finder_spec.rb +11 -0
- data/spec/inputs/base/collections_spec.rb +78 -0
- data/spec/inputs/base/validations_spec.rb +481 -0
- data/spec/inputs/boolean_input_spec.rb +73 -72
- data/spec/inputs/check_boxes_input_spec.rb +174 -123
- data/spec/inputs/color_input_spec.rb +53 -64
- data/spec/inputs/country_input_spec.rb +23 -22
- data/spec/inputs/custom_input_spec.rb +3 -6
- data/spec/inputs/datalist_input_spec.rb +62 -0
- data/spec/inputs/date_picker_input_spec.rb +114 -113
- data/spec/inputs/date_select_input_spec.rb +76 -61
- data/spec/inputs/datetime_picker_input_spec.rb +123 -122
- data/spec/inputs/datetime_select_input_spec.rb +85 -68
- data/spec/inputs/email_input_spec.rb +17 -16
- data/spec/inputs/file_input_spec.rb +18 -17
- data/spec/inputs/hidden_input_spec.rb +32 -31
- data/spec/inputs/include_blank_spec.rb +10 -9
- data/spec/inputs/label_spec.rb +36 -31
- data/spec/inputs/number_input_spec.rb +212 -211
- data/spec/inputs/password_input_spec.rb +17 -16
- data/spec/inputs/phone_input_spec.rb +17 -16
- data/spec/inputs/placeholder_spec.rb +18 -17
- data/spec/inputs/radio_input_spec.rb +92 -65
- data/spec/inputs/range_input_spec.rb +136 -135
- data/spec/inputs/readonly_spec.rb +51 -0
- data/spec/inputs/search_input_spec.rb +16 -15
- data/spec/inputs/select_input_spec.rb +209 -102
- data/spec/inputs/string_input_spec.rb +51 -50
- data/spec/inputs/text_input_spec.rb +34 -33
- data/spec/inputs/time_picker_input_spec.rb +115 -114
- data/spec/inputs/time_select_input_spec.rb +84 -70
- data/spec/inputs/time_zone_input_spec.rb +58 -31
- data/spec/inputs/url_input_spec.rb +17 -16
- data/spec/inputs/with_options_spec.rb +9 -8
- data/spec/localizer_spec.rb +18 -17
- data/spec/namespaced_class_finder_spec.rb +91 -0
- data/spec/schema.rb +22 -0
- data/spec/spec_helper.rb +180 -249
- data/spec/support/custom_macros.rb +128 -98
- data/spec/support/deprecation.rb +2 -1
- data/spec/support/shared_examples.rb +13 -0
- data/spec/support/specialized_class_finder_shared_example.rb +28 -0
- data/spec/support/test_environment.rb +25 -10
- metadata +95 -136
- data/.travis.yml +0 -28
- data/Appraisals +0 -25
- data/CHANGELOG +0 -27
- data/gemfiles/rails_3.2.gemfile +0 -7
- data/gemfiles/rails_4.0.4.gemfile +0 -7
- data/gemfiles/rails_4.1.gemfile +0 -7
- data/gemfiles/rails_4.gemfile +0 -7
- data/gemfiles/rails_edge.gemfile +0 -10
- data/lib/formtastic/util.rb +0 -53
- data/spec/support/deferred_garbage_collection.rb +0 -21
- data/spec/util_spec.rb +0 -52
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
# Set the default text field size when input is a string. Default is nil.
|
4
5
|
# Formtastic::FormBuilder.default_text_field_size = 50
|
@@ -17,15 +18,15 @@
|
|
17
18
|
# Defaults to true.
|
18
19
|
# Formtastic::FormBuilder.include_blank_for_select_by_default = true
|
19
20
|
|
20
|
-
# Set the string that will be appended to the labels/fieldsets which are required
|
21
|
+
# Set the string that will be appended to the labels/fieldsets which are required.
|
21
22
|
# It accepts string or procs and the default is a localized version of
|
22
23
|
# '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
|
23
24
|
# in your locale, it will replace the abbr title properly. But if you don't want to use
|
24
|
-
# abbr tag, you can simply give a string as below
|
25
|
+
# abbr tag, you can simply give a string as below.
|
25
26
|
# Formtastic::FormBuilder.required_string = "(required)"
|
26
27
|
|
27
|
-
# Set the string that will be appended to the labels/fieldsets which are optional
|
28
|
-
# Defaults to an empty string ("") and also accepts procs (see required_string above)
|
28
|
+
# Set the string that will be appended to the labels/fieldsets which are optional.
|
29
|
+
# Defaults to an empty string ("") and also accepts procs (see required_string above).
|
29
30
|
# Formtastic::FormBuilder.optional_string = "(optional)"
|
30
31
|
|
31
32
|
# Set the way inline errors will be displayed.
|
@@ -33,7 +34,7 @@
|
|
33
34
|
# Formtastic::FormBuilder.inline_errors = :sentence
|
34
35
|
# Formtastic uses the following classes as default for hints, inline_errors and error list
|
35
36
|
|
36
|
-
# If you override the class here, please ensure to override it in your stylesheets as well
|
37
|
+
# If you override the class here, please ensure to override it in your stylesheets as well.
|
37
38
|
# Formtastic::FormBuilder.default_hint_class = "inline-hints"
|
38
39
|
# Formtastic::FormBuilder.default_inline_error_class = "inline-errors"
|
39
40
|
# Formtastic::FormBuilder.default_error_list_class = "errors"
|
@@ -70,7 +71,7 @@
|
|
70
71
|
# can change it to any class you want.
|
71
72
|
# Formtastic::Helpers::FormHelper.default_form_class = 'formtastic'
|
72
73
|
|
73
|
-
# Formtastic will infer a class name from the model, array, string
|
74
|
+
# Formtastic will infer a class name from the model, array, string or symbol you pass to the
|
74
75
|
# form builder. You can customize the way that class is presented by overriding
|
75
76
|
# this proc.
|
76
77
|
# Formtastic::Helpers::FormHelper.default_form_model_class_proc = proc { |model_class_name| model_class_name }
|
@@ -85,6 +86,27 @@
|
|
85
86
|
# Formtastic::FormBuilder.use_required_attribute = false
|
86
87
|
|
87
88
|
# You can opt-in to new HTML5 browser validations (for things like email and url inputs) by setting
|
88
|
-
# this to true. Doing so will
|
89
|
+
# this to true. Doing so will omit the `novalidate` attribute from the `<form>` tag.
|
89
90
|
# See http://diveintohtml5.org/forms.html#validation for more info.
|
90
91
|
# Formtastic::FormBuilder.perform_browser_validations = true
|
92
|
+
|
93
|
+
# By creating custom input class finder, you can change how input classes are looked up.
|
94
|
+
# For example you can make it to search for TextInputFilter instead of TextInput.
|
95
|
+
# See https://github.com/formtastic/formtastic/wiki/Custom-Class-Finders
|
96
|
+
# Formtastic::FormBuilder.input_class_finder = Formtastic::InputClassFinder
|
97
|
+
|
98
|
+
# Define custom namespaces in which to look up your Input classes. Default is
|
99
|
+
# to look up in the global scope and in Formtastic::Inputs.
|
100
|
+
# Formtastic::FormBuilder.input_namespaces = [ ::Object, ::MyInputsModule, ::Formtastic::Inputs ]
|
101
|
+
|
102
|
+
# By creating custom action class finder, you can change how action classes are looked up.
|
103
|
+
# For example you can make it to search for MyButtonAction instead of ButtonAction.
|
104
|
+
# See https://github.com/formtastic/formtastic/wiki/Custom-Class-Finders
|
105
|
+
# Formtastic::FormBuilder.action_class_finder = Formtastic::ActionClassFinder
|
106
|
+
|
107
|
+
# Define custom namespaces in which to look up your Action classes. Default is
|
108
|
+
# to look up in the global scope and in Formtastic::Actions.
|
109
|
+
# Formtastic::FormBuilder.action_namespaces = [ ::Object, ::MyActionsModule, ::Formtastic::Actions ]
|
110
|
+
|
111
|
+
# Which columns to skip when automatically rendering a form without any fields specified.
|
112
|
+
# Formtastic::FormBuilder.skipped_columns = [:created_at, :updated_at, :created_on, :updated_on, :lock_version, :version]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class <%= name.camelize %>Input <%= @extension_sentence %>
|
2
|
+
<%- if !options[:extend] -%>
|
3
|
+
include Formtastic::Inputs::Base
|
4
|
+
<%- end -%>
|
5
|
+
|
6
|
+
<%- if !options[:extend] || (options[:extend] == "extend") -%>
|
7
|
+
def to_html
|
8
|
+
# Add your custom input definition here.
|
9
|
+
<%- if options[:extend] == "extend" -%>
|
10
|
+
super
|
11
|
+
<%- end -%>
|
12
|
+
end
|
13
|
+
|
14
|
+
<%- else -%>
|
15
|
+
def input_html_options
|
16
|
+
# Add your custom input extension here.
|
17
|
+
end
|
18
|
+
<%- end -%>
|
19
|
+
end
|
data/sample/basic_inputs.html
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
<li class="input url stringish optional" id="gem_url_input">
|
37
37
|
<label class="label" for="gem_url">URL</label>
|
38
38
|
<input id="gem_url" name="gem[url]" type="url">
|
39
|
-
<p class="inline-hints">Example: https://github.com/
|
39
|
+
<p class="inline-hints">Example: https://github.com/formtastic/formtastic</p>
|
40
40
|
</li>
|
41
41
|
|
42
42
|
<li class="input password stringish required" id="gem_password_input">
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
gem 'formtastic', path: '..'
|
3
|
+
gem 'bcrypt', '~> 3.1.7'
|
4
|
+
gem 'rails-dom-testing', group: :test
|
5
|
+
gem 'rexml', '~> 3.2' # to compensate for missing dependency in selenium-webdriver
|
6
|
+
|
7
|
+
# to speed up bundle install, reuse the bundle path
|
8
|
+
def bundle_path
|
9
|
+
File.expand_path ENV.fetch('BUNDLE_PATH', 'vendor/bundle')
|
10
|
+
end
|
11
|
+
|
12
|
+
if Rails.version >= '6.2'
|
13
|
+
gsub_file 'Gemfile', /gem 'rails'.*/, "gem 'rails', '~> #{Rails.version}', github: 'rails/rails'"
|
14
|
+
elsif Rails.version >= '6.1'
|
15
|
+
gsub_file 'Gemfile', /gem 'rails'.*/, "gem 'rails', '~> #{Rails.version}', github: 'rails/rails', branch: '6-1-stable'"
|
16
|
+
elsif Rails.version >= '6.0'
|
17
|
+
gsub_file 'Gemfile', /gem 'rails'.*/, "gem 'rails', '~> #{Rails.version}', github: 'rails/rails', branch: '6-0-stable'"
|
18
|
+
end
|
19
|
+
|
20
|
+
### Ensure Dummy App's Ruby version matches the current environments Ruby Version
|
21
|
+
ruby_version = "ruby '#{RUBY_VERSION}'"
|
22
|
+
gsub_file 'Gemfile', /ruby '\d+.\d+.\d+'/, ruby_version
|
23
|
+
|
24
|
+
if bundle_install?
|
25
|
+
def run_bundle
|
26
|
+
previous_bundle_path = bundle_path
|
27
|
+
|
28
|
+
require "bundler"
|
29
|
+
Bundler.with_clean_env do
|
30
|
+
system("bundle install --jobs=3 --retry=3 --path=#{previous_bundle_path}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
in_root do
|
36
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('Gemfile')
|
37
|
+
end
|
38
|
+
|
39
|
+
formtastic = -> do
|
40
|
+
generate(:scaffold, 'user name:string password:digest')
|
41
|
+
generate('formtastic:install')
|
42
|
+
generate('formtastic:form', 'user name password --force')
|
43
|
+
|
44
|
+
rails_command('db:migrate')
|
45
|
+
|
46
|
+
in_root do
|
47
|
+
inject_into_class 'app/models/user.rb', 'User', " has_secure_password\n"
|
48
|
+
inject_into_file 'app/assets/stylesheets/application.css', " *= require formtastic\n", before: ' *= require_self'
|
49
|
+
inject_into_class 'test/controllers/users_controller_test.rb', 'UsersControllerTest', <<-RUBY
|
50
|
+
|
51
|
+
test "should show form" do
|
52
|
+
get edit_user_path(@user)
|
53
|
+
|
54
|
+
assert_select 'form' do
|
55
|
+
assert_select 'li.input.string' do
|
56
|
+
assert_select 'input#user_name[type=text]'
|
57
|
+
end
|
58
|
+
assert_select 'li.input.password' do
|
59
|
+
assert_select 'input#user_password[type=password]'
|
60
|
+
end
|
61
|
+
|
62
|
+
assert_select 'fieldset.actions' do
|
63
|
+
assert_select 'li.action.input_action' do
|
64
|
+
assert_select 'input[type=submit]'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end # test "should show form"
|
69
|
+
RUBY
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
after_bundle(&formtastic)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env sh
|
2
|
+
|
3
|
+
set -e
|
4
|
+
set -o verbose
|
5
|
+
|
6
|
+
test_app=dummy
|
7
|
+
|
8
|
+
rm -rf ${test_app}
|
9
|
+
|
10
|
+
bundle exec rails new ${test_app} \
|
11
|
+
--template=$(dirname "$0")/integration-template.rb \
|
12
|
+
--skip-bootsnap \
|
13
|
+
--skip-javascript \
|
14
|
+
--skip-spring \
|
15
|
+
--skip-turbolinks
|
16
|
+
|
17
|
+
cd ${test_app} && export BUNDLE_GEMFILE=Gemfile
|
18
|
+
|
19
|
+
bundle exec rake test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'formtastic/action_class_finder'
|
5
|
+
|
6
|
+
RSpec.describe Formtastic::ActionClassFinder do
|
7
|
+
include FormtasticSpecHelper
|
8
|
+
|
9
|
+
it_behaves_like 'Specialized Class Finder' do
|
10
|
+
let(:default) { Formtastic::Actions }
|
11
|
+
let(:namespaces_setting) { :action_namespaces }
|
12
|
+
end
|
13
|
+
end
|
@@ -1,63 +1,64 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
|
-
describe 'ButtonAction', 'when submitting' do
|
5
|
+
RSpec.describe 'ButtonAction', 'when submitting' do
|
5
6
|
|
6
7
|
include FormtasticSpecHelper
|
7
8
|
|
8
9
|
before do
|
9
|
-
@output_buffer = ''
|
10
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
10
11
|
mock_everything
|
11
|
-
|
12
|
+
|
12
13
|
concat(semantic_form_for(@new_post) do |builder|
|
13
14
|
concat(builder.action(:submit, :as => :button))
|
14
15
|
end)
|
15
16
|
end
|
16
|
-
|
17
|
+
|
17
18
|
it 'should render a submit type of button' do
|
18
|
-
output_buffer.
|
19
|
+
expect(output_buffer.to_str).to have_tag('li.action.button_action button[@type="submit"]')
|
19
20
|
end
|
20
21
|
|
21
22
|
end
|
22
23
|
|
23
|
-
describe 'ButtonAction', 'when resetting' do
|
24
|
+
RSpec.describe 'ButtonAction', 'when resetting' do
|
24
25
|
|
25
26
|
include FormtasticSpecHelper
|
26
|
-
|
27
|
+
|
27
28
|
before do
|
28
|
-
@output_buffer = ''
|
29
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
29
30
|
mock_everything
|
30
|
-
|
31
|
+
|
31
32
|
concat(semantic_form_for(@new_post) do |builder|
|
32
33
|
concat(builder.action(:reset, :as => :button))
|
33
34
|
end)
|
34
35
|
end
|
35
|
-
|
36
|
+
|
36
37
|
it 'should render a reset type of button' do
|
37
|
-
output_buffer.
|
38
|
+
expect(output_buffer.to_str).to have_tag('li.action.button_action button[@type="reset"]', :text => "Reset Post")
|
38
39
|
end
|
39
40
|
|
40
41
|
it 'should not render a value attribute' do
|
41
|
-
output_buffer.
|
42
|
+
expect(output_buffer.to_str).not_to have_tag('li.action.button_action button[@value]')
|
42
43
|
end
|
43
|
-
|
44
|
+
|
44
45
|
end
|
45
46
|
|
46
|
-
describe 'InputAction', 'when cancelling' do
|
47
|
+
RSpec.describe 'InputAction', 'when cancelling' do
|
47
48
|
|
48
49
|
include FormtasticSpecHelper
|
49
|
-
|
50
|
+
|
50
51
|
before do
|
51
|
-
@output_buffer = ''
|
52
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
52
53
|
mock_everything
|
53
54
|
end
|
54
|
-
|
55
|
+
|
55
56
|
it 'should raise an error' do
|
56
|
-
|
57
|
+
expect {
|
57
58
|
concat(semantic_form_for(@new_post) do |builder|
|
58
59
|
concat(builder.action(:cancel, :as => :button))
|
59
60
|
end)
|
60
|
-
}.
|
61
|
+
}.to raise_error(Formtastic::UnsupportedMethodForAction)
|
61
62
|
end
|
62
|
-
|
63
|
+
|
63
64
|
end
|