Panayotis Matsinopoulos

...Senior Software Engineer & Project Manager

  • Increase font size
  • Default font size
  • Decrease font size
Welcome to My Personal Web Site

Asserting Template and Layout

E-mail Print PDF

Testing - Asserting Template and Layout

I consider testing one of the most important phase in application development and Rails does a very good job on that. However, testing documentation on Rails Guides is still work under development.

Here is a short tutorial on how you can test that a reponse has rendered the correct template and the correct layout.

If you want to make sure that the response rendered the correct template and layout, you can use the assert_template method:

test “index should render correct template and layout” do
  get :index
  assert_template :index
  assert_template :layout => “layouts/application”
end

Note that you cannot test for template and layout at the same time, with one call to assert_template method. Also, for the layout test, you can give a regular expression instead of a string, but using the string, makes things clearer. On the other hand, you have to include the “layouts” directory name even if you save your layout file in this standard layout directory. Hence,

assert_template :layout => “application”

will not work.

Gotcha: Watch out if your view renders any partial

If your view renders any partial, when asserting for the layout, you have to assert for the partial at the same time. Otherwise, assertion will fail.

Hence:

test “new should render correct layout” do
  get :new
  assert_template :layout => “layouts/application”, :partial => “_form”
end

is the correct way to assert for the layout when the view renders a partial with name _form. Omitting the :partial key in your assert_template call will complain.

Yesterday, March 24th, I tried to commit the above as my first improvement on Rails Guides, testing guide. Let us see whether this will make it through.

Panayotis

 

QlikView Developer II - Day II

E-mail Print PDF

 

QlikView Developer II - Day II

[My sponsor on this training is Fraudpointer S.A.]

On, March 6th, 2012, I followed the 2nd day of the QlikView Developer II training course. (Read about Day I here).

Day II was even more interesting. What I have underlined as most important to my mind were the following:

  1. We continued with SET ANALYSIS from Day I. SET ANALYSIS is extremely useful if you want to easily do comparisons.
  2. Dollar Sign Expansions. They are definitions of text replacements used in the script or in expressions.
  3. AGGR function. This is a powerful QlikView function that can be used to group by results.
  4. Talked about scripting and data modeling optimization.
  5. QlikView security.
  6. Next part of day was consumed to execute advanced scripting exercises.
Everything was very interesting and I believe that training was really worth the money.
Panayotis

 

Last Updated on Saturday, 24 March 2012 09:19
 

QlikView Developer II - Day I

E-mail Print PDF

QlikView Developer II - Day I

[My sponsor on this training is Fraudpointer S.A.]

Today, March 5th, 2012, I followed the 1st day of the QlikView Developer II training course. Actually, it is my 1st official QlikView training since my first encounter with QlikView, back in start of November 2011.

I really enjoyed that. What I have underlined as most important to my mind were the following:

  1. CONNECT and CONNECT32 commands used to connect from 64-bit to 32-bit databases.
  2. Why shall we avoid having documents with synthetic keys.
  3. INLINE loading and how we can use them to give descriptive labels to numeric fields.
  4. Nice hint: When you are on Table View and you right click on a table, you can select Preview and you see sample of the data that this table bares.
  5. Explanation of "rowno()" and "Ceil()" and AUTOGENERATE().
  6. Mapping tables with two fields (ID and DESCRIPTION) and use the mapping (applymap() function) in other tables. This helps avoid having two many tables with only two fields, the second of which just gives a description of the value of the first field.
  7. Usage of "null()"
  8. Best practice to use "SELECT *" to bring everything from database as is, and on top of that use "LOAD ..." to actually get whatever you want in the format that you want.
  9. We did a nice example to load a budget from an EXCEL crosstable.
  10. INPUTFIELD to allow user to give values to a field.
  11. INNER JOIN, CONCATENATE, NOCONCATENATE, PRECEDING LOAD on PRECEDING LOAD.
  12. Finally, we started with SET ANALYSIS, which will continue the 2nd day of the training.

Panayotis

 

 

Ruby Style Guide from Github

E-mail Print PDF

Ruby Style Guide

This is a very good guide on how one should style its Ruby code. I am following this since I started Ruby and I suggest that everybody does the same.

One extra on usage of {...} vs do...end blocks can be found here (Weirich Convention).

Panayotis

  
Last Updated on Saturday, 24 March 2012 08:52
 

MySQL Replication

E-mail Print PDF

Read my new article on Site Point about MySQL Replication (Part I and Part II)

Last Updated on Friday, 24 February 2012 14:39
 
More Articles...
  • «
  •  Start 
  •  Prev 
  •  1 
  •  2 
  •  Next 
  •  End 
  • »


Page 1 of 2

Main Menu


Who's Online

We have 1 guest online