require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'

describe "/<%= table_name %>/new.<%= default_file_extension %>" do
  # Some handy methods for mocking records according to auto_rest mechanisms
  include AutoRest::SpecsHelper
  
  include <%= controller_class_name %>Helper
  
  before do
    assigns[:resource]= assigns[:<%= file_name %>]= @<%= file_name %>=  \
      ar_fake_model(<%= class_name %>, :controller => <%= controller_class_name %>Controller, :action => :new)
    
    # Every foreing model will instantiate a collection of records to select one.
    ar_mock_foreing_models :controller => <%= controller_class_name %>Controller, :action => :new
    
    def @controller.ardata
      <%= controller_class_name %>Controller.ardata
    end
  end

  it "should render new form" do
    render <%= controller_class_name %>Controller.ardata.templates.new
    
    response.should have_tag("form[action=?][method=post]", <%= table_name %>_path) do
      <%= controller_class_name %>Controller.ardata.fields.for_new.each do |attr, title|
        ar_spec_form_tag_of_attribute(attr, title, <%= controller_class_name %>Controller.ardata)
      end
    end
  end
end


