shared_examples_for "input" do let(:form) { mock(data: {myfield: "some value"}) } let(:name) { "myfield" } context "with custom attributes" do let(:options) { {autofocus: true, class: "some-class"} } let(:html) { Form::Component::Input.new(form, name, options).to_html } subject { Nokogiri(html).css("input").first } its(["type"]) { should eql(type) } its(["value"]) { should eql("some value") } end end