require "spec_helper" describe Form::Builder do describe "#initialize" do let(:data) { mock } let(:base_name) { mock } subject { described_class.new(data, base_name) } its(:data) { should eql(data) } its(:base_name) { should eql(base_name) } end context "building fields" do describe "#text" do let(:component) { Form::Component::Input } let(:type) { "text" } let(:helper) { "text" } it_behaves_like "input instantiation" end describe "#password" do let(:component) { Form::Component::Input } let(:type) { "password" } let(:helper) { "password" } it_behaves_like "input instantiation" end describe "#file" do let(:component) { Form::Component::Input } let(:type) { "file" } let(:helper) { "file" } it_behaves_like "input instantiation" end describe "#hidden" do let(:component) { Form::Component::Input } let(:type) { "hidden" } let(:helper) { "hidden" } it_behaves_like "input instantiation" end describe "#number" do let(:component) { Form::Component::Input } let(:type) { "number" } let(:helper) { "number" } it_behaves_like "input instantiation" end describe "#email" do let(:component) { Form::Component::Input } let(:type) { "email" } let(:helper) { "email" } it_behaves_like "input instantiation" end describe "#url" do let(:component) { Form::Component::Input } let(:type) { "url" } let(:helper) { "url" } it_behaves_like "input instantiation" end describe "#search" do let(:component) { Form::Component::Input } let(:type) { "search" } let(:helper) { "search" } it_behaves_like "input instantiation" end describe "#phone" do let(:component) { Form::Component::Input } let(:type) { "tel" } let(:helper) { "phone" } it_behaves_like "input instantiation" end describe "#textarea" do let(:data) { mock("dataset").as_null_object } let(:options) { mock("textarea options").as_null_object } let(:textarea) { mock("textarea").as_null_object } subject { described_class.new(data, :user) } it "instantiates Form::Component::TextArea" do Form::Component::TextArea.should_receive(:new).with(subject, :bio, options).and_return(textarea) subject.textarea :bio, options end it "calls #to_html" do Form::Component::TextArea.stub :new => textarea textarea.should_receive(:to_html) subject.textarea :bio end end end end