2013-02-25 19:05:37 -05:00
|
|
|
require 'helper'
|
2011-10-26 01:27:07 -04:00
|
|
|
|
|
|
|
describe OmniAuth::Form do
|
2014-01-15 23:00:46 -05:00
|
|
|
describe '.build' do
|
|
|
|
it 'yields the instance when called with a block and argument' do
|
|
|
|
OmniAuth::Form.build { |f| expect(f).to be_kind_of(OmniAuth::Form) }
|
2011-10-26 01:27:07 -04:00
|
|
|
end
|
|
|
|
|
2014-01-15 23:00:46 -05:00
|
|
|
it 'evaluates in the instance when called with a block and no argument' do
|
2020-03-02 15:09:14 -05:00
|
|
|
f = OmniAuth::Form.build { @html = '<h1>OmniAuth</h1>' }
|
|
|
|
expect(f.instance_variable_get(:@html)).to eq('<h1>OmniAuth</h1>')
|
2011-10-26 01:27:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-15 23:00:46 -05:00
|
|
|
describe '#initialize' do
|
|
|
|
it 'sets the form action to the passed :url option' do
|
2012-10-10 04:32:55 -04:00
|
|
|
expect(OmniAuth::Form.new(:url => '/awesome').to_html).to be_include("action='/awesome'")
|
2011-10-26 01:27:07 -04:00
|
|
|
end
|
|
|
|
|
2014-01-15 23:00:46 -05:00
|
|
|
it 'sets an H1 tag from the passed :title option' do
|
2012-10-10 04:32:55 -04:00
|
|
|
expect(OmniAuth::Form.new(:title => 'Something Cool').to_html).to be_include('<h1>Something Cool</h1>')
|
2011-10-26 01:27:07 -04:00
|
|
|
end
|
|
|
|
end
|
2020-03-02 15:09:14 -05:00
|
|
|
|
|
|
|
describe '#password_field' do
|
|
|
|
it 'adds a labeled input field' do
|
|
|
|
form = OmniAuth::Form.new.password_field('pass', 'password')
|
|
|
|
form_html = form.to_html
|
|
|
|
expect(form_html).to include('<label for=\'password\'>pass:</label>')
|
|
|
|
expect(form_html).to include('<input type=\'password\' id=\'password\' name=\'password\'/>')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#html' do
|
|
|
|
it 'appends to the html body' do
|
2020-12-10 11:01:41 -05:00
|
|
|
form = OmniAuth::Form.build { @html = +'<p></p>' }
|
2020-03-02 15:09:14 -05:00
|
|
|
form.html('<h1></h1>')
|
|
|
|
|
|
|
|
expect(form.instance_variable_get(:@html)).to eq '<p></p><h1></h1>'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'fieldset' do
|
|
|
|
it 'creates a fieldset with options' do
|
|
|
|
form = OmniAuth::Form.new
|
|
|
|
options = {:style => 'color: red', :id => 'fieldSetId'}
|
|
|
|
expected = "<fieldset style='color: red' id='fieldSetId'>\n <legend>legendary</legend>\n\n</fieldset>"
|
|
|
|
|
|
|
|
form.fieldset('legendary', options) {}
|
|
|
|
|
|
|
|
expect(form.to_html).to include expected
|
|
|
|
end
|
|
|
|
end
|
2011-10-26 01:27:07 -04:00
|
|
|
end
|