<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-1601257872697763756</atom:id><lastBuildDate>Sun, 22 Sep 2024 19:23:14 +0000</lastBuildDate><category>testing</category><category>Hint</category><category>RSpec</category><category>bdd</category><category>best practices</category><category>first</category><category>focused</category><category>question</category><category>rails</category><category>request for comments</category><category>ruby on rails</category><category>small</category><category>tdd</category><category>test frameworks</category><category>test/unit</category><category>textmate</category><category>welcome</category><title>test practices</title><description>This blog is about best practices concerning testing Ruby on Rails applications.</description><link>http://testpractices.blogspot.com/</link><managingEditor>noreply@blogger.com (Thorsten Böttger)</managingEditor><generator>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1601257872697763756.post-547478264639695135</guid><pubDate>Thu, 11 Jun 2009 20:28:00 +0000</pubDate><atom:updated>2009-06-11T22:43:54.147+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">focused</category><category domain="http://www.blogger.com/atom/ns#">test/unit</category><category domain="http://www.blogger.com/atom/ns#">textmate</category><title>Run focused tests in TextMate with test/unit</title><description>If you are using TextMate version 1.5.8 (1498) and want to run focused test (⌘-shift-r) with the test/unit notation&lt;div&gt;&lt;br /&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;&lt;span class=&quot;meta meta_rails meta_rails_unit_test&quot;&gt;&lt;span class=&quot;meta meta_class meta_class_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_class keyword_control_class_ruby&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby&quot;&gt;SimpleTest&lt;span class=&quot;entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby&quot;&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby&quot;&gt;&amp;lt;&lt;/span&gt; Test::Unit::TestCase&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;test &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;simple me&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;    &lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; test code&lt;br /&gt;&lt;/span&gt;  &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;then modify the file&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&quot;text text_plain&quot;&gt;&lt;span class=&quot;meta meta_paragraph meta_paragraph_text&quot;&gt;/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/RubyMate/run_script.rb&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;and add lines 1, 5-7 and 15-16&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&quot;linenum&quot;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;  spec&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; context&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; test_name &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant constant_language constant_language_ruby&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;constant constant_language constant_language_ruby&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;constant constant_language constant_language_ruby&quot;&gt;nil&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    2&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    3&lt;/span&gt;   &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;open&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;meta meta_environment-variable meta_environment-variable_ruby&quot;&gt;&lt;span class=&quot;variable variable_other variable_other_constant variable_other_constant_ruby&quot;&gt;ENV&lt;/span&gt;[&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;TM_FILEPATH&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;]&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;variable variable_other variable_other_block variable_other_block_ruby&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    4&lt;/span&gt; &lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;    &lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; test/unit&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    5&lt;/span&gt;     lines     &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; f&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;read&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;split&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;constant constant_numeric constant_numeric_ruby&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;...&lt;/span&gt;n&lt;span class=&quot;punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;reverse&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    6&lt;/span&gt;     name      &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; lines&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;find &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block&quot;&gt; &lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;variable variable_other variable_other_block variable_other_block_ruby&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt; line &lt;span class=&quot;keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby&quot;&gt;=~&lt;/span&gt; &lt;span class=&quot;string string_regexp string_regexp_classic string_regexp_classic_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;^&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;*def test&lt;span class=&quot;string string_regexp string_regexp_character-class string_regexp_character-class_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby&quot;&gt;[&lt;/span&gt;_a-z0-9&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby&quot;&gt;]&lt;/span&gt;&lt;/span&gt;*&lt;span class=&quot;string string_regexp string_regexp_character-class string_regexp_character-class_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\?&lt;/span&gt;!&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby&quot;&gt;]&lt;/span&gt;&lt;/span&gt;?&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/i&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;to_s&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;sub&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_regexp string_regexp_classic string_regexp_classic_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;^&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;*def &lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;.*?&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;*$&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block&quot;&gt; &lt;/span&gt;&lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_pre-defined variable_other_readwrite_global_pre-defined_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;$&lt;/span&gt;1&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    7&lt;/span&gt; &lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;    &lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; ActiveSupport::Testing::Declarative#test&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    8&lt;/span&gt; &lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;    &lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; to use the new test &quot;&quot; do;end syntax&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    9&lt;/span&gt;     test_name &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_pre-defined variable_other_readwrite_global_pre-defined_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;$&lt;/span&gt;3&lt;/span&gt; &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_pre-defined variable_other_readwrite_global_pre-defined_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;$&lt;/span&gt;4&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;if&lt;/span&gt; lines&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;find &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block&quot;&gt; &lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;variable variable_other variable_other_block variable_other_block_ruby&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt; line &lt;span class=&quot;keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby&quot;&gt;=~&lt;/span&gt; &lt;span class=&quot;string string_regexp string_regexp_classic string_regexp_classic_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;^&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;*&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;test&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;+&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;&#39;&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;.*&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&#39;|&quot;&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;.*&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&quot;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;+&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;*&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\{&lt;/span&gt;|do&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   10&lt;/span&gt; &lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;    &lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; test/spec.&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   11&lt;/span&gt;     spec      &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_pre-defined variable_other_readwrite_global_pre-defined_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;$&lt;/span&gt;3&lt;/span&gt; &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_pre-defined variable_other_readwrite_global_pre-defined_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;$&lt;/span&gt;4&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;if&lt;/span&gt; lines&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;find &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block&quot;&gt; &lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;variable variable_other variable_other_block variable_other_block_ruby&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt; line &lt;span class=&quot;keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby&quot;&gt;=~&lt;/span&gt; &lt;span class=&quot;string string_regexp string_regexp_classic string_regexp_classic_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;^&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;*&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;specify|it&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;+&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;&#39;&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;.*&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&#39;|&quot;&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;.*&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&quot;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;+&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;*&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\{&lt;/span&gt;|do&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   12&lt;/span&gt;     context   &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_pre-defined variable_other_readwrite_global_pre-defined_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;$&lt;/span&gt;3&lt;/span&gt; &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_global variable_other_readwrite_global_pre-defined variable_other_readwrite_global_pre-defined_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;$&lt;/span&gt;4&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;if&lt;/span&gt; lines&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;find &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block&quot;&gt; &lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;variable variable_other variable_other_block variable_other_block_ruby&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt; line &lt;span class=&quot;keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby&quot;&gt;=~&lt;/span&gt; &lt;span class=&quot;string string_regexp string_regexp_classic string_regexp_classic_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;^&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;*&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;context|describe&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;+&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;&#39;&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;.*&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&#39;|&quot;&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;.*&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&quot;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;+&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;*&lt;span class=&quot;string string_regexp string_regexp_group string_regexp_group_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\{&lt;/span&gt;|do&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   13&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   14&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   15&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;if&lt;/span&gt; name &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;!&lt;/span&gt;name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;empty?&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   16&lt;/span&gt;     args &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;--name=&lt;span class=&quot;source source_ruby source_ruby_embedded source_ruby_embedded_source&quot;&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;#{&lt;/span&gt;name&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   17&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;elsif&lt;/span&gt; test_name &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;!&lt;/span&gt;test_name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;empty?&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   18&lt;/span&gt;     args &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;--name=test_&lt;span class=&quot;source source_ruby source_ruby_embedded source_ruby_embedded_source&quot;&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;#{&lt;/span&gt;test_name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;gsub&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_regexp string_regexp_classic string_regexp_classic_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\s&lt;/span&gt;+&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;_&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   19&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;elsif&lt;/span&gt; spec &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;!&lt;/span&gt;spec&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;empty? &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;and&lt;/span&gt; context &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby&quot;&gt;!&lt;/span&gt;context&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;empty?&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   20&lt;/span&gt;     args &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby string_quoted_double_ruby_mod&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;%Q{&lt;/span&gt;--name=&quot;/test_spec &lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;{&lt;/span&gt;.*&lt;span class=&quot;source source_ruby source_ruby_embedded source_ruby_embedded_source&quot;&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;#{&lt;/span&gt;context&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\\&lt;/span&gt;d&lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;{&lt;/span&gt;3&lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\\&lt;/span&gt;[&lt;span class=&quot;source source_ruby source_ruby_embedded source_ruby_embedded_source&quot;&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;#{&lt;/span&gt;spec&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;constant constant_character constant_character_escape constant_character_escape_ruby&quot;&gt;\\&lt;/span&gt;]/&quot;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   21&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   22&lt;/span&gt;     puts &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;Error:  This doesn&#39;t appear to be a TestCase or spec.&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   23&lt;/span&gt;     exit&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   24&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   25&lt;/span&gt; &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://testpractices.blogspot.com/2009/06/run-focused-tests-in-textmate-with.html</link><author>noreply@blogger.com (Thorsten Böttger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1601257872697763756.post-5572368478269579115</guid><pubDate>Sun, 30 Nov 2008 20:05:00 +0000</pubDate><atom:updated>2008-11-30T21:08:22.741+01:00</atom:updated><title>Sometimes</title><description>Have a look at this interesting &lt;a href=&quot;http://giantrobots.thoughtbot.com/2008/11/7/a-critical-look-at-the-current-state-of-ruby-testing&quot;&gt;blog post from Dan Croak&lt;/a&gt; about questioning current testing methods.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://testpractices.blogspot.com/2008/11/sometimes.html</link><author>noreply@blogger.com (Thorsten Böttger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1601257872697763756.post-12879357375599839</guid><pubDate>Thu, 24 Jul 2008 07:56:00 +0000</pubDate><atom:updated>2008-07-24T10:08:32.244+02:00</atom:updated><title>Remember to reload your associations in your tests</title><description>Save time by reloading your associations when using RSpec.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&#39;linenum&#39;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rspec&quot;&gt;&lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; your_object.rb&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;    2&lt;/span&gt; &lt;span class=&quot;meta meta_class meta_class_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_class keyword_control_class_ruby&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby&quot;&gt;YourObject&lt;span class=&quot;entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby&quot;&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    3&lt;/span&gt;   &lt;span class=&quot;meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_def keyword_control_def_ruby&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_function entity_name_function_ruby&quot;&gt;your_method&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    4&lt;/span&gt;     &lt;span class=&quot;variable variable_language variable_language_ruby&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;your_association &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;TestObject&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby&quot;&gt;new&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    5&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    6&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    7&lt;/span&gt; &lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    8&lt;/span&gt; &lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; your_object_spec.rb&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;    9&lt;/span&gt; &lt;span class=&quot;meta meta_rspec meta_rspec_example&quot;&gt;&lt;span class=&quot;keyword keyword_other keyword_other_rspec keyword_other_rspec_example&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should test your_method&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block&quot;&gt;do&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;   10&lt;/span&gt;   lambda &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block&quot;&gt; &lt;/span&gt;your_object&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;your_method &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should change&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;your_object&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;your_association&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;size&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;   &lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; =&amp;gt; no change, test fails....&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;   11&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;   12&lt;/span&gt; &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Just put a reload after your association call:&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&#39;linenum&#39;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rspec&quot;&gt;&lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; your_object_spec.rb&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;    2&lt;/span&gt; &lt;span class=&quot;meta meta_rspec meta_rspec_example&quot;&gt;&lt;span class=&quot;keyword keyword_other keyword_other_rspec keyword_other_rspec_example&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should test your_method&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block&quot;&gt;do&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    3&lt;/span&gt;   lambda &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block&quot;&gt; &lt;/span&gt;your_object&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;your_method &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should change&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;your_object&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;your_association&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;reload&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;size&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;   &lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; =&amp;gt; association reloads and the test succeeds&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;    4&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;</description><link>http://testpractices.blogspot.com/2008/07/remember-to-reload-your-associations-in.html</link><author>noreply@blogger.com (Benjamin Behr)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1601257872697763756.post-5267274076478739064</guid><pubDate>Mon, 21 Jul 2008 23:04:00 +0000</pubDate><atom:updated>2008-07-22T02:04:44.488+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Hint</category><category domain="http://www.blogger.com/atom/ns#">RSpec</category><category domain="http://www.blogger.com/atom/ns#">testing</category><title>ordered method testing with rspec</title><description>Since I am learning RSpec for Rails I wonder how to write a test which tests the order of the methods called by my method. Now I found a solution which works. The answer is simple: should_receive takes a block which is called after the assertion of the should_receive ran.&lt;br /&gt;&lt;br /&gt;Your code may look like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&#39;linenum&#39;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;&lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; user.rb&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;    2&lt;/span&gt; &lt;span class=&quot;meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_def keyword_control_def_ruby&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_function entity_name_function_ruby&quot;&gt;change_my_attributes&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;variable variable_parameter variable_parameter_function variable_parameter_function_ruby&quot;&gt;name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt;login&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt;password&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    3&lt;/span&gt;   &lt;span class=&quot;variable variable_language variable_language_ruby&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; name&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    4&lt;/span&gt;   &lt;span class=&quot;variable variable_language variable_language_ruby&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;login &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; login&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    5&lt;/span&gt;   &lt;span class=&quot;variable variable_language variable_language_ruby&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;password &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; password&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    6&lt;/span&gt;   save!&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    7&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    8&lt;/span&gt; &lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;    9&lt;/span&gt; &lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; user_spec.rb&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;   10&lt;/span&gt; it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should run my methods in #change_my_attributes in the correct order&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;   11&lt;/span&gt;   &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt; &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby&quot;&gt;new&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;   12&lt;/span&gt;   &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should_receive&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;name=&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;   13&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should_receive&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;login=&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;   14&lt;/span&gt;       &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should_receive&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;password=&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&#39;linenum&#39;&gt;   15&lt;/span&gt;         &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should_receive&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;save!&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;   16&lt;/span&gt;       &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;   17&lt;/span&gt;     &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;   18&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;   19&lt;/span&gt;   &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;change_my_attributes&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;foo&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;bar&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;foobar&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&#39;linenum&#39;&gt;   20&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Looks kind of ugly but it works...</description><link>http://testpractices.blogspot.com/2008/07/ordered-method-testing-with-rspec.html</link><author>noreply@blogger.com (Benjamin Behr)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1601257872697763756.post-5468318957873016214</guid><pubDate>Mon, 14 Jul 2008 19:08:00 +0000</pubDate><atom:updated>2008-07-14T21:10:08.038+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">question</category><category domain="http://www.blogger.com/atom/ns#">request for comments</category><category domain="http://www.blogger.com/atom/ns#">test frameworks</category><title>test/unit, test/spec, RSpec, shoulda</title><description>Who has experience with two of these test frameworks, and can tell about this? Which one is better, and why?</description><link>http://testpractices.blogspot.com/2008/07/rspec.html</link><author>noreply@blogger.com (Thorsten Böttger)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1601257872697763756.post-2948661764700073678</guid><pubDate>Sat, 12 Jul 2008 19:43:00 +0000</pubDate><atom:updated>2008-07-12T21:58:31.818+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">small</category><title>Keep your tests small</title><description>Keeping your tests small sounds a bit odd, but it&#39;s quite easy to get in a test flow and to write spaghetti tests, testing too much at once. Stay focussed on what to test, and just test this single aspect of your code!&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&quot;linenum&quot;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;&lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; don&#39;t do this!&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    2&lt;/span&gt; describe &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;A user&#39;s display name&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    3&lt;/span&gt;   it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should reflect the user&#39;s name&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    4&lt;/span&gt;     user &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;login&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_key-value&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;alto&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    5&lt;/span&gt;     user&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;display_name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should eql&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;alto&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    6&lt;/span&gt;  &lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    7&lt;/span&gt;     user&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;firstname &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Thorsten&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    8&lt;/span&gt;     user&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;display_name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should eql&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Thorsten&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    9&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   10&lt;/span&gt;     user&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;lastname &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Böttger&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   11&lt;/span&gt;     user&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;display_name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should eql&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Thorsten Böttger&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   12&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   13&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   14&lt;/span&gt; &lt;/pre&gt;This test is hard to read, since it tests three aspects at once. Even the dscription block is a bit ambiguous. The test is unfocused, and as a matter of result, in case your test contains an error itself, it&#39;s hard to debug. The following three tests are much better:&lt;br /&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&quot;linenum&quot;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;&lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; much better&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    2&lt;/span&gt; describe &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;A user&#39;s display name&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    3&lt;/span&gt;   before &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    4&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt; &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;login&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_key-value&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;alto&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    5&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    6&lt;/span&gt;   it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should equal the login name if no other name is given&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    7&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;display_name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should eql&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;alto&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    8&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    9&lt;/span&gt;   it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should equal his firstname if it is given&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   10&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;firstname &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Thorsten&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   11&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;display_name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should eql&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Thorsten&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   12&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   13&lt;/span&gt;   it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should equal his fullname if firstname and lastname are given&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   14&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;firstname &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Thorsten&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   15&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;lastname &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Böttger&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   16&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;user&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;display_name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should eql&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Thorsten Böttger&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   17&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   18&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   19&lt;/span&gt; &lt;/pre&gt;</description><link>http://testpractices.blogspot.com/2008/07/keep-your-tests-small.html</link><author>noreply@blogger.com (Thorsten Böttger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1601257872697763756.post-6285131626467337249</guid><pubDate>Sat, 28 Jun 2008 20:29:00 +0000</pubDate><atom:updated>2008-06-28T22:51:12.496+02:00</atom:updated><title>Hide external access behind a small facade for easy mocking</title><description>Imagine you have validation like this, where you call the youtube website to make sure the provided video id is valid:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;&lt;span class=&quot;meta meta_rails meta_rails_model&quot;&gt;&lt;span class=&quot;meta meta_class meta_class_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_class keyword_control_class_ruby&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby&quot;&gt;Video&lt;span class=&quot;entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby&quot;&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    2&lt;/span&gt;   &lt;span class=&quot;meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_def keyword_control_def_ruby&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_function entity_name_function_ruby&quot;&gt;validate&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    3&lt;/span&gt;     response &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;Net&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_other punctuation_separator_other_ruby&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;support support_class support_class_ruby&quot;&gt;HTTP&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;start&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;youtube.com&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block&quot;&gt; &lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;variable variable_other variable_other_block variable_other_block_ruby&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt; http&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;head&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;/v/&lt;span class=&quot;source source_ruby source_ruby_embedded source_ruby_embedded_source&quot;&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;variable variable_language variable_language_ruby&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;youtube_video_id&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    4&lt;/span&gt;     &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;unless&lt;/span&gt; response&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;is_a?&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;support support_class support_class_ruby&quot;&gt;Net&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_other punctuation_separator_other_ruby&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;variable variable_other variable_other_constant variable_other_constant_ruby&quot;&gt;HTTPOK&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    5&lt;/span&gt;       errors&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;add&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;youtube_video_id&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;no valid Youtube Video ID&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    6&lt;/span&gt;     &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    7&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    8&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    9&lt;/span&gt; &lt;/pre&gt;Actually, this code fragment is a pain in the neck to test. If you hide the external access behind a small facade (or wrapper if you like) like this:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&quot;linenum&quot;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;&lt;span class=&quot;meta meta_class meta_class_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_class keyword_control_class_ruby&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby&quot;&gt;YouTube&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    2&lt;/span&gt;   &lt;span class=&quot;meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_def keyword_control_def_ruby&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_function entity_name_function_ruby&quot;&gt;self.video_id_valid?&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;variable variable_parameter variable_parameter_function variable_parameter_function_ruby&quot;&gt;video_id&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    3&lt;/span&gt;     response &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;Net&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_other punctuation_separator_other_ruby&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;support support_class support_class_ruby&quot;&gt;HTTP&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;start&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;youtube.com&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;variable variable_other variable_other_block variable_other_block_ruby&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby&quot;&gt;|&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    4&lt;/span&gt;       http&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;head&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;/v/&lt;span class=&quot;source source_ruby source_ruby_embedded source_ruby_embedded_source&quot;&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;variable variable_language variable_language_ruby&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;youtube_video_id&lt;span class=&quot;punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    5&lt;/span&gt;     &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    6&lt;/span&gt;     response&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;is_a?&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;Net&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_other punctuation_separator_other_ruby&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;variable variable_other variable_other_constant variable_other_constant_ruby&quot;&gt;HTTPOK&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    7&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    8&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    9&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   10&lt;/span&gt; &lt;span class=&quot;meta meta_rails meta_rails_model&quot;&gt;&lt;span class=&quot;meta meta_class meta_class_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_class keyword_control_class_ruby&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby&quot;&gt;Video&lt;span class=&quot;entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby&quot;&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   11&lt;/span&gt;   &lt;span class=&quot;meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_def keyword_control_def_ruby&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_function entity_name_function_ruby&quot;&gt;validate&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   12&lt;/span&gt;     &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;Youtube&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;video_id_valid?&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;variable variable_language variable_language_ruby&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;youtube_video_id&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   13&lt;/span&gt;       errors&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;add&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;youtube_video_id&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;no valid Youtube Video ID&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   14&lt;/span&gt;     &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   15&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   16&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   17&lt;/span&gt; &lt;/pre&gt;it&#39;s much easier to test:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&quot;linenum&quot;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;&lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; video_spec.rb&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    2&lt;/span&gt; describe &lt;span class=&quot;variable variable_other variable_other_constant variable_other_constant_ruby&quot;&gt;Video&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;validations&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    3&lt;/span&gt;   before&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;each&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    4&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;video&lt;/span&gt; &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;Video&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;youtube_video_id&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_key-value&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;iY6VroKoB8E&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    5&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    6&lt;/span&gt;   it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should succeed with correct youtube video id&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    7&lt;/span&gt;     &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;Youtube&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;stub!&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;video_id_valid?&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;and_return&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_language constant_language_ruby&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    8&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;video&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should be_valid&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    9&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   10&lt;/span&gt;   it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should fail with incorrect youtube video id&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   11&lt;/span&gt;     &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;Youtube&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;stub!&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;video_id_valid?&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;and_return&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_language constant_language_ruby&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   12&lt;/span&gt;     &lt;span class=&quot;variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby&quot;&gt;@&lt;/span&gt;video&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should_not be_valid&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   13&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   14&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   15&lt;/span&gt; &lt;/pre&gt;</description><link>http://testpractices.blogspot.com/2008/06/hide-external-access-behind-small.html</link><author>noreply@blogger.com (Thorsten Böttger)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1601257872697763756.post-1327662059694367580</guid><pubDate>Mon, 09 Jun 2008 10:13:00 +0000</pubDate><atom:updated>2008-06-22T13:11:59.300+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">bdd</category><category domain="http://www.blogger.com/atom/ns#">first</category><category domain="http://www.blogger.com/atom/ns#">tdd</category><title>Test first</title><description>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe-aHo5J4U4tDELWKHmbcctiLFqsrJN6ydpldSA-zSEN1W2HZ8o6iVHhR-oGb3r4-6IyUyYSNbf6NJ8qrSoQdvXctzNHlw8xykyPWQwKLoJiQKhd_yQ3_3DsL67nSXZA824AO-twZGVpq3/s1600-h/test_first.jpg&quot;&gt;&lt;img style=&quot;float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe-aHo5J4U4tDELWKHmbcctiLFqsrJN6ydpldSA-zSEN1W2HZ8o6iVHhR-oGb3r4-6IyUyYSNbf6NJ8qrSoQdvXctzNHlw8xykyPWQwKLoJiQKhd_yQ3_3DsL67nSXZA824AO-twZGVpq3/s320/test_first.jpg&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5214661953946125586&quot; /&gt;&lt;/a&gt;&lt;div&gt;There is a long history of postings and even books written about this topic. Most of the time it is called test-driven development (or design resp.) or behavior-driven development, what doesn&#39;t matter now. The important thing about it is that you do it first, before writing a single line of code.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;Why should I do that?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Most important, it helps you to look at your application from a different point of view. You just concentrate on the desired behavior, and don&#39;t think about the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: italic;&quot;&gt;how&lt;/span&gt; (you would do it), just the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: italic;&quot;&gt;what&lt;/span&gt; (to do). Next, when writing the tests after your code, you simply test too much or too less, and are too close to the implementation details. And finally, it&#39;s best practice to write a test first for every bug you encounter, just to reproduce the error and make sure that it will never ever happen again!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;Are there any problems?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;One might say your tests are too integrative, meaning that you focus on more than the unit to test, and you probably and simply test too much. But I think it&#39;s just a matter of experience, and at the end you can optimize your tests just like the application code later on.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;A simple example&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You start by describing what your application, method or class should behave like. The &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: italic;&quot;&gt;user&lt;/span&gt; model in this case:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&quot;linenum&quot;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;&lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; user_spec.rb&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    2&lt;/span&gt; describe &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;A user&#39;s display name&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    3&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    4&lt;/span&gt;   it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should equal his/her login if no other name is available&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    5&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    6&lt;/span&gt;   it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should equal his/her full name if available&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    7&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    8&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    9&lt;/span&gt; &lt;/pre&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What do we have here? First, at line 1 we defined a context for our test, using RSpec&#39;s describe block (have a look at &lt;a href=&quot;http://rspec.info/&quot;&gt;RSpec documentation&lt;/a&gt; for details). Furthermore we have two behaviors (it-blocks), defining what we expect our system to behave like. Let&#39;s go a step further and fill these up a bit:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&quot;linenum&quot;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;&lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; user_spec.rb&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    2&lt;/span&gt; describe &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;A user&#39;s display name&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    3&lt;/span&gt;   it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should equal his/her login name if no other is available&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    4&lt;/span&gt;     user &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;login&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_key-value&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;dude&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    5&lt;/span&gt;     user&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;display_name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should eql&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;dude&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    6&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    7&lt;/span&gt;   it &lt;span class=&quot;string string_quoted string_quoted_double string_quoted_double_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&quot;&lt;/span&gt;should equal his/her full name if available&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby&quot;&gt;do&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    8&lt;/span&gt;     user &lt;span class=&quot;keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;support support_class support_class_ruby&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;login&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_key-value&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;dude&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;constant constant_other constant_other_symbol constant_other_symbol_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby&quot;&gt;:&lt;/span&gt;name&lt;/span&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_key-value&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Thorsten Böttger&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    9&lt;/span&gt;     user&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;display_name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;should eql&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;string string_quoted string_quoted_single string_quoted_single_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby&quot;&gt;&#39;&lt;/span&gt;Thorsten Böttger&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby&quot;&gt;&#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   10&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;   11&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;   12&lt;/span&gt; &lt;/pre&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;At the very end, you write the application code, and fire up the tests to check, if it behaves&lt;/div&gt;&lt;div&gt;the way you wanted while writing the tests:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;span class=&quot;linenum&quot;&gt;    1&lt;/span&gt; &lt;span class=&quot;source source_ruby source_ruby_rails&quot;&gt;&lt;span class=&quot;comment comment_line comment_line_number-sign comment_line_number-sign_ruby&quot;&gt;&lt;span class=&quot;punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby&quot;&gt;#&lt;/span&gt; user.rb&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    2&lt;/span&gt; &lt;span class=&quot;meta meta_rails meta_rails_model&quot;&gt;&lt;span class=&quot;meta meta_class meta_class_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_class keyword_control_class_ruby&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby&quot;&gt;User&lt;span class=&quot;entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby&quot;&gt; &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    3&lt;/span&gt;   &lt;span class=&quot;meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby&quot;&gt;&lt;span class=&quot;keyword keyword_control keyword_control_def keyword_control_def_ruby&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;entity entity_name entity_name_function entity_name_function_ruby&quot;&gt;display_name&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    4&lt;/span&gt;     name&lt;span class=&quot;punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby&quot;&gt;.&lt;/span&gt;blank? &lt;span class=&quot;keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby&quot;&gt;?&lt;/span&gt; login &lt;span class=&quot;punctuation punctuation_separator punctuation_separator_other punctuation_separator_other_ruby&quot;&gt;:&lt;/span&gt; name&lt;br /&gt;&lt;span class=&quot;linenum&quot;&gt;    5&lt;/span&gt;   &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    6&lt;/span&gt; &lt;span class=&quot;keyword keyword_control keyword_control_ruby&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;linenum&quot;&gt;    7&lt;/span&gt; &lt;/pre&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre class=&quot;textmate-source&quot;&gt;&lt;br /&gt;&lt;/pre&gt;</description><link>http://testpractices.blogspot.com/2008/06/test-first.html</link><author>noreply@blogger.com (Thorsten Böttger)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe-aHo5J4U4tDELWKHmbcctiLFqsrJN6ydpldSA-zSEN1W2HZ8o6iVHhR-oGb3r4-6IyUyYSNbf6NJ8qrSoQdvXctzNHlw8xykyPWQwKLoJiQKhd_yQ3_3DsL67nSXZA824AO-twZGVpq3/s72-c/test_first.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1601257872697763756.post-4473459572016467498</guid><pubDate>Sat, 07 Jun 2008 11:11:00 +0000</pubDate><atom:updated>2008-06-07T13:16:00.778+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">best practices</category><category domain="http://www.blogger.com/atom/ns#">rails</category><category domain="http://www.blogger.com/atom/ns#">ruby on rails</category><category domain="http://www.blogger.com/atom/ns#">testing</category><category domain="http://www.blogger.com/atom/ns#">welcome</category><title>Welcome</title><description>Welcome aboard this blog about best practices for testing &lt;a href=&quot;http://rubyonrails.org&quot;&gt;Ruby on Rails&lt;/a&gt; applications. We are &lt;a href=&quot;http://jan.krutisch.de/&quot;&gt;Jan Krutisch&lt;/a&gt; and &lt;a href=&quot;http://mt7.de&quot;&gt;Thorsten Böttger&lt;/a&gt;, two Rails hackers from Hamburg, Germany.</description><link>http://testpractices.blogspot.com/2008/06/welcome.html</link><author>noreply@blogger.com (Thorsten Böttger)</author><thr:total>0</thr:total></item></channel></rss>