[rspec-users] rspec-users Digest, Vol 84, Issue 8

Oliver Jesus oliverjesus2008 at yahoo.com
Tue Jun 11 01:22:56 UTC 2013


Yes I've done that. I think it is on rendering on <select_tag> causes error.---------------------------------------------------------------------------------------------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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20130610/81785c45/attachment.html>


More information about the rspec-users mailing list