Archive for the 'software' Category

assert_select Plugin Allows you to Run Funtional Tests on your .rhtml

assert_select picture

Ruby Inside just posted an interesting tidbit about the assert_select plugin written by Assaf Arkin. This is a cool little plugin which allows you to run functional tests on your .rhtml pages.

I wasn’t aware of a previous method to run functionjal tests on HTML elements, but I guess that *should* be a valuable part of our testing cycle.

Anyways, this is a cool little plugin. I think it will soon be added into some of my personal projects. Here are some code examples for it:

def test_login_form_has_all_fields
get :login
assert_select "form[action=http://myapp/login] input" do |inputs|
assert_equal 3, inputs.size
assert_select inputs[0], "input[type=name][name=username]"
assert_select inputs[1], "input[type=password][name=password]"
assert_select inputs[2], "input[type=submit][value=Login]"
end
end

And another one….

# Form includes four input fields
assert_select "form input", 4

# Page does not have any forms in it.
assert_select "form", false, "Page must contain no forms"

# Page has one link back to user's page.
assert_select "a[href=?]", url_for(:controller=>"user", :id=>user_id),
:count=>1, :text=>"Back to page"

19 Rails Tricks Most Rails Coders Don’t Know

I just came across this on Digg… There are alot fo great suggestions for anyone who codes with Rails. There are about 20 tips here, most of which I thought were good to know, especially as I hadn’t come across them, read, or even thought of them before….

This is a must-read for any serious rails coder!

read more | digg story

MVC: The Most Vexing Conundrum

Elementary explanation of the Model/View/Controller design pattern, particularly as it applies to Ruby on Rails. Extremely concise explanation that should be everyone’s first stop in understanding Rails (or any other MVC based framework). I wish I had found this a month ago.

Anyone who writes any Rails code should have a solid understanding of MVC, since it is the basis of just about everything you do in rails. To provide a bit of a preview to what you find in the article, MVC, which stands for ‘Model-View-Controller’ is a design pattern commonly used by Web apps. A Design pattern is an architecture for writing software. Common design patterns such as MVC have evolved over time as developers find better ways of doing things.

The MVC essentially advocates dividing your program into three somewhat seperate parts. The Model, which handles your data records, the Controller, which handles what operations can be performed on the data, and the View, which governs how the results of Controller operations are displayed.

If you are new to Ruby on Rails, or haven’t heard of the MVC pattern before, I would really recommend you read the article!

MVC: The Most Vexing Conundrum

read more | digg story

TextMate Cheat Sheet for Ruby and Rails Developers

Hey - all you Mac Ruby on Rails People - this is for you!

This was just posted on Digg, so I thought I would post it here as well. While I myself don’t have Mac/Textmate, after all that I have seen about it, I am kind of tempted to switch over to take advantage of this platform. Does anyone know the latest state of getting MacOSX running on an Intel Machine?

Pragmatic Programmer, Mike Clark, has produced a single page PDF cheat sheet of about fifty TextMate keyboard shortcuts to speed up your Ruby development. As a long time TextMate user who never uses the shortcuts, this is very useful.

read more | digg story

« Previous Page