<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Feed&#039;em with rubiez! #*^(@!!</title>
	<atom:link href="http://rubynoobie.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rubynoobie.wordpress.com</link>
	<description>&#039;cause they luv ruby on rails!</description>
	<lastBuildDate>Thu, 28 Jan 2010 19:47:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='rubynoobie.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/c9efae8e25f098d74546936166b6739f?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Feed&#039;em with rubiez! #*^(@!!</title>
		<link>http://rubynoobie.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://rubynoobie.wordpress.com/osd.xml" title="Feed&#039;em with rubiez! #*^(@!!" />
	<atom:link rel='hub' href='http://rubynoobie.wordpress.com/?pushpress=hub'/>
		<item>
		<title>RSpec Expectations Introduction</title>
		<link>http://rubynoobie.wordpress.com/2010/01/27/rspec-expectations/</link>
		<comments>http://rubynoobie.wordpress.com/2010/01/27/rspec-expectations/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 18:14:26 +0000</pubDate>
		<dc:creator>Lucas d'Acampora Prim</dc:creator>
				<category><![CDATA[RSpec]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[matchers]]></category>

		<guid isPermaLink="false">http://rubynoobie.wordpress.com/?p=36</guid>
		<description><![CDATA[I still reading The RSpec Book, which is amazing! I´m doing a little review of what i´ve been reading about. 1.1 Creating Expectations There are two methods available for checking expectations: should() and should_not(). 1.2 Built-in Matchers There are several matchers that can be used with should and should_not, which are divided into well-separated categories. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubynoobie.wordpress.com&amp;blog=11514194&amp;post=36&amp;subd=rubynoobie&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I still reading <a href="http://www.pragprog.com/titles/achbd/the-rspec-book">The RSpec Book</a>, which is amazing! I´m doing a little review of what i´ve been reading about.</p>
<h2>1.1 Creating Expectations</h2>
<p>There are two methods available for checking expectations: should() and should_not().</p>
<h2>1.2 Built-in Matchers</h2>
<p>There are several matchers that can be used with should and should_not, which are divided into well-separated categories.</p>
<h3>1.2.1 Equality: Equivalence and Identity</h3>
<p><pre class="brush: ruby;">
 cow.should == twin_cow
 cow.should === twin_cow
 cow.should eql(cow)
 cow.should equal(cow)
</pre></p>
<p>The == method is used to express equivalence and equal is used when you want the receiver and the argument to be the same object.</p>
<p><strong>Note:</strong> Instead of using !=, you should use the should_not method!</p>
<h3>1.2.2 Floating Point Calculations</h3>
<p><pre class="brush: ruby;">
 result.should be_close(3.14, 0.005)
 </pre></p>
<p>When dealing with floating points, sometimes you expect 3.14 but 3.1415 is returned, which would be a pain to express on expectations if it wasn´t for the built in matcher be_close(), which takes two arguments: the floating point <strong>number</strong> you are expecting and the <strong>precision</strong> you require.</p>
<h3>1.2.3 Regular Expressions</h3>
<p><pre class="brush: ruby;">
 result.should match(/this regexp/)

result.should =~ /this regexp/
 </pre></p>
<p>This can be very useful when dealing with multiple-line expectations, instead of using the open file technique to compare contents.</p>
<h3>1.2.4 Changes</h3>
<p><pre class="brush: ruby;">
 lambda {

User.create!(:role =&gt; &quot;admin&quot; )

}.should change{ User.admins.count }
 ## OR

 lambda {

User.create!(:role =&gt; &quot;admin&quot; )

}.should change{ User.admins.count }.to(1)

 ## OR

 lambda {

User.create!(:role =&gt; &quot;admin&quot; )

}.should change{ User.admins.count }.from(0).to(1)
 </pre></p>
<p>This is really useful when working with database changes or changes to objects. Another way of writing this is by using the before_state -&gt; change -&gt; after_state technique, as follows:</p>
<p><pre class="brush: ruby;">
 total.price.should == 0

buyer.inserts Product.new(:price =&gt; 250)

total.price.should == 250
 </pre></p>
<p>The matcher is change(), which takes a block with the object attribute/method and accepts the from(), to() or by() modifiers.</p>
<h3>1.2.5 Errors</h3>
<p><pre class="brush: ruby;">
 field = SoccerField.new(:players =&gt; 20)

lambda {

field.remove(:players, 25)

}.should raise_error(NotEnoughPlayers,“attempted to remove more players than there is on field”)
 </pre></p>
<p>Useful when needed to check for Exceptions. The matcher is raise_error and takes an ExceptionObject and/or a String/Regexp.</p>
<h3>1.2.6 Throw</h3>
<p><pre class="brush: ruby;">
 speech = Speech.new(:seats =&gt; 100)

100.times { speech.register Person.new }
 lambda {

speech.register Person.new

}.should throw_symbol(:speech_full, 100)
 </pre></p>
<p>When dealing with “errors that are not really exceptions”, you use catch and throw. Rspec can check if a throw has been called by using the throw_symbol matcher. It accepts 0,1 or 2 arguments. The first argument needs to be a Symbol and the second can be any Object that is thrown along.</p>
<h2>1.3 Predicate Matchers</h2>
<p>A Ruby predicate method is a method that ends with a “?” and returns a boolean value, like string.empty? or regexp.match? methods. Rspec allows us to write expectations to these methods in a beautiful, understandable way, instead of writing:</p>
<p><pre class="brush: ruby;">
 a_string.empty?.should == true
 </pre></p>
<p>We can write:</p>
<p><pre class="brush: ruby;">
 a_string.should be_empty
 </pre></p>
<h3>1.3.1 The be_something method</h3>
<p>When using a be_something matcher, RSpec removes the “be_”, appends a “?” and calls the resulting method in the receiver.</p>
<p>A very common construct of this method is be_true, which checks if the receiver is true (any object except false or nil) or false (false or nil).</p>
<h2>1.4 Checking ownership</h2>
<p>Sometimes you will want to check not the object itself, but something the object owns. In this case, RSpec allows you to write some beautiful sentences to check for owned objects.</p>
<h3>1.4.1 The have_something method</h3>
<p><pre class="brush: ruby;">
 request_parameters.has_key?(:id).should == true
 # is the same as

request_parameters.should have_key(:id)
 </pre></p>
<p>RSpec uses method_missing to convert anything that begins with have_something to has_something? and performs the checking.</p>
<h3>1.4.2 The have() method</h3>
<p><pre class="brush: ruby;">
 field.players.select {|p| p.team == home_team }.length.should == 9

# is the same as

home_team.should have(9).players_on(field)
 </pre></p>
<p>As have() does not respond to players_on(), it delegates to the receiver (home_team). It encourages the home_team object to have useful methods like players_on.</p>
<p>You can get a NoMethodError if the players_on method doesn´t exist, you can get another NoMethodError if the result of the players_on method doesn´t respond to size() or length() and if the size of the collection doesn´t match the expected size, you will get a failed expectation.</p>
<h2>1.5 Checking Collections Themselves</h2>
<p>Sometimes we create expectations about a collection itself and not about an owned collection. RSpec lets us use the have() method to express this as well, as in:</p>
<p><pre class="brush: ruby;">
 a_collection.should have(10).items
 </pre></p>
<p>items is just providing some meaning to the expectation.</p>
<h3>1.5.1 Strings</h3>
<p>Strings are not collections by definition but they respond to a lot of methods that collections do, like length() and size(). This allow us to use have() to expect a string of a specific length.</p>
<p><pre class="brush: ruby;">
 “lucas”.should have(5).characters
 </pre></p>
<p>characters is just providing meaning to the expectation as well.</p>
<h3>1.5.2 Have() modifiers for precision</h3>
<p>The have() method has some relatives that allow us to check for upper and lower conditions.</p>
<p><pre class="brush: ruby;">
 work.should have_exactly(8).hours

basket.should have_at_least(5).items

auditorium.should have_at_most(100).people
 </pre></p>
<h2>1.6 Operator Expressions</h2>
<p>There may be sometimes when you want to expect a value to be not an exact amount but something like greater than or less than. RSpec allows you to do this by using the regular operators from Ruby!</p>
<p><pre class="brush: ruby;">
 number.should == 3

number.should be &gt;= 2

number.should be &lt;= 4

number should be &gt; 0
 </pre></p>
<h2>1.7 Generated Descriptions</h2>
<p>Sometimes the code within a expectation looks the same as the string used to describe it. In this cases, you can omit the string by using the specify() method, which is an alias of the it() method but reads better when there is no documentation string.</p>
<p><pre class="brush: ruby;">
 describe “A new user” do
 specify { User.new().should be_confused }
 end

 #is the same as:
 describe “A new user” do
 it “should be confused” do
 User.new.should be_confused
 end
 end
 </pre></p>
<p>This should be used carefully and only in cases where the docstring and the code look exactly the same.</p>
<h2>1.8 Subjects</h2>
<p>Sometimes within an example group we want to use a subject on which we will develop the expectations. To create a subject you have to use the subject() method, which takes a code block creating the subject. Once you specify a subject, all the should() and should_not() methods can be called without a receiver as it will point to the subject in question.</p>
<p><pre class="brush: ruby;">
 describe Rabbit
 subject { Rabbit.new(:age =&gt; 1) }
 specify { subject.should be_aged(1) }
 end
 # or even better
 describe Rabbit
 subject { Rabbit.new(:age =&gt; 1) }
 it { should be_aged(1) }
 end
 </pre></p>
<p>You can also use implicit subjects when describing a class. RSpec will automatically create an instance of the described object, allowing us to write expectations like this:</p>
<p><pre class="brush: ruby;">
 describe Rabbit
 it { should eat_carrots }
 end
 </pre></p>
<p>This should be used with caution though! You should not coerce your objects to fit into this model instead of writing it as you should really have written!</p>
<h2>1.9 Matchers Table and Thoughts</h2>
<table border="1" cellspacing="0" cellpadding="0" width="581">
<tbody>
<tr>
<td width="365" valign="top"><strong>Matcher</strong></td>
<td width="216" valign="top"><strong>Used to expect</strong></td>
</tr>
<tr>
<td width="365" valign="top"><em>==, ===, eql, equal (</em>other<em>)</em></td>
<td width="216" valign="top">Equality between objects</td>
</tr>
<tr>
<td width="365" valign="top"><em>be_close(</em>other<em>, </em>precision<em>)</em></td>
<td width="216" valign="top">Floating Points</td>
</tr>
<tr>
<td width="365" valign="top"><em>match, =~ (</em>other<em>)</em></td>
<td width="216" valign="top">Regular Expressions</td>
</tr>
<tr>
<td width="365" valign="top">CodeBlock<em>.should Change(</em>&amp;attribute<em>)[.by(</em>num<em>)][.from(</em>num<em>).to(</em>num<em>)]</em></td>
<td width="216" valign="top">Changes in   attributes</td>
</tr>
<tr>
<td width="365" valign="top">CodeBlock<em>.should raise_error([</em>ErrorClass<em>,[</em>Error<em> </em>String/Regexp<em>]])</em></td>
<td width="216" valign="top">Exceptions</td>
</tr>
<tr>
<td width="365" valign="top">CodeBlock<em>.should throw_symbol([</em>Symbol<em>,[</em>Object<em>]])</em></td>
<td width="216" valign="top">Throws</td>
</tr>
<tr>
<td width="365" valign="top"><em>be_</em>xxx<em> (like be_empty)</em></td>
<td width="216" valign="top">Predicate methods   (ending on ?)</td>
</tr>
<tr>
<td width="365" valign="top"><em>have_</em>xxx<em> (like have_key)</em></td>
<td width="216" valign="top">has_xxx? Methods</td>
</tr>
<tr>
<td width="365" valign="top"><em>have(</em>number<em>)[.</em>receiver_method<em>]</em></td>
<td width="216" valign="top">Number informations</td>
</tr>
<tr>
<td width="365" valign="top"><em>be (==,&gt;=,&gt;,&lt;=,&lt;)</em></td>
<td width="216" valign="top">Operators</td>
</tr>
</tbody>
</table>
<ul>
<li>The specify() method can be used when a docstring looks like the code within the expectation.</li>
<li>The subject() method takes a code block and can be used to specify a subject. Once specified, the subject becomes the receiver for every should and should_not.</li>
<li>Subjects can be automatically created when describing a class. RSpec calls the new() method to the object and use it as the subject to the following expectations.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubynoobie.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubynoobie.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubynoobie.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubynoobie.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubynoobie.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubynoobie.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubynoobie.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubynoobie.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubynoobie.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubynoobie.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubynoobie.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubynoobie.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubynoobie.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubynoobie.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubynoobie.wordpress.com&amp;blog=11514194&amp;post=36&amp;subd=rubynoobie&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubynoobie.wordpress.com/2010/01/27/rspec-expectations/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d7556befd6b2a40d5618be1c0340e54a?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">Lucas d'Acampora Prim</media:title>
		</media:content>
	</item>
		<item>
		<title>RSpec Example Building</title>
		<link>http://rubynoobie.wordpress.com/2010/01/26/rspec-example-building/</link>
		<comments>http://rubynoobie.wordpress.com/2010/01/26/rspec-example-building/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 01:33:29 +0000</pubDate>
		<dc:creator>Lucas d'Acampora Prim</dc:creator>
				<category><![CDATA[RSpec]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[examples]]></category>

		<guid isPermaLink="false">http://rubynoobie.wordpress.com/?p=30</guid>
		<description><![CDATA[Some stuff I´ve learned while reading the RSpec book, which is very good as the latest beta version. describe and context are synonyms. Describe is better for actions and Context is better for hm.. well.. contexts! They work by supplying a string that describe the behavior you are trying to test (or a reference to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubynoobie.wordpress.com&amp;blog=11514194&amp;post=30&amp;subd=rubynoobie&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Some stuff I´ve learned while reading the RSpec book, which is very good as the latest beta version.</p>
<ul>
<li><em>describe </em>and <em>context</em> are synonyms. Describe is better for actions and Context is better for hm.. well.. contexts! They work by supplying a string that describe the behavior you are trying to test (or a reference to a class or a Module) and a code block where the expectations should be placed.<br />
<pre class="brush: ruby;">
# some google code...
describe User do
describe &quot;should not be chinese&quot; do
[...]
</pre>
</li>
<li>RSpec supports &#8220;nesting&#8221; to give context to your tests!</li>
<li>The <em>it()</em> method takes a string, an optional hash and an optional code block.</li>
<li><em>it()</em> called with no block is marked as <strong>pending</strong>. Experienced developers recommend writing down everything you want the application to do, even when developing some other code if you remember something you missed, and leave it as pending until you get to it. Very easy to do, isn´t it?</li>
<li>Other ways to set a description to <strong>pending</strong> is by calling the pending() method inside of it. It even supports a code block that gets executed even with the description pending. If the code block succeeds, RSpec alerts you that it has been implemented (actually, it says it is <strong>fixed</strong>).</li>
<li>RSpec provides a <em>before()</em> method that takes supplied code block to be executed before all of the examples inside the context or before each of them. The only argument it takes is :all or :each. It´s highly recommended that you use :each as it starts a new context when checking an example.</li>
<li>The counterpart of the <em>before</em> method is the.. Hmm.. you guessed! The <em>after</em> method. It´s basically the same thing with the same arguments, except it runs after the examples have been executed, even if errors or exceptions are raised.</li>
<li>You can create <em>helper methods</em> that are methods defined inside the context that can be used by all the examples inside that context. It´s useful to keep things clean and DRY-compliant (Don´t Repeat Yourself). However, the goal is to make things clean but without loosing the readability. Keep things consistent!</li>
<li>To share helper methods across contexts, you can create a module with the methods and then include the module within the context.</li>
<li>You can share examples too! just start the example with <em>shared_examples_for &#8220;name&#8221; do [...] end</em> and then call it within the context by using the <em>it_should_behave_like &#8220;name&#8221;</em> method.</li>
<li>Another way to share examples is by creating example modules, with the <em>share_as :Name do [...] end</em> method. When needed, just include the created module inside the context by calling <em>include Name</em>.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubynoobie.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubynoobie.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubynoobie.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubynoobie.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubynoobie.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubynoobie.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubynoobie.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubynoobie.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubynoobie.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubynoobie.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubynoobie.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubynoobie.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubynoobie.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubynoobie.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubynoobie.wordpress.com&amp;blog=11514194&amp;post=30&amp;subd=rubynoobie&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubynoobie.wordpress.com/2010/01/26/rspec-example-building/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d7556befd6b2a40d5618be1c0340e54a?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">Lucas d'Acampora Prim</media:title>
		</media:content>
	</item>
		<item>
		<title>Debugging and Optimizing Ruby Applications</title>
		<link>http://rubynoobie.wordpress.com/2010/01/19/debugging-and-optimizing-ruby-applications/</link>
		<comments>http://rubynoobie.wordpress.com/2010/01/19/debugging-and-optimizing-ruby-applications/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 20:24:17 +0000</pubDate>
		<dc:creator>Lucas d'Acampora Prim</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[bottleneck]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[profiler]]></category>

		<guid isPermaLink="false">http://rubynoobie.wordpress.com/?p=25</guid>
		<description><![CDATA[I´m gonna keep it simple: Ruby has an excellent native debugger, that runs when you insert the -r debug parameter when calling the interpreter, such as this: Debugger commands are: b[reak] [file:]line Set breakpoint at given line in file (default current file). b[reak] [file:]name Set breakpoint at method in file. b[reak] Display breakpoints and watchpoints. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubynoobie.wordpress.com&amp;blog=11514194&amp;post=25&amp;subd=rubynoobie&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I´m gonna keep it simple: Ruby has an excellent native debugger, that runs when you insert the <strong>-r debug</strong> parameter when calling the interpreter, such as this:</p>
<p><pre class="brush: bash;">

ruby -r debug [debug options] [program file] [program arguments]

</pre></p>
<p>Debugger commands are:<br />
<strong> </strong></p>
<table style="height:570px;" border="1" cellspacing="0" cellpadding="0" width="500">
<tbody>
<tr>
<td width="196" valign="top"><strong>b[reak] [file:]line</strong></td>
<td width="449" valign="top">Set   breakpoint at given line in <em>file</em> (default current file).</td>
</tr>
<tr>
<td width="196" valign="top"><strong>b[reak] [file:]name</strong></td>
<td width="449" valign="top">Set breakpoint at <em>method</em> in <em>file</em>.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>b[reak]</strong></td>
<td width="449" valign="top">Display breakpoints and watchpoints.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>wat[ch] expr</strong></td>
<td width="449" valign="top">Break when expression   becomes true.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>del[ete] [nnn]</strong></td>
<td width="449" valign="top">Delete   breakpoint <em>nnn</em> (default all).</td>
</tr>
<tr>
<td width="196" valign="top"><strong>disp[lay] expr</strong></td>
<td width="449" valign="top">Display value of <em>nnn</em> every time debugger gets control.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>disp[lay]</strong></td>
<td width="449" valign="top">Show current displays.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>undisp[lay] [nnn]</strong></td>
<td width="449" valign="top">Remove display (default all).</td>
</tr>
<tr>
<td width="196" valign="top"><strong>c[ont]</strong></td>
<td width="449" valign="top">Continue execution.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>s[tep] nnn=1</strong></td>
<td width="449" valign="top">Execute next <em>nnn</em> lines, stepping into methods.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>n[ext] nnn=1</strong></td>
<td width="449" valign="top">Execute   next <em>nnn</em> lines, stepping over methods.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>fi[nish]</strong></td>
<td width="449" valign="top">Finish execution of the   current function.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>q[uit]</strong></td>
<td width="449" valign="top">Exit the debugger.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>w[here]</strong></td>
<td width="449" valign="top">Display current stack frame.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>f[rame]</strong></td>
<td width="449" valign="top">Synonym for where.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>l[ist] [start--end]</strong></td>
<td width="449" valign="top">List source lines from   start to end.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>up nnn=1</strong></td>
<td width="449" valign="top">Move up   <em>nnn</em> levels in the stack frame.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>down nnn=1</strong></td>
<td width="449" valign="top">Move down <em>nnn</em> levels in the stack frame.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>v[ar] g[lobal]</strong></td>
<td width="449" valign="top">Display global variables.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>v[ar] l[ocal]</strong></td>
<td width="449" valign="top">Display local variables.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>v[ar] i[stance] <em>obj</em></strong></td>
<td width="449" valign="top">Display   instance variables of <em>obj</em>.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>v[ar] c[onst] Name</strong></td>
<td width="449" valign="top">Display constants in   class or module name.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>m[ethod] i[nstance] <em>obj</em></strong></td>
<td width="449" valign="top">Display   instance methods of <em>obj</em>.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>m[ethod] Name</strong></td>
<td width="449" valign="top">Display instance methods   of the class or module name.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>th[read] l[ist]</strong></td>
<td width="449" valign="top">List all threads.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>th[read] [c[ur[rent]]]</strong></td>
<td width="449" valign="top">Display status of current   thread.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>th[read] [c[ur[rent]]] nnn</strong></td>
<td width="449" valign="top">Make   thread <em>nnn</em> current and stop it.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>th[read] stop nnn</strong></td>
<td width="449" valign="top">Make thread <em>nnn</em> current and stop it.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>th[read] resume nnn</strong></td>
<td width="449" valign="top">Resume thread <em>nnn</em>.</td>
</tr>
<tr>
<td width="196" valign="top"><strong>[p] expr</strong></td>
<td width="449" valign="top">Evaluate <em>expr</em> in   the current context. <em>expr</em> may include assignment to variables and   method invocations.</td>
</tr>
<tr>
<td width="196" valign="top"><strong><em>empty</em></strong><strong></strong></td>
<td width="449" valign="top">A null   command repeats the last command.</td>
</tr>
</tbody>
</table>
<p>Source: <a href="http://www.ruby-doc.org/docs/ProgrammingRuby/html/trouble.html" target="_blank">PickAxe</a></p>
<p>When searching for bottlenecks, your best bet is to use the <strong>benchmark </strong>module to check the execution of code chunks. The best thing to learn how to deal with the <strong>benchmark </strong>module is checking its documentation <a href="http://ruby-doc.org/core/classes/Benchmark.html" target="_blank">here</a>.</p>
<p>There´s also an easy way to track your code execution: The <strong>profiler</strong>. To run it, you should just put the <strong>-r profile</strong> parameter when calling the interpreter.</p>
<p><pre class="brush: bash;">

ruby -r profile [program file] [program arguments]

</pre></p>
<p>Seems like an easy way to track down those nasty bottlenecks! Still, the best way to ensure great performance is to keep your code clean and avoid creating unnecessary crap!</p>
<p>Hope I remember this when running after my slow applications cemeteries!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubynoobie.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubynoobie.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubynoobie.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubynoobie.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubynoobie.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubynoobie.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubynoobie.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubynoobie.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubynoobie.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubynoobie.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubynoobie.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubynoobie.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubynoobie.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubynoobie.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubynoobie.wordpress.com&amp;blog=11514194&amp;post=25&amp;subd=rubynoobie&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubynoobie.wordpress.com/2010/01/19/debugging-and-optimizing-ruby-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d7556befd6b2a40d5618be1c0340e54a?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">Lucas d'Acampora Prim</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting to know ruby exceptions</title>
		<link>http://rubynoobie.wordpress.com/2010/01/18/getting-to-know-ruby-exceptions/</link>
		<comments>http://rubynoobie.wordpress.com/2010/01/18/getting-to-know-ruby-exceptions/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 23:23:38 +0000</pubDate>
		<dc:creator>Lucas d'Acampora Prim</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[catch]]></category>
		<category><![CDATA[ensure]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[error handling]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[exception handling]]></category>
		<category><![CDATA[rescue]]></category>
		<category><![CDATA[throw]]></category>

		<guid isPermaLink="false">http://rubynoobie.wordpress.com/?p=6</guid>
		<description><![CDATA[Today i was reading the chapter 10 of my Programming Ruby book, about Ruby Exception Handling, Catch and Throw. Found some really interesting stuff, as usual, and i´m gonna write it all down here. Exception Objects Ruby lets you insert exception/error information into an object of class Exception (or its children). This object is passed [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubynoobie.wordpress.com&amp;blog=11514194&amp;post=6&amp;subd=rubynoobie&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today i was reading the chapter 10 of my Programming Ruby book, about Ruby Exception Handling, Catch and Throw. Found some really interesting stuff, <em>as usual</em>, and i´m gonna write it all down here.</p>
<h2>Exception Objects</h2>
<p>Ruby lets you insert exception/error information into an object of class<strong> Exception </strong>(or its children). This object is passed to the preceding code, searching for a declaration that some code is capable of handling that exception. You can create your own <strong>Exception </strong>classes. To do this, all you need is to make your class children of <strong>StandardError </strong>or one of its children. It´s as simple as it gets:</p>
<p><pre class="brush: ruby;">
class SomeVeryNastyError &lt; StandardError
end
</pre></p>
<h2>Error Handling</h2>
<p>Things useful to know when dealing with error handling:</p>
<ul>
<li>To cast an exception, just use the <strong>raise </strong>or <strong>Kernel.raise</strong> method. Arguments can be: <strong>raise [Exception class, [Message, [Callback array]]]</strong></li>
</ul>
<ul>
<li>The code that is gonna have exception handling should be wrapped inside a <em>begin/rescue/end</em> block if it´s multilined <strong>or</strong> you can use <a title="Ruby´s Rescue as a Statement Modifier" href="http://whynotwiki.com/Ruby_/_Exception_handling#The_rescue_statement_modifier" target="_blank">rescue as a statement modifier</a> for single-lines. The arguments to rescue clause are the exception classes it can handle (comma-separated) and an optional local variable to store a reference to the <strong>Exception </strong>object.<br />
<pre class="brush: ruby;">
begin
# some code...
rescue MyError, BadError, StandardError =&gt; err_reference
#rescue stuff...
end
</pre></li>
<li> Along with <em>rescue</em>, there are the <em>else</em> clause and the <em>ensure</em> clause:<br />
Code inside the <em>else</em> clause will execute if no exceptions happen;<br />
Code inside the <em>ensure</em> clause is always executed when the block terminates.<br />
<pre class="brush: ruby;">
begin
  # some code is executing and..
  raise SomeVeryNastyError, &quot;Very nasty error occurred!&quot;
rescue SomeVeryNastyError =&gt; err_reference
  # here comes the rescue!
  puts &quot;An error ocurred: #{err_reference.inspect}&quot;
  # rescue code ...
else
  puts &quot;No error occurred!&quot;
ensure
  # having an error or not ...
  puts &quot;execution ended!&quot;
end
</pre></li>
<li>There can be multiple <em>rescue</em> clauses within a block.<br />
<pre class="brush: ruby;">
begin
#some code
rescue ForcedError
puts &quot;Forced Error occurred!&quot;
rescue StandardError
puts &quot;Standard Error occurred!&quot;
end
</pre></li>
<li>A reference to the associated raised Exception object is placed into the global variable <strong>$! </strong></li>
</ul>
<ul>
<li>Within a <em>rescue</em> clause, you can call the <strong>retry</strong> method, so that the code block begins its execution again.</li>
</ul>
<ul>
<li>You can add your own attributes and methods to your <strong>Exception </strong>classes.<br />
<pre class="brush: ruby;">
class MyError &lt; StandardError
attr_reader :ok_to_retry
def initialize(retry)
@ok_to_retry = retry
end
end
begin
#some code ...
raise MyError(true)
rescue MyError
if $1.ok_to_retry
    puts &quot;Retrying...&quot;
    retry
  else
    puts &quot;Not retrying!&quot;
  end
end
</pre></li>
</ul>
<h2>Catch and Throw</h2>
<p>If you ever need to get a signal to terminate execution of some code, you will be in good hands when using <strong>catch </strong>and <strong>throw</strong>.</p>
<p>Firstly, you specify what to &#8220;catch&#8221;: it can be a Symbol or a String. A code block comes after and will be executed until it runs to the end or until the specified catch argument is thrown with the <strong>throw</strong> method. The <strong>throw</strong> method supports two arguments: a Symbol/String and a <em>return value</em>.</p>
<p><pre class="brush: ruby;">
a = catch(:fire) do
  puts &quot;Catching fire now!&quot;
  throw(:fire,&quot;fireee!&quot;)
end
puts a
# =&gt; fireee!
</pre></p>
<p>And that´s it for today! I´m heading towards chapter 11 of Programming Ruby tonight!<br />
Feel free to post comments and examples in order to help me and the other fellas!</p>
<p>Other references: <a title="Programming Ruby Exception Handling" href="http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html" target="_blank">Programming Ruby</a> &#8211; <a href="http://www.skorks.com/2009/09/ruby-exceptions-and-exception-handling/" target="_blank">Skorks post on exceptions</a> &#8211; <a href="http://www.google.com/search?q=ruby+exceptions" target="_blank">Google</a></p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=bb5bbc97-fa51-8e7f-a639-94af195d0a16" alt="" /></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubynoobie.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubynoobie.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubynoobie.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubynoobie.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubynoobie.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubynoobie.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubynoobie.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubynoobie.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubynoobie.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubynoobie.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubynoobie.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubynoobie.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubynoobie.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubynoobie.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubynoobie.wordpress.com&amp;blog=11514194&amp;post=6&amp;subd=rubynoobie&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubynoobie.wordpress.com/2010/01/18/getting-to-know-ruby-exceptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d7556befd6b2a40d5618be1c0340e54a?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">Lucas d'Acampora Prim</media:title>
		</media:content>

		<media:content url="http://img.zemanta.com/pixy.gif?x-id=bb5bbc97-fa51-8e7f-a639-94af195d0a16" medium="image" />
	</item>
		<item>
		<title>Hello world!</title>
		<link>http://rubynoobie.wordpress.com/2010/01/18/hello-world/</link>
		<comments>http://rubynoobie.wordpress.com/2010/01/18/hello-world/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 21:02:50 +0000</pubDate>
		<dc:creator>Lucas d'Acampora Prim</dc:creator>
				<category><![CDATA[Personal Comments]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[personal]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Hello everyone! My name is Lucas d&#8217;Acampora Prim and i´m a Ruby Noobie! After spending about ten years programming PHP and playing with some low-level C++, i´ve decided to make programming as fun as it gets, and Ruby seems to be the gemstone that is gonna provide me that. Equipped with my Programming Ruby 1.9 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubynoobie.wordpress.com&amp;blog=11514194&amp;post=1&amp;subd=rubynoobie&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello everyone!</p>
<p>My name is Lucas d&#8217;Acampora Prim and i´m a Ruby Noobie!</p>
<p>After spending about ten years programming PHP and playing with some low-level C++, i´ve decided to make programming as fun as it gets, and Ruby seems to be the gemstone that is gonna provide me that. Equipped with my <em>Programming Ruby 1.9</em> by Dave Thomas (<a title="Amazon: Programming Ruby 1.9" href="http://www.amazon.com/Programming-Ruby-1-9-Pragmatic-Programmers/dp/1934356085/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1263849568&amp;sr=8-1" target="_blank">Amazon it!</a>) i´m starting to get what this language has to offer and, believe me, i´m wowing.</p>
<p>Every time i´m learning something, i do it better by playing with it: writing it down, trying some examples, creating exercices, among other <em>weird</em> stuff so, as i want to learn to program in Ruby by the <span style="text-decoration:line-through;">only</span> best way i know, i´ve decided to create a place to write down every single <em>nuance</em> of the language and, not being a greedy selfish world-dominator nerd, i thought: &#8211; <em>Oh! Why not creating a blog where everything learned get documented and publicated?</em></p>
<p>That´s what i am doing right now! Ruby Noobie is my way to document the things i´m learning and to make this content publicly-available, helping other people along their way to learn this astonishing programming language!</p>
<p>So welcome to Ruby Noobie! I´d love to see this blog as a space to learn with other beginners and as a way to learn Ruby (and Rails, of course!) while having fun!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rubynoobie.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rubynoobie.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rubynoobie.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rubynoobie.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rubynoobie.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rubynoobie.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rubynoobie.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rubynoobie.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rubynoobie.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rubynoobie.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rubynoobie.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rubynoobie.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rubynoobie.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rubynoobie.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rubynoobie.wordpress.com&amp;blog=11514194&amp;post=1&amp;subd=rubynoobie&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rubynoobie.wordpress.com/2010/01/18/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d7556befd6b2a40d5618be1c0340e54a?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">Lucas d'Acampora Prim</media:title>
		</media:content>
	</item>
	</channel>
</rss>
