jeudi 7 mai 2015

get value of instance var controller method being tested

I have a method that essentially clones a record. Then redirects to the cloned records edit page. I have a mini test that needs to test that the record gets cloned and redirected to the new records edit path.

@new_record is a new object created in the controller method

  describe 'clone_record' do
    it 'should clone record' do
      @first_record = FactoryGirl.create(:blah)
      get :clone_record, :first_record_id => @first_record, :new_record => 'new_record'
      assert_redirected_to(edit_record_path(@new_record.id))
    end
  end

Aucun commentaire:

Enregistrer un commentaire