From work at ashleymoran.me.uk Thu Feb 1 10:54:48 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Thu, 1 Feb 2007 15:54:48 +0000 Subject: [rspec-users] Structure for library code specs Message-ID: Hi Are there any plans to add a structure for library specs, eg RAILS_ROOT/spec/lib ? There's no equivalent spec:libraries task, and any spec lines for library code are lost from the rake stats output. Ashley From dchelimsky at gmail.com Thu Feb 1 11:35:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 1 Feb 2007 10:35:05 -0600 Subject: [rspec-users] Structure for library code specs In-Reply-To: References: Message-ID: <57c63afe0702010835y4df95882o1d5bdb793c8b7af7@mail.gmail.com> There's been no plan for it but we would consider this. If you're interested in seeing it happen, please submit an RFE: http://rspec.rubyforge.org/contribute.html http://rubyforge.org/tracker/?group_id=797 Cheers, David On 2/1/07, Ashley Moran wrote: > Hi > > Are there any plans to add a structure for library specs, eg > RAILS_ROOT/spec/lib ? There's no equivalent spec:libraries task, and > any spec lines for library code are lost from the rake stats output. > > Ashley > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Thu Feb 1 12:38:57 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Thu, 1 Feb 2007 17:38:57 +0000 Subject: [rspec-users] Structure for library code specs In-Reply-To: <57c63afe0702010835y4df95882o1d5bdb793c8b7af7@mail.gmail.com> References: <57c63afe0702010835y4df95882o1d5bdb793c8b7af7@mail.gmail.com> Message-ID: <5739D55F-ED92-4D6E-846A-171BBEC056E2@ashleymoran.me.uk> On 1 Feb 2007, at 16:35, David Chelimsky wrote: > There's been no plan for it but we would consider this. If you're > interested in seeing it happen, please submit an RFE: > > http://rspec.rubyforge.org/contribute.html > http://rubyforge.org/tracker/?group_id=797 > > Cheers, > David Thanks - just done From cwdinfo at gmail.com Thu Feb 1 14:23:09 2007 From: cwdinfo at gmail.com (s.ross) Date: Thu, 1 Feb 2007 11:23:09 -0800 Subject: [rspec-users] should_redirect_to in rspec-0.8.0 / rspec_on_rails 1453 Message-ID: <94A8EC69-794A-4951-BD64-4518AB39A75E@gmail.com> I have a spec: specify "a post with no user id should add a record" do post :edit_or_create, :user => {:login => 'joeschmoe', :email => 'joe at shmoe.com', :email_confirmation => 'joe at shmoe.com', :full_name => 'Joe Schmoe'} assigns[:user].should_not_be_nil assigns[:user].new_record?.should_not_be(true) flash[:notice].should_match(/user added/) response.should_be_redirect puts "redirecting to #{response.redirect_url}" puts "this response was #{response.redirect?}" controller.should_redirect_to 'http://test.host/user' end the puts statements output the following: redirecting to http://test.host/user this response was true Any idea why this line: controller.should_redirect_to 'http://test.host/user' would fail with the message: 'Given a UserController edit a post with no user id should add a record' FAILED controller expected call to redirect_to "http://test.host/user" but it was never received From unclebob at objectmentor.com Thu Feb 1 16:20:04 2007 From: unclebob at objectmentor.com (Robert Martin) Date: Thu, 1 Feb 2007 15:20:04 -0600 Subject: [rspec-users] should_redirect_to in rspec-0.8.0 / rspec_on_rails 1453 In-Reply-To: <94A8EC69-794A-4951-BD64-4518AB39A75E@gmail.com> References: <94A8EC69-794A-4951-BD64-4518AB39A75E@gmail.com> Message-ID: <3213E149-A8FB-42B4-889B-D7C57AF9041B@objectmentor.com> The "should-redirect-to" has to be called before the 'post'. I think it's setting up a mock. On Feb 1, 2007, at 1:23 PM, s.ross wrote: > I have a spec: > > specify "a post with no user id should add a record" do > post :edit_or_create, :user => {:login => 'joeschmoe', :email => > 'joe at shmoe.com', :email_confirmation => 'joe at shmoe.com', :full_name > => 'Joe Schmoe'} > assigns[:user].should_not_be_nil > assigns[:user].new_record?.should_not_be(true) > flash[:notice].should_match(/user added/) > response.should_be_redirect > puts "redirecting to #{response.redirect_url}" > puts "this response was #{response.redirect?}" > controller.should_redirect_to 'http://test.host/user' > end > > the puts statements output the following: > > redirecting to http://test.host/user > this response was true > > Any idea why this line: > > controller.should_redirect_to 'http://test.host/user' > > would fail with the message: > > 'Given a UserController edit a post with no user id should add a > record' FAILED > controller expected call to redirect_to "http://test.host/user" but > it was never received > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users ---- Robert C. Martin (Uncle Bob) | email: unclebob at objectmentor.com Object Mentor Inc. | blog: www.butunclebob.com The Agile Transition Experts | web: www.objectmentor.com 800-338-6716 | -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070201/04ad8626/attachment.html From cwdinfo at gmail.com Thu Feb 1 17:22:21 2007 From: cwdinfo at gmail.com (s.ross) Date: Thu, 1 Feb 2007 14:22:21 -0800 Subject: [rspec-users] should_redirect_to in rspec-0.8.0 / rspec_on_rails 1453 In-Reply-To: <3213E149-A8FB-42B4-889B-D7C57AF9041B@objectmentor.com> References: <94A8EC69-794A-4951-BD64-4518AB39A75E@gmail.com> <3213E149-A8FB-42B4-889B-D7C57AF9041B@objectmentor.com> Message-ID: I changed it to: response.should_redirect_to and it worked. I'm most interested in whether, given a set of circumstances, a particular redirection happens, so I think it has to go after the post. I'm not certain how controller.should_redirect_to would answer this question. Thoughts? On Feb 1, 2007, at 1:20 PM, Robert Martin wrote: > The "should-redirect-to" has to be called before the 'post'. I > think it's setting up a mock. > On Feb 1, 2007, at 1:23 PM, s.ross wrote: > >> I have a spec: >> >> specify "a post with no user id should add a record" do >> post :edit_or_create, :user => {:login => 'joeschmoe', :email => >> 'joe at shmoe.com', :email_confirmation => 'joe at shmoe.com', :full_name >> => 'Joe Schmoe'} >> assigns[:user].should_not_be_nil >> assigns[:user].new_record?.should_not_be(true) >> flash[:notice].should_match(/user added/) >> response.should_be_redirect >> puts "redirecting to #{response.redirect_url}" >> puts "this response was #{response.redirect?}" >> controller.should_redirect_to 'http://test.host/user' >> end >> >> the puts statements output the following: >> >> redirecting to http://test.host/user >> this response was true >> >> Any idea why this line: >> >> controller.should_redirect_to 'http://test.host/user' >> >> would fail with the message: >> >> 'Given a UserController edit a post with no user id should add a >> record' FAILED >> controller expected call to redirect_to "http://test.host/user" but >> it was never received >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > ---- > Robert C. Martin (Uncle Bob) | email: unclebob at objectmentor.com > Object Mentor Inc. | blog: www.butunclebob.com > The Agile Transition Experts | web: www.objectmentor.com > 800-338-6716 | > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070201/310da6fa/attachment.html From dchelimsky at gmail.com Thu Feb 1 18:23:18 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 1 Feb 2007 17:23:18 -0600 Subject: [rspec-users] should_redirect_to in rspec-0.8.0 / rspec_on_rails 1453 In-Reply-To: References: <94A8EC69-794A-4951-BD64-4518AB39A75E@gmail.com> <3213E149-A8FB-42B4-889B-D7C57AF9041B@objectmentor.com> Message-ID: <57c63afe0702011523n29b5a958ud729a0c7ac568165@mail.gmail.com> On 2/1/07, s.ross wrote: > I changed it to: > > response.should_redirect_to > > and it worked. I'm most interested in whether, given a set of circumstances, > a particular redirection happens, so I think it has to go after the post. > > I'm not certain how controller.should_redirect_to would answer this > question. > > Thoughts? Definitely use response.should_redirect_to after the action. The before the action version is going to be deprecated (it is invasive and buggy). Also, if you're using the trunk, I'd recommend that you give the matcher equivalent a shot: response.should redirect_to #no space after should Cheers, David > > > > On Feb 1, 2007, at 1:20 PM, Robert Martin wrote: > The "should-redirect-to" has to be called before the 'post'. I think it's > setting up a mock. > > On Feb 1, 2007, at 1:23 PM, s.ross wrote: > > I have a spec: > > specify "a post with no user id should add a record" do > post :edit_or_create, :user => {:login => 'joeschmoe', :email => > 'joe at shmoe.com', :email_confirmation => 'joe at shmoe.com', :full_name > => 'Joe Schmoe'} > assigns[:user].should_not_be_nil > assigns[:user].new_record?.should_not_be(true) > flash[:notice].should_match(/user added/) > response.should_be_redirect > puts "redirecting to #{response.redirect_url}" > puts "this response was #{response.redirect?}" > controller.should_redirect_to 'http://test.host/user' > end > > the puts statements output the following: > > redirecting to http://test.host/user > this response was true > > Any idea why this line: > > controller.should_redirect_to 'http://test.host/user' > > would fail with the message: > > 'Given a UserController edit a post with no user id should add a > record' FAILED > controller expected call to redirect_to "http://test.host/user" but > it was never received > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > ---- > Robert C. Martin (Uncle Bob) | email: unclebob at objectmentor.com > Object Mentor Inc. | blog: www.butunclebob.com > The Agile Transition Experts | web: www.objectmentor.com > 800-338-6716 | > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Feb 2 05:53:50 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Feb 2007 04:53:50 -0600 Subject: [rspec-users] Coming Soon... Message-ID: <57c63afe0702020253y5b5597f3odb63df0e8bbed1de@mail.gmail.com> Dear spec'ers, As many of you already know, we're gearing up for a pretty big 0.8 release of RSpec in the next couple of weeks. I'm writing in advance because I want to give you a heads up about upcoming changes and how they may impact your existing specs. Two important things to note first: 1. We will provide a translator that you'll be able to use to convert the majority of your existing specs to the new syntax before we remove deprecated methods. 2. The syntax changes described below will be the last major changes you'll see before a 1.0 release. Here is the plan, though the time line is not yet clear. == rspec-0.8.0-RC1 * Will be released within the next couple of weeks. * Will be fully backwards compatible with 0.7.5.1. * Will also support all of the new syntax using expectation matchers (see below). Because this is such a significant change, we want to do a Release Candidate first. == rspec-0.8.x Between 0.8.0 and 0.9.0, there will be at least one release that will include: * A pre-0.8 to 0.9 translator. * Noisy deprecation warnings that will let you know what methods will be going and what you should use instead. * A simple means of silencing those warnings (at your own peril!) == rspec-0.9 * Will remove all of the old syntax. ======================================= Here are some answers to some questions that some of you may have: == What is changing? All of the should_xyz methods will be losing an underscore and gaining a space: #before actual.should_equal(expected) actual.should_not_equal(expected) #after actual.should equal(expected) actual.should_not equal(expected) #equal, in this example, is a method that returns an expectation matcher, which Ruby passes to #should, which then interacts with the matcher to evaluate whether or not the expectation is met and report accordingly. All args to expectation matchers will require parens, and blocks must be expressed using curly braces. This has to do with ambiguity of arguments and operator precedence. Don't worry, if you do the wrong thing you'll get a warning. More on this below. == Why this change? The current syntax is supported by some very clever use of method_missing. I'm allowed to say it was clever because I didn't write it ;). At first it seemed awesome, but we've found that it conflicts with other frameworks that use metaprogramming techniques to late-bind to method_missing. So we had to make a choice between rethinking RSpec's implementation or commit to a future of monkey patching other frameworks as they introduce new uses of method_missing. Using expectation matchers means that we only need to add 4 methods to Object: #for expectation matchers should should_not #for mocks/stubs should_receive should_not_receive So it is much less invasive than it was before and, because we are not using method_missing on YOUR objects, is much less conflict/error prone. It also supports a clear entry point to writing custom expectation matchers, so if you have some domain-specific expectations like "should travel_more" or "should get_a_raise", you'll have a very easy means of doing so. == Will there be any existing expectations that will no longer be supported at all? Yes, but only a few, and only related to RSpec on Rails. We will NOT be supporting the following in the new syntax: controller.should_render controller.should_redirect_to You will be able to use instead: response.should render_template response.should render_text response.should redirect_to ... but only after the action. == For )(*&)(*'s sake, WHEN will you stop making changes like this? Right now. While we will not commit to 100% backwards compatibility, we on the RSpec Development Team are as anxious for this to stabilize as you are. We just feel that when we get to a 1.0 release we absolutely must have an API that is solid, easy to use, stable and maintainable. We just didn't see an end in sight to the problems we'd been seeing w/ the soon-to-be-ex-syntax, and we are very confident in this move and its potential to fulfill those requirements. == What's up w/ the parens and {} blocks? Parens: When you do this: a.b c d ... Ruby gives you the all familiar: "warning: parenthesize argument(s) for future version" If you can live w/ that, then have at it w/o the parens. Curly braces: This has to do w/ precedence. do/end has a lower precedence than {}, which means that in this expression: target.should satisfy do end ... the block will be passed to #should instead of #satisfy. We need the blocks to be passed to the matcher (#satisfy in this example), so curly braces are required. This will be enforced by RSpec. When #should or #should_not receive a block, the spec will fail with a warning telling you to use {} instead of do/end. So you won't have the opportunity to simply forget. ======================================= We're very excited about this release. I hope this email answers most of your questions. If you have others, please feel free, though I may punt on technical questions as many of those will be answered by documentation in the 0.8.0-RC1 release. Thanks for your patience with this and thanks especially to all of those who contribute to RSpec's evolution by participating with this list and submitting RFEs to the tracker. Cheers, David on behalf of The RSpec Development Team From bkeepers at gmail.com Fri Feb 2 09:31:33 2007 From: bkeepers at gmail.com (Brandon Keepers) Date: Fri, 2 Feb 2007 09:31:33 -0500 Subject: [rspec-users] Coming Soon... In-Reply-To: <57c63afe0702020253y5b5597f3odb63df0e8bbed1de@mail.gmail.com> References: <57c63afe0702020253y5b5597f3odb63df0e8bbed1de@mail.gmail.com> Message-ID: <1FB51DB3-E876-4B86-810E-AB3365140CC2@gmail.com> David & crew, On Feb 2, 2007, at 5:53 AM, David Chelimsky wrote: > == What's up w/ the parens and {} blocks? > > Parens: When you do this: > > a.b c d > > ... Ruby gives you the all familiar: > > "warning: parenthesize argument(s) for future version" > > If you can live w/ that, then have at it w/o the parens. > > Curly braces: This has to do w/ precedence. do/end has a lower > precedence than {}, which means that in this expression: > > target.should satisfy do > end > > ... the block will be passed to #should instead of #satisfy. We need > the blocks to be passed to the matcher (#satisfy in this example), so > curly braces are required. This will be enforced by RSpec. When > #should or #should_not receive a block, the spec will fail with a > warning telling you to use {} instead of do/end. So you won't have the > opportunity to simply forget. You could also do: target.should(satisfy do # block here end) It's not necessarily any cleaner, but it works. Good work! I like the new syntax and am looking forward to being able to write my own expectations. Brandon From dchelimsky at gmail.com Fri Feb 2 09:51:23 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Feb 2007 08:51:23 -0600 Subject: [rspec-users] Coming Soon... In-Reply-To: <1FB51DB3-E876-4B86-810E-AB3365140CC2@gmail.com> References: <57c63afe0702020253y5b5597f3odb63df0e8bbed1de@mail.gmail.com> <1FB51DB3-E876-4B86-810E-AB3365140CC2@gmail.com> Message-ID: <57c63afe0702020651x6c3ef2ah7da1a8f889e726dc@mail.gmail.com> On 2/2/07, Brandon Keepers wrote: > David & crew, > > On Feb 2, 2007, at 5:53 AM, David Chelimsky wrote: > > > == What's up w/ the parens and {} blocks? > > > > Parens: When you do this: > > > > a.b c d > > > > ... Ruby gives you the all familiar: > > > > "warning: parenthesize argument(s) for future version" > > > > If you can live w/ that, then have at it w/o the parens. > > > > Curly braces: This has to do w/ precedence. do/end has a lower > > precedence than {}, which means that in this expression: > > > > target.should satisfy do > > end > > > > ... the block will be passed to #should instead of #satisfy. We need > > the blocks to be passed to the matcher (#satisfy in this example), so > > curly braces are required. This will be enforced by RSpec. When > > #should or #should_not receive a block, the spec will fail with a > > warning telling you to use {} instead of do/end. So you won't have the > > opportunity to simply forget. > > You could also do: > > target.should(satisfy do > # block here > end) > > It's not necessarily any cleaner, but it works. > > Good work! I like the new syntax and am looking forward to being > able to write my own expectations. Cool. Let us know as you do, especially if you come up w/ some that are more general purpose. Thanks, David > > Brandon > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jodi at nnovation.ca Fri Feb 2 10:42:00 2007 From: jodi at nnovation.ca (Jodi Showers) Date: Fri, 2 Feb 2007 10:42:00 -0500 Subject: [rspec-users] Coming Soon... In-Reply-To: <57c63afe0702020253y5b5597f3odb63df0e8bbed1de@mail.gmail.com> References: <57c63afe0702020253y5b5597f3odb63df0e8bbed1de@mail.gmail.com> Message-ID: <219BF561-853F-4E42-B202-301E27DA78EB@nNovation.ca> On 2-Feb-07, at 5:53 AM, David Chelimsky wrote: > Dear spec'ers, > > As many of you already know, we're gearing up for a pretty big 0.8 > release of RSpec in the next couple of weeks. I'm writing in advance > because I want to give you a heads up about upcoming changes and how > they may impact your existing specs. David - I've monkey patched[1] 0.7.5.1 to support simply_helpful, and the rspec on rails plugin to support testing of mime return types (rss, atom, xml, etc). Should I continue to patch, or does big .8 address them? Cheers, Jodi General Partner The nNovation Group inc. www.nnovation.ca/blog [1] http://www.nnovation.ca/2006/12/17/rspec-rails12-and-testing- return-types From lists-rspec at shopwatch.org Fri Feb 2 10:47:09 2007 From: lists-rspec at shopwatch.org (Jay Levitt) Date: Fri, 02 Feb 2007 10:47:09 -0500 Subject: [rspec-users] Coming Soon... In-Reply-To: <57c63afe0702020651x6c3ef2ah7da1a8f889e726dc@mail.gmail.com> References: <57c63afe0702020253y5b5597f3odb63df0e8bbed1de@mail.gmail.com> <1FB51DB3-E876-4B86-810E-AB3365140CC2@gmail.com> <57c63afe0702020651x6c3ef2ah7da1a8f889e726dc@mail.gmail.com> Message-ID: <45C35CFD.4090809@rubyforge.org> David Chelimsky wrote: >>> Parens: When you do this: >>> >>> a.b c d >>> >>> ... Ruby gives you the all familiar: >>> >>> "warning: parenthesize argument(s) for future version" Nutty thought: the code is executed by eval'ing the block passed to context, right? So couldn't context eval a version of the code that was parsed by something like, though more robust than, s/\.should/\.should\(.*\)/ ? Jay From dchelimsky at gmail.com Fri Feb 2 10:48:24 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Feb 2007 09:48:24 -0600 Subject: [rspec-users] Coming Soon... In-Reply-To: <219BF561-853F-4E42-B202-301E27DA78EB@nNovation.ca> References: <57c63afe0702020253y5b5597f3odb63df0e8bbed1de@mail.gmail.com> <219BF561-853F-4E42-B202-301E27DA78EB@nNovation.ca> Message-ID: <57c63afe0702020748t3345d37coe8cf06324f16213e@mail.gmail.com> On 2/2/07, Jodi Showers wrote: > > On 2-Feb-07, at 5:53 AM, David Chelimsky wrote: > > > Dear spec'ers, > > > > As many of you already know, we're gearing up for a pretty big 0.8 > > release of RSpec in the next couple of weeks. I'm writing in advance > > because I want to give you a heads up about upcoming changes and how > > they may impact your existing specs. > > David - > > I've monkey patched[1] 0.7.5.1 to support simply_helpful, and the > rspec on rails plugin to support testing of mime return types (rss, > atom, xml, etc). > > Should I continue to patch, or does big .8 address them? 0.8 includes a complete port of assert_select, so it does support testing feeds, email, etc. I can't be certain though without more specifics. What exactly did you monkey patch? > > Cheers, > Jodi > General Partner > The nNovation Group inc. > www.nnovation.ca/blog > > [1] http://www.nnovation.ca/2006/12/17/rspec-rails12-and-testing- > return-types > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From jodi at nnovation.ca Fri Feb 2 11:00:01 2007 From: jodi at nnovation.ca (Jodi Showers) Date: Fri, 2 Feb 2007 11:00:01 -0500 Subject: [rspec-users] Coming Soon... In-Reply-To: <57c63afe0702020748t3345d37coe8cf06324f16213e@mail.gmail.com> References: <57c63afe0702020253y5b5597f3odb63df0e8bbed1de@mail.gmail.com> <219BF561-853F-4E42-B202-301E27DA78EB@nNovation.ca> <57c63afe0702020748t3345d37coe8cf06324f16213e@mail.gmail.com> Message-ID: On 2-Feb-07, at 10:48 AM, David Chelimsky wrote: > On 2/2/07, Jodi Showers wrote: >> >> On 2-Feb-07, at 5:53 AM, David Chelimsky wrote: >> >>> Dear spec'ers, >>> >>> As many of you already know, we're gearing up for a pretty big 0.8 >>> release of RSpec in the next couple of weeks. I'm writing in advance >>> because I want to give you a heads up about upcoming changes and how >>> they may impact your existing specs. >> >> David - >> >> I've monkey patched[1] 0.7.5.1 to support simply_helpful, and the >> rspec on rails plugin to support testing of mime return types (rss, >> atom, xml, etc). >> >> Should I continue to patch, or does big .8 address them? > > 0.8 includes a complete port of assert_select, so it does support > testing feeds, email, etc. I can't be certain though without more > specifics. What exactly did you monkey patch? The patching builds upon Louren's work and is probably best understood here: http://www.nnovation.ca/2006/12/17/rspec-rails12-and-testing-return- types Thanx David. Jodi From dchelimsky at gmail.com Fri Feb 2 11:06:33 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 2 Feb 2007 10:06:33 -0600 Subject: [rspec-users] Coming Soon... In-Reply-To: <45C35CFD.4090809@rubyforge.org> References: <57c63afe0702020253y5b5597f3odb63df0e8bbed1de@mail.gmail.com> <1FB51DB3-E876-4B86-810E-AB3365140CC2@gmail.com> <57c63afe0702020651x6c3ef2ah7da1a8f889e726dc@mail.gmail.com> <45C35CFD.4090809@rubyforge.org> Message-ID: <57c63afe0702020806v55233bf5l631f97b795ac9351@mail.gmail.com> On 2/2/07, Jay Levitt wrote: > David Chelimsky wrote: > >>> Parens: When you do this: > >>> > >>> a.b c d > >>> > >>> ... Ruby gives you the all familiar: > >>> > >>> "warning: parenthesize argument(s) for future version" > > Nutty thought: the code is executed by eval'ing the block passed to > context, right? So couldn't context eval a version of the code that was > parsed by something like, though more robust than, > s/\.should/\.should\(.*\)/ ? It doesn't parse the block - it executes it. I think that parsing it would open up a huge can of worms. Nutty idea though ;) Cheers, David > > Jay > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Sun Feb 4 13:53:39 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 4 Feb 2007 10:53:39 -0800 Subject: [rspec-users] Spec'ing ActionMailer Message-ID: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> Good morning (Pacific Time). I have a controller action that, as a side-effect, sends an email to an administrator. I want it to do something like this: specify "when someone successfully signs up, an email should be sent to the administrator with the person's contact page" do post :signup, {...lots o' params} response should_be success # here's where I want to see whether email was sent. Of course, the code is bogus. email.body.should have_tag(:p, :content => /page=/) end Is there some way to reach in and grab the message (what I've written as "email" above) so I can test the various parameters such as the "to" array and the email contents? I'm most interested in whether the controller/mailer interaction is working properly. Also, can I use the DOM select expectations or is it a simple matcher? Thanks From cdemyanovich at gmail.com Sun Feb 4 14:56:51 2007 From: cdemyanovich at gmail.com (Craig Demyanovich) Date: Sun, 4 Feb 2007 14:56:51 -0500 Subject: [rspec-users] Spec'ing ActionMailer In-Reply-To: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> References: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> Message-ID: <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> On Feb 4, 2007, at 1:53 PM, s.ross wrote: > Good morning (Pacific Time). I have a controller action that, as a > side-effect, sends an email to an administrator. I want it to do > something like this: > > specify "when someone successfully signs up, an email should be sent > to the administrator with the person's contact page" do > post :signup, {...lots o' params} > response should_be success > > # here's where I want to see whether email was sent. Of course, > the code is bogus. > email.body.should have_tag(:p, :content => /page=/) > end > > Is there some way to reach in and grab the message (what I've written > as "email" above) so I can test the various parameters such as the > "to" array and the email contents? I'm most interested in whether the > controller/mailer interaction is working properly. Also, can I use > the DOM select expectations or is it a simple matcher? On my first Rails project, I had to test whether a controller sent email when a job application was submitted. Fortunately, ActionMailer doesn't deliver email when running in a test environment. Rather, it records deliveries and makes them available via ActionMailer::Base.deliveries. I demonstrate this below. Note that the chapter on ActionMailer in AWDwR was very helpful to me, since it described a couple of ways to test sending email. Anyway, here's the code. Perhaps you can translate it into some specs. Craig require File.dirname(__FILE__) + '/../test_helper' require 'jobs_controller' # Re-raise errors caught by the controller. class JobsController; def rescue_action(e) raise e end; end class JobsControllerTest < Test::Unit::TestCase fixtures #... def setup #... @emails = ActionMailer::Base.deliveries @emails.clear end def test_submit_application post :submit_application, :job_application => { # lots of params } assert_response :success assert_template 'submit_application' assert_equal(2, @emails.size) email = @emails.first assert_match(/Confirm/, email.subject) assert_equal('john at doe.com', email.to()[0]) email = @emails[1] assert_match(/Resume received/, email.subject) assert_equal('jobs at host.com', email.to()[0]) end end From cwdinfo at gmail.com Sun Feb 4 16:14:08 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 4 Feb 2007 13:14:08 -0800 Subject: [rspec-users] Spec'ing ActionMailer In-Reply-To: <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> References: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> Message-ID: <676E68F2-5DEE-4743-BF4F-52FE33823220@gmail.com> Yes, this works in the Test::Unit framework, but the rSpec behavior specing is -- to me -- different in spirit. My scenario is less about testing whether the mailer should send mail than it is about whether the action should trigger an email and then what the email should contain. I settled on this hack: specify "should send a ping when a signup occurs" do post :signup, {"member"=>{ "email_confirmation"=>"joe at schmoe.com", "last"=>"Schmoe", "first"=>"Joe", "phone"=>"111-222-3333", "working_with_agent"=>"0", "preferred_contact_method"=>"email", "agent_name"=>"", "email"=>"joe at schmoe.com"}, "projects"=>["3"]} response.should be_success email = ActionMailer::Base.deliveries[0] email.body.should include('joe at schmoe.com') email.body.should include(projects(:trace).name) email.body.should include('member/show') email.to.should include('webmaster at test.host') end end The code works, but relies on me knowing something about how ActionMailer collects emails in test mode. My question is: Should my spec presume this much knowledge or is there a better way to accomplish it? Steve On Feb 4, 2007, at 11:56 AM, Craig Demyanovich wrote: > On Feb 4, 2007, at 1:53 PM, s.ross wrote: > >> Good morning (Pacific Time). I have a controller action that, as a >> side-effect, sends an email to an administrator. I want it to do >> something like this: >> >> specify "when someone successfully signs up, an email should be sent >> to the administrator with the person's contact page" do >> post :signup, {...lots o' params} >> response should_be success >> >> # here's where I want to see whether email was sent. Of course, >> the code is bogus. >> email.body.should have_tag(:p, :content => /page=/) >> end >> >> Is there some way to reach in and grab the message (what I've written >> as "email" above) so I can test the various parameters such as the >> "to" array and the email contents? I'm most interested in whether the >> controller/mailer interaction is working properly. Also, can I use >> the DOM select expectations or is it a simple matcher? > > On my first Rails project, I had to test whether a controller sent > email when a job application was submitted. Fortunately, ActionMailer > doesn't deliver email when running in a test environment. Rather, it > records deliveries and makes them available via > ActionMailer::Base.deliveries. I demonstrate this below. Note that > the chapter on ActionMailer in AWDwR was very helpful to me, since it > described a couple of ways to test sending email. Anyway, here's the > code. Perhaps you can translate it into some specs. > > Craig > > > > require File.dirname(__FILE__) + '/../test_helper' > require 'jobs_controller' > > # Re-raise errors caught by the controller. > class JobsController; def rescue_action(e) raise e end; end > > class JobsControllerTest < Test::Unit::TestCase > fixtures #... > > def setup > #... > @emails = ActionMailer::Base.deliveries > @emails.clear > end > > def test_submit_application > post :submit_application, :job_application => { > # lots of params > } > > assert_response :success > assert_template 'submit_application' > > assert_equal(2, @emails.size) > > email = @emails.first > assert_match(/Confirm/, email.subject) > assert_equal('john at doe.com', email.to()[0]) > > email = @emails[1] > assert_match(/Resume received/, email.subject) > assert_equal('jobs at host.com', email.to()[0]) > end > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun Feb 4 16:35:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Feb 2007 15:35:05 -0600 Subject: [rspec-users] Spec'ing ActionMailer In-Reply-To: <676E68F2-5DEE-4743-BF4F-52FE33823220@gmail.com> References: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> <676E68F2-5DEE-4743-BF4F-52FE33823220@gmail.com> Message-ID: <57c63afe0702041335j4f56988egb786e6d9f77518c6@mail.gmail.com> Steve - are you using the RSpec trunk? If you are, AND your email is html email, you can use this right now: response.should send_email { with_tag("div", "joe at shmoe.com") with_tag("div", projects(:trace).name) with_tag("div", member/show) } There is no specific support yet for email headers, nor raw text, though I can see now there is a need for that and will raise the appropriate RFE. David On 2/4/07, s.ross wrote: > Yes, this works in the Test::Unit framework, but the rSpec behavior > specing is -- to me -- different in spirit. My scenario is less about > testing whether the mailer should send mail than it is about whether > the action should trigger an email and then what the email should > contain. I settled on this hack: > > specify "should send a ping when a signup occurs" do > post :signup, {"member"=>{ > "email_confirmation"=>"joe at schmoe.com", > "last"=>"Schmoe", > "first"=>"Joe", > "phone"=>"111-222-3333", > "working_with_agent"=>"0", > "preferred_contact_method"=>"email", > "agent_name"=>"", > "email"=>"joe at schmoe.com"}, "projects"=>["3"]} > > response.should be_success > email = ActionMailer::Base.deliveries[0] > email.body.should include('joe at schmoe.com') > email.body.should include(projects(:trace).name) > email.body.should include('member/show') > email.to.should include('webmaster at test.host') > end > end > > The code works, but relies on me knowing something about how > ActionMailer collects emails in test mode. My question is: Should my > spec presume this much knowledge or is there a better way to > accomplish it? > > Steve > > On Feb 4, 2007, at 11:56 AM, Craig Demyanovich wrote: > > > On Feb 4, 2007, at 1:53 PM, s.ross wrote: > > > >> Good morning (Pacific Time). I have a controller action that, as a > >> side-effect, sends an email to an administrator. I want it to do > >> something like this: > >> > >> specify "when someone successfully signs up, an email should be sent > >> to the administrator with the person's contact page" do > >> post :signup, {...lots o' params} > >> response should_be success > >> > >> # here's where I want to see whether email was sent. Of course, > >> the code is bogus. > >> email.body.should have_tag(:p, :content => /page=/) > >> end > >> > >> Is there some way to reach in and grab the message (what I've written > >> as "email" above) so I can test the various parameters such as the > >> "to" array and the email contents? I'm most interested in whether the > >> controller/mailer interaction is working properly. Also, can I use > >> the DOM select expectations or is it a simple matcher? > > > > On my first Rails project, I had to test whether a controller sent > > email when a job application was submitted. Fortunately, ActionMailer > > doesn't deliver email when running in a test environment. Rather, it > > records deliveries and makes them available via > > ActionMailer::Base.deliveries. I demonstrate this below. Note that > > the chapter on ActionMailer in AWDwR was very helpful to me, since it > > described a couple of ways to test sending email. Anyway, here's the > > code. Perhaps you can translate it into some specs. > > > > Craig > > > > > > > > require File.dirname(__FILE__) + '/../test_helper' > > require 'jobs_controller' > > > > # Re-raise errors caught by the controller. > > class JobsController; def rescue_action(e) raise e end; end > > > > class JobsControllerTest < Test::Unit::TestCase > > fixtures #... > > > > def setup > > #... > > @emails = ActionMailer::Base.deliveries > > @emails.clear > > end > > > > def test_submit_application > > post :submit_application, :job_application => { > > # lots of params > > } > > > > assert_response :success > > assert_template 'submit_application' > > > > assert_equal(2, @emails.size) > > > > email = @emails.first > > assert_match(/Confirm/, email.subject) > > assert_equal('john at doe.com', email.to()[0]) > > > > email = @emails[1] > > assert_match(/Resume received/, email.subject) > > assert_equal('jobs at host.com', email.to()[0]) > > end > > end > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Feb 4 16:47:55 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 4 Feb 2007 15:47:55 -0600 Subject: [rspec-users] Spec'ing ActionMailer In-Reply-To: <57c63afe0702041335j4f56988egb786e6d9f77518c6@mail.gmail.com> References: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> <676E68F2-5DEE-4743-BF4F-52FE33823220@gmail.com> <57c63afe0702041335j4f56988egb786e6d9f77518c6@mail.gmail.com> Message-ID: <57c63afe0702041347p51c4ecdeyad91dc79cfa6c096@mail.gmail.com> On 2/4/07, David Chelimsky wrote: > Steve - are you using the RSpec trunk? > > If you are, AND your email is html email, you can use this right now: > > response.should send_email { > with_tag("div", "joe at shmoe.com") > with_tag("div", projects(:trace).name) > with_tag("div", member/show) > } I forgot to mention that you'll need this in setup/teardown when interacting w/ mail: setup do ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] end teardown ActionMailer::Base.deliveries.clear end This email support is from a port of assert_select, and that's how assert_select works. > > There is no specific support yet for email headers, nor raw text, > though I can see now there is a need for that and will raise the > appropriate RFE. > > David > > On 2/4/07, s.ross wrote: > > Yes, this works in the Test::Unit framework, but the rSpec behavior > > specing is -- to me -- different in spirit. My scenario is less about > > testing whether the mailer should send mail than it is about whether > > the action should trigger an email and then what the email should > > contain. I settled on this hack: > > > > specify "should send a ping when a signup occurs" do > > post :signup, {"member"=>{ > > "email_confirmation"=>"joe at schmoe.com", > > "last"=>"Schmoe", > > "first"=>"Joe", > > "phone"=>"111-222-3333", > > "working_with_agent"=>"0", > > "preferred_contact_method"=>"email", > > "agent_name"=>"", > > "email"=>"joe at schmoe.com"}, "projects"=>["3"]} > > > > response.should be_success > > email = ActionMailer::Base.deliveries[0] > > email.body.should include('joe at schmoe.com') > > email.body.should include(projects(:trace).name) > > email.body.should include('member/show') > > email.to.should include('webmaster at test.host') > > end > > end > > > > The code works, but relies on me knowing something about how > > ActionMailer collects emails in test mode. My question is: Should my > > spec presume this much knowledge or is there a better way to > > accomplish it? > > > > Steve > > > > On Feb 4, 2007, at 11:56 AM, Craig Demyanovich wrote: > > > > > On Feb 4, 2007, at 1:53 PM, s.ross wrote: > > > > > >> Good morning (Pacific Time). I have a controller action that, as a > > >> side-effect, sends an email to an administrator. I want it to do > > >> something like this: > > >> > > >> specify "when someone successfully signs up, an email should be sent > > >> to the administrator with the person's contact page" do > > >> post :signup, {...lots o' params} > > >> response should_be success > > >> > > >> # here's where I want to see whether email was sent. Of course, > > >> the code is bogus. > > >> email.body.should have_tag(:p, :content => /page=/) > > >> end > > >> > > >> Is there some way to reach in and grab the message (what I've written > > >> as "email" above) so I can test the various parameters such as the > > >> "to" array and the email contents? I'm most interested in whether the > > >> controller/mailer interaction is working properly. Also, can I use > > >> the DOM select expectations or is it a simple matcher? > > > > > > On my first Rails project, I had to test whether a controller sent > > > email when a job application was submitted. Fortunately, ActionMailer > > > doesn't deliver email when running in a test environment. Rather, it > > > records deliveries and makes them available via > > > ActionMailer::Base.deliveries. I demonstrate this below. Note that > > > the chapter on ActionMailer in AWDwR was very helpful to me, since it > > > described a couple of ways to test sending email. Anyway, here's the > > > code. Perhaps you can translate it into some specs. > > > > > > Craig > > > > > > > > > > > > require File.dirname(__FILE__) + '/../test_helper' > > > require 'jobs_controller' > > > > > > # Re-raise errors caught by the controller. > > > class JobsController; def rescue_action(e) raise e end; end > > > > > > class JobsControllerTest < Test::Unit::TestCase > > > fixtures #... > > > > > > def setup > > > #... > > > @emails = ActionMailer::Base.deliveries > > > @emails.clear > > > end > > > > > > def test_submit_application > > > post :submit_application, :job_application => { > > > # lots of params > > > } > > > > > > assert_response :success > > > assert_template 'submit_application' > > > > > > assert_equal(2, @emails.size) > > > > > > email = @emails.first > > > assert_match(/Confirm/, email.subject) > > > assert_equal('john at doe.com', email.to()[0]) > > > > > > email = @emails[1] > > > assert_match(/Resume received/, email.subject) > > > assert_equal('jobs at host.com', email.to()[0]) > > > end > > > end > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > From cwdinfo at gmail.com Mon Feb 5 00:09:19 2007 From: cwdinfo at gmail.com (s.ross) Date: Sun, 4 Feb 2007 21:09:19 -0800 Subject: [rspec-users] Spec'ing ActionMailer In-Reply-To: <57c63afe0702041347p51c4ecdeyad91dc79cfa6c096@mail.gmail.com> References: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> <676E68F2-5DEE-4743-BF4F-52FE33823220@gmail.com> <57c63afe0702041335j4f56988egb786e6d9f77518c6@mail.gmail.com> <57c63afe0702041347p51c4ecdeyad91dc79cfa6c096@mail.gmail.com> Message-ID: I'm running trunk and tried this. I put a pastie on: http://pastie.caboo.se/37928 Everything up to line 37 passes, but there it fails. The actual html sent to the mailer is:

Joe Schmoe signed the form and expressed interest in the following project(s): #snip#. You may reach Joe at: (111) 222-3333 or email at joe at schmoe.com.

Full contact information has been saved to your database and you may view it at here.

Perhaps I misunderstand how to use with_tag. I've tried: with_tag("p", "joe at schmoe.com") and I tried: with_tag("p", /joe at schmoe.com/) At this point, I'm really guessing but I know the results are good but the spec isn't satisfied. Thoughts? On Feb 4, 2007, at 1:47 PM, David Chelimsky wrote: > On 2/4/07, David Chelimsky wrote: >> Steve - are you using the RSpec trunk? >> >> If you are, AND your email is html email, you can use this right now: >> >> response.should send_email { >> with_tag("div", "joe at shmoe.com") >> with_tag("div", projects(:trace).name) >> with_tag("div", member/show) >> } > > I forgot to mention that you'll need this in setup/teardown when > interacting w/ mail: > > setup do > ActionMailer::Base.delivery_method = :test > ActionMailer::Base.perform_deliveries = true > ActionMailer::Base.deliveries = [] > end > > teardown > ActionMailer::Base.deliveries.clear > end > > This email support is from a port of assert_select, and that's how > assert_select works. > >> >> There is no specific support yet for email headers, nor raw text, >> though I can see now there is a need for that and will raise the >> appropriate RFE. >> >> David >> >> On 2/4/07, s.ross wrote: >>> Yes, this works in the Test::Unit framework, but the rSpec behavior >>> specing is -- to me -- different in spirit. My scenario is less >>> about >>> testing whether the mailer should send mail than it is about whether >>> the action should trigger an email and then what the email should >>> contain. I settled on this hack: >>> >>> specify "should send a ping when a signup occurs" do >>> post :signup, {"member"=>{ >>> "email_confirmation"=>"joe at schmoe.com", >>> "last"=>"Schmoe", >>> "first"=>"Joe", >>> "phone"=>"111-222-3333", >>> "working_with_agent"=>"0", >>> "preferred_contact_method"=>"email", >>> "agent_name"=>"", >>> "email"=>"joe at schmoe.com"}, "projects"=>["3"]} >>> >>> response.should be_success >>> email = ActionMailer::Base.deliveries[0] >>> email.body.should include('joe at schmoe.com') >>> email.body.should include(projects(:trace).name) >>> email.body.should include('member/show') >>> email.to.should include('webmaster at test.host') >>> end >>> end >>> >>> The code works, but relies on me knowing something about how >>> ActionMailer collects emails in test mode. My question is: Should my >>> spec presume this much knowledge or is there a better way to >>> accomplish it? >>> >>> Steve >>> >>> On Feb 4, 2007, at 11:56 AM, Craig Demyanovich wrote: >>> >>>> On Feb 4, 2007, at 1:53 PM, s.ross wrote: >>>> >>>>> Good morning (Pacific Time). I have a controller action that, as a >>>>> side-effect, sends an email to an administrator. I want it to do >>>>> something like this: >>>>> >>>>> specify "when someone successfully signs up, an email should be >>>>> sent >>>>> to the administrator with the person's contact page" do >>>>> post :signup, {...lots o' params} >>>>> response should_be success >>>>> >>>>> # here's where I want to see whether email was sent. Of course, >>>>> the code is bogus. >>>>> email.body.should have_tag(:p, :content => /page=/) >>>>> end >>>>> >>>>> Is there some way to reach in and grab the message (what I've >>>>> written >>>>> as "email" above) so I can test the various parameters such as the >>>>> "to" array and the email contents? I'm most interested in >>>>> whether the >>>>> controller/mailer interaction is working properly. Also, can I use >>>>> the DOM select expectations or is it a simple matcher? >>>> >>>> On my first Rails project, I had to test whether a controller sent >>>> email when a job application was submitted. Fortunately, >>>> ActionMailer >>>> doesn't deliver email when running in a test environment. >>>> Rather, it >>>> records deliveries and makes them available via >>>> ActionMailer::Base.deliveries. I demonstrate this below. Note that >>>> the chapter on ActionMailer in AWDwR was very helpful to me, >>>> since it >>>> described a couple of ways to test sending email. Anyway, here's >>>> the >>>> code. Perhaps you can translate it into some specs. >>>> >>>> Craig >>>> >>>> >>>> >>>> require File.dirname(__FILE__) + '/../test_helper' >>>> require 'jobs_controller' >>>> >>>> # Re-raise errors caught by the controller. >>>> class JobsController; def rescue_action(e) raise e end; end >>>> >>>> class JobsControllerTest < Test::Unit::TestCase >>>> fixtures #... >>>> >>>> def setup >>>> #... >>>> @emails = ActionMailer::Base.deliveries >>>> @emails.clear >>>> end >>>> >>>> def test_submit_application >>>> post :submit_application, :job_application => { >>>> # lots of params >>>> } >>>> >>>> assert_response :success >>>> assert_template 'submit_application' >>>> >>>> assert_equal(2, @emails.size) >>>> >>>> email = @emails.first >>>> assert_match(/Confirm/, email.subject) >>>> assert_equal('john at doe.com', email.to()[0]) >>>> >>>> email = @emails[1] >>>> assert_match(/Resume received/, email.subject) >>>> assert_equal('jobs at host.com', email.to()[0]) >>>> end >>>> end >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jchris at mfdz.com Mon Feb 5 01:47:32 2007 From: jchris at mfdz.com (Chris Anderson) Date: Sun, 4 Feb 2007 22:47:32 -0800 Subject: [rspec-users] long jumping out of code in specs Message-ID: I wrote this abomination just now, and wonder if anyone else has had experience with the pattern behind it. In short, I'm specing an after_create hook on an ActiveRecord model, that calls a bunch of private methods. Instead of stubbing all those private methods (which is verboten anyway, as well as impossible because creating the object which owns those methods is what I'm specing, so I don't have the object until I call do_action.) I'm stubbing a public method that would only get called if control-flow worked out like it should (the proverbial canary in the coal mine), and telling it to raise an exception which I catch in my spec. This way I don't have to bother with either stubbing all the private methods called in my after_create hook, or making the mock I'm sending though this gauntlet respond properly to all the calls it gets. In my case calling RssParser.new is evidence enough that my code executed like it should. class SpecShortcut < Exception; end specify "should call the standard parsing methods" do RssParser.should_receive(:new).and_raise(SpecShortcut) lambda{do_action}.should_raise(SpecShortcut) end Feeling pain like this while writing specs is usally an indication that the code could be better designed. But I don't see how else one could spec ActiveRecord's after_create hook, without going through with mocking and stubbing all the code the after_create hook uses. Stopping execution at the point where the expectation is satisfied is also appealing, in a premature optimization kind of way. Like I said, an abomination, but maybe a useful one. -- Chris Anderson http://jchris.mfdz.com From crafterm at gmail.com Mon Feb 5 06:11:40 2007 From: crafterm at gmail.com (Marcus Crafter) Date: Mon, 5 Feb 2007 22:11:40 +1100 Subject: [rspec-users] Structure for library code specs In-Reply-To: <5739D55F-ED92-4D6E-846A-171BBEC056E2@ashleymoran.me.uk> References: <57c63afe0702010835y4df95882o1d5bdb793c8b7af7@mail.gmail.com> <5739D55F-ED92-4D6E-846A-171BBEC056E2@ashleymoran.me.uk> Message-ID: Just catching up on messages after being away for a few days - cool - I've been looking for this too - thanks for submitting the RFE. Cheers, Marcus On 02/02/2007, at 4:38 AM, Ashley Moran wrote: > > On 1 Feb 2007, at 16:35, David Chelimsky wrote: > >> There's been no plan for it but we would consider this. If you're >> interested in seeing it happen, please submit an RFE: >> >> http://rspec.rubyforge.org/contribute.html >> http://rubyforge.org/tracker/?group_id=797 >> >> Cheers, >> David > > > Thanks - just done From dchelimsky at gmail.com Mon Feb 5 07:53:05 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 5 Feb 2007 06:53:05 -0600 Subject: [rspec-users] long jumping out of code in specs In-Reply-To: References: Message-ID: <57c63afe0702050453s7a98ea45q4627a7971be23487@mail.gmail.com> On 2/5/07, Chris Anderson wrote: > I wrote this abomination just now, and wonder if anyone else has had > experience with the pattern behind it. In short, I'm specing an > after_create hook on an ActiveRecord model, that calls a bunch of > private methods. Instead of stubbing all those private methods (which > is verboten anyway, as well as impossible because creating the object > which owns those methods is what I'm specing, so I don't have the > object until I call do_action.) > > I'm stubbing a public method that would only get called if > control-flow worked out like it should (the proverbial canary in the > coal mine), and telling it to raise an exception which I catch in my > spec. This way I don't have to bother with either stubbing all the > private methods called in my after_create hook, or making the mock I'm > sending though this gauntlet respond properly to all the calls it > gets. > > In my case calling RssParser.new is evidence enough that my code > executed like it should. > > class SpecShortcut < Exception; end > > specify "should call the standard parsing methods" do > RssParser.should_receive(:new).and_raise(SpecShortcut) > lambda{do_action}.should_raise(SpecShortcut) > end > > Feeling pain like this while writing specs is usally an indication > that the code could be better designed. But I don't see how else one > could spec ActiveRecord's after_create hook, without going through > with mocking and stubbing all the code the after_create hook uses. > Stopping execution at the point where the expectation is satisfied is > also appealing, in a premature optimization kind of way. > > Like I said, an abomination, but maybe a useful one. ActiveRecord puts us in an interesting bind with regard to the rules that come out of TDD. Testing privates is a no-no, but testing that a public method on the same class gets called is almost as dirty for the same reasons. It's less likely to be a problem than private methods because it's more stable (public methods are inherently more stable than privates), but it still feels like a design smell - especially if you have to intercept calls to that method (partial mocks), as you are doing. This is not your fault! It is because ActiveRecord violates and/or encourages the violation several OO design principles: Single Responsibility Principle Liskov Substitutiion Principle Dependency Inversion Principle Law of Demeter Tell, Don't Ask All of these principles, when applied, help you to build systems that are highly decoupled and easy to test. When ignored you often end up with tightly bound systems that, in spite of their up-front productivity, are difficult to test and difficult to change over time. Rails is difficult to test outside of the built-in testing support that you get. If you take a look at that support, it goes a long way to monkey patch itself into something usable in a test environment. This is true of our own 'spec/rails' as well. As for the ability to make changes later, try to use some other persistence framework like Og in a Rails app and you'll see the problem. Also, good luck trying to put plugins somewhere other than inside your rails app. These are trade-offs that one accepts when one uses Rails, and the benefits we get in terms of elegant feel, up-front productivity, low barrier to entry, etc, seem to make it worth it. My hope is that over time the Rails code base will improve from community contributions that make it a more highly decoupled system. Admittedly, we have a similar problem in RSpec: you can't (yet) easily plug in a different mocking framework because things are too tightly bound to RSpec's own. This is something that we're looking at changing in the near future, but there are other priorities at the forefront. But it was an easy trap to fall into. All of this must lead to looking at testing practices slightly differently in the short run. Jay Fields blogs quite a bit about solutions to problems like this. One thing he's doing for declarations like ActiveRecord validations is really interesting to me. You can read about it: http://jayfields.blogspot.com/2006/12/rails-unit-testing-activerecord.html but in a nutshell, he mocks ActiveRecord::Base telling it to expect a declaration when a file is loaded. This solution to your problem might look like this: context "RssParser" do specify "should do x after_create" do Thing.should_receive(:after_create).with(:x) load "#{RAILS_ROOT}/app/models/rss_parser.rb" end end I'm not ready to advocate this as THE solution. This approach does have its own problems, at least one of which is noted in a comment on the blog. Still, I've done this in a couple of places and it has worked well. WDYT? David > > -- > Chris Anderson > http://jchris.mfdz.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cwdinfo at gmail.com Mon Feb 5 13:52:04 2007 From: cwdinfo at gmail.com (s.ross) Date: Mon, 5 Feb 2007 10:52:04 -0800 Subject: [rspec-users] Spec'ing ActionMailer In-Reply-To: <57c63afe0702041335j4f56988egb786e6d9f77518c6@mail.gmail.com> References: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> <676E68F2-5DEE-4743-BF4F-52FE33823220@gmail.com> <57c63afe0702041335j4f56988egb786e6d9f77518c6@mail.gmail.com> Message-ID: David-- I still don't have this working (see my previous email with the pastie attached), but now have another ActionMailer/rSpec question. I'm spec'ing a different mailer model directly (instead of through the controller). It's meant to be invoked through script/runner, so I won't have a response object. I can see in the plugin source that there is assert_select_email support, but I'm pretty sure there is no expectation that starts with "assert." How would one spec something like: setup do ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] MyMailer.trigger_emails # invokes model method to send 4 emails end specify "d'oh! should have a non-empty recipient list" do ActionMailer::Base.deliveries.size.should be(4) ActionMailer::Base.deliveries.each do |email| email.recipients.should_not be_empty end end specify "first email should have a list item with the name of the first guy" do ActionMailer::Base.deliveries[0].should select_tag('li', members (:joe).name) end The above code is truly bogus and doesn't work. I'm trying to figure out where to get the messages and how to specify the expectations on them. Thanks, Steve On Feb 4, 2007, at 1:35 PM, David Chelimsky wrote: > Steve - are you using the RSpec trunk? > > If you are, AND your email is html email, you can use this right now: > > response.should send_email { > with_tag("div", "joe at shmoe.com") > with_tag("div", projects(:trace).name) > with_tag("div", member/show) > } > > There is no specific support yet for email headers, nor raw text, > though I can see now there is a need for that and will raise the > appropriate RFE. > > David > From dchelimsky at gmail.com Mon Feb 5 14:12:25 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 5 Feb 2007 13:12:25 -0600 Subject: [rspec-users] Spec'ing ActionMailer In-Reply-To: References: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> <676E68F2-5DEE-4743-BF4F-52FE33823220@gmail.com> <57c63afe0702041335j4f56988egb786e6d9f77518c6@mail.gmail.com> Message-ID: <57c63afe0702051112p7097624cj85fc813c30839653@mail.gmail.com> On 2/5/07, s.ross wrote: > David-- > > I still don't have this working (see my previous email with the > pastie attached), but now have another ActionMailer/rSpec question. > I'm spec'ing a different mailer model directly (instead of through > the controller). It's meant to be invoked through script/runner, so I > won't have a response object. > > I can see in the plugin source that there is assert_select_email > support, but I'm pretty sure there is no expectation that starts with > "assert." How would one spec something like: > > setup do > ActionMailer::Base.delivery_method = :test > ActionMailer::Base.perform_deliveries = true > ActionMailer::Base.deliveries = [] > MyMailer.trigger_emails # invokes model method to send 4 emails > end > > specify "d'oh! should have a non-empty recipient list" do > ActionMailer::Base.deliveries.size.should be(4) > ActionMailer::Base.deliveries.each do |email| > email.recipients.should_not be_empty > end > end assert_select doesn't wrap this sort of access, so neither does the port. What you've got there is probably what I'd do. Anything that RSpec would provide would wrap that anyhow. One thing you can do slightly differently is this: ActionMailer::Base.should have(4).deliveries That's in rspec core. > > specify "first email should have a list item with the name of the > first guy" do > ActionMailer::Base.deliveries[0].should select_tag('li', members > (:joe).name) > end This one you shold be able to do like this: specify "first email should have a list item with the name of the first guy" do response.should be_email { with_tag('li', members(:joe).name) } end Hope that helps a little. David > > > The above code is truly bogus and doesn't work. I'm trying to figure > out where to get the messages and how to specify the expectations on > them. > > Thanks, > > Steve > > > On Feb 4, 2007, at 1:35 PM, David Chelimsky wrote: > > > Steve - are you using the RSpec trunk? > > > > If you are, AND your email is html email, you can use this right now: > > > > response.should send_email { > > with_tag("div", "joe at shmoe.com") > > with_tag("div", projects(:trace).name) > > with_tag("div", member/show) > > } > > > > There is no specific support yet for email headers, nor raw text, > > though I can see now there is a need for that and will raise the > > appropriate RFE. > > > > David > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From cdemyanovich at gmail.com Mon Feb 5 14:22:04 2007 From: cdemyanovich at gmail.com (Craig Demyanovich) Date: Mon, 5 Feb 2007 14:22:04 -0500 Subject: [rspec-users] Spec'ing ActionMailer In-Reply-To: References: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> <676E68F2-5DEE-4743-BF4F-52FE33823220@gmail.com> <57c63afe0702041335j4f56988egb786e6d9f77518c6@mail.gmail.com> Message-ID: <9C71BD00-27F6-497C-AFF7-55700C335A9A@gmail.com> On Feb 5, 2007, at 1:52 PM, s.ross wrote: > David-- > > I still don't have this working (see my previous email with the > pastie attached), but now have another ActionMailer/rSpec question. > I'm spec'ing a different mailer model directly (instead of through > the controller). It's meant to be invoked through script/runner, so I > won't have a response object. Steve, Your comments got me thinking about this again. First, there is the behavior that you expect your controller to exhibit: that certain actions send email. Second, there is the behavior that your ActionMailer::Base derivative should exhibit: that it creates email as you like. Furthermore, you write that you want to invoke an ActionMailer::Base derivative via script/runner instead of or in addition to a controller. Therefore, you should specify their respective behaviors independently of one another. I'm including a code snippet from _Agile Web Development with Rails, 2nd ed._, that shows an example of testing the ActionMailer::Base derivative by itself. I'm sure you can translate the test to a spec. require File.dirname(__FILE__) + '/../test_helper' require 'order_mailer' class OrderMailerTest < Test::Unit::TestCase def setup @order = Order.new(:name =>"Dave Thomas", :email => "dave at pragprog.com") end def test_confirm response = OrderMailer.create_confirm(@order) assert_equal("Pragmatic Store Order Confirmation", response.subject) assert_equal("dave at pragprog.com", response.to[0]) assert_match(/Dear Dave Thomas/, response.body) end end Taking this approach will allow you to minimize the number of tests that you write to prove that the controller behaves as it should. Then, you can focus your attention on the ActionMailer::Base derivative alone for all the things you want to verify about the content of email. I hope this helps somehow. Regards, Craig From cwdinfo at gmail.com Mon Feb 5 14:45:56 2007 From: cwdinfo at gmail.com (s.ross) Date: Mon, 5 Feb 2007 11:45:56 -0800 Subject: [rspec-users] Spec'ing ActionMailer In-Reply-To: <9C71BD00-27F6-497C-AFF7-55700C335A9A@gmail.com> References: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> <676E68F2-5DEE-4743-BF4F-52FE33823220@gmail.com> <57c63afe0702041335j4f56988egb786e6d9f77518c6@mail.gmail.com> <9C71BD00-27F6-497C-AFF7-55700C335A9A@gmail.com> Message-ID: <1B5F5370-7A4A-43CA-AD9E-764FE9D57DE8@gmail.com> David/Craig-- Two tests are actually what I'm doing. I'm testing two separate mailers. The first is triggered as a side effect of an action. That mailer is inextricably intertwined with the controller, as it has to provide a URL to the page of someone who signed up, etc. I suppose I could mock the controller object, but does that really provide better results? The second mailer is, as mentioned, triggered from the command line and is being tested in a fashion similar to AWDROR's. Here is the (acckkk!) code I settled on, which IMO violates a lot of OO principles. require File.dirname(__FILE__) + '/../spec_helper.rb' context "A MemberDigest" do fixtures :members setup do ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] MemberDigest.trigger_emails # invokes model method to send 4 emails end specify "d'oh! should have a non-empty recipient list" do ActionMailer::Base.deliveries.size.should be(4) ActionMailer::Base.deliveries.inspect ActionMailer::Base.deliveries.each do |email| email.to_addrs.should_not be_empty end end specify "first email should have a list item with the name of the first guy" do ActionMailer::Base.deliveries.first.body.should_include(members (:existing_user_1).first) end teardown do ActionMailer::Base.deliveries.clear end end Comments? On Feb 5, 2007, at 11:22 AM, Craig Demyanovich wrote: > > On Feb 5, 2007, at 1:52 PM, s.ross wrote: > >> David-- >> >> I still don't have this working (see my previous email with the >> pastie attached), but now have another ActionMailer/rSpec question. >> I'm spec'ing a different mailer model directly (instead of through >> the controller). It's meant to be invoked through script/runner, so I >> won't have a response object. > > Steve, > > Your comments got me thinking about this again. First, there is the > behavior that you expect your controller to exhibit: that certain > actions send email. Second, there is the behavior that your > ActionMailer::Base derivative should exhibit: that it creates email > as you like. Furthermore, you write that you want to invoke an > ActionMailer::Base derivative via script/runner instead of or in > addition to a controller. > > Therefore, you should specify their respective behaviors > independently of one another. I'm including a code snippet from > _Agile Web Development with Rails, 2nd ed._, that shows an example of > testing the ActionMailer::Base derivative by itself. I'm sure you can > translate the test to a spec. > > require File.dirname(__FILE__) + '/../test_helper' > require 'order_mailer' > > class OrderMailerTest < Test::Unit::TestCase > def setup > @order = Order.new(:name =>"Dave Thomas", :email => > "dave at pragprog.com") > end > > def test_confirm > response = OrderMailer.create_confirm(@order) > assert_equal("Pragmatic Store Order Confirmation", > response.subject) > assert_equal("dave at pragprog.com", response.to[0]) > assert_match(/Dear Dave Thomas/, response.body) > end > end > > Taking this approach will allow you to minimize the number of tests > that you write to prove that the controller behaves as it should. > Then, you can focus your attention on the ActionMailer::Base > derivative alone for all the things you want to verify about the > content of email. I hope this helps somehow. > > Regards, > Craig > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From cdemyanovich at gmail.com Mon Feb 5 19:02:26 2007 From: cdemyanovich at gmail.com (Craig Demyanovich) Date: Mon, 5 Feb 2007 19:02:26 -0500 Subject: [rspec-users] Spec'ing ActionMailer In-Reply-To: <1B5F5370-7A4A-43CA-AD9E-764FE9D57DE8@gmail.com> References: <6062617A-0CEB-4C3E-8174-8037C3B756F7@gmail.com> <9C0A4BB1-16F3-447B-BAEC-19CAC144A52F@gmail.com> <676E68F2-5DEE-4743-BF4F-52FE33823220@gmail.com> <57c63afe0702041335j4f56988egb786e6d9f77518c6@mail.gmail.com> <9C71BD00-27F6-497C-AFF7-55700C335A9A@gmail.com> <1B5F5370-7A4A-43CA-AD9E-764FE9D57DE8@gmail.com> Message-ID: <2D3A5909-BA53-4DF1-95E4-EBFE2E7EB8DA@gmail.com> On Feb 5, 2007, at 2:45 PM, s.ross wrote: > David/Craig-- > > Two tests are actually what I'm doing. I'm testing two separate > mailers. The first is triggered as a side effect of an action. That > mailer is inextricably intertwined with the controller, as it has to > provide a URL to the page of someone who signed up, etc. I suppose I > could mock the controller object, but does that really provide better > results? Isolating the controller and mailer as much as possible is the best approach, IMHO. And, I don't think any mailer has to be bound tightly to a controller. Here's what I'd do. Specify each mailer in isolation, focusing on all the interesting bits of the email messages that the mailers will create. For example: context "An email for a new member" do ... specify "includes the URL used at sign up" do mail = MemberDigest.create_welcome(@member) mail.body.should_match /"#{@member.url}"/ end ... end Then I'd mock/stub the one mailer and verify that the controller uses it correctly. As a second option, I'd just let the controller use the mailer and verify that I had one delivery; I wouldn't pick apart the delivery, though, since I'd be comfortable that I'd specified the mailer well enough already. > > The second mailer is, as mentioned, triggered from the command line > and is being tested in a fashion similar to AWDROR's. Here is the > (acckkk!) code I settled on, which IMO violates a lot of OO > principles. > > require File.dirname(__FILE__) + '/../spec_helper.rb' > > context "A MemberDigest" do > fixtures :members > > setup do > ActionMailer::Base.delivery_method = :test > ActionMailer::Base.perform_deliveries = true > ActionMailer::Base.deliveries = [] > MemberDigest.trigger_emails # invokes model method to send 4 > emails > end > > specify "d'oh! should have a non-empty recipient list" do > ActionMailer::Base.deliveries.size.should be(4) > ActionMailer::Base.deliveries.inspect > ActionMailer::Base.deliveries.each do |email| > email.to_addrs.should_not be_empty > end > end > > specify "first email should have a list item with the name of the > first guy" do > ActionMailer::Base.deliveries.first.body.should_include(members > (:existing_user_1).first) > end > > teardown do > ActionMailer::Base.deliveries.clear > end > end > > Comments? Again, I'm tempted to specify the mailer in isolation and either trust that delivery will happen if I ask for it or specify delivery in isolation. Bear in mind that I might be missing something about this example, as my experience with Rails is still somewhat limited. > > > On Feb 5, 2007, at 11:22 AM, Craig Demyanovich wrote: > >> >> On Feb 5, 2007, at 1:52 PM, s.ross wrote: >> >>> David-- >>> >>> I still don't have this working (see my previous email with the >>> pastie attached), but now have another ActionMailer/rSpec question. >>> I'm spec'ing a different mailer model directly (instead of through >>> the controller). It's meant to be invoked through script/runner, >>> so I >>> won't have a response object. >> >> Steve, >> >> Your comments got me thinking about this again. First, there is the >> behavior that you expect your controller to exhibit: that certain >> actions send email. Second, there is the behavior that your >> ActionMailer::Base derivative should exhibit: that it creates email >> as you like. Furthermore, you write that you want to invoke an >> ActionMailer::Base derivative via script/runner instead of or in >> addition to a controller. >> >> Therefore, you should specify their respective behaviors >> independently of one another. I'm including a code snippet from >> _Agile Web Development with Rails, 2nd ed._, that shows an example of >> testing the ActionMailer::Base derivative by itself. I'm sure you can >> translate the test to a spec. >> >> require File.dirname(__FILE__) + '/../test_helper' >> require 'order_mailer' >> >> class OrderMailerTest < Test::Unit::TestCase >> def setup >> @order = Order.new(:name =>"Dave Thomas", :email => >> "dave at pragprog.com") >> end >> >> def test_confirm >> response = OrderMailer.create_confirm(@order) >> assert_equal("Pragmatic Store Order Confirmation", >> response.subject) >> assert_equal("dave at pragprog.com", response.to[0]) >> assert_match(/Dear Dave Thomas/, response.body) >> end >> end >> >> Taking this approach will allow you to minimize the number of tests >> that you write to prove that the controller behaves as it should. >> Then, you can focus your attention on the ActionMailer::Base >> derivative alone for all the things you want to verify about the >> content of email. I hope this helps somehow. >> >> Regards, >> Craig >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From pergesu at gmail.com Tue Feb 6 21:11:17 2007 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 6 Feb 2007 18:11:17 -0800 Subject: [rspec-users] Mocking ActiveResource Message-ID: <810a540e0702061811n5036f613i6070d24df05f82aa@mail.gmail.com> I want to use ActiveResource in my app. Instead of hitting server though, I want it to load from a file when I call find. Any clue how I do that? Pat From aslak.hellesoy at gmail.com Wed Feb 7 03:41:35 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 7 Feb 2007 09:41:35 +0100 Subject: [rspec-users] Mocking ActiveResource In-Reply-To: <810a540e0702061811n5036f613i6070d24df05f82aa@mail.gmail.com> References: <810a540e0702061811n5036f613i6070d24df05f82aa@mail.gmail.com> Message-ID: <8d961d900702070041l5ee5d43dv743386b3cfbb3fed@mail.gmail.com> On 2/7/07, Pat Maddox wrote: > I want to use ActiveResource in my app. Instead of hitting server > though, I want it to load from a file when I call find. Any clue how > I do that? > In the same way as you'd mock ActiveRecord I would think. Is this not working for you? Aslak > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mlangenberg at gmail.com Wed Feb 7 03:53:20 2007 From: mlangenberg at gmail.com (Matthijs Langenberg) Date: Wed, 7 Feb 2007 09:53:20 +0100 Subject: [rspec-users] Mocking ActiveResource In-Reply-To: <810a540e0702061811n5036f613i6070d24df05f82aa@mail.gmail.com> References: <810a540e0702061811n5036f613i6070d24df05f82aa@mail.gmail.com> Message-ID: <27c0ac6d0702070053y3bf14754k6474d91df5d32c0e@mail.gmail.com> I think you need to stub the ActiveResource methods like 'create' and 'find', assuming the ActiveResource library is well tested you should be able to test only the behaviour you are writing instead of the REST communication. On 2/7/07, Pat Maddox wrote: > I want to use ActiveResource in my app. Instead of hitting server > though, I want it to load from a file when I call find. Any clue how > I do that? > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Wed Feb 7 05:55:29 2007 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 Feb 2007 02:55:29 -0800 Subject: [rspec-users] Mocking ActiveResource In-Reply-To: <8d961d900702070041l5ee5d43dv743386b3cfbb3fed@mail.gmail.com> References: <810a540e0702061811n5036f613i6070d24df05f82aa@mail.gmail.com> <8d961d900702070041l5ee5d43dv743386b3cfbb3fed@mail.gmail.com> Message-ID: <810a540e0702070255o31b21bc7w1d42e5c0935a2716@mail.gmail.com> On 2/7/07, aslak hellesoy wrote: > On 2/7/07, Pat Maddox wrote: > > I want to use ActiveResource in my app. Instead of hitting server > > though, I want it to load from a file when I call find. Any clue how > > I do that? > > > > In the same way as you'd mock ActiveRecord I would think. Is this not > working for you? No I want it to actually go through the process of finding something, but just have it use a file rather than an actual server. Takes a couple steps (with my current solution): 1. Mock Net::HTTP.new to return some mock http object 2. mock http_object.get to return a mock http response 3. mock http_response.body to return the contents of your file I think http_object has to have :null_object => true if you want to keep things simple. I ended up tossing ARes altogether, so I'm not actually using it at this point. But that's at least pretty close to what I did. Ugly, but it worked. Pat From aslak.hellesoy at gmail.com Wed Feb 7 06:49:40 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 7 Feb 2007 12:49:40 +0100 Subject: [rspec-users] Mocking ActiveResource In-Reply-To: <810a540e0702070255o31b21bc7w1d42e5c0935a2716@mail.gmail.com> References: <810a540e0702061811n5036f613i6070d24df05f82aa@mail.gmail.com> <8d961d900702070041l5ee5d43dv743386b3cfbb3fed@mail.gmail.com> <810a540e0702070255o31b21bc7w1d42e5c0935a2716@mail.gmail.com> Message-ID: <8d961d900702070349v534aed03l7616279e5f717783@mail.gmail.com> On 2/7/07, Pat Maddox wrote: > On 2/7/07, aslak hellesoy wrote: > > On 2/7/07, Pat Maddox wrote: > > > I want to use ActiveResource in my app. Instead of hitting server > > > though, I want it to load from a file when I call find. Any clue how > > > I do that? > > > > > > > In the same way as you'd mock ActiveRecord I would think. Is this not > > working for you? > > No I want it to actually go through the process of finding something, > but just have it use a file rather than an actual server. > I see, so you don't want to mock ActiveResource, but the transport used by it. This is an approach that I generally don't recommend. The lower level you're mocking at (HTTP, database connections, File I/O etc) the more you have to set up and things become very verbose and fragile. As a general rule: Don't mock APIs you don't own. Why don't you just mock at a higher level - your ActiveResource classes? The ActiveResource classes themselves I would verify against the real transport, without mocking. The same goes for ActiveRecord. Their specs run against the database, but specs for anything *using* ActiveRecord/ActiveResource will talk to mock instances. Aslak > Takes a couple steps (with my current solution): > 1. Mock Net::HTTP.new to return some mock http object > 2. mock http_object.get to return a mock http response > 3. mock http_response.body to return the contents of your file > > I think http_object has to have :null_object => true if you want to > keep things simple. > > I ended up tossing ARes altogether, so I'm not actually using it at > this point. But that's at least pretty close to what I did. Ugly, > but it worked. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Wed Feb 7 12:10:16 2007 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 7 Feb 2007 09:10:16 -0800 Subject: [rspec-users] Mocking ActiveResource In-Reply-To: <8d961d900702070349v534aed03l7616279e5f717783@mail.gmail.com> References: <810a540e0702061811n5036f613i6070d24df05f82aa@mail.gmail.com> <8d961d900702070041l5ee5d43dv743386b3cfbb3fed@mail.gmail.com> <810a540e0702070255o31b21bc7w1d42e5c0935a2716@mail.gmail.com> <8d961d900702070349v534aed03l7616279e5f717783@mail.gmail.com> Message-ID: <810a540e0702070910p5f4656ecp370fece7306c51fb@mail.gmail.com> On 2/7/07, aslak hellesoy wrote: > On 2/7/07, Pat Maddox wrote: > > On 2/7/07, aslak hellesoy wrote: > > > On 2/7/07, Pat Maddox wrote: > > > > I want to use ActiveResource in my app. Instead of hitting server > > > > though, I want it to load from a file when I call find. Any clue how > > > > I do that? > > > > > > > > > > In the same way as you'd mock ActiveRecord I would think. Is this not > > > working for you? > > > > No I want it to actually go through the process of finding something, > > but just have it use a file rather than an actual server. > > > > I see, so you don't want to mock ActiveResource, but the transport used by it. Right > This is an approach that I generally don't recommend. The lower level > you're mocking at (HTTP, database connections, File I/O etc) the more > you have to set up and things become very verbose and fragile. As a > general rule: > > Don't mock APIs you don't own. I agree with you. This is certainly how I work with my AR classes. However there's a big difference in maturity between AR and ARes. ARes isn't even "official" yet. So while with AR I can mock MyClass.find and know that AR does the right thing, I'm not entirely sure with ARes. I don't know how it's going to parse an XML document. Turns out it did some funky things and I couldn't use it. Once I had one spec that demonstrated ARes worked for my purposes, I'd just mock out all subsequent specs. Pat From jeremy.burks at gmail.com Wed Feb 7 12:14:20 2007 From: jeremy.burks at gmail.com (Jeremy Burks) Date: Wed, 7 Feb 2007 11:14:20 -0600 Subject: [rspec-users] advice on a spec'ing best practice Message-ID: i am in the process of converting the tests in two projects that i am working on (one rails, one ruby) to rspec. i felt like i was doing ok applying BDD and using rspec properly until i read a comment in another topic on the list from David (subject "long jumping out of code in specs"). In there it was said: --- Testing privates is a no-no, but testing that a public method on the same class gets called is almost as dirty for the same reasons. It's less likely to be a problem than private methods because it's more stable (public methods are inherently more stable than privates), but it still feels like a design smell - especially if you have to intercept calls to that method (partial mocks), as you are doing. --- Hopefully i didn't take that out of context. This statement got me thinking about how i am witting my sepcs because i have been intercepting calls to methods on the class that is being spec'd. I do it mostly to isolate the code being tested as much as possible. I am hoping to get some advice on how to spec this method. class Foo def each_project projects.each do|project| yield(project, project.name) end end end projects is an attribute of class Foo. Normally i would mock the projects attribute to return an array of mocks. That would allow me to verify the yield is working as it should. Based on David's comment that seems to be a smell. Is that correct? The alternative i see is to use dependency injection and pass the list of projects in the initialize method of class Foo. Or maybe inject the class responsible for initializing the projects. class Foo def initialize(projects) @projects = projects end end Thoughts? From micah at 8thlight.com Wed Feb 7 11:59:25 2007 From: micah at 8thlight.com (Micah Martin) Date: Wed, 7 Feb 2007 10:59:25 -0600 Subject: [rspec-users] odd mock behavior Message-ID: <2BE5CDA0-BF97-495D-8577-699FEA57257E@8thlight.com> I'm seeing some odd behavior around the should_receive() when given a block combined with some cardinality. For example, with the following... my_mock.should_receive(:foo).twice do |i| puts i end ... the spec passes but i never gets puts'ed. With the following... my_mock.should_receive(:foo) do |i| puts i end ... i gets puts'ed twice but the spec fails because it was only expecting one call to :foo. Micah Martin 8th Light, Inc. 8thlight.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070207/19e5c667/attachment-0001.html From dchelimsky at gmail.com Wed Feb 7 12:45:44 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Feb 2007 11:45:44 -0600 Subject: [rspec-users] odd mock behavior In-Reply-To: <2BE5CDA0-BF97-495D-8577-699FEA57257E@8thlight.com> References: <2BE5CDA0-BF97-495D-8577-699FEA57257E@8thlight.com> Message-ID: <57c63afe0702070945x7486fe17r474e2668378b96c@mail.gmail.com> On 2/7/07, Micah Martin wrote: > I'm seeing some odd behavior around the should_receive() when given a block > combined with some cardinality. > > For example, with the following... > > my_mock.should_receive(:foo).twice do |i| > puts i > end Blocks aren't currently supported in any form besides: my_mock.should_receive(args) { } Since none of the other methods (#with, #once, #twice, etc) deal with a block, the block is never being invoked. Feel free to submit an RFE if you feel this should be supported. Cheers, David > > ... the spec passes but i never gets puts'ed. > > With the following... > > my_mock.should_receive(:foo) do |i| > puts i > end > > ... i gets puts'ed twice but the spec fails because it was only expecting > one call to :foo. > > > Micah Martin > 8th Light, Inc. > 8thlight.com > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Feb 7 12:54:13 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Feb 2007 11:54:13 -0600 Subject: [rspec-users] advice on a spec'ing best practice In-Reply-To: References: Message-ID: <57c63afe0702070954n709602fcg7264c0eea78b036a@mail.gmail.com> On 2/7/07, Jeremy Burks wrote: > i am in the process of converting the tests in two projects that i am > working on (one rails, one ruby) to rspec. i felt like i was doing ok > applying BDD and using rspec properly until i read a comment in > another topic on the list from David (subject "long jumping out of > code in specs"). In there it was said: > > --- > Testing privates is a no-no, but testing that a public method on the > same class gets called is almost as dirty for the same reasons. It's > less likely to be a problem than private methods > because it's more stable (public methods are inherently more stable > than privates), but it still feels like a design smell - especially if > you have to intercept calls to that method (partial mocks), as you are > doing. > --- > > Hopefully i didn't take that out of context. > > This statement got me thinking about how i am witting my sepcs because > i have been intercepting calls to methods on the class that is being > spec'd. I do it mostly to isolate the code being tested as much as > possible. > > I am hoping to get some advice on how to spec this method. > > class Foo > def each_project > projects.each do|project| > yield(project, project.name) > end > end > end > > projects is an attribute of class Foo. Normally i would mock the > projects attribute to return an array of mocks. That would allow me to > verify the yield is working as it should. Based on David's comment > that seems to be a smell. > > Is that correct? > > The alternative i see is to use dependency injection and pass the list > of projects in the initialize method of class Foo. Or maybe inject the > class responsible for initializing the projects. > > class Foo > def initialize(projects) > @projects = projects > end > end I'd rather add an add_project method than have a list passed in. Otherwise, this is probably how I'd approach it. > > Thoughts? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From micah at 8thlight.com Wed Feb 7 14:29:47 2007 From: micah at 8thlight.com (Micah Martin) Date: Wed, 7 Feb 2007 13:29:47 -0600 Subject: [rspec-users] odd mock behavior In-Reply-To: <57c63afe0702070945x7486fe17r474e2668378b96c@mail.gmail.com> References: <2BE5CDA0-BF97-495D-8577-699FEA57257E@8thlight.com> <57c63afe0702070945x7486fe17r474e2668378b96c@mail.gmail.com> Message-ID: <6C49DA98-FAE0-4ACF-838D-92023D0AB923@8thlight.com> Thanks David. That explains it. RFE submitted with specs: https://rubyforge.org/tracker/index.php? func=detail&aid=8484&group_id=797&atid=3152 Micah Martin 8th Light, Inc. 8thlight.com On Feb 7, 2007, at 11:45 AM, David Chelimsky wrote: > > Blocks aren't currently supported in any form besides: > > my_mock.should_receive(args) { > } > > Since none of the other methods (#with, #once, #twice, etc) deal with > a block, the block is never being invoked. > > Feel free to submit an RFE if you feel this should be supported. > > Cheers, > David -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070207/4e8ae9a4/attachment.html From dchelimsky at gmail.com Wed Feb 7 15:07:31 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 7 Feb 2007 14:07:31 -0600 Subject: [rspec-users] odd mock behavior In-Reply-To: <6C49DA98-FAE0-4ACF-838D-92023D0AB923@8thlight.com> References: <2BE5CDA0-BF97-495D-8577-699FEA57257E@8thlight.com> <57c63afe0702070945x7486fe17r474e2668378b96c@mail.gmail.com> <6C49DA98-FAE0-4ACF-838D-92023D0AB923@8thlight.com> Message-ID: <57c63afe0702071207q4c396bcbt71ba351569e15a9b@mail.gmail.com> On 2/7/07, Micah Martin wrote: > Thanks David. That explains it. > > RFE submitted with specs: > https://rubyforge.org/tracker/index.php?func=detail&aid=8484&group_id=797&atid=3152 Thanks. I'm already on this and will commit the fix tonight. Cheers > > Micah Martin > 8th Light, Inc. > 8thlight.com > > On Feb 7, 2007, at 11:45 AM, David Chelimsky wrote: > > Blocks aren't currently supported in any form besides: > > my_mock.should_receive(args) { > } > > Since none of the other methods (#with, #once, #twice, etc) deal with > a block, the block is never being invoked. > > Feel free to submit an RFE if you feel this should be supported. > > Cheers, > David > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From kevwil at gmail.com Thu Feb 8 00:17:41 2007 From: kevwil at gmail.com (Kevin Williams) Date: Wed, 7 Feb 2007 22:17:41 -0700 Subject: [rspec-users] testing ajax responder actions Message-ID: <683a886f0702072117i3aaa4fbcs52c9a2fe1fa2cf27@mail.gmail.com> I have an Ajax responder method which uses respond_to to make sure it only works with Ajax. I'm having trouble figuring out how to call this action successfully. I'm using Rails 1.2.x. Any thoughts? -- Cheers, Kevin Williams http://www.almostserio.us/ "Any sufficiently advanced technology is indistinguishable from Magic." - Arthur C. Clarke From jerry.west at ntlworld.com Thu Feb 8 08:46:34 2007 From: jerry.west at ntlworld.com (Jerry West) Date: Thu, 08 Feb 2007 13:46:34 +0000 Subject: [rspec-users] testing ajax responder actions In-Reply-To: <683a886f0702072117i3aaa4fbcs52c9a2fe1fa2cf27@mail.gmail.com> References: <683a886f0702072117i3aaa4fbcs52c9a2fe1fa2cf27@mail.gmail.com> Message-ID: <45CB29BA.8030108@ntlworld.com> An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070208/067b6733/attachment.html From kevwil at gmail.com Thu Feb 8 10:05:51 2007 From: kevwil at gmail.com (Kevin Williams) Date: Thu, 8 Feb 2007 08:05:51 -0700 Subject: [rspec-users] testing ajax responder actions In-Reply-To: <45CB29BA.8030108@ntlworld.com> References: <683a886f0702072117i3aaa4fbcs52c9a2fe1fa2cf27@mail.gmail.com> <45CB29BA.8030108@ntlworld.com> Message-ID: <683a886f0702080705g3e3970bbx303b8face5ff9713@mail.gmail.com> Sweet! I can't wait to try that tonight. Thanks! On 2/8/07, Jerry West wrote: > > Kevin, > > You can use #xhr instead of #get or #post, thus... > > xhr :post, :create, :id => etc... > > this will send something that the controller is able to recognise as an > AJAX request. > > #xhr is inherited from the original Rails test framework, but rather taken > for granted in the Rspec docs (I'll submit a request to improve them). > > Hope this helps, > Jerry > > Kevin Williams wrote: > I have an Ajax responder method which uses respond_to to make sure it > only works with Ajax. I'm having trouble figuring out how to call this > action successfully. I'm using Rails 1.2.x. Any thoughts? > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Cheers, Kevin Williams http://www.almostserio.us/ "Any sufficiently advanced technology is indistinguishable from Magic." - Arthur C. Clarke From ed.howland at gmail.com Fri Feb 9 11:49:35 2007 From: ed.howland at gmail.com (Ed Howland) Date: Fri, 9 Feb 2007 10:49:35 -0600 Subject: [rspec-users] testing ajax responder actions In-Reply-To: <45CB29BA.8030108@ntlworld.com> References: <683a886f0702072117i3aaa4fbcs52c9a2fe1fa2cf27@mail.gmail.com> <45CB29BA.8030108@ntlworld.com> Message-ID: <3df642dd0702090849x5c5a0eaboc63590998e5d3f3c@mail.gmail.com> On 2/8/07, Jerry West wrote: > > Kevin, > > You can use #xhr instead of #get or #post, thus... > > xhr :post, :create, :id => etc... > > this will send something that the controller is able to recognise as an > AJAX request. This part seems to work, but when I do: controller.should_render_rjs :replace_html 'div_id', 'some text' I get nil does not respond to 'rjs' or 'has_rjs' Any help would be appreciated. Thanks > > #xhr is inherited from the original Rails test framework, but rather taken > for granted in the Rspec docs (I'll submit a request to improve them). > > Hope this helps, > Jerry > > Kevin Williams wrote: > I have an Ajax responder method which uses respond_to to make sure it > only works with Ajax. I'm having trouble figuring out how to call this > action successfully. I'm using Rails 1.2.x. Any thoughts? > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Ed Howland http://greenprogrammer.blogspot.com From justnothing at tiscali.co.uk Sat Feb 10 09:43:48 2007 From: justnothing at tiscali.co.uk (David Green) Date: Sat, 10 Feb 2007 06:43:48 -0800 (PST) Subject: [rspec-users] rspec and cookies In-Reply-To: <41d5fadf0701291203y6b4fb291l234a32000594ede2@mail.gmail.com> References: <8686339.post@talk.nabble.com> <41d5fadf0701291203y6b4fb291l234a32000594ede2@mail.gmail.com> Message-ID: <8901309.post@talk.nabble.com> Hello David, 2007/1/29, David Green : > I know I can use cookies[:name] = 'value' to set a cookie but how would I > set expiry information on such a cookie? when i try to pass a hash {:value > => 'value', :expires => 3.days.from_now} the entire hash becomes the value > of cookies[:name] When the cookie comes back through the browser, it never has any expiration or options. The browser handles that information. That's why you can't set those options on the requesting side. When responding, however... that's another story. Hope that helps ! -- thanks Francois. That explains a lot. -- View this message in context: http://www.nabble.com/rspec-and-cookies-tf3134883.html#a8901309 Sent from the rspec-users mailing list archive at Nabble.com. From graeme.nelson at gmail.com Sun Feb 11 16:07:19 2007 From: graeme.nelson at gmail.com (Graeme Nelson) Date: Sun, 11 Feb 2007 13:07:19 -0800 Subject: [rspec-users] Specing Rails Views Message-ID: Hello - I'm currently trying to write some specs for my rails views. My views depend upon the restful authentication plugin method logged_in? Like so, <% if logged_in? %>
    <%= link_to "create a new product", new_product_url %>
<% end %> However, when I have the following in my specification: render "products/show" I get an error 'logged_in?' isn't defined for <#Class....> My rails app gets 'logged_in?' via 'include AuthenticatedSystem' in my application controller. I understand that views are tested in isolation from their controller counterpart in rpsec, so 'include AuthenticatedSystem' isn't called and thus 'logged_in?' isn't available for the test/spec. I found a couple of work arounds. 1) add a method logged_in? into the application_helper.rb or _helper.rb (where is the controller associated with the current view being tested.) 2) add a method in my setup to mock the :logged_in? call in the template, like so: @controller.template.stub!(:logged_in?).and_return(true) I am sure there are other ways to make 'logged_in?' available to the template being tested. I am currently leaning towards #2 since it doesn't touch any of my application code. Anyone else have some ideas? Thanks in advanced. graeme nelson From jchris at mfdz.com Sun Feb 11 17:47:03 2007 From: jchris at mfdz.com (Chris Anderson) Date: Sun, 11 Feb 2007 14:47:03 -0800 Subject: [rspec-users] Specing Rails Views In-Reply-To: References: Message-ID: On 2/11/07, Graeme Nelson wrote: > 2) add a method in my setup to mock the :logged_in? call in the > template, like so: > > > @controller.template.stub!(:logged_in?).and_return(true) > This looks like a fine way to do it, to me. Treating logged_in? as just another attribute to be passed to the view (albeit in a slightly specialized way, as it is a method called in the view) seems like the right thing. This would make it easy to spec views in both the logged in and logged out cases. I still haven't gotten into specing views - as long as they don't throw nasty errors, and they are valid xml, I let my designers handle the work. But once we stablize the look and feel, I'll probably be looking to add some regression type verification on the views. -- Chris Anderson http://jchris.mfdz.com From work at ashleymoran.me.uk Mon Feb 12 09:43:23 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Mon, 12 Feb 2007 14:43:23 +0000 Subject: [rspec-users] Specs for Ajax partials with unicode characters Message-ID: <4E6DFE03-2915-4E6F-AEAD-F91056FE23A0@ashleymoran.me.uk> Hi Not sure if this is more Rails or RSpec related... I've got an app with an RJS view that updates a div in a page with the contents of a partial. The partial contains a non-ascii character namely a pound sign. I set up a simple test app with this RJS view: page.replace_html("test_div", :partial => "test_action") and this _test_action.rhtml:

?500

Now this spec fails: require File.dirname(__FILE__) + '/../../spec_helper' context "Given a request to render view_test/test_action" do setup do render 'view_test/test_action' end specify "the response should have a p with ?500" do response.should_have_tag 'p', :content => '?500' end specify "the response should definitely have a p with ?500" do response.should_have 'p', :text => '?500' end end The error for the should_have_tag gives this error message: Element.update("test_div", "

\u00a3500

"); should include ["[\"p\", {:content=>\"?500\"}]"] I don't know, well, anything about JavaScript but I'm informed by one of our developers that the replacement string is in JSON format. Either way the only way to make the specs pass is to use :content (or :text) => '\u00a3500' which is completely different from the contents of the partial, so not a brilliant solution. An alternative is to use £ for ?, but that kinda defeats the point of using UTF8. Any ideas how I can get round this? Cheers Ashley From dchelimsky at gmail.com Mon Feb 12 10:13:38 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 12 Feb 2007 08:13:38 -0700 Subject: [rspec-users] Specs for Ajax partials with unicode characters In-Reply-To: <4E6DFE03-2915-4E6F-AEAD-F91056FE23A0@ashleymoran.me.uk> References: <4E6DFE03-2915-4E6F-AEAD-F91056FE23A0@ashleymoran.me.uk> Message-ID: <57c63afe0702120713s1003d1cbm2ee7a6482ea05795@mail.gmail.com> On 2/12/07, Ashley Moran wrote: > Hi > > Not sure if this is more Rails or RSpec related... > > I've got an app with an RJS view that updates a div in a page with > the contents of a partial. The partial contains a non-ascii > character namely a pound sign. > > I set up a simple test app with this RJS view: > page.replace_html("test_div", :partial => "test_action") > > and this _test_action.rhtml: >

?500

> > Now this spec fails: > require File.dirname(__FILE__) + '/../../spec_helper' > > context "Given a request to render view_test/test_action" do > setup do > render 'view_test/test_action' > end > > specify "the response should have a p with ?500" do > response.should_have_tag 'p', :content => '?500' > end > > specify "the response should definitely have a p with ?500" do > response.should_have 'p', :text => '?500' > end > end > > The error for the should_have_tag gives this error message: > Element.update("test_div", "

\u00a3500

"); should include > ["[\"p\", {:content=>\"?500\"}]"] Ashley - are both specs failing? Or just the one using "should_have_tag"? > > I don't know, well, anything about JavaScript but I'm informed by one > of our developers that the replacement string is in JSON format. > Either way the only way to make the specs pass is to use :content > (or :text) => '\u00a3500' which is completely different from the > contents of the partial, so not a brilliant solution. An alternative > is to use £ for ?, but that kinda defeats the point of using UTF8. > > Any ideas how I can get round this? > > Cheers > Ashley > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From work at ashleymoran.me.uk Mon Feb 12 11:30:00 2007 From: work at ashleymoran.me.uk (Ashley Moran) Date: Mon, 12 Feb 2007 16:30:00 +0000 Subject: [rspec-users] Specs for Ajax partials with unicode characters In-Reply-To: <57c63afe0702120713s1003d1cbm2ee7a6482ea05795@mail.gmail.com> References: <4E6DFE03-2915-4E6F-AEAD-F91056FE23A0@ashleymoran.me.uk> <57c63afe0702120713s1003d1cbm2ee7a6482ea05795@mail.gmail.com> Message-ID: <1B7BC488-E5AA-41CA-9924-89A4DECC2636@ashleymoran.me.uk> On 12 Feb 2007, at 15:13, David Chelimsky wrote: > Ashley - are both specs failing? Or just the one using > "should_have_tag"? David Both specs fail. The text mangling must happen before it reaches RSpec, so that both assertions see the same encoded string. Ashley From deepak.jois at gmail.com Tue Feb 13 01:33:54 2007 From: deepak.jois at gmail.com (Deepak Jois) Date: Tue, 13 Feb 2007 14:33:54 +0800 Subject: [rspec-users] Error against latest trunk while testing via spec for model Message-ID: <24dc07380702122233n264be62bqe5d3dffb59536684@mail.gmail.com> Hi I just did an update to lates trunk ================= context "Given a generated venue_spec.rb with fixtures loaded" do fixtures :venues specify "fixtures should load two Venues" do Venue.should have(2).records end end ================== gives me ========== 1) TypeError in 'Given a generated venue_spec.rb with fixtures loaded fixtures should load two Venues' can't convert nil into String ========== This was working fine before I did an update. Could anyone tell me what is going on? From aslak.hellesoy at gmail.com Tue Feb 13 02:20:16 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Feb 2007 08:20:16 +0100 Subject: [rspec-users] Error against latest trunk while testing via spec for model In-Reply-To: <24dc07380702122233n264be62bqe5d3dffb59536684@mail.gmail.com> References: <24dc07380702122233n264be62bqe5d3dffb59536684@mail.gmail.com> Message-ID: <8d961d900702122320v780ce47av32586be83fae90ce@mail.gmail.com> We need the backtrace. Can you run again with --backtrace Aslak On 2/13/07, Deepak Jois wrote: > Hi > I just did an update to lates trunk > ================= > context "Given a generated venue_spec.rb with fixtures loaded" do > fixtures :venues > > specify "fixtures should load two Venues" do > Venue.should have(2).records > end > end > ================== > > gives me > > ========== > 1) > TypeError in 'Given a generated venue_spec.rb with fixtures loaded > fixtures should load two Venues' > can't convert nil into String > ========== > > This was working fine before I did an update. Could anyone tell me > what is going on? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From deepak.jois at gmail.com Tue Feb 13 02:28:49 2007 From: deepak.jois at gmail.com (Deepak Jois) Date: Tue, 13 Feb 2007 15:28:49 +0800 Subject: [rspec-users] Error against latest trunk while testing via spec for model In-Reply-To: <8d961d900702122320v780ce47av32586be83fae90ce@mail.gmail.com> References: <24dc07380702122233n264be62bqe5d3dffb59536684@mail.gmail.com> <8d961d900702122320v780ce47av32586be83fae90ce@mail.gmail.com> Message-ID: <24dc07380702122328x3dbcd8b1g6018dbd8848048fc@mail.gmail.com> On 2/13/07, aslak hellesoy wrote: > We need the backtrace. Can you run again with --backtrace > > =============== 1) TypeError in 'Given a generated venue_spec.rb with fixtures loaded fixtures should load two Venues' can't convert nil into String /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:251:in `join' /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:251:in `create_fixtures' /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:250:in `create_fixtures' /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/base.rb:890:in `silence' /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:248:in `create_fixtures' /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:581:in `load_fixtures' /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:535:in `setup_with_fixtures' /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_eval.rb:131:in `create_block_from_parts' /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_eval.rb:129:in `create_block_from_parts' /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/specification.rb:47:in `setup_spec' /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/specification.rb:29:in `run' /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context.rb:58:in `run' /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context.rb:55:in `run' /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_runner.rb:23:in `run' /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_runner.rb:22:in `run' /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/command_line.rb:27:in `run' vendor/plugins/rspec/bin/spec:4: ======================== FWIW, here is my fixtures file file ======= one: id: 1 name: LT1 description: Lecture Theatre 1 active: 1 two: id: 2 name: LT2 description: Lecture Theatre 2 active: 0 ========= The schema of the table matches the fields in the YAML file From aslak.hellesoy at gmail.com Tue Feb 13 03:11:47 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Feb 2007 09:11:47 +0100 Subject: [rspec-users] Error against latest trunk while testing via spec for model In-Reply-To: <24dc07380702122328x3dbcd8b1g6018dbd8848048fc@mail.gmail.com> References: <24dc07380702122233n264be62bqe5d3dffb59536684@mail.gmail.com> <8d961d900702122320v780ce47av32586be83fae90ce@mail.gmail.com> <24dc07380702122328x3dbcd8b1g6018dbd8848048fc@mail.gmail.com> Message-ID: <8d961d900702130011q63f52ffbja0f69bd90bb937be@mail.gmail.com> Rails version? svn revision? On 2/13/07, Deepak Jois wrote: > On 2/13/07, aslak hellesoy wrote: > > We need the backtrace. Can you run again with --backtrace > > > > > =============== > 1) > TypeError in 'Given a generated venue_spec.rb with fixtures loaded > fixtures should load two Venues' > can't convert nil into String > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:251:in > `join' > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:251:in > `create_fixtures' > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:250:in > `create_fixtures' > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/base.rb:890:in > `silence' > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:248:in > `create_fixtures' > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:581:in > `load_fixtures' > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:535:in > `setup_with_fixtures' > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_eval.rb:131:in > `create_block_from_parts' > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_eval.rb:129:in > `create_block_from_parts' > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/specification.rb:47:in > `setup_spec' > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/specification.rb:29:in > `run' > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context.rb:58:in > `run' > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context.rb:55:in > `run' > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_runner.rb:23:in > `run' > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_runner.rb:22:in > `run' > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/command_line.rb:27:in > `run' > vendor/plugins/rspec/bin/spec:4: > ======================== > > FWIW, here is my fixtures file file > > ======= > one: > id: 1 > name: LT1 > description: Lecture Theatre 1 > active: 1 > two: > id: 2 > name: LT2 > description: Lecture Theatre 2 > active: 0 > ========= > > The schema of the table matches the fields in the YAML file > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From deepak.jois at gmail.com Tue Feb 13 03:23:43 2007 From: deepak.jois at gmail.com (Deepak Jois) Date: Tue, 13 Feb 2007 16:23:43 +0800 Subject: [rspec-users] Error against latest trunk while testing via spec for model In-Reply-To: <8d961d900702130011q63f52ffbja0f69bd90bb937be@mail.gmail.com> References: <24dc07380702122233n264be62bqe5d3dffb59536684@mail.gmail.com> <8d961d900702122320v780ce47av32586be83fae90ce@mail.gmail.com> <24dc07380702122328x3dbcd8b1g6018dbd8848048fc@mail.gmail.com> <8d961d900702130011q63f52ffbja0f69bd90bb937be@mail.gmail.com> Message-ID: <24dc07380702130023r2a033f07q5dc5a9d3b6efe8f1@mail.gmail.com> On 2/13/07, aslak hellesoy wrote: > Rails version? svn revision? > I am running edge rails (HEAD) with rspec trunk HEAD. > On 2/13/07, Deepak Jois wrote: > > On 2/13/07, aslak hellesoy wrote: > > > We need the backtrace. Can you run again with --backtrace > > > > > > > > =============== > > 1) > > TypeError in 'Given a generated venue_spec.rb with fixtures loaded > > fixtures should load two Venues' > > can't convert nil into String > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:251:in > > `join' > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:251:in > > `create_fixtures' > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:250:in > > `create_fixtures' > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/base.rb:890:in > > `silence' > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:248:in > > `create_fixtures' > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:581:in > > `load_fixtures' > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:535:in > > `setup_with_fixtures' > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_eval.rb:131:in > > `create_block_from_parts' > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_eval.rb:129:in > > `create_block_from_parts' > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/specification.rb:47:in > > `setup_spec' > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/specification.rb:29:in > > `run' > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context.rb:58:in > > `run' > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context.rb:55:in > > `run' > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_runner.rb:23:in > > `run' > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_runner.rb:22:in > > `run' > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/command_line.rb:27:in > > `run' > > vendor/plugins/rspec/bin/spec:4: > > ======================== > > > > FWIW, here is my fixtures file file > > > > ======= > > one: > > id: 1 > > name: LT1 > > description: Lecture Theatre 1 > > active: 1 > > two: > > id: 2 > > name: LT2 > > description: Lecture Theatre 2 > > active: 0 > > ========= > > > > The schema of the table matches the fields in the YAML file > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Feb 13 04:18:58 2007 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 13 Feb 2007 10:18:58 +0100 Subject: [rspec-users] Error against latest trunk while testing via spec for model In-Reply-To: <24dc07380702130023r2a033f07q5dc5a9d3b6efe8f1@mail.gmail.com> References: <24dc07380702122233n264be62bqe5d3dffb59536684@mail.gmail.com> <8d961d900702122320v780ce47av32586be83fae90ce@mail.gmail.com> <24dc07380702122328x3dbcd8b1g6018dbd8848048fc@mail.gmail.com> <8d961d900702130011q63f52ffbja0f69bd90bb937be@mail.gmail.com> <24dc07380702130023r2a033f07q5dc5a9d3b6efe8f1@mail.gmail.com> Message-ID: <8d961d900702130118w7eab765bwd9d1e2b867f80acc@mail.gmail.com> On 2/13/07, Deepak Jois wrote: > On 2/13/07, aslak hellesoy wrote: > > Rails version? svn revision? > > > I am running edge rails (HEAD) with rspec trunk HEAD. > We haven't tested RSpec on Rails with Rails Edge because Rails (or some of its dependencies) seems to exit the ruby interpreter while running the test suite. Until we solve this problem, we cannot ensure compatibility with Edge Rails > > On 2/13/07, Deepak Jois wrote: > > > On 2/13/07, aslak hellesoy wrote: > > > > We need the backtrace. Can you run again with --backtrace > > > > > > > > > > > =============== > > > 1) > > > TypeError in 'Given a generated venue_spec.rb with fixtures loaded > > > fixtures should load two Venues' > > > can't convert nil into String > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:251:in > > > `join' > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:251:in > > > `create_fixtures' > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:250:in > > > `create_fixtures' > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/base.rb:890:in > > > `silence' > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:248:in > > > `create_fixtures' > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:581:in > > > `load_fixtures' > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:535:in > > > `setup_with_fixtures' > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_eval.rb:131:in > > > `create_block_from_parts' > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_eval.rb:129:in > > > `create_block_from_parts' > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/specification.rb:47:in > > > `setup_spec' > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/specification.rb:29:in > > > `run' > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context.rb:58:in > > > `run' > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context.rb:55:in > > > `run' > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_runner.rb:23:in > > > `run' > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_runner.rb:22:in > > > `run' > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/command_line.rb:27:in > > > `run' > > > vendor/plugins/rspec/bin/spec:4: > > > ======================== > > > > > > FWIW, here is my fixtures file file > > > > > > ======= > > > one: > > > id: 1 > > > name: LT1 > > > description: Lecture Theatre 1 > > > active: 1 > > > two: > > > id: 2 > > > name: LT2 > > > description: Lecture Theatre 2 > > > active: 0 > > > ========= > > > > > > The schema of the table matches the fields in the YAML file > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Tue Feb 13 06:23:06 2007 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 13 Feb 2007 04:23:06 -0700 Subject: [rspec-users] Error against latest trunk while testing via spec for model In-Reply-To: <8d961d900702130118w7eab765bwd9d1e2b867f80acc@mail.gmail.com> References: <24dc07380702122233n264be62bqe5d3dffb59536684@mail.gmail.com> <8d961d900702122320v780ce47av32586be83fae90ce@mail.gmail.com> <24dc07380702122328x3dbcd8b1g6018dbd8848048fc@mail.gmail.com> <8d961d900702130011q63f52ffbja0f69bd90bb937be@mail.gmail.com> <24dc07380702130023r2a033f07q5dc5a9d3b6efe8f1@mail.gmail.com> <8d961d900702130118w7eab765bwd9d1e2b867f80acc@mail.gmail.com> Message-ID: <57c63afe0702130323l6c6a3037u72b26c95dd99d154@mail.gmail.com> On 2/13/07, aslak hellesoy wrote: > On 2/13/07, Deepak Jois wrote: > > On 2/13/07, aslak hellesoy wrote: > > > Rails version? svn revision? > > > > > I am running edge rails (HEAD) with rspec trunk HEAD. Deepak - please provide revision numbers. HEAD is a moving target. > We haven't tested RSpec on Rails with Rails Edge because Rails (or > some of its dependencies) seems to exit the ruby interpreter while > running the test suite. > > Until we solve this problem, we cannot ensure compatibility with Edge Rails Even after we solve this problem, we will not ensure compatibility with edge. There is simply no way for us to do that. That said, it is important that we hear about problems so that we can be reasonably up to date when releases of Rails come out, so thanks Deepak for bringing this up. Again, please do include revision numbers in the future. Cheers, David > > > > On 2/13/07, Deepak Jois wrote: > > > > On 2/13/07, aslak hellesoy wrote: > > > > > We need the backtrace. Can you run again with --backtrace > > > > > > > > > > > > > > =============== > > > > 1) > > > > TypeError in 'Given a generated venue_spec.rb with fixtures loaded > > > > fixtures should load two Venues' > > > > can't convert nil into String > > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:251:in > > > > `join' > > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:251:in > > > > `create_fixtures' > > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:250:in > > > > `create_fixtures' > > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/base.rb:890:in > > > > `silence' > > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:248:in > > > > `create_fixtures' > > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:581:in > > > > `load_fixtures' > > > > /home/deepak/personalcode/worlds/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:535:in > > > > `setup_with_fixtures' > > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_eval.rb:131:in > > > > `create_block_from_parts' > > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_eval.rb:129:in > > > > `create_block_from_parts' > > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/specification.rb:47:in > > > > `setup_spec' > > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/specification.rb:29:in > > > > `run' > > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context.rb:58:in > > > > `run' > > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context.rb:55:in > > > > `run' > > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_runner.rb:23:in > > > > `run' > > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/context_runner.rb:22:in > > > > `run' > > > > /home/deepak/personalcode/worlds/vendor/plugins/rspec/lib/spec/runner/command_line.rb:27:in > > > > `run' > > > > vendor/plugins/rspec/bin/spec:4: > > > > ======================== > > > > > > > > FWIW, here is my fixtures file file > > > > > > > > ======= > > > > one: > > > > id: 1 > > > > name: LT1 > > > > description: Lecture Theatre 1 > > > > active: 1 > > > > two: > > > > id: 2 > > > > name: LT2 > > > > description: Lecture Theatre 2 > > > > active: 0 > > > > ========= > > > > > > > > The schema of the table matches the fields in the YAML file > > > > _______________________________________