@@ -23,51 +23,53 @@ def success_submit
2323 allow_any_instance_of ( EmitFormTestController ) . to receive ( :expect_params )
2424 end
2525
26- describe "data is accessable within form without component in pure Vue.js" do
27-
28- it "if set, emits event directly when form is submitted (not waiting for success or failure)" do
29- class ExamplePage < Matestack ::Ui ::Page
30- def response
31- matestack_form form_config do
32- plain "{{ data }}"
33- form_input key : :foo_input , type : :text , id : "foo-input"
34- form_textarea key : :foo_textarea , type : :text , id : "foo-textarea"
35- form_select key : :foo_select , options : [ 1 , 2 , 3 ] , id : "foo-select" , init : 2
36- form_checkbox key : :foo_single_checkbox , id : "foo-single-checkbox"
37- form_checkbox key : :foo_multi_checkbox , options : [ 1 , 2 , 3 ] , id : "foo-multi-checkbox"
38- form_radio key : :foo_radio , options : [ 1 , 2 , 3 ] , id : "foo-radio-checkbox"
39- button 'Submit me!'
40- end
41- toggle show_on : "form_submitted" , id : 'async-form' do
42- plain "form submitted!"
43- end
26+ it "data is accessable within form without component in pure Vue.js" do
27+ class ExamplePage < Matestack ::Ui ::Page
28+ def response
29+ matestack_form form_config do
30+ plain "{{ data }}"
31+ form_input key : :foo_input , type : :text , id : "foo-input"
32+ form_textarea key : :foo_textarea , type : :text , id : "foo-textarea"
33+ form_select key : :foo_select , options : [ 1 , 2 , 3 ] , id : "foo-select" , init : 2
34+ form_checkbox key : :foo_single_checkbox , id : "foo-single-checkbox"
35+ form_checkbox key : :foo_multi_checkbox , options : [ 1 , 2 , 3 ] , id : "foo-multi-checkbox"
36+ form_radio key : :foo_radio , options : [ 1 , 2 , 3 ] , id : "foo-radio-checkbox"
37+ button 'Submit me!'
4438 end
45-
46- def form_config
47- return {
48- for : :my_object ,
49- method : :post ,
50- path : form_data_access_submit_path ,
51- emit : "form_submitted"
52- }
39+ toggle show_on : "form_submitted" , id : 'async-form' do
40+ plain "form submitted!"
5341 end
5442 end
5543
56- visit '/example'
44+ def form_config
45+ return {
46+ for : :my_object ,
47+ method : :post ,
48+ path : form_data_access_submit_path ,
49+ emit : "form_submitted"
50+ }
51+ end
52+ end
5753
58- expect ( page ) . to have_content ( '{ "foo_input": null, "foo_textarea": null, "foo_single_checkbox": null, "foo_multi_checkbox": [], "foo_radio": null, "foo_select": 2 }' )
54+ visit '/example'
5955
60- fill_in "foo-input" , with : "1"
61- fill_in "foo-textarea" , with : "2"
62- select "3" , from : "foo-select"
63- check "foo-single-checkbox_1"
64- check "foo-multi-checkbox_1"
65- check "foo-multi-checkbox_2"
66- choose "foo-radio-checkbox_3"
56+ expect ( page ) . to have_content ( '{ "foo_input": null, "foo_textarea": null, "foo_single_checkbox": null, "foo_multi_checkbox": [], "foo_radio": null, "foo_select": 2 }' )
6757
68- expect ( page ) . to have_content ( '{ "foo_input": "1", "foo_textarea": "2", "foo_single_checkbox": true, "foo_multi_checkbox": [ 1, 2 ], "foo_radio": 3, "foo_select": 3 }' )
58+ fill_in "foo-input" , with : "1"
59+ fill_in "foo-textarea" , with : "2"
60+ select "3" , from : "foo-select"
61+ check "foo-single-checkbox_1"
62+ check "foo-multi-checkbox_1"
63+ check "foo-multi-checkbox_2"
64+ choose "foo-radio-checkbox_3"
65+
66+ expect ( page ) . to have_content ( '{ "foo_input": "1", "foo_textarea": "2", "foo_single_checkbox": true, "foo_multi_checkbox": [ 1, 2 ], "foo_radio": 3, "foo_select": 3 }' )
67+
68+ click_on "Submit me!"
69+
70+ expect ( page ) . to have_content ( '{ "foo_input": null, "foo_textarea": null, "foo_single_checkbox": null, "foo_multi_checkbox": [], "foo_radio": null, "foo_select": 2 }' )
6971
70- end
7172 end
7273
74+
7375end
0 commit comments