diff --git a/lib/omniauth/form.rb b/lib/omniauth/form.rb index 09ef89d..fbb44ac 100644 --- a/lib/omniauth/form.rb +++ b/lib/omniauth/form.rb @@ -97,8 +97,8 @@ module OmniAuth header(options[:title],options[:header_info]) end - def self.build(title=nil,&block) - form = OmniAuth::Form.new(:title => title) + def self.build(options = {},&block) + form = OmniAuth::Form.new(options) if block.arity > 0 yield form else diff --git a/spec/omniauth/form_spec.rb b/spec/omniauth/form_spec.rb new file mode 100644 index 0000000..9aac4ec --- /dev/null +++ b/spec/omniauth/form_spec.rb @@ -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('

Something Cool

') + end + end +end