require 'spec_helper'

describe 'form_tag blocks' do
  it "form_tag '/articles'" do
    expect(
      render_slim do
        <<-HTML.unindent
          == fh.form_tag '/articles' do
            == fh.input_tag :title, size: 25, value: 'Hamlet'
        HTML
      end
    ).to eq(
      <<-HTML.unindent
        <form action="/articles" method="post">
          <input name="title" size="25" type="text" value="Hamlet">
        </form>
      HTML
    )
  end

  it "form_tag '/articles' with two inputs" do
    expect(
      render_slim do
        <<-HTML.unindent
          == fh.form_tag '/articles'
            == fh.input_tag :title, size: 25, value: 'Hamlet'
            == fh.input_tag :author, value: 'Hillbilly'
        HTML
      end
    ).to eq(
      <<-HTML.unindent
        <form action="/articles" method="post">
          <input name="title" size="25" type="text" value="Hamlet">
          <input name="author" type="text" value="Hillbilly">
        </form>
      HTML
    )
  end

  it "form_tag '/articles, method: :put'" do
    expect(
      render_slim do
        <<-HTML.unindent
          == fh.form_tag '/articles', method: :put
            == fh.input_tag :title, size: 25, value: 'Hamlet'
        HTML
      end
    ).to eq(
      <<-HTML.unindent
        <form action="/articles" method="post">
          <input name="_method" type="hidden" value="put">
          <input name="title" size="25" type="text" value="Hamlet">
        </form>
      HTML
    )
  end
end
