<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Pragmatic Forums | Posts in forum 'Rails Test Prescriptions'</title>
    <link>/forums/140/posts.rss</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <item>
      <title>3.1 What is this symbol :db use for? posted by Dawid Stępień @ Wed, 24 Apr 2013 07:47:49 +0000</title>
      <description/>
      <pubDate>Thu, 25 Apr 2013 11:57:18 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:11102:32629</guid>
      <author>Dawid Stępień</author>
      <link>http://forums.pragprog.com/forums/140/topics/11102</link>
    </item>
    <item>
      <title>3.1 What is this symbol :db use for? posted by Albert Yu @ Sat, 22 Sep 2012 23:01:06 +0000</title>
      <description/>
      <pubDate>Sat, 22 Sep 2012 23:01:06 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:11102:31017</guid>
      <author>Albert Yu</author>
      <link>http://forums.pragprog.com/forums/140/topics/11102</link>
    </item>
    <item>
      <title>Why does this line of code work? posted by Charles de Bueger @ Thu, 19 Apr 2012 12:28:50 +0000</title>
      <description/>
      <pubDate>Thu, 19 Apr 2012 12:28:50 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9371:29693</guid>
      <author>Charles de Bueger</author>
      <link>http://forums.pragprog.com/forums/140/topics/9371</link>
    </item>
    <item>
      <title>Mocha Stub problem posted by Andrew Sage @ Sun, 21 Aug 2011 14:21:34 +0000</title>
      <description>&lt;p&gt;I&amp;#8217;ve no idea what page it is as I&amp;#8217;m viewing on a Kindle but it is 30% in.&lt;/p&gt;


	&lt;p&gt;When I added the &amp;#8220;lets stub an object&amp;#8221; test to project_test.rb I got the following error:&lt;/p&gt;


	&lt;p&gt;ProjectTest:
 test_lets_stub_an_object (0.06s) 
    &lt;span class="caps"&gt;ERROR&lt;/span&gt; test_should_be_able_to_retrieve_projects_based_on_day (0.12s) 
          NoMethodError: undefined method `assigns&amp;#8217; for #
          /Users/andrew/Rails/huddle/test/unit/project_test.rb:7:in `block in &amp;#8216;&lt;/p&gt;


	&lt;p&gt;Any suggestions?&lt;/p&gt;</description>
      <pubDate>Sun, 21 Aug 2011 14:21:34 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9524:25899</guid>
      <author>Andrew Sage</author>
      <link>http://forums.pragprog.com/forums/140/topics/9524</link>
    </item>
    <item>
      <title>Why does this line of code work? posted by Danny O Cuiv @ Mon, 18 Jul 2011 18:52:20 +0000</title>
      <description>&lt;p&gt;status_date is an ActiveRecord attribute, which means that the accessors are generated, specifically a setter (status_date=) and a setter (status_date). When these are invoked from outside the class, there is no ambiguity&lt;/p&gt;


	&lt;p&gt;object.status_date = Date.today&lt;br /&gt;and&lt;br /&gt;foo = object.status_date&lt;/p&gt;


	&lt;p&gt;When you want to invoke them inside the class, the getter can be called unqualified, but you need to qualify the setter (with self), because of an ambiguity in the grammar. Specifically&lt;/p&gt;


	&lt;p&gt;status_date = Date.today&lt;/p&gt;


	&lt;p&gt;would look to the interpreter like an assignment to a local variable. Obviously you can qualify the getter too. It&amp;#8217;s just that it&amp;#8217;s not necessary.&lt;/p&gt;


	&lt;p&gt;Danny.&lt;/p&gt;</description>
      <pubDate>Mon, 18 Jul 2011 18:52:20 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9371:25526</guid>
      <author>Danny O Cuiv</author>
      <link>http://forums.pragprog.com/forums/140/topics/9371</link>
    </item>
    <item>
      <title>Why does this line of code work? posted by Noah Chase @ Fri, 15 Jul 2011 04:19:47 +0000</title>
      <description>&lt;p&gt;I&amp;#8217;m using the ePub formatted book, so I can&amp;#8217;t give the best page number here. Roughly p.45&amp;#8212;&amp;#8220;The First Refactor&amp;#8221;&lt;/p&gt;


	&lt;p&gt;Noel Rappin is fleshing out the StatusReport model to make the &amp;#8220;saving a status report that has a date doesn&amp;#8217;t override&amp;#8221; test.&lt;/p&gt;


	&lt;p&gt;His code reads&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;def set_status_date
  self.status_date = Date.today if status_date.nil?
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Instead, I expected to see&lt;br /&gt;&lt;pre&gt;&lt;code&gt;def set_status_date
  self.status_date = Date.today if self.status_date.nil?
end
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;, but it works as-is. I must be missing something basic here.&lt;/p&gt;</description>
      <pubDate>Fri, 15 Jul 2011 04:20:43 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9371:25476</guid>
      <author>Noah Chase</author>
      <link>http://forums.pragprog.com/forums/140/topics/9371</link>
    </item>
    <item>
      <title>make class method posted by Jonathan Lim @ Mon, 04 Jul 2011 10:28:04 +0000</title>
      <description>&lt;p&gt;&lt;span class="caps"&gt;PDF&lt;/span&gt; p.111, 112 code samples call Project.make&lt;/p&gt;


	&lt;p&gt;Should this be Project.new? If not, where is it defined?&lt;/p&gt;


	&lt;p&gt;Thanks,&lt;br /&gt;Jon&lt;/p&gt;</description>
      <pubDate>Mon, 04 Jul 2011 10:28:04 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9308:25287</guid>
      <author>Jonathan Lim</author>
      <link>http://forums.pragprog.com/forums/140/topics/9308</link>
    </item>
    <item>
      <title>Chapter 3 Test Errors Missing posted by Danny O Cuiv @ Fri, 03 Jun 2011 21:08:36 +0000</title>
      <description>&lt;p&gt;Hi James,&lt;/p&gt;


	&lt;p&gt;My guess from the above is that you have downloaded the code from the PragProg site and used that in your work-through. However, this code is for the completed example. What you needed to have done is to get a starting setup as explained in Appendix A: Sample Application Setup. I say this because your first two errors above are undefined method errors for a method called &lt;code&gt;users&lt;/code&gt; on a &lt;code&gt;Project&lt;/code&gt; instance. This method is being called on line 5 of your show view for projects. When I was working through the example, there was no &lt;code&gt;users&lt;/code&gt; association in the &lt;code&gt;Project&lt;/code&gt; model at that stage and the first few lines of the show view were like this:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&amp;lt;p id="notice"&amp;gt;&amp;lt;%= notice %&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;
  &amp;lt;b&amp;gt;Name:&amp;lt;/b&amp;gt;
  &amp;lt;%= @project.name %&amp;gt;
&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;However, in the version from the code download, there is indeed a call to &lt;code&gt;project.users&lt;/code&gt; on line 5 of the show view:&lt;/p&gt;


&lt;code&gt;&amp;lt;% @project.users.each do |user| %&amp;gt;&lt;/code&gt;

	&lt;p&gt;The &lt;code&gt;users&lt;/code&gt; association isn&amp;#8217;t added until the top of page 243, much further on from where you are now. Oddly enough, this association is actually missing from the code download version. It should really be there.&lt;/p&gt;


	&lt;p&gt;Regards,&lt;/p&gt;


	&lt;p&gt;Danny.&lt;/p&gt;</description>
      <pubDate>Fri, 03 Jun 2011 21:40:00 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9166:24940</guid>
      <author>Danny O Cuiv</author>
      <link>http://forums.pragprog.com/forums/140/topics/9166</link>
    </item>
    <item>
      <title>Chapter 3 Test Errors Missing posted by James Strocel @ Wed, 01 Jun 2011 23:05:50 +0000</title>
      <description>&lt;p&gt;Hi There,&lt;/p&gt;


	&lt;p&gt;I was working my way through the book and I ran the tests for huddle3 as advised on page 55. Instead of getting this error:&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
1) Error: test_creation_of_status_report_with_data(StatusReportsControllerTest): ArgumentError: wrong number of arguments (1 for 0)     /test/functional/status_reports_controller_test.rb:58:in ✎to_s'     /test/functional/status_reports_controller_test.rb:58:in      ✎test_creation_of_status_report_with_data'
&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;

	&lt;p&gt;I get these errors:&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
1) Error:
test_index_should_display_project_timeline(ProjectsControllerTest):
ActionView::Template::Error: undefined method `users' for #&amp;lt;Project:0x102c59bc8&amp;gt;
    app/views/projects/show.html.erb:5:in `_app_views_projects_show_html_erb__1391822682_2176008960_0'
    app/controllers/projects_controller.rb:26:in `show'
    /test/functional/projects_controller_test.rb:73:in `test_index_should_display_project_timeline'

  2) Error:
test_project_timeline_index_should_be_sorted_correctly(ProjectsControllerTest):
ActionView::Template::Error: undefined method `users' for #&amp;lt;Project:0x10351df98&amp;gt;
    app/views/projects/show.html.erb:5:in `_app_views_projects_show_html_erb__1391822682_2176008960_0'
    app/controllers/projects_controller.rb:26:in `show'
    /test/functional/projects_controller_test.rb:63:in `test_project_timeline_index_should_be_sorted_correctly'

  3) Error:
test_should_get_edit(ProjectsControllerTest):
ActionView::Template::Error: undefined method `projects' for #&amp;lt;User:0x1031ae678&amp;gt;
    app/views/projects/edit.html.erb:12:in `_app_views_projects_edit_html_erb__1954596551_2173714420_0'
    app/views/projects/edit.html.erb:8:in `each'
    app/views/projects/edit.html.erb:8:in `_app_views_projects_edit_html_erb__1954596551_2173714420_0'
    /test/functional/projects_controller_test.rb:44:in `test_should_get_edit'

  4) Error:
test_should_show_project(ProjectsControllerTest):
ActionView::Template::Error: undefined method `users' for #&amp;lt;Project:0x102f0fdb8&amp;gt;
    app/views/projects/show.html.erb:5:in `_app_views_projects_show_html_erb__1391822682_2176008960_0'
    app/controllers/projects_controller.rb:26:in `show'
    /test/functional/projects_controller_test.rb:39:in `test_should_show_project'

  5) Error:
test_should_update_project(ProjectsControllerTest):
NoMethodError: undefined method `users=' for #&amp;lt;Project:0x102d56760&amp;gt;
    app/controllers/projects_controller.rb:69:in `update'
    /test/functional/projects_controller_test.rb:49:in `test_should_update_project'

  6) Error:
test_should_update_with_users(ProjectsControllerTest):
StandardError: No fixture with name 'quentin' found for table 'users'
    /test/functional/projects_controller_test.rb:90:in `test_should_update_with_users'
&lt;/code&gt;

&lt;/pre&gt;

	&lt;p&gt;Am I doing something wrong here or did I use the wrong code sample?&lt;/p&gt;


	&lt;p&gt;Keep up the good work!&lt;/p&gt;


	&lt;p&gt;-James&lt;/p&gt;</description>
      <pubDate>Wed, 01 Jun 2011 23:06:44 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9166:24924</guid>
      <author>James Strocel</author>
      <link>http://forums.pragprog.com/forums/140/topics/9166</link>
    </item>
    <item>
      <title>Fixtures bypassing ActiveRecord posted by Danny O Cuiv @ Fri, 27 May 2011 20:57:06 +0000</title>
      <description>&lt;p&gt;I&amp;#8217;m going to bump this one if that&amp;#8217;s OK. (It&amp;#8217;s been almost two weeks and 130 views.)&lt;/p&gt;


	&lt;p&gt;Anyone got any idea what was being referred to here?&lt;/p&gt;


	&lt;p&gt;Thanks,&lt;/p&gt;


	&lt;p&gt;Danny.&lt;/p&gt;</description>
      <pubDate>Fri, 27 May 2011 20:57:06 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9081:24879</guid>
      <author>Danny O Cuiv</author>
      <link>http://forums.pragprog.com/forums/140/topics/9081</link>
    </item>
    <item>
      <title>Framework? posted by Danny O Cuiv @ Wed, 25 May 2011 08:01:21 +0000</title>
      <description>&lt;p&gt;From page 16 of the print edition:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;For its part, Rails smooths out the difference between minitest and Test::Unit 1.3 and adds its own features on top of both. For our purposes, we don’t need to worry about the difference, and to minimize confusion (too late?), I’ll continue to refer to that library as Test::Unit. Since I’m boldly assuming you are writing a Rails application, I’m not going to sweat the difference between what’s in Rails and what’s in Test::Unit. Test::Unit 2.0 doesn’t seem to have much of a constituency at the moment, so I’m going to ignore it.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;Danny&lt;/p&gt;</description>
      <pubDate>Wed, 25 May 2011 08:02:34 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9142:24849</guid>
      <author>Danny O Cuiv</author>
      <link>http://forums.pragprog.com/forums/140/topics/9142</link>
    </item>
    <item>
      <title>Framework? posted by Ron Green @ Tue, 24 May 2011 22:28:57 +0000</title>
      <description>&lt;p&gt;Does this cover Test::Unit or MiniTest or either&lt;/p&gt;</description>
      <pubDate>Tue, 24 May 2011 22:28:57 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9142:24848</guid>
      <author>Ron Green</author>
      <link>http://forums.pragprog.com/forums/140/topics/9142</link>
    </item>
    <item>
      <title>Zebra missing? posted by Noel Rappin @ Sat, 21 May 2011 23:08:04 +0000</title>
      <description>&lt;p&gt;Try&lt;/p&gt;


	&lt;p&gt;&lt;a href="https://github.com/jamesgolick/zebra"&gt;https://github.com/jamesgolick/zebra&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 21 May 2011 23:08:04 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8945:24792</guid>
      <author>Noel Rappin</author>
      <link>http://forums.pragprog.com/forums/140/topics/8945</link>
    </item>
    <item>
      <title>Fixtures bypassing ActiveRecord posted by Danny O Cuiv @ Sun, 15 May 2011 12:24:11 +0000</title>
      <description>&lt;p&gt;Thanks Noel for your answer to my previous question. I&amp;#8217;ve got another. On page 77 of the print edition (or page 83 of the &lt;span class="caps"&gt;PDF&lt;/span&gt;), you say:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;This means you can’t use arbitrary methods of the model as attributes in the fixture the way you can in a create( ) call. Fixture attributes have to be either actual database columns or ActiveRecord associations explicitly defined in the model.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;This implies to me that things like virtual attributes are allowed in a call to create, whereas fixtures are restricted to actual database columns (and associations). I was curious and looked this up in the &lt;span class="caps"&gt;API&lt;/span&gt;. create() just calls new() before saving and in the documentation for the &lt;a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-c-new"&gt;new() method&lt;/a&gt;, it states:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;In both instances, valid attribute keys are determined by the column names of the associated table – hence you can’t have attributes that aren’t part of the table columns.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;This seems to me to be at odds with you wrote above. Can you clarify?&lt;/p&gt;


	&lt;p&gt;Thanks,&lt;/p&gt;


	&lt;p&gt;Danny.&lt;/p&gt;</description>
      <pubDate>Sun, 15 May 2011 12:25:42 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:9081:24669</guid>
      <author>Danny O Cuiv</author>
      <link>http://forums.pragprog.com/forums/140/topics/9081</link>
    </item>
    <item>
      <title>Zebra missing? posted by Christian Schell @ Thu, 14 Apr 2011 15:39:57 +0000</title>
      <description>&lt;p&gt;Hey,&lt;br /&gt;just wanted to try Shoulda with Zebra, but &amp;#8220;gem &amp;#8216;zebra&amp;#8217;&amp;#8221; in a rails3-app doesn&amp;#8217;t work:&lt;br /&gt;&amp;#8220;Could not find gem &amp;#8216;zebra (&amp;gt;= 0, runtime)&amp;#8217; in any of the gem sources listed in your Gemfile.&amp;#8221; &lt;br /&gt;Even gem search &amp;#8216;zebra&amp;#8217; wasn&amp;#8217;t successfull. Do I need more than that entry in the gemfile?&lt;br /&gt;CS&lt;/p&gt;</description>
      <pubDate>Thu, 14 Apr 2011 15:39:57 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8945:24246</guid>
      <author>Christian Schell</author>
      <link>http://forums.pragprog.com/forums/140/topics/8945</link>
    </item>
    <item>
      <title>Strange passage on page 48 posted by Noel Rappin @ Wed, 06 Apr 2011 22:27:40 +0000</title>
      <description>&lt;p&gt;Following up. Since status_date is a Date in the database, the type issue is not a problem in this case. It would be if you were using created_at.&lt;/p&gt;


	&lt;p&gt;So this text seems to be totally out of sync with the example it is near.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m sorry about that. I&amp;#8217;ll put an errata in so that it will be clarified in the text.&lt;/p&gt;


	&lt;p&gt;Thanks for letting me know about this issue.&lt;/p&gt;


	&lt;p&gt;Noel&lt;/p&gt;</description>
      <pubDate>Wed, 06 Apr 2011 22:27:40 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8890:24152</guid>
      <author>Noel Rappin</author>
      <link>http://forums.pragprog.com/forums/140/topics/8890</link>
    </item>
    <item>
      <title>Strange passage on page 48 posted by Noel Rappin @ Wed, 06 Apr 2011 22:06:23 +0000</title>
      <description>&lt;p&gt;It&amp;#8217;s a badly phrased passage.&lt;/p&gt;


	&lt;p&gt;Well, it&amp;#8217;s a passage that seems to have been moved out of it&amp;#8217;s original context, and doesn&amp;#8217;t make sense where it is.&lt;/p&gt;


	&lt;p&gt;The text in question really applies largely to controller testing, as the following paragraph in the book suggests. I suspect this paragraph that is confusing you was originally placed near a controller test, but got moved, and it&amp;#8217;s meaning got garbled.&lt;/p&gt;


	&lt;p&gt;The problem that you try to solve with reload is this:&lt;/p&gt;


	&lt;p&gt;1. You create an instance of an object in a test, and save it to the database, call this instance &amp;#8220;foo&amp;#8221;&lt;/p&gt;


	&lt;p&gt;2. You then make a call into the application, where that object is read from the database into a new Ruby object, call it &amp;#8220;bar&amp;#8221;. This is most common when you create an object, and then call, say, the show method of a controller via the ID, the controller reads the object from the database and creates a new object in memory backed by the same database row. (That&amp;#8217;s what I mean by &amp;#8220;creates a new instance from the database&amp;#8221;, which, again, doesn&amp;#8217;t actually apply to the example as I said it does.)&lt;/p&gt;


	&lt;p&gt;3. You make changes to instance &amp;#8220;bar&amp;#8221; in the code, and those changes get saved to the database&lt;/p&gt;


	&lt;p&gt;4. Now in the test, you still have a reference to &amp;#8220;foo&amp;#8221;, but &amp;#8220;foo&amp;#8221; does not have the changes made to &amp;#8220;bar&amp;#8221; and saved to the database, because they are two different objects. You call &amp;#8220;reload&amp;#8221; to allow the &amp;#8220;foo&amp;#8221; instance to have changes made to &amp;#8220;bar&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;Now, about the typecast issue. I believe that what I was trying to guard against is that when you create the instance from the ActiveRecord code, the status_state is a Date object, but when you read one from the database, it is a DateTime object, so you need to change one into the other in order to do a comparison. Your &lt;span class="caps"&gt;IRB&lt;/span&gt; snippet is correct, but if you had done a create on the object, and then read it back out of the database, the status_date.class would be a DateTime. I can&amp;#8217;t completely recreate this right now, but I&amp;#8217;ll give it a try later and report back.&lt;/p&gt;


	&lt;p&gt;Sorry about the confusion&amp;#8212;I think this one should have been caught.&lt;/p&gt;


	&lt;p&gt;Noel&lt;/p&gt;</description>
      <pubDate>Wed, 06 Apr 2011 22:06:23 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8890:24151</guid>
      <author>Noel Rappin</author>
      <link>http://forums.pragprog.com/forums/140/topics/8890</link>
    </item>
    <item>
      <title>Strange passage on page 48 posted by Danny O Cuiv @ Tue, 05 Apr 2011 13:33:17 +0000</title>
      <description>&lt;p&gt;I&amp;#8217;m going to bump this one, if that&amp;#8217;s OK. It&amp;#8217;s had a good number of eyeballs at this stage, but nobody&amp;#8217;s replied. Which either means that it&amp;#8217;s a really basic question or it&amp;#8217;s a really badly phrased passage.&lt;/p&gt;


	&lt;p&gt;Let me simplify my question. An object is created with attribute called status_date that is of type Date. It&amp;#8217;s saved to the database. After retrieval, you will still get a Date object if you read the attribute. In what sense is there any kind of &amp;#8220;typecast&amp;#8221; happening here?&lt;/p&gt;


	&lt;p&gt;If anyone has any insights, I&amp;#8217;d be very grateful.&lt;/p&gt;


	&lt;p&gt;Danny.&lt;/p&gt;</description>
      <pubDate>Tue, 05 Apr 2011 13:33:17 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8890:24136</guid>
      <author>Danny O Cuiv</author>
      <link>http://forums.pragprog.com/forums/140/topics/8890</link>
    </item>
    <item>
      <title>Strange passage on page 48 posted by Danny O Cuiv @ Fri, 01 Apr 2011 16:18:51 +0000</title>
      <description>&lt;p&gt;Hi,&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve been reading the book and enjoying the approach, but am stumped by a passage on page 48. Can anyone who has read the book enlighten me? The passage is:&lt;/p&gt;


	&lt;p&gt;&amp;#8220;In this particular case, the controller creates a new instance from the database and saves that instance, without touching the actual variable created for the test. As a result, the database version has typecast the status_date to a Date when saving, but the live version in memory hasn’t gotten that change.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;So, my difficulties are:&lt;/p&gt;


	&lt;p&gt;(i) The controller creates a new instance from a hash, not from the database. (I can&amp;#8217;t even think what creating a new instance &lt;em&gt;from&lt;/em&gt; the database could mean.)&lt;/p&gt;


	&lt;p&gt;(ii) I&amp;#8217;m not sure what is meant by saving the instance without touching the variable. The call is:&lt;br /&gt;actual.save&lt;br /&gt;Does this constitute not &amp;#8220;touching&amp;#8221; the variable?&lt;/p&gt;


	&lt;p&gt;(iii) Most puzzling of all is the bit about the database version having typecast the status_date to a Date when saving. As far as I can see, status_date was a Date right from the time the value appeared in the hash. Playing around on the console gives:&lt;/p&gt;


&lt;blockquote&gt;
	&lt;blockquote&gt;
	&lt;p&gt;actual = StatusReport.new(:status_date =&amp;gt; 10.days.ago.to_date)&lt;br /&gt;=&amp;gt; #&lt;br /&gt;&amp;gt;&amp;gt; actual.status_date.class&lt;br /&gt;=&amp;gt; Date&lt;/p&gt;

	&lt;/blockquote&gt;



&lt;/blockquote&gt;




	&lt;p&gt;So that status_date was always a Date. What&amp;#8217;s meant by it being &amp;#8220;typecast&amp;#8221; to a Date?&lt;/p&gt;


	&lt;p&gt;Thanks in advance,&lt;/p&gt;


	&lt;p&gt;Danny.&lt;/p&gt;</description>
      <pubDate>Fri, 01 Apr 2011 16:18:51 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8890:24084</guid>
      <author>Danny O Cuiv</author>
      <link>http://forums.pragprog.com/forums/140/topics/8890</link>
    </item>
    <item>
      <title>Sec 3.1: Why not change the default "should create status_report" in status_reports_controller_test.rb posted by Alexander Maiburg @ Wed, 09 Mar 2011 08:08:03 +0000</title>
      <description>&lt;p&gt;Is there any chance to get an answer?&lt;/p&gt;


	&lt;p&gt;Alex&lt;/p&gt;</description>
      <pubDate>Wed, 09 Mar 2011 08:08:03 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8740:23682</guid>
      <author>Alexander Maiburg</author>
      <link>http://forums.pragprog.com/forums/140/topics/8740</link>
    </item>
    <item>
      <title>Sec 3.1: Why not change the default "should create status_report" in status_reports_controller_test.rb posted by Alexander Maiburg @ Fri, 04 Mar 2011 11:20:09 +0000</title>
      <description>&lt;p&gt;In my opinion the default test &amp;#8220;should create status_report&amp;#8221; and the new added test &amp;#8220;creation of status report with data&amp;#8221; do very similar things.&lt;/p&gt;


	&lt;p&gt;So, why did you decide to put the logic for testing the creation of a status report in another test?&lt;br /&gt;Isn&amp;#8217;t the default test obsolete?&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;TIA&lt;/span&gt;, Alex&lt;/p&gt;</description>
      <pubDate>Fri, 04 Mar 2011 11:20:09 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8740:23584</guid>
      <author>Alexander Maiburg</author>
      <link>http://forums.pragprog.com/forums/140/topics/8740</link>
    </item>
    <item>
      <title>Shoulda fails with missing translations posted by Justin Case @ Wed, 23 Feb 2011 15:45:47 +0000</title>
      <description>&lt;p&gt;When trying to test validations shoulda kept throwing me &lt;code&gt;Expected block to return true value&lt;/code&gt; even though the validations were present in the model. Turns out that I was missing a locale translation. After adding the missing translation the tests ran fine.&lt;/p&gt;


	&lt;p&gt;Hopefully this might save someone a few hours.&lt;/p&gt;</description>
      <pubDate>Wed, 23 Feb 2011 15:46:17 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8700:23454</guid>
      <author>Justin Case</author>
      <link>http://forums.pragprog.com/forums/140/topics/8700</link>
    </item>
    <item>
      <title>mobi version chapter number posted by Noel Rappin @ Sun, 06 Feb 2011 22:17:27 +0000</title>
      <description>&lt;p&gt;I&amp;#8217;m pretty sure that&amp;#8217;s an artifact of the beta process&amp;#8212;the beta changelog is listed as chapter 1.&lt;/p&gt;</description>
      <pubDate>Sun, 06 Feb 2011 22:17:27 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8608:23175</guid>
      <author>Noel Rappin</author>
      <link>http://forums.pragprog.com/forums/140/topics/8608</link>
    </item>
    <item>
      <title>mobi version chapter number posted by Keith Bawden @ Sun, 06 Feb 2011 14:13:15 +0000</title>
      <description>&lt;p&gt;The mobi version b11_0 chapter numbers appear to be incorrect. Numbering begins from 2.&lt;/p&gt;</description>
      <pubDate>Sun, 06 Feb 2011 14:13:15 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8608:23165</guid>
      <author>Keith Bawden</author>
      <link>http://forums.pragprog.com/forums/140/topics/8608</link>
    </item>
    <item>
      <title>One-liner shoulda syntax using braces posted by Noel Rappin @ Sun, 02 Jan 2011 16:30:09 +0000</title>
      <description>&lt;p&gt;Sorry for not getting to this sooner, I was away.&lt;/p&gt;


	&lt;p&gt;I need to poke at this a little bit, this may be a mistake on my part in trying to get the example to take up fewer line. I think that the proper way to rewrite this as a one-liner is:&lt;/p&gt;


	&lt;p&gt;should(&amp;#8220;be successful&amp;#8221;) { assert_response :success }&lt;/p&gt;


	&lt;p&gt;Or use the shoulda macro:&lt;/p&gt;


	&lt;p&gt;should respond_with(:success)&lt;/p&gt;


	&lt;p&gt;Thanks,&lt;/p&gt;


	&lt;p&gt;Noel&lt;/p&gt;</description>
      <pubDate>Sun, 02 Jan 2011 16:30:09 +0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:140:8370:22538</guid>
      <author>Noel Rappin</author>
      <link>http://forums.pragprog.com/forums/140/topics/8370</link>
    </item>
  </channel>
</rss>
