[rspec-users] tutes on testing controllers
hello spec'ers, i'm in the hunt for guides on testing controllers with rspec, would you guys recommend any? thanks Oliver -- Oliver Azevedo Barnes [EMAIL PROTECTED] +55 11 9768 0193 http://www.linkedin.com/in/oliverbarnes http://workingwithrails.com/person/4704-oliver-barnes ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] tutes on testing controllers
On Mon, Mar 10, 2008 at 2:01 PM, Oliver Barnes [EMAIL PROTECTED] wrote: hello spec'ers, i'm in the hunt for guides on testing controllers with rspec, would you guys recommend any? Oldie but goodie (I hope) - http://evang.eli.st/blog/2007/9/15/easy-controller-tests-and-expressing-intent-through-expectations Pat ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story testing views in isolation
On Tue, Mar 11, 2008 at 2:53 AM, Corey Haines [EMAIL PROTECTED] wrote: Hi, I've been investigating plain text stories, and I had a quick question. How would I go about creating story tests for views in isolation, instead of the full stack? I had hoped to be able to do a straight render '/', but it says it can't find the method. We didn't really think of views in isolation for stories. The reason that I want to do this is that I want to give our designer/business people a way to write stories to describe their user interface while they work on the prototype, then give us the stories to help us integrate their prototypes more safely. So you're hoping they'll use the stories and get them to pass against the views as they evolve? I realize that I could use examples for this, but I was hoping to use stories. There's really no support for this as it stands. Not sure if I'd want that to change. Other opinions? David -Corey -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] outside-in = integration tests on views?
I just watched the story one on Sunday, and it was great. I bought a 5 pack and can't wait to watch the next one. -Corey On Sun, Mar 2, 2008 at 10:49 PM, Ben Mabey [EMAIL PROTECTED] wrote: BTW, Are the PeepCode rSpec tutorials worth buying? They are a steal. I watched them after I had already been using rSpec for a couple months and I still learned a lot and felt like they were a great investment. I haven't watched the Story one yet but the general rspec ones were great. -Ben ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Composed Stories/Scenarios
In using stories, I find myself wanting to build scenarios on top of each other, For example I want something like Scenario: The user logs on Given a And b When c And d Then e And f Scenario: The user changes his password Given the user logs on And g Then h In other words, I'd like to write the second scenario starting with the 'state' produced by the first. I'd like to 'invoke' a scenario in a Given or When clause. I think that this should mean that the Given and When clauses of the scenario being invoked would be inserted/run at this point. The Then clauses wouldn't I would think since these are 'tested' when the original scenario is run. Does this make sense? How have others dealt with this? This is probably at tension with the XP notion of stories being minimal and isolated, but RBehave/RSpec stories already seem to have that tension IMHO. Thoughts? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story testing views in isolation
On Tue, Mar 11, 2008 at 6:16 AM, David Chelimsky [EMAIL PROTECTED] wrote: The reason that I want to do this is that I want to give our designer/business people a way to write stories to describe their user interface while they work on the prototype, then give us the stories to help us integrate their prototypes more safely. So you're hoping they'll use the stories and get them to pass against the views as they evolve? Yeah. I'd like to have them use the stories against the mockups they build, then we move the stories to the live app as we integrate their changes. These are just some initial thoughts I've had, so I'm always open to alternate ideas. One option I thought about was to use pages that don't have any functionality behind them (other than perhaps some basic navigation), then they could design their mockups against these. As we integrate their designs in, we can start adding functionality behind it. This seems more in line with (perhaps one of) the original ideas for stories. I realize that I could use examples for this, but I was hoping to use stories. There's really no support for this as it stands. Not sure if I'd want that to change. Other opinions? Would it be as simple as supporting render/assigns, like in view specs? In the end, our designer/business have programming skills, so I could have them use example groups; it isn't like example groups are so incredibly cryptic. When you format as specdoc, they provide a decent doumentation; I do like stories better, though. :) -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story testing views in isolation
On Tue, Mar 11, 2008 at 8:03 AM, Corey Haines [EMAIL PROTECTED] wrote: On Tue, Mar 11, 2008 at 6:16 AM, David Chelimsky [EMAIL PROTECTED] wrote: The reason that I want to do this is that I want to give our designer/business people a way to write stories to describe their user interface while they work on the prototype, then give us the stories to help us integrate their prototypes more safely. So you're hoping they'll use the stories and get them to pass against the views as they evolve? Yeah. I'd like to have them use the stories against the mockups they build, then we move the stories to the live app as we integrate their changes. These are just some initial thoughts I've had, so I'm always open to alternate ideas. One option I thought about was to use pages that don't have any functionality behind them (other than perhaps some basic navigation), then they could design their mockups against these. As we integrate their designs in, we can start adding functionality behind it. This seems more in line with (perhaps one of) the original ideas for stories. I realize that I could use examples for this, but I was hoping to use stories. There's really no support for this as it stands. Not sure if I'd want that to change. Other opinions? This feels like a square peg in a round hole type of situation. It doesn't seem like in practice this works very well: Given a user where? When they do something Then they see what? In isolation the Given/When/Then don't make as much sense because you can't do anything, you don't go anywhere and the Given/When/Then make less sense in the context of isolation. It also seems to muddy the definition of a story. All in all it just feels kind of funny. +1 for keeping view specs act as view specs and stories act as stories. -- Zach Dennis http://www.continuousthinking.com ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Composed Stories/Scenarios
On Tue, Mar 11, 2008 at 12:14 PM, Rick DeNatale [EMAIL PROTECTED] wrote: In using stories, I find myself wanting to build scenarios on top of each other, For example I want something like Scenario: The user logs on Given a And b When c And d Then e And f Scenario: The user changes his password Given the user logs on And g Then h In other words, I'd like to write the second scenario starting with the 'state' produced by the first. I'd like to 'invoke' a scenario in a Given or When clause. I think that this should mean that the Given and When clauses of the scenario being invoked would be inserted/run at this point. The Then clauses wouldn't I would think since these are 'tested' when the original scenario is run. Does this make sense? How have others dealt with this? This is probably at tension with the XP notion of stories being minimal and isolated, but RBehave/RSpec stories already seem to have that tension IMHO. This is already supported - use GivenScenario like this: Scenario: The user changes his password GivenScenario: The user logs on And g Then h This only works within the same story. Cheers, David Thoughts? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story testing views in isolation
Corey, What part of the Story do you like that you want the designers to be exposed to? A higher level API, the plain text part (separation from implementation of the test), etc... ? Zach On Tue, Mar 11, 2008 at 8:39 AM, Zach Dennis [EMAIL PROTECTED] wrote: On Tue, Mar 11, 2008 at 8:03 AM, Corey Haines [EMAIL PROTECTED] wrote: On Tue, Mar 11, 2008 at 6:16 AM, David Chelimsky [EMAIL PROTECTED] wrote: The reason that I want to do this is that I want to give our designer/business people a way to write stories to describe their user interface while they work on the prototype, then give us the stories to help us integrate their prototypes more safely. So you're hoping they'll use the stories and get them to pass against the views as they evolve? Yeah. I'd like to have them use the stories against the mockups they build, then we move the stories to the live app as we integrate their changes. These are just some initial thoughts I've had, so I'm always open to alternate ideas. One option I thought about was to use pages that don't have any functionality behind them (other than perhaps some basic navigation), then they could design their mockups against these. As we integrate their designs in, we can start adding functionality behind it. This seems more in line with (perhaps one of) the original ideas for stories. I realize that I could use examples for this, but I was hoping to use stories. There's really no support for this as it stands. Not sure if I'd want that to change. Other opinions? This feels like a square peg in a round hole type of situation. It doesn't seem like in practice this works very well: Given a user where? When they do something Then they see what? In isolation the Given/When/Then don't make as much sense because you can't do anything, you don't go anywhere and the Given/When/Then make less sense in the context of isolation. It also seems to muddy the definition of a story. All in all it just feels kind of funny. +1 for keeping view specs act as view specs and stories act as stories. -- Zach Dennis http://www.continuousthinking.com -- Zach Dennis http://www.continuousthinking.com ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Composed Stories/Scenarios
On 3/11/08, David Chelimsky [EMAIL PROTECTED] wrote: On Tue, Mar 11, 2008 at 12:14 PM, Rick DeNatale [EMAIL PROTECTED] wrote: In using stories, I find myself wanting to build scenarios on top of each other, For example I want something like Scenario: The user logs on Given a And b When c And d Then e And f Scenario: The user changes his password Given the user logs on And g Then h In other words, I'd like to write the second scenario starting with the 'state' produced by the first. I'd like to 'invoke' a scenario in a Given or When clause. I think that this should mean that the Given and When clauses of the scenario being invoked would be inserted/run at this point. The Then clauses wouldn't I would think since these are 'tested' when the original scenario is run. Does this make sense? How have others dealt with this? This is probably at tension with the XP notion of stories being minimal and isolated, but RBehave/RSpec stories already seem to have that tension IMHO. This is already supported - use GivenScenario like this: Scenario: The user changes his password GivenScenario: The user logs on And g Then h This only works within the same story. Cool! -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] view spec on rails questions
For content_for blocks we have a separate testing.html.erb layout which we use when rendering our view from our spec. We then ensure the things generated in content_for are rendered correctly.. ie: render foo/index, :layout = testing Zach On Mon, Mar 10, 2008 at 11:23 PM, Jonathan Linowes [EMAIL PROTECTED] wrote: Hi I have a couple of questions 1) how do you test the response inside a content_for block I see reference to it in the release notes but dont know where to find it (tried http://rspec.info/rdoc-rails/ ) 2) I dont seem to be able to stub partials in a different directory eg %= render :partial = foos/show % And I put this in the spec template.stub_render(:partial = foos/show) the stub gets ignored and the partial still gets rendered It works fine with partials in the same directory I'm runing rspec 1.1.3 thanks linoj ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users -- Zach Dennis http://www.continuousthinking.com ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] for a beginner - good rspec examples?
I'm learning to use rspec and I want to see some good examples. Any recommendations of open source projects that demonstrate the use of rspec? So far I've found: 1) the Caboose sample app (http://sample.caboo.se/) 2) the Altered Beast forums app (http://beast.caboo.se/forums/1/topics/4650 ) Any others come to mind? I'm especially interested in seeing examples that spec RESTful authentication. Thanks, Daniel ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story testing views in isolation
On Tue, Mar 11, 2008 at 2:39 PM, Zach Dennis [EMAIL PROTECTED] wrote: +1 for keeping view specs act as view specs and stories act as stories. Agreed. AFAIK stories are for describing a series of actions and behavior and that doesn't really fit in nicely with specifying views in isolation. //jarkko -- Jarkko Laine http://jlaine.net http://odesign.fi ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] for a beginner - good rspec examples?
On Mar 11, 2008, at 8:52 AM, Daniel Kehoe wrote: I'm learning to use rspec and I want to see some good examples. Any recommendations of open source projects that demonstrate the use of rspec? So far I've found: 1) the Caboose sample app (http://sample.caboo.se/) 2) the Altered Beast forums app (http://beast.caboo.se/forums/1/topics/4650 ) Any others come to mind? I'm especially interested in seeing examples that spec RESTful authentication. Daniel, I was in your place asking this question about a month ago. Here are the pointers that were helpful to me. [1] http://www.oreillynet.com/pub/a/ruby/2007/08/09/behavior-driven-development-using-ruby-part-1.html [2] http://svn.nightlite.org/applications/cody/trunk/ After examining the links above, I rewrote a small project that I already had working only this time I used BDD for the process. I ended up writing about 50% more code and created about 100% more methods, but the resulting program was much easier to understand and very easy to extend. I also had 100% code coverage which was a first for me. I don't know if the code I wrote would be useful to you but I would be happy to send you a tarball (under 50k) containing this project. Good luck. cr ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] [Stories]Changes in the database not taken into account
I have these scenarios : Story: Filling a profile As a user I want to fill a profile So that I can see my score Scenario: Starting a new profile ...* And 3 questions ...* When the user answers a question Then there should be one more answer Then there should be one question less to answer Scenario: Ending a profile ...* And 1 question ...* When the user answers a question Then there should be one more answer Then there should be no more question to answer * code hidden for clarity If I run these two scenarios independently they both work, but when i run them one after the other, the second scenario fails. The problem appears in Given($amount questions?), even I create a new question in the database, it doesn't seem to be taken into account and keeps the 3 questions I created in the previous scenario. Here is what it looks like : Given($amount questions?) do |amount| Question.delete_all amount.to_i.times do Factory.create_valid_question end end class Factory def self.create_valid_question() Question.create!(:value = some question ) end end By adding outputs I observed that during the second scenario there are no questions in the database before the times loop, that they are created inside it, but after the loop I have the same questions in the database as the ones i had in the previous scenario and not the one i just created through the loop. This is really strange. (Sorry for this long question). Do you have any idea what I do wrong ? ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] for a beginner - good rspec examples?
David Chelimsky's http://blog.davidchelimsky.net/ blog has a lot of good information as well. On Tue, Mar 11, 2008 at 9:06 AM, Chuck Remes [EMAIL PROTECTED] wrote: On Mar 11, 2008, at 8:52 AM, Daniel Kehoe wrote: I'm learning to use rspec and I want to see some good examples. Any recommendations of open source projects that demonstrate the use of rspec? So far I've found: 1) the Caboose sample app (http://sample.caboo.se/) 2) the Altered Beast forums app ( http://beast.caboo.se/forums/1/topics/4650 ) Any others come to mind? I'm especially interested in seeing examples that spec RESTful authentication. Daniel, I was in your place asking this question about a month ago. Here are the pointers that were helpful to me. [1] http://www.oreillynet.com/pub/a/ruby/2007/08/09/behavior-driven-development-using-ruby-part-1.html [2] http://svn.nightlite.org/applications/cody/trunk/ After examining the links above, I rewrote a small project that I already had working only this time I used BDD for the process. I ended up writing about 50% more code and created about 100% more methods, but the resulting program was much easier to understand and very easy to extend. I also had 100% code coverage which was a first for me. I don't know if the code I wrote would be useful to you but I would be happy to send you a tarball (under 50k) containing this project. Good luck. cr ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users -- Bryan Ray http://www.bryanray.net Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] [ANN] RSpactor 0.0.2 : autorun your spec files
Hi all. I want to introduce RSpactor and its draft release 0.2.0. RSpactor is a little command line tool to automatically run your changed specs (much like autotest). As you may expect, it concentrates on the use of RSpec. It was especially designed to use filesystem events like FSEvent on Leopard (Mac OS X 10.5) instead of permanently polling a directory structure. RSpactor is currently only working on Mac OS 10.5, but I'm very confident that the next version of RSpactor will work on Linux boxes, too. I would really appreciate if you give it try: sudo gem install rspactor, to help me find bugs and make it a good working application. You can read the rest of this introduction at: http://rubyphunk.com/2008/3/11/hello-world-introducing-rspactor Project page and bug tracker: http://rubyforge.org/projects/rspactor/ bye, - andreas ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] RSpec view test for :partial with :locals?
I'm currently working on some RSpec view tests and I'm having problems with expect_render. Most of the expect_render's work fine, but in one of my views I have: %= render :partial = user_cloud, :locals = {:user = @featured_user} % I see that expect_render supports :object or :collection for the second parameter, but this partial uses :locals. I tried expect_render without the second parameter and with :locals and it failed to match both times. I confirmed that the partial is rendering in the test.log. Is there a way to match this render? On a similar note, is there a way to test that layout views are rendered? I can test that the :partials in the layout are rendered, but not the layout file itself. In both of these cases I know I could do a has_tag and test for something inside the layout file or partial, but I'd rather test contents in a view test for each partial and just verify that the partial is rendered in the view tests that render the partial. Thank you, David ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] rspec groups?
Using the -e option from the command line, you can also specify a string which is to be run, this is a way to run only one describe block, or one it block. The rake task method suggested by Edvard is the other option On Mar 10, 2008, at 5:42 AM, Edvard Majakari wrote: The idea is that you can specify that certain tests exist in groups, and can be run as a set. You can define groups and groups of groups, and so you can run a set of functional tests or all the tests dealing with a specific feature without running through the entire thing. It's kinda like an rspec pattern, but more flexible. Might not be of help, but my problem was a tad similar when I used test/spec (rspecish test/unit wrapper). I had five types of test tasks in my Rakefile: test:units, test:functionals, test:integration, test:libs and test:helpers. The integration and lib tests took the most of the time, so I created custom tasks test:all_but_integration (quite self-explanatory, no?) and test:webserver, which ran everything else except test:libs. The way I did it was that test:all_but_integration just depended on the tasks test:units, tests:functionals etc. So, if you want grouping inside features in a single test suite, this won't help, but for me, being able to control which (whole) files were run with Rake was sufficient for me. The whole suite took something like 15 minutes, but we had thousands of tests and when we started, we didn't use that much mock objects. That said, I have never needed nor wished the ability to combine test suites using test/spec or rspec. Being able to choose which contexts/describes or individual specs will be run has been more than sufficient to me, but of course, YNMDFTOM. -- One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair. -- Terry Pratchett, Mr. Bunnsy Has An Adventure ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users James Deville http://devillecompanies.org [EMAIL PROTECTED] rspec r3172 rspec_on_rails r3172 rails r8331 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] running a specific describe block
the -e option should run a describe block if the string passed matches a describe block On Feb 29, 2008, at 10:57 AM, Jay Donnell wrote: I use a lot of nested describe blocks and am wondering if there is a way to run a specific describe block similar to the -e option for running specific examples. Jay Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users James Deville http://devillecompanies.org [EMAIL PROTECTED] rspec r3172 rspec_on_rails r3172 rails r8331 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users