require 'helper' describe OmniAuth::Form do 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) } end it 'evaluates in the instance when called with a block and no argument' do f = OmniAuth::Form.build { @html = '

OmniAuth

' } expect(f.instance_variable_get(:@html)).to eq('

OmniAuth

') end end describe '#initialize' do it 'sets the form action to the passed :url option' do expect(OmniAuth::Form.new(:url => '/awesome').to_html).to be_include("action='/awesome'") end it 'sets an H1 tag from the passed :title option' do expect(OmniAuth::Form.new(:title => 'Something Cool').to_html).to be_include('

Something Cool

') end end 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('') expect(form_html).to include('') end end describe '#html' do it 'appends to the html body' do form = OmniAuth::Form.build { @html = +'

' } form.html('

') expect(form.instance_variable_get(:@html)).to eq '

' end end describe 'fieldset' do it 'creates a fieldset with options' do form = OmniAuth::Form.new options = {:style => 'color: red', :id => 'fieldSetId'} expected = "
\n legendary\n\n
" form.fieldset('legendary', options) {} expect(form.to_html).to include expected end end end