On my _form.html.erb, I have this: <%= f.select :group_name, options_for_select(@group_mst.collect{|x| [x.group_name]}), {:multiple => :multiple} %>
------------------------------------------------------------------------------------------------- On my user_mst_controller.rb: def new @user_mst = UserMst.new @group_mst = GroupMst.all #GroupMst.stub(:all => []) respond_to do |format| format.html # new.html.erb format.xml { render :xml => @user_mst } end end # GET /user_msts/1/edit def edit @user_mst = UserMst.find(params[:id]) @group_mst = GroupMst.all end # POST /user_msts # POST /user_msts.xml def create @user_mst = UserMst.new(params[:user_mst]) @group_mst = GroupMst.all respond_to do |format| if @user_mst.save format.html { redirect_to(@user_mst, :notice => 'User mst was successfully created.') } format.xml { render :xml => @user_mst, :status => :created, :location => @user_mst } else format.html { render :action => "new" } format.xml { render :xml => @user_mst.errors, :status => :unprocessable_entity } end end end ------------------------------------------------------------------------------------------------- On my new.html.erb: require 'spec_helper' describe "user_msts/new.html.erb" do before(:each) do assign(:user_mst, stub_model(UserMst, :username => "MyString", :password => "MyString", :confirm_password => "MyString", :first_name => "MyString", :middle_name => "MyString", :last_name => "MyString", :group_name => "MyString", :position => "MyString" ).as_new_record) end it "renders new user_mst form" do render # Run the generator again with the --webrat flag if you want to use webrat matchers assert_select "form", :action => user_msts_path, :method => "post" do assert_select "input#user_mst_username", :name => "user_mst[username]" assert_select "input#user_mst_password", :name => "user_mst[password]" assert_select "input#user_mst_confirm_password", :name => "user_mst[confirm_password]" assert_select "input#user_mst_first_name", :name => "user_mst[first_name]" assert_select "input#user_mst_middle_name", :name => "user_mst[middle_name]" assert_select "input#user_mst_last_name", :name => "user_mst[last_name]" assert_select "input#user_mst_group_name", :name => "user_mst[group_name]" assert_select "input#user_mst_position", :name => "user_mst[position]" end end end ----------------------------------------------------------------------------------------------------------------- I see that the problem is not extracting the @group_mst = GroupMst.all on the <select> That's the one I don't know how. -- View this message in context: http://ruby.11.x6.nabble.com/RSpec-in-controller-tp4991621p4991672.html Sent from the rspec-users mailing list archive at Nabble.com. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users