This repository was archived by the owner on Oct 22, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 2121 res . body = body
2222 res . code = code
2323
24- allow ( subject ) . to receive ( :execute_post_request ) . and_return ( res )
24+ allow ( subject ) . to receive ( :execute_request ) . and_return ( res )
2525 end
2626
2727 describe '#wordpress_user_exists?' do
3030 expect ( subject . wordpress_user_exists? ( 'foo' ) ) . to be true
3131 end
3232 end
33+
34+ describe '#wordpress_user_profile_form_fields' do
35+ context 'when the profile form is accessible and contains a valid form' do
36+ let ( :code ) { 200 }
37+ let ( :body ) { '<form><input name="key" value="value"><input name="foo" required value="bar"/>' }
38+ it 'returns a hash constructed from the input elements in the profile form' do
39+ fields = subject . wordpress_user_profile_form_fields ( '' )
40+ expect ( fields ) . to eq ( 'key' => 'value' , 'foo' => 'bar' )
41+ end
42+ end
43+
44+ context 'when the profile form is accessible and contains no form elements' do
45+ let ( :code ) { 200 }
46+ let ( :body ) { '<form></form>' }
47+ it 'returns an empty hash' do
48+ expect ( subject . wordpress_user_profile_form_fields ( '' ) ) . to eq ( { } )
49+ end
50+ end
51+
52+ context 'when the profile form request returns a code != 200' do
53+ let ( :code ) { 404 }
54+ let ( :body ) { nil }
55+ it 'returns nil' do
56+ expect ( subject . wordpress_user_profile_form_fields ( '' ) ) . to be_nil
57+ end
58+ end
59+ end
3360end
You can’t perform that action at this time.
0 commit comments