Technical
Functional Tests

Test Sessions


assert_not_nil session[:legal_entity_id]

Assert_raises

Checks if model allows blanks


assert_raises(ActiveRecord::StatementInvalid) {GedClientMapping.create(:source_id => nil,:region_id => nil, :account_name => nil)}
Check if nothing is thrown

assert_nothing_raised(ActiveRecord::StatementInvalid) {GedClientMapping.create(:source_id => nil,:region_id => nil, :account_name => nil)}

Testing RJS


#controller
def show_by_date
  render :update do |page|
     page.replace_html :feeds_data_div,:partial => "feeds_data" 
  end
end
#test
assert_nothing_raised{get :show_by_date,:cob_date => "02/22/2007"}
assert_select_rjs :replace_html,:feeds_data_div

To test what will be parsed in to the element

code class="ruby">
#say i have a method
page.replace_html :results_container,%(<h3 style="color:red">Your search did not return any results</h3>)
# To Test
 assert_select_rjs(:replace_html,:results_container) do
      assert_select "h3","Your search did not return any results" 
 end

Test Session presence


@response.has_session_object? "user" 

Test for errors in the returned record


  assert(assigns(:user).errors.invalid?  "password")