1
0
Fork 0
mirror of https://github.com/omniauth/omniauth.git synced 2022-11-09 12:31:49 -05:00

Consistent interface for Forms. Closes #520

This commit is contained in:
Michael Bleigh 2011-10-26 01:27:07 -04:00
parent da328e96bd
commit 5c585eeeb2
2 changed files with 25 additions and 2 deletions

View file

@ -97,8 +97,8 @@ module OmniAuth
header(options[:title],options[:header_info]) header(options[:title],options[:header_info])
end end
def self.build(title=nil,&block) def self.build(options = {},&block)
form = OmniAuth::Form.new(:title => title) form = OmniAuth::Form.new(options)
if block.arity > 0 if block.arity > 0
yield form yield form
else else

View file

@ -0,0 +1,23 @@
require 'spec_helper'
describe OmniAuth::Form do
describe '.build' do
it 'should yield the instance when called with a block and argument' do
OmniAuth::Form.build{|f| f.should be_kind_of(OmniAuth::Form)}
end
it 'should evaluate in the instance when called with a block and no argument' do
OmniAuth::Form.build{ self.class.should == OmniAuth::Form }
end
end
describe '#initialize' do
it 'the :url option should supply to the form that is built' do
OmniAuth::Form.new(:url => '/awesome').to_html.should be_include("action='/awesome'")
end
it 'the :title option should set an H1 tag' do
OmniAuth::Form.new(:title => 'Something Cool').to_html.should be_include('<h1>Something Cool</h1>')
end
end
end