From matt at mattwynne.net Mon Dec 1 02:50:06 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 1 Dec 2008 07:50:06 +0000 Subject: [rspec-users] cucumber and autotest - running all features? In-Reply-To: <937d9d810811301845x29632c37p7ffc80b5537b4450@mail.gmail.com> References: <306b6bd9a7f00af8464713c73dc929de@ruby-forum.com> <4ee52ac742558d3aeb2d560fef7b27fe@ruby-forum.com> <937d9d810811301845x29632c37p7ffc80b5537b4450@mail.gmail.com> Message-ID: <5BCECC48-3374-462B-9493-63715A7AEB26@mattwynne.net> On 1 Dec 2008, at 02:45, Peter Jaros wrote: > The Autotest support in Cucumber doesn't currently associate any files > with specific scenarios. It only keeps track of failed scenarios. If > any are failing, changing any file will run those scenarios. If > everything has been passing, changing any file will run the whole > feature suite. > > Features should be orthogonal to your classes, so there's no good way > to associate a scenario with the classes it tests. I've been thinking about a more sophisticated mechanism for this, using code coverage. If autotest / rspactor was able to record and remember the LOC covered by each scenario / example, it would be possible to do more focussed regression testing when a source file was changed. That's as far as I've got: an idea. I just though I'd mention it in case anyone has time on their hands... ;) Matt Wynne matt at songkick.com From dchelimsky at gmail.com Mon Dec 1 05:21:53 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 1 Dec 2008 04:21:53 -0600 Subject: [rspec-users] Ruby 1.9 - autospec loadpath problem In-Reply-To: <57a815bf0811301424k131b4155xafee88459449eb@mail.gmail.com> References: <57a815bf0811301424k131b4155xafee88459449eb@mail.gmail.com> Message-ID: <57c63afe0812010221x58dd37e3w1a7d741df1256b70@mail.gmail.com> On Sun, Nov 30, 2008 at 4:24 PM, Mikel Lindsaar wrote: > Mac OSX 10.5.5 > (Ruby 1.8.6 installed already) > I installed Ruby 1.9.1 preview thusly: > ============================================== > port install readline > cd ruby-1.9.1-preview1 > ./configure --program-suffix=-trunk --with-readline-dir=/usr/local > make > make install > ============================================== > > Then move my environment over to the trunk version: > ============================================== > ln -s /usr/local/bin/ruby-trunk /usr/bin/ruby > ln -s /usr/local/bin/rake-trunk /usr/bin/rake > ln -s /usr/local/bin/gem-trunk /usr/bin/gem > ============================================== > > Then the first thing to do of course: > ============================================== > gem install rspec > gem install ZenTest > ============================================== > > all good so far > Then change into my new mail project (rewriting all the good bits of tmail > into a 1.9 based, encoding savvy, oniguma laced, mail hooligan) and do the > deed: > ============================================== > cd ~/ruby_programs/mail > autospec > ============================================== > > Gets me: > ============================================== > mikel at baci.local ~/ruby_programs/mail > $ autospec > /usr/local/bin/autotest:19:in `load': Is a directory - > /usr/local/lib/ruby-trunk/gems/1.9.1/gems/rspec-1.1.11/lib/autotest > (Errno::EISDIR) > from /usr/local/bin/autotest:19:in `
' > ============================================== > > Opening up /usr/local/bin/autotest shows me that line 19 says: > load 'autotest' > Thinks... "Ah... load path problem". so I puts a puts to see what puts: > ============================================== > puts $LOAD_PATH > load 'autotest' > ============================================== > > And I gets: > ============================================== > mikel at baci.local ~/ruby_programs/mail > $ autospec > /usr/local/lib/ruby-trunk/gems/1.9.1/gems/columnize-0.2/lib > /usr/local/lib/ruby-trunk/gems/1.9.1/gems/linecache-0.43/lib > /usr/local/lib/ruby-trunk/gems/1.9.1/gems/rspec-1.1.11/bin > /usr/local/lib/ruby-trunk/gems/1.9.1/gems/rspec-1.1.11/lib > /usr/local/lib/ruby-trunk/gems/1.9.1/gems/ZenTest-3.11.0/bin > /usr/local/lib/ruby-trunk/gems/1.9.1/gems/ZenTest-3.11.0/lib > /usr/local/lib/ruby-trunk/site_ruby/1.9.1 > /usr/local/lib/ruby-trunk/site_ruby/1.9.1/i386-darwin9.5.0 > /usr/local/lib/ruby-trunk/site_ruby > /usr/local/lib/ruby-trunk/vendor_ruby/1.9.1 > /usr/local/lib/ruby-trunk/vendor_ruby/1.9.1/i386-darwin9.5.0 > /usr/local/lib/ruby-trunk/vendor_ruby > /usr/local/lib/ruby-trunk/1.9.1 > /usr/local/lib/ruby-trunk/1.9.1/i386-darwin9.5.0 > . > loading autotest/rspec > /usr/local/lib/ruby-trunk/gems/1.9.1/gems/ZenTest-3.11.0/bin/autotest:49:in > `require': > /usr/local/lib/ruby-trunk/gems/1.9.1/gems/rspec-1.1.11/lib/autotest/rspec.rb:31: > target of repeat operator is invalid: /\n(\.\/)?(.*spec\.rb):[\d]+:\Z?/ > (SyntaxError) > from > /usr/local/lib/ruby-trunk/gems/1.9.1/gems/ZenTest-3.11.0/bin/autotest:49:in > `' > from /usr/local/bin/autotest:20:in `load' > from /usr/local/bin/autotest:20:in `
' > ============================================== > > Looking in /usr/local/lib/ruby-trunk/gems/1.9.1/gems/rspec-1.1.11/lib gives: > ============================================== > mikel at baci.local ~/ruby_programs/mail > $ ls -al /usr/local/lib/ruby-trunk/gems/1.9.1/gems/rspec-1.1.11/lib > total 8 > drwxr-xr-x 5 root wheel 170 1 Dec 09:05 . > drwxr-xr-x 19 root wheel 646 1 Dec 09:05 .. > drwxr-xr-x 4 root wheel 136 1 Dec 09:05 autotest > drwxr-xr-x 21 root wheel 714 1 Dec 09:05 spec > -rw-r--r-- 1 root wheel 561 1 Dec 09:05 spec.rb > ============================================== > > So load is trying to load autotest the directory instead of autotest the > script. > Any ideas on how to get it to load the right thing? I'm not sure how to fix that problem, but before you go much further you should know that RSpec does not yet run under 1.9. It's something I want to raise in priority soon, and patches are welcome, but that's the state of things today. > -- > http://lindsaar.net/ > Rails, RSpec and Life blog.... > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mauricio.linhares at gmail.com Mon Dec 1 09:39:33 2008 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Mon, 1 Dec 2008 11:39:33 -0300 Subject: [rspec-users] Undefined method "full_description" when trying to run "rake spec" Message-ID: Hello guys, I'm getting this weird error when trying to run the specs using "rake spec": /home/mauricio/NetBeansProjects/talkies/vendor/rails/actionpack/lib/action_controller/test_process.rb:471:in `method_missing': undefined method `full_description' for # (NoMethodError) from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers.rb:155:in `method_missing' from /home/mauricio/NetBeansProjects/talkies/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb:25:in `example_pending' from /home/mauricio/NetBeansProjects/talkies/vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb:18:in `example_pending' from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/reporter.rb:125:in `example_pending' from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/reporter.rb:120:in `each' from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/reporter.rb:120:in `example_pending' from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/reporter.rb:29:in `example_finished' from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/example_methods.rb:26:in `execute' ... 6 levels... from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:21:in `run' from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:115:in `run_examples' from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in `run' from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 rake aborted! Any ideas about what this might be? Rspec gems are 1.1.11 and we also have the same gems installed in the app as plugins. My machine is a "Linux linux-fof0 2.6.25.18-0.2-default #1 SMP 2008-10-21 16:30:26 +0200 x86_64 x86_64 x86_64 GNU/Linux " - Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) From lists at ruby-forum.com Mon Dec 1 10:07:53 2008 From: lists at ruby-forum.com (James Byrne) Date: Mon, 1 Dec 2008 16:07:53 +0100 Subject: [rspec-users] Variance in behaviour: rake features vs. autotest In-Reply-To: <88fd8ddc0811291752w624acf66i410ff9f2c75c426@mail.gmail.com> References: <0de1542c5ae2682273e86017ffc7d14c@ruby-forum.com> <303438f30a77b24f1f2c8d53a9965b2b@ruby-forum.com> <492DF9DC.3070509@benmabey.com> <465c06b0a1f2f3b368c19a60e94bc18e@ruby-forum.com> <492ECA75.6010605@benmabey.com> <492ED2FD.2040105@benmabey.com> <8d961d900811281433k3b968576tb3cc3ff1911fcddc@mail.gmail.com> <541ccfc985743bb7101a49a389e491b4@ruby-forum.com> <88fd8ddc0811291752w624acf66i410ff9f2c75c426@mail.gmail.com> Message-ID: <3e64d7a363ef32295cc147e2b8c43897@ruby-forum.com> Andrew Premdas wrote: > No it isn't you can have > > When /determine the party (.*)/ do > > And call that in in other nested step using a string literal > > When > When "deterimine the party foo" > end > > In fact I never enclose the arguments with a string delimiter as I > think it makes the feature less clear - don't think feature writers > should have to worry about having correct quotes. just my 2c Non, you misunderstood what I wrote, although in retrospect I should have been more explicit and precise with my terminology. It is NOT the feature file that I was speaking of. It was within the step_definitions file, as your example employs itself. When I referred to step files it was to the step_definitions.rb files, a clarification that I have since made to the article. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Dec 1 10:11:55 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 1 Dec 2008 09:11:55 -0600 Subject: [rspec-users] Undefined method "full_description" when trying to run "rake spec" In-Reply-To: References: Message-ID: <57c63afe0812010711l79c4bb8evb3d86537b0ece318@mail.gmail.com> On Mon, Dec 1, 2008 at 8:39 AM, Maur?cio Linhares wrote: > Hello guys, > > I'm getting this weird error when trying to run the specs using "rake spec": > > /home/mauricio/NetBeansProjects/talkies/vendor/rails/actionpack/lib/action_controller/test_process.rb:471:in > `method_missing': undefined method `full_description' for > # > (NoMethodError) > from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers.rb:155:in > `method_missing' > from /home/mauricio/NetBeansProjects/talkies/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb:25:in > `example_pending' > from /home/mauricio/NetBeansProjects/talkies/vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb:18:in > `example_pending' > from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/reporter.rb:125:in > `example_pending' > from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/reporter.rb:120:in > `each' > from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/reporter.rb:120:in > `example_pending' > from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/reporter.rb:29:in > `example_finished' > from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/example_methods.rb:26:in > `execute' > ... 6 levels... > from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb:21:in > `run' > from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:115:in > `run_examples' > from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:10:in > `run' > from /usr/lib64/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 > rake aborted! > > Any ideas about what this might be? Yeah - we removed that method from rspec a while back. Netbeans was using it, but we weren't coordinating w/ the netbeans team and had no way of knowing. I am in contact w/ the netbeans team and we are talking about formalizing an API for them and other IDE vendors to use, which will help to avoid this sort of problem in the future. In the mean time, you can do this in your app (in spec_helper.rb I guess): module Spec module Example module ExampleMethods alias :full_description, :__full_description end end end HTH, David > > Rspec gems are 1.1.11 and we also have the same gems installed in the > app as plugins. My machine is a "Linux linux-fof0 > 2.6.25.18-0.2-default #1 SMP 2008-10-21 16:30:26 +0200 x86_64 x86_64 > x86_64 GNU/Linux > " > > - > Maur?cio Linhares > http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Mon Dec 1 10:34:43 2008 From: lists at ruby-forum.com (Pau Cor) Date: Mon, 1 Dec 2008 16:34:43 +0100 Subject: [rspec-users] Sample App - TDD with Cucumber and RSpec Message-ID: Hi, I just posted a tiny app that I put together for a presentation on Cucumber. http://github.com/thoughtless/cuc_demo/tree/master This essentially mirrors the workflow that I strive towards. (The README explains more.) I don't want to put myself out there as the standard to immitate, but I think it will be helpful for people just getting started with TDD/Cucumber/RSpec. I'd really appreciate your feedback! Paul P.S. Sorry to the guys on IRC who got this message twice. -- Posted via http://www.ruby-forum.com/. From apremdas at gmail.com Mon Dec 1 12:09:34 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 1 Dec 2008 17:09:34 +0000 Subject: [rspec-users] Variance in behaviour: rake features vs. autotest In-Reply-To: <3e64d7a363ef32295cc147e2b8c43897@ruby-forum.com> References: <0de1542c5ae2682273e86017ffc7d14c@ruby-forum.com> <492DF9DC.3070509@benmabey.com> <465c06b0a1f2f3b368c19a60e94bc18e@ruby-forum.com> <492ECA75.6010605@benmabey.com> <492ED2FD.2040105@benmabey.com> <8d961d900811281433k3b968576tb3cc3ff1911fcddc@mail.gmail.com> <541ccfc985743bb7101a49a389e491b4@ruby-forum.com> <88fd8ddc0811291752w624acf66i410ff9f2c75c426@mail.gmail.com> <3e64d7a363ef32295cc147e2b8c43897@ruby-forum.com> Message-ID: <88fd8ddc0812010909h151e9836r20e8ff2099613d88@mail.gmail.com> James,James, Ok I think I get what your saying. You seem to be quite focused on the idea of having quotes around variables in features subsequently in matchers and connecting this with calls in steps to steps. I think there two separate topics. Anyhow I wrote the following to try and explain things a bit better. I hope its 1) reasonably accurate 2) helpful All best Andrew Cucumber decides what you want it to do by comparing things you want to happen which are defined in strings, and matching these with ruby code (defined in steps) via regular expressions. The main way this happens is between strings in feature files and steps in step definitions. However it can also happen when one step definition "calls" another. Feature files only contain strings so you don't need any quotes in them. However when you "call" a step from within a step you have to use quotes to differentiate the string that is going to be matched from the rest of the ruby code in the step. The regular expressions defined in step files can have many different matchers. A top tip I got from Aslak was to use Rubular (www.rubular.com) to explore things. One of the things we need to with our regex's is capture "variables" in our features. Initially we see (.*) being used in the regex for capturing these. However (.*) is a really crude capture device. I think this crudeness is why we quite often get the idea of using quotes around the variable and the capture device. However IMO its much better to use slightly subtle captchers in your steps and keep the features cleaner. Feature writers shouldn't be expected to understand the concept of variables and don't need to be dealing with putting quotes around things. (just my opinion and contradicted by the common_webrat steps, but I think the quotes there are a bit of a hangover from the old story matcher) Some simple capture examples might help (\d+) # capture an integer (any number of numeric characters) product[s] # optionally capture a plural. This matches 'product' and 'products' (?:the|my) # match either 'the' or 'my' but also don't ignore the variable captured (done by ?:) e.g. so you don't have to have this argument if you use more examples in a table Now you can write steps that make things convenient for the feature writer and precise enough for the step writer. You can also make your regex's so complicated that only 4 people on the planet can understand them! You have to balance the benefits against this complexity. One of my more complex captures so far is /^there (?:is|are) (\d+)(?:\s*|\s*more\s*)product[s]?$/ this is to get only number of products as a variable and give the flexibility to match Given there is 1 product Given there are 2 products Given there are 4 more products Given there are 4 more products Better might be /^there (?:is|are) (\d+) (?:more\s)?product[s]?$ this won't match Given there are 4 more products but will match the other steps and is a bit simpler Writing and using regular expressions is an art in itself and one that's very useful in Ruby programming in general. One of the side effects I've found from using Cucumber is getting a gentle and useful introduction to this arcane topic. 2008/12/1 James Byrne : > Andrew Premdas wrote: >> No it isn't you can have >> >> When /determine the party (.*)/ do >> >> And call that in in other nested step using a string literal >> >> When >> When "deterimine the party foo" >> end >> >> In fact I never enclose the arguments with a string delimiter as I >> think it makes the feature less clear - don't think feature writers >> should have to worry about having correct quotes. just my 2c > > > Non, you misunderstood what I wrote, although in retrospect I should > have been more explicit and precise with my terminology. It is NOT the > feature file that I was speaking of. It was within the step_definitions > file, as your example employs itself. When I referred to step files it > was to the step_definitions.rb files, a clarification that I have since > made to the article. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Mon Dec 1 12:22:30 2008 From: ben at benmabey.com (Ben Mabey) Date: Mon, 01 Dec 2008 10:22:30 -0700 Subject: [rspec-users] Variance in behaviour: rake features vs. autotest In-Reply-To: References: <0de1542c5ae2682273e86017ffc7d14c@ruby-forum.com> <303438f30a77b24f1f2c8d53a9965b2b@ruby-forum.com> <492DF9DC.3070509@benmabey.com> <465c06b0a1f2f3b368c19a60e94bc18e@ruby-forum.com> <492ECA75.6010605@benmabey.com> <492ED2FD.2040105@benmabey.com> Message-ID: <49341D56.2030807@benmabey.com> James Byrne wrote: > Ben Mabey wrote: > >> Sorry if that last remark came across a little snide. What I meant to >> say was that the wiki is a community effort and it would be great if you >> could improve it with your insight and point of view. >> >> The wiki instructions probably do suffer from what you described because >> most of the wiki has been written by people who have been involved in >> cucumber/rspec story runner from the beginning (or who are familiar with >> the code base.) So our instructions may not be as helpful to newcomers >> as we had hoped. Since you are coming from a different perspective it >> would be extremely helpful for your insights to be added to the wiki to >> help other people who are beginning and will probably have the same >> questions you have had. >> >> Thanks, >> Ben >> > > How is this? > http://github.com/aslakhellesoy/cucumber/wikis/cucumber-backgrounder > This looks great, thanks for adding it! The only thing I would change, that Aslak already mentioned, is that the word Tests should be changed to Features in most places. -Ben From lists at ruby-forum.com Mon Dec 1 12:39:06 2008 From: lists at ruby-forum.com (James Byrne) Date: Mon, 1 Dec 2008 18:39:06 +0100 Subject: [rspec-users] Variance in behaviour: rake features vs. autotest In-Reply-To: <49341D56.2030807@benmabey.com> References: <0de1542c5ae2682273e86017ffc7d14c@ruby-forum.com> <303438f30a77b24f1f2c8d53a9965b2b@ruby-forum.com> <492DF9DC.3070509@benmabey.com> <465c06b0a1f2f3b368c19a60e94bc18e@ruby-forum.com> <492ECA75.6010605@benmabey.com> <492ED2FD.2040105@benmabey.com> <49341D56.2030807@benmabey.com> Message-ID: <410ee01682ae49e19d65eb7c0b6712fe@ruby-forum.com> Ben Mabey wrote: > James Byrne wrote: >>> as we had hoped. Since you are coming from a different perspective it >> > This looks great, thanks for adding it! The only thing I would change, > that Aslak already mentioned, is that the word Tests should be changed > to Features in most places. > -Ben I have added a reference that BDD uses the term features in the place of tests, but I believe that the intended audience will discover that for themselves as they learn. Recall that my initial comment was related to the observation that experienced users often do not make things explicit enough for the many who lack that knowledge. Features are tests, or at least they ultimately depend upon tests, and I believe that to be a distinction too fine to make in an introductory document. Regards, -- Posted via http://www.ruby-forum.com/. From fernando.garcia at the-cocktail.com Mon Dec 1 14:00:10 2008 From: fernando.garcia at the-cocktail.com (=?ISO-8859-1?Q?Fernando_Garc=EDa_Samblas?=) Date: Mon, 01 Dec 2008 20:00:10 +0100 Subject: [rspec-users] Sample App - TDD with Cucumber and RSpec In-Reply-To: References: Message-ID: <4934343A.50106@the-cocktail.com> Paul, thanks for sharing your examples. I was just thinking about posting something that can be introduced nicely with your sample app. Now in cuc_demo we've got a step definition for /^there are no posties$/ in postie_steps.rb. This way, if we'd need to add a "Given there are no users" step we should create a user_steps.rb with a similar definition. IMHO it would be nice to have instead a "context_definitions.rb" with common "givens" (similar to navigation_definitions.rb) and there a more general definition, like for instance: Given /^there are no (.*)$/ do |thing| thing_to_model(thing).destroy_all end In our World we should have a thing_to_class method with the mappings between the names used in features and the model class that implement them. I think this mapping is also useful if tomorrow you and/or your client decides to call it "pasties" instead of "posties" (and is more than useful if you're writing your features in other language than English, cause you cannot obtain the class name through transformations of the original "thing"). Cheers, nando Pau Cor escribi?: > Hi, > > I just posted a tiny app that I put together for a presentation on > Cucumber. > http://github.com/thoughtless/cuc_demo/tree/master > > This essentially mirrors the workflow that I strive towards. (The README > explains more.) I don't want to put myself out there as the standard to > immitate, but I think it will be helpful for people just getting started > with TDD/Cucumber/RSpec. > > I'd really appreciate your feedback! > > Paul > > P.S. Sorry to the guys on IRC who got this message twice. > -- Fernando Garc?a Samblas fernando.garcia at the-cocktail.com The Cocktail C/ Salamanca 17 28020 Madrid +34 91 567 06 05 From josephwilk at joesniff.co.uk Mon Dec 1 17:00:07 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Mon, 01 Dec 2008 22:00:07 +0000 Subject: [rspec-users] Musical Cucumber Message-ID: <49345E67.8010507@joesniff.co.uk> http://www.youtube.com/watch?v=U3OxKdDxkpg Sorry, I had to share that :) -- Joseph Wilk http://blog.josephwilk.net From aslak.hellesoy at gmail.com Mon Dec 1 17:15:01 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 1 Dec 2008 23:15:01 +0100 Subject: [rspec-users] Musical Cucumber In-Reply-To: <49345E67.8010507@joesniff.co.uk> References: <49345E67.8010507@joesniff.co.uk> Message-ID: <8d961d900812011415m6652a005o6ba8c5be46b430e8@mail.gmail.com> On Mon, Dec 1, 2008 at 11:00 PM, Joseph Wilk wrote: > http://www.youtube.com/watch?v=U3OxKdDxkpg > > Sorry, I had to share that :) Thank you! Fantastic. And for those who missed the kitten: http://aimee.mychores.co.uk/2008/11/10/post/362/ Aslak > -- > Joseph Wilk > http://blog.josephwilk.net > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Mon Dec 1 18:17:21 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 1 Dec 2008 23:17:21 +0000 Subject: [rspec-users] Sample App - TDD with Cucumber and RSpec In-Reply-To: <4934343A.50106@the-cocktail.com> References: <4934343A.50106@the-cocktail.com> Message-ID: <25363906-3747-423D-A040-3C3325DE5DA6@mattwynne.net> On 1 Dec 2008, at 19:00, Fernando Garc?a Samblas wrote: > > Paul, > > thanks for sharing your examples. I was just thinking about posting > something that can be introduced nicely with your sample app. > > Now in cuc_demo we've got a step definition for /^there are no > posties$/ > in postie_steps.rb. This way, if we'd need to add a "Given there are > no > users" step we should create a user_steps.rb with a similar > definition. > > IMHO it would be nice to have instead a "context_definitions.rb" with > common "givens" (similar to navigation_definitions.rb) and there a > more > general definition, like for instance: > > Given /^there are no (.*)$/ do |thing| > thing_to_model(thing).destroy_all > end > > In our World we should have a thing_to_class method with the mappings > between the names used in features and the model class that > implement them. > > I think this mapping is also useful if tomorrow you and/or your client > decides to call it "pasties" instead of "posties" (and is more than > useful if you're writing your features in other language than English, > cause you cannot obtain the class name through transformations of the > original "thing"). We have a convention here at Songkick (after a great deal of debate) that it's OK to refer to key domain concepts like Concerts, Artists, Venues etc by their Ruby class name from within the scenario. Thus our thing_to_model function is always a matter of just calling thing.constantize. I greatly prefer this to having any kind of custom mapping - it promotes the 'ubiquitous language' that Eric Evans talks about in the original DDD book. Maybe it's different when you're working in another language though - I guess it's preferable to use English names for classes etc, is it? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From dchelimsky at gmail.com Mon Dec 1 18:26:47 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 1 Dec 2008 17:26:47 -0600 Subject: [rspec-users] Musical Cucumber In-Reply-To: <49345E67.8010507@joesniff.co.uk> References: <49345E67.8010507@joesniff.co.uk> Message-ID: <57c63afe0812011526o3e9eb3d8j9d9f20c0f1baf221@mail.gmail.com> On Mon, Dec 1, 2008 at 4:00 PM, Joseph Wilk wrote: > http://www.youtube.com/watch?v=U3OxKdDxkpg > > Sorry, I had to share that :) That guy can not phrase a scenario to save his life! > -- > Joseph Wilk > http://blog.josephwilk.net > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Tue Dec 2 03:04:20 2008 From: lists at ruby-forum.com (Pau Cor) Date: Tue, 2 Dec 2008 09:04:20 +0100 Subject: [rspec-users] Sample App - TDD with Cucumber and RSpec In-Reply-To: <4934343A.50106@the-cocktail.com> References: <4934343A.50106@the-cocktail.com> Message-ID: <09f88f67ad0d9ac99ee28d0f9ee5aa41@ruby-forum.com> Fernando Garc?a Samblas wrote: > IMHO it would be nice to have instead a "context_definitions.rb" with > common "givens" (similar to navigation_definitions.rb) and there a more > general definition, like for instance: ... > Given /^there are no (.*)$/ do |thing| I really like that. It will make it much more clear since "Given there are no" will be a very common step. Paul -- Posted via http://www.ruby-forum.com/. From ashley.moran at patchspace.co.uk Tue Dec 2 07:40:16 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 2 Dec 2008 12:40:16 +0000 Subject: [rspec-users] Sample App - TDD with Cucumber and RSpec In-Reply-To: <09f88f67ad0d9ac99ee28d0f9ee5aa41@ruby-forum.com> References: <4934343A.50106@the-cocktail.com> <09f88f67ad0d9ac99ee28d0f9ee5aa41@ruby-forum.com> Message-ID: On 2 Dec 2008, at 08:04, Pau Cor wrote: >> Given /^there are no (.*)$/ do |thing| > > I really like that. It will make it much more clear since "Given there > are no" will be a very common step. Hmmm, I personally think it's safer to set up each scenario from a blank slate. I've used "Given there are no X" steps before, but they are just stubs to make the scenario read right, ie they simply don't create anything, rather than destroying existing data. The current implementation, Given /^there are no posties$/ do Postie.destroy_all end strikes me more of a when step, eg When /^all posties are destroyed$/ do Postie.destroy_all end A Before block to destroy the Posties (and any other models) will probably reduce issues in the long run if Postie began to depend on another object, and was trapped by a database constraint. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From peter.a.jaros at gmail.com Tue Dec 2 09:11:21 2008 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Tue, 2 Dec 2008 09:11:21 -0500 Subject: [rspec-users] cucumber and autotest - running all features? In-Reply-To: <5BCECC48-3374-462B-9493-63715A7AEB26@mattwynne.net> References: <306b6bd9a7f00af8464713c73dc929de@ruby-forum.com> <4ee52ac742558d3aeb2d560fef7b27fe@ruby-forum.com> <937d9d810811301845x29632c37p7ffc80b5537b4450@mail.gmail.com> <5BCECC48-3374-462B-9493-63715A7AEB26@mattwynne.net> Message-ID: <937d9d810812020611t3a9f4c74hc85dae7b55c56a9d@mail.gmail.com> On Mon, Dec 1, 2008 at 2:50 AM, Matt Wynne wrote: > > I've been thinking about a more sophisticated mechanism for this, using code > coverage. If autotest / rspactor was able to record and remember the LOC > covered by each scenario / example, it would be possible to do more focussed > regression testing when a source file was changed. It's a clever thought, but you don't know about code which scenarios *will* depend on in the future. You'd have to manually restart autotest and have it recalculate all of the mappings. Peter From fernando.garcia at the-cocktail.com Tue Dec 2 09:22:54 2008 From: fernando.garcia at the-cocktail.com (=?ISO-8859-1?Q?Fernando_Garc=EDa_Samblas?=) Date: Tue, 02 Dec 2008 15:22:54 +0100 Subject: [rspec-users] Sample App - TDD with Cucumber and RSpec In-Reply-To: <25363906-3747-423D-A040-3C3325DE5DA6@mattwynne.net> References: <4934343A.50106@the-cocktail.com> <25363906-3747-423D-A040-3C3325DE5DA6@mattwynne.net> Message-ID: <493544BE.3090203@the-cocktail.com> Matt Wynne escribi?: > Maybe it's different when you're working in another language though - > I guess it's preferable to use English names for classes etc, is it? Exactly Matt that's it. I forgot to explain that, thanks for mention it. We use pure English in our code and Spanish in the features. A business term in Spanish can have a bunch of possible translations to English. The mapping functions let us now exactly what are we talking about, reducing ambiguity and improving communication with business people. > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Fernando Garc?a Samblas fernando.garcia at the-cocktail.com http://nando.lacoctelera.com The Cocktail C/ Salamanca 17 28020 Madrid +34 91 567 06 05 From ashley.moran at patchspace.co.uk Tue Dec 2 09:56:14 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Tue, 2 Dec 2008 14:56:14 +0000 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? Message-ID: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> Hi The code I'm working on now is a server daemon that talks to Twitter, an RSS feed, and some web pages. I've got mock implementations of Twitter and the web stuff, which I start and stop with daemon_controller[1]. I do all the setup in a Before block, but this makes the feature runs agonisingly slow due to the time waiting for everything to restart. I'm now starting a Merb app which will rely on the database created by the server daemon, so it's going to get even slower. Are there any plans to add BeforeStory or BeforeAll blocks to Cucumber? With this I could start everything once and add reset code to each daemon. Ashley [1] http://blog.phusion.nl/2008/08/25/daemon_controller-a-library-for-robust-daemon-management/ -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From lists at ruby-forum.com Tue Dec 2 10:25:33 2008 From: lists at ruby-forum.com (Stephen Veit) Date: Tue, 2 Dec 2008 16:25:33 +0100 Subject: [rspec-users] Using Cucumber with latest Webrat Message-ID: <91953e7b6ebf063e56dbb38c472c85f3@ruby-forum.com> I added cucumber to my rails project using the following commands: git submodule add git://github.com/aslakhellesoy/cucumber.git \ vendor/plugins/cucumber ruby script/generate cucumber git submodule add git://github.com/brynary/webrat.git \ vendor/plugins/webrat git submodule add git://github.com/dchelimsky/rspec.git \ vendor/plugins/rspec git submodule add git://github.com/dchelimsky/rspec-rails.git \ vendor/plugins/rspec-rails script/generate rspec I create a feature that used steps that included visits. I got the following error: /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- webrat (LoadError) This occurred at line 4 in webrat_steps.rb So I commented out that line and added "require 'webrat'" to env.rb This time I got the following error: undefined method `visits' for # (NoMethodError) So I had to change the require in env.rb to require 'webrat/rails' It worked but I got the following deprecation errors: visits is deprecated. Use visit instead. fills_in is deprecated. Use fill_in instead. clicks_button is deprecated. Use click_button instead. I changed these in my steps file, and it worked fine. The problem with requiring webrat from webrat_steps, is that when this line is executed, the $LOAD_PATHS has not been modified to include the plugin lib directories. That is done by support/env.rb. The rake task "features" creates a command line that looks like: -I "/home/sveit/Projects/rails/varsitytutors/vendor/plugins/cucumber/lib" "/home/sveit/Projects/rails/varsitytutors/vendor/plugins/cucumber/bin/cucumber" --format pretty --require features/step_definitions/user_steps.rb --require features/step_definitions/webrat_steps.rb --require features/step_definitions/frooble_steps.rb --require features/support/env.rb features/manage_users.feature "support/env.rb" is required after "step_definitions/webrat_steps.rb". this should probably be changed. -- Posted via http://www.ruby-forum.com/. From josephwilk at joesniff.co.uk Tue Dec 2 10:26:52 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Tue, 02 Dec 2008 15:26:52 +0000 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> Message-ID: <493553BC.8060300@joesniff.co.uk> Ashley Moran wrote: > Hi > > The code I'm working on now is a server daemon that talks to Twitter, > an RSS feed, and some web pages. I've got mock implementations of > Twitter and the web stuff, which I start and stop with > daemon_controller[1]. I do all the setup in a Before block, All defined before blocks are run for each scenario so this would slow down every scenario. > but this makes the feature runs agonisingly slow due to the time > waiting for everything to restart. I'm now starting a Merb app which > will rely on the database created by the server daemon, so it's going > to get even slower. > > Are there any plans to add BeforeStory or BeforeAll blocks to > Cucumber? With this I could start everything once and add reset code > to each daemon. > > Ashley > > [1] > http://blog.phusion.nl/2008/08/25/daemon_controller-a-library-for-robust-daemon-management/ > > BeforeAll (Before running any feature) is currently possible through putting something in your env.rb or really any ruby file that gets required. It will be run once (and before anything else). I use this to manage ferret/selenium. The before/afters being used to tell the service to cleanup so we have clean environment for each test. Could you do the same? And Afterall is possible through: at_exit BeforeFeature sounds like it could be useful for preparing services for that specific feature and you don't want them running for other features. I guess currently the only way of achieving this is separating those features and running them in separate cucumber runs. This is what I have done with something similar, using --profile to run different sets of features. I prefer this (in my experience so far) as it allows me to re-use my rake tasks for setting things up and keeps that setup from adding noise to my test code. I appreciate with mock services your situation is slightly different. -- Joseph Wilk http://blog.josephwilk.net From aslak.hellesoy at gmail.com Tue Dec 2 10:42:26 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 2 Dec 2008 16:42:26 +0100 Subject: [rspec-users] Using Cucumber with latest Webrat In-Reply-To: <91953e7b6ebf063e56dbb38c472c85f3@ruby-forum.com> References: <91953e7b6ebf063e56dbb38c472c85f3@ruby-forum.com> Message-ID: <8d961d900812020742q3c17c5co93794053f5f8b599@mail.gmail.com> On Tue, Dec 2, 2008 at 4:25 PM, Stephen Veit wrote: > I added cucumber to my rails project using the following commands: > > git submodule add git://github.com/aslakhellesoy/cucumber.git \ > vendor/plugins/cucumber > ruby script/generate cucumber > git submodule add git://github.com/brynary/webrat.git \ > vendor/plugins/webrat > git submodule add git://github.com/dchelimsky/rspec.git \ > vendor/plugins/rspec > git submodule add git://github.com/dchelimsky/rspec-rails.git \ > vendor/plugins/rspec-rails > script/generate rspec > > I create a feature that used steps that included visits. I got the > following error: > > /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require': no such file to load -- webrat (LoadError) > > This occurred at line 4 in webrat_steps.rb > > So I commented out that line and added "require 'webrat'" to env.rb > > This time I got the following error: > > undefined method `visits' for > # (NoMethodError) > > So I had to change the require in env.rb to > > require 'webrat/rails' > > It worked but I got the following deprecation errors: > > visits is deprecated. Use visit instead. > fills_in is deprecated. Use fill_in instead. > clicks_button is deprecated. Use click_button instead. > > I changed these in my steps file, and it worked fine. > > I just (1 hour ago) incorporated some recent Cucumber changes from Bryan (who writes Webrat) and released cucumber 0.1.11. Can you try with the latest release? It should work well with Bryan's latest webrat. Cheers, Aslak > > > The problem with requiring webrat from webrat_steps, is that when this > line is executed, the $LOAD_PATHS has not been modified to include the > plugin lib directories. That is done by support/env.rb. The rake task > "features" creates a command line that looks like: > > -I > "/home/sveit/Projects/rails/varsitytutors/vendor/plugins/cucumber/lib" > > "/home/sveit/Projects/rails/varsitytutors/vendor/plugins/cucumber/bin/cucumber" > --format pretty --require features/step_definitions/user_steps.rb > --require features/step_definitions/webrat_steps.rb --require > features/step_definitions/frooble_steps.rb --require > features/support/env.rb features/manage_users.feature > > "support/env.rb" is required after "step_definitions/webrat_steps.rb". > this should probably be changed. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From motzfeldt at gmail.com Tue Dec 2 11:00:00 2008 From: motzfeldt at gmail.com (Peter Nicolai Motzfeldt) Date: Tue, 2 Dec 2008 17:00:00 +0100 Subject: [rspec-users] Using Rspec for web tests Message-ID: <94b8e5e60812020800y5a5a4b79yf0ad40749f1ea16c@mail.gmail.com> Hi, I am trying to use Rspec together with FunFX for Flex testing. To ease the number of tests and the functionality each test does, I would like to run all the it "shoulds..." in sequence. This works just fine, but the creation of FunFX is created after each it "should..." and no wonder since I create it in the before method. But my question is where should I put the two lines of code that creates an instance of FunFx so that all the it "should .. " uses the same @flex instance, that should be created just once in for each describe? describe "DemoApp" do before do browser.goto(DEMO_APP) @flex = browser.flex_app('DemoAppId', 'DemoAppName') end it "should click on a checkbox" do # do somthing end it "should assert that it is checked" do # do something end end - Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: From jim at saturnflyer.com Tue Dec 2 11:14:59 2008 From: jim at saturnflyer.com (Jim Gay) Date: Tue, 2 Dec 2008 11:14:59 -0500 Subject: [rspec-users] Using Cucumber with latest Webrat In-Reply-To: <8d961d900812020742q3c17c5co93794053f5f8b599@mail.gmail.com> References: <91953e7b6ebf063e56dbb38c472c85f3@ruby-forum.com> <8d961d900812020742q3c17c5co93794053f5f8b599@mail.gmail.com> Message-ID: <83408847-59A0-4BF1-892C-C440EA1D7E15@saturnflyer.com> On Dec 2, 2008, at 10:42 AM, aslak hellesoy wrote: > On Tue, Dec 2, 2008 at 4:25 PM, Stephen Veit > wrote: > I added cucumber to my rails project using the following commands: > > git submodule add git://github.com/aslakhellesoy/cucumber.git \ > vendor/plugins/cucumber > ruby script/generate cucumber > git submodule add git://github.com/brynary/webrat.git \ > vendor/plugins/webrat > git submodule add git://github.com/dchelimsky/rspec.git \ > vendor/plugins/rspec > git submodule add git://github.com/dchelimsky/rspec-rails.git \ > vendor/plugins/rspec-rails > script/generate rspec > > I create a feature that used steps that included visits. I got the > following error: > > /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require': no such file to load -- webrat (LoadError) > > This occurred at line 4 in webrat_steps.rb > > So I commented out that line and added "require 'webrat'" to env.rb > > This time I got the following error: > > undefined method `visits' for > # > (NoMethodError) > > So I had to change the require in env.rb to > > require 'webrat/rails' > > It worked but I got the following deprecation errors: > > visits is deprecated. Use visit instead. > fills_in is deprecated. Use fill_in instead. > clicks_button is deprecated. Use click_button instead. > > I changed these in my steps file, and it worked fine. > > > I just (1 hour ago) incorporated some recent Cucumber changes from > Bryan (who writes Webrat) and released cucumber 0.1.11. > Can you try with the latest release? It should work well with > Bryan's latest webrat. I had the same problem. The fix was to install Webrat as a plugin. I'll try out the updated versions. > > > Cheers, > Aslak > > > > The problem with requiring webrat from webrat_steps, is that when this > line is executed, the $LOAD_PATHS has not been modified to include the > plugin lib directories. That is done by support/env.rb. The rake task > "features" creates a command line that looks like: > > -I > "/home/sveit/Projects/rails/varsitytutors/vendor/plugins/cucumber/lib" > "/home/sveit/Projects/rails/varsitytutors/vendor/plugins/cucumber/ > bin/cucumber" > --format pretty --require features/step_definitions/user_steps.rb > --require features/step_definitions/webrat_steps.rb --require > features/step_definitions/frooble_steps.rb --require > features/support/env.rb features/manage_users.feature > > "support/env.rb" is required after "step_definitions/webrat_steps.rb". > this should probably be changed. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Dec 2 11:14:43 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 2 Dec 2008 10:14:43 -0600 Subject: [rspec-users] Using Rspec for web tests In-Reply-To: <94b8e5e60812020800y5a5a4b79yf0ad40749f1ea16c@mail.gmail.com> References: <94b8e5e60812020800y5a5a4b79yf0ad40749f1ea16c@mail.gmail.com> Message-ID: <57c63afe0812020814m54f1b34aode6472e12f192145@mail.gmail.com> On Tue, Dec 2, 2008 at 10:00 AM, Peter Nicolai Motzfeldt wrote: > Hi, I am trying to use Rspec together with FunFX for Flex testing. To ease > the number of tests and the functionality each test does, I would like to > run all the it "shoulds..." in sequence. > > This works just fine, but the creation of FunFX is created after each it > "should..." and no wonder since I create it in the before method. > > But my question is where should I put the two lines of code that creates an > instance of FunFx so that all the it "should .. " uses the same @flex > instance, that should be created just once in for each describe? before(:all) http://rspec.info/documentation/before_and_after.html Cheers, David > > describe "DemoApp" do > before do > browser.goto(DEMO_APP) > @flex = browser.flex_app('DemoAppId', 'DemoAppName') > end > > it "should click on a checkbox" do > # do somthing > end > > it "should assert that it is checked" do > # do something > end > end > > - Peter > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Tue Dec 2 12:01:30 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Tue, 2 Dec 2008 12:01:30 -0500 Subject: [rspec-users] Setup for autospec for non-rails project Message-ID: I brought this up some time ago. I'm trying to use autotest to run specs in a non-rails project. FWIW the project is structured using the bones gem. $ spec -v rspec 1.1.11 k$ gem list zentest *** LOCAL GEMS *** ZenTest (3.11.0, 3.9.1, 3.9.0, 3.8.0, 3.7.1, 3.7.0, 3.6.1) $ cat .autotest Autotest.add_hook :initialize do |at| %w{.svn .hg .git .bzr}.each { |exception| at.add_exception(exception) } at.clear_mappings at.add_mapping(%r%^(spec/(spec_helper|shared/.*)|config/(boot|environment(s/test)?))\.rb$%) { at.files_matching %r%^spec/(models|controllers|views|helpers)/.*_spec\.rb$% } at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| ["spec/lib/#{m[1]}_spec.rb"] } end Autotest.add_discovery do "rspec" if File.directory?('spec') && ENV['RSPEC'] end $ autospec loading autotest/rspec /opt/local/bin/ruby -S spec/lib/v_date_time_property_spec.rb spec/lib/v_date_property_spec.rb spec/lib/v_property_spec.rb spec/lib/parser_spec.rb spec/lib/t_z_info_vtimezone_spec.rb spec/lib/v_date_time_property_spec.rb:8: warning: parenthesize argument(s) for future version spec/lib/v_date_time_property_spec.rb:12: warning: parenthesize argument(s) for future version spec/lib/v_date_time_property_spec.rb:4: undefined method `describe' for main:Object (NoMethodError) For some reason, it's running the specs as plain old ruby files and the RSpec framework doesn't seem to be being intialized. I've done lots of googling about this, and everything about running autotest for RSpec for non-rails projects seems to be quite old. I did find one old post which recommended making a .autotest file in the project with mappings based on the rspec-rails mappings, which is what I tried above, but no joy. Any insight? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Tue Dec 2 12:12:30 2008 From: mark at mwilden.com (Mark Wilden) Date: Tue, 2 Dec 2008 09:12:30 -0800 Subject: [rspec-users] Setup for autospec for non-rails project In-Reply-To: References: Message-ID: <3c30da400812020912q30d5afabwe56e2c33c8ac50d2@mail.gmail.com> On Tue, Dec 2, 2008 at 9:01 AM, Rick DeNatale wrote: > $ autospec > loading autotest/rspec > /opt/local/bin/ruby -S spec/lib/v_date_time_property_spec.rb > spec/lib/v_date_property_spec.rb spec/lib/v_property_spec.rb > spec/lib/parser_spec.rb spec/lib/t_z_info_vtimezone_spec.rb > spec/lib/v_date_time_property_spec.rb:8: warning: parenthesize argument(s) > for future version > spec/lib/v_date_time_property_spec.rb:12: warning: parenthesize argument(s) > for future version > spec/lib/v_date_time_property_spec.rb:4: undefined method `describe' for > main:Object (NoMethodError) > Are you requiring 'spec' anywhere? ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From rick.denatale at gmail.com Tue Dec 2 13:05:13 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Tue, 2 Dec 2008 13:05:13 -0500 Subject: [rspec-users] Setup for autospec for non-rails project In-Reply-To: <3c30da400812020912q30d5afabwe56e2c33c8ac50d2@mail.gmail.com> References: <3c30da400812020912q30d5afabwe56e2c33c8ac50d2@mail.gmail.com> Message-ID: On Tue, Dec 2, 2008 at 12:12 PM, Mark Wilden wrote: > On Tue, Dec 2, 2008 at 9:01 AM, Rick DeNatale wrote: > > >> $ autospec >> loading autotest/rspec >> /opt/local/bin/ruby -S spec/lib/v_date_time_property_spec.rb >> spec/lib/v_date_property_spec.rb spec/lib/v_property_spec.rb >> spec/lib/parser_spec.rb spec/lib/t_z_info_vtimezone_spec.rb >> spec/lib/v_date_time_property_spec.rb:8: warning: parenthesize argument(s) >> for future version >> spec/lib/v_date_time_property_spec.rb:12: warning: parenthesize >> argument(s) for future version >> spec/lib/v_date_time_property_spec.rb:4: undefined method `describe' for >> main:Object (NoMethodError) >> > > Are you requiring 'spec' anywhere? > Adding require 'spec' at the top of the .autospec file doesn't change anything. I didn't mention (this time) that the specs run fine if I use: * cmd-R in Textmate to run them via the RSpec bundle. * using rake spec * individually using the spec command. The problem seems to lie in something missing in the autotest/autospec setup. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Dec 2 13:09:48 2008 From: lists at ruby-forum.com (James Byrne) Date: Tue, 2 Dec 2008 19:09:48 +0100 Subject: [rspec-users] cucumber/rspec pending call Message-ID: I have tried to do this in a step definition: When /set the "(.*)" to "(.*)"/ do |a,v| pending end However, no matter how I invoke cucumber, I get this error: And I set the "type" to "main" # features/locations/step_definitions/location_steps.rb:33 TODO (Spec::Example::ExamplePendingError) /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/pending.rb:13:in `pending' ./features/locations/step_definitions/location_steps.rb:34:in `And /set the "(.*)" to "(.*)"/' features/locations/location.feature:24:in `And I set the "type" to "main"' My env.rb file looks like this: # Sets up the Rails environment for Cucumber ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') require 'cucumber/rails/world' Cucumber::Rails.use_transactional_fixtures # If webrat is a gem then uncomment this require 'webrat' if !defined?(Webrat) # If webrat is a plugin then uncomment this #require 'webrat/rails' # Comment out the next two lines if you're not using RSpec's matchers (should / should_not) in your steps. require 'cucumber/rails/rspec' #require 'webrat/rspec-rails' -- Posted via http://www.ruby-forum.com/. From josephwilk at joesniff.co.uk Tue Dec 2 13:16:51 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Tue, 02 Dec 2008 18:16:51 +0000 Subject: [rspec-users] cucumber/rspec pending call In-Reply-To: References: Message-ID: <49357B93.2010308@joesniff.co.uk> James Byrne wrote: > I have tried to do this in a step definition: > > When /set the "(.*)" to "(.*)"/ do |a,v| > pending > end > > However, no matter how I invoke cucumber, I get this error: > > And I set the "type" to "main" # > features/locations/step_definitions/location_steps.rb:33 > TODO (Spec::Example::ExamplePendingError) > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/pending.rb:13:in > `pending' > ./features/locations/step_definitions/location_steps.rb:34:in `And > /set the "(.*)" to "(.*)"/' > features/locations/location.feature:24:in `And I set the "type" to > "main"' > > My env.rb file looks like this: > > # Sets up the Rails environment for Cucumber > ENV["RAILS_ENV"] = "test" > require File.expand_path(File.dirname(__FILE__) + > '/../../config/environment') > require 'cucumber/rails/world' > Cucumber::Rails.use_transactional_fixtures > > # If webrat is a gem then uncomment this > require 'webrat' if !defined?(Webrat) > > # If webrat is a plugin then uncomment this > #require 'webrat/rails' > > # Comment out the next two lines if you're not using RSpec's matchers > (should / should_not) in your steps. > require 'cucumber/rails/rspec' > #require 'webrat/rspec-rails' > 'pending' is not supported yet. There is some work waiting to be done on pending steps: http://rspec.lighthouseapp.com/projects/16211/tickets/52-unmatched-steps-should-less-tolerable-than-pending-steps But I think it could do with a new ticket. Would you mind creating one please? Thanks, -- Joseph Wilk http://blog.josephwilk.net From rick.denatale at gmail.com Tue Dec 2 13:18:18 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Tue, 2 Dec 2008 13:18:18 -0500 Subject: [rspec-users] Setup for autospec for non-rails project In-Reply-To: References: <3c30da400812020912q30d5afabwe56e2c33c8ac50d2@mail.gmail.com> Message-ID: Okay, If I add this to my .autospec file class Autotest::Rspec def make_test_cmd(files_to_test) return '' if files_to_test.empty? return "spec #{files_to_test.keys.flatten.join(' ')} #{add_options_if_present}" end end It works. This replaces a method defined in the rspec gem in lib/autotest/rspec.rb def make_test_cmd(files_to_test) return '' if files_to_test.empty? return "#{ruby} -S #{files_to_test.keys.flatten.join(' ')} #{add_options_if_present}" end I guess I need to file a bug report?!? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From rick.denatale at gmail.com Tue Dec 2 13:27:17 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Tue, 2 Dec 2008 13:27:17 -0500 Subject: [rspec-users] Setup for autospec for non-rails project In-Reply-To: References: <3c30da400812020912q30d5afabwe56e2c33c8ac50d2@mail.gmail.com> Message-ID: On Tue, Dec 2, 2008 at 1:18 PM, Rick DeNatale wrote: > Okay, > > If I add this to my .autospec file > > class Autotest::Rspec > > def make_test_cmd(files_to_test) > return '' if files_to_test.empty? > return "spec #{files_to_test.keys.flatten.join(' ')} > #{add_options_if_present}" > end > end > > It works. > > This replaces a method defined in the rspec gem in lib/autotest/rspec.rb > > def make_test_cmd(files_to_test) > return '' if files_to_test.empty? > return "#{ruby} -S #{files_to_test.keys.flatten.join(' ')} > #{add_options_if_present}" > end > > > I guess I need to file a bug report?!? > After investigating github, it looks like a slightly different fix for this is already in the works. http://github.com/dchelimsky/rspec/commit/d6029bd91a08ce87ad10c917bfb7b4c75645bf79 although it will only work if it's in the gem code rather than in .autotest (it finds the spec command file path relative to the source file). So for the time being, I'll just use my .autotest patch -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From josephwilk at joesniff.co.uk Tue Dec 2 13:50:26 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Tue, 02 Dec 2008 18:50:26 +0000 Subject: [rspec-users] cucumber/rspec pending call In-Reply-To: References: Message-ID: <49358372.4050103@joesniff.co.uk> James Byrne wrote: > I have tried to do this in a step definition: > > When /set the "(.*)" to "(.*)"/ do |a,v| > pending > end > > However, no matter how I invoke cucumber, I get this error: > > And I set the "type" to "main" # > features/locations/step_definitions/location_steps.rb:33 > TODO (Spec::Example::ExamplePendingError) > /usr/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/example/pending.rb:13:in > `pending' > ./features/locations/step_definitions/location_steps.rb:34:in `And > /set the "(.*)" to "(.*)"/' > features/locations/location.feature:24:in `And I set the "type" to > "main"' > > My env.rb file looks like this: > > # Sets up the Rails environment for Cucumber > ENV["RAILS_ENV"] = "test" > require File.expand_path(File.dirname(__FILE__) + > '/../../config/environment') > require 'cucumber/rails/world' > Cucumber::Rails.use_transactional_fixtures > > # If webrat is a gem then uncomment this > require 'webrat' if !defined?(Webrat) > > # If webrat is a plugin then uncomment this > #require 'webrat/rails' > > # Comment out the next two lines if you're not using RSpec's matchers > (should / should_not) in your steps. > require 'cucumber/rails/rspec' > #require 'webrat/rspec-rails' > Having said that if you need an instant solution you can use: @@@ When /set the "(.*)" to "(.*)"/ do |a,v| raise Cucumber::Pending.new("I need to implement this asap") end @@@ -- Joseph Wilk http://blog.josephwilk.net From lists at ruby-forum.com Tue Dec 2 14:03:24 2008 From: lists at ruby-forum.com (James Byrne) Date: Tue, 2 Dec 2008 20:03:24 +0100 Subject: [rspec-users] cucumber/rspec pending call In-Reply-To: <49357B93.2010308@joesniff.co.uk> References: <49357B93.2010308@joesniff.co.uk> Message-ID: Joseph Wilk wrote: > 'pending' is not supported yet. > > There is some work waiting to be done on pending steps: > http://rspec.lighthouseapp.com/projects/16211/tickets/52-unmatched-steps-should-less-tolerable-than-pending-steps > > But I think it could do with a new ticket. Would you mind creating one > please? > > Thanks, Here you got: http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/112-add-pending-or-perhaps-pending-method -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Tue Dec 2 14:25:31 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 02 Dec 2008 11:25:31 -0800 Subject: [rspec-users] Sample App - TDD with Cucumber and RSpec In-Reply-To: (Ashley Moran's message of "Tue\, 2 Dec 2008 12\:40\:16 +0000") References: <4934343A.50106@the-cocktail.com> <09f88f67ad0d9ac99ee28d0f9ee5aa41@ruby-forum.com> Message-ID: Ashley Moran writes: > On 2 Dec 2008, at 08:04, Pau Cor wrote: > >>> Given /^there are no (.*)$/ do |thing| >> >> I really like that. It will make it much more clear since "Given there >> are no" will be a very common step. > > Hmmm, I personally think it's safer to set up each scenario from a > blank slate. I've used "Given there are no X" steps before, but they > are just stubs to make the scenario read right, ie they simply don't > create anything, rather than destroying existing data. > > The current implementation, > Given /^there are no posties$/ do > Postie.destroy_all > end > > strikes me more of a when step, eg > When /^all posties are destroyed$/ do > Postie.destroy_all > end > > A Before block to destroy the Posties (and any other models) will > probably reduce issues in the long run if Postie began to depend on > another object, and was trapped by a database constraint. > > Ashley I'm with you on this. In fact, I think my implementation would be Given ... Postie.count.should == 0 end It's just an assertion (in the C sense of the word, not testing). You should be starting off with a clean slate anyway...but having a couple assertions before you run can be very helpful for localization. Plus this step can obviously be reused as a When. Pat From lists at ruby-forum.com Tue Dec 2 14:47:49 2008 From: lists at ruby-forum.com (James Byrne) Date: Tue, 2 Dec 2008 20:47:49 +0100 Subject: [rspec-users] cucumber/rspec pending call In-Reply-To: <49358372.4050103@joesniff.co.uk> References: <49358372.4050103@joesniff.co.uk> Message-ID: <53ae3a2ae4a7d53040b6e6139e4b499b@ruby-forum.com> Joseph Wilk wrote: > When /set the "(.*)" to "(.*)"/ do |a,v| > raise Cucumber::Pending.new("I need to implement this asap") > end That works nicely. The string argument does not show up anywhere that I could find when this is invoked from autotest but the step definition itself is treated as pending. This technique also seems to have the effect of escaping any following code in the definition block. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Dec 2 15:41:28 2008 From: lists at ruby-forum.com (James Byrne) Date: Tue, 2 Dec 2008 21:41:28 +0100 Subject: [rspec-users] stepping across features Message-ID: I am perplexed by a situation that I am creating for myself, probably out of ignorance. I have two models connected through a join table which itself contains information related to the join. I am testing the creation of this join. I already have step definitions written for one of the outside models that include methods to create new records. I say methods because I have broken down the processing to initializing the model instance, populating the attributes, and then saving it. Now, where I think I may be about to commit a grave error is in the step definitions for the features relating to the join model. Which path should I take: 1. Call the existing step definitions in the outer model to create a test instance? or 2. Replicate the effect of those existing steps inside the step definition file for the join model and create test instances of the outer models completely from within that file. Regards, -- Posted via http://www.ruby-forum.com/. From fernando.garcia at the-cocktail.com Tue Dec 2 16:16:06 2008 From: fernando.garcia at the-cocktail.com (=?ISO-8859-1?Q?Fernando_Garc=EDa_Samblas?=) Date: Tue, 02 Dec 2008 22:16:06 +0100 Subject: [rspec-users] Sample App - TDD with Cucumber and RSpec In-Reply-To: References: <4934343A.50106@the-cocktail.com> <09f88f67ad0d9ac99ee28d0f9ee5aa41@ruby-forum.com> Message-ID: <4935A596.6020301@the-cocktail.com> Ashley Moran escribi?: > > On 2 Dec 2008, at 08:04, Pau Cor wrote: > >>> Given /^there are no (.*)$/ do |thing| >> >> I really like that. It will make it much more clear since "Given there >> are no" will be a very common step. > > Hmmm, I personally think it's safer to set up each scenario from a > blank slate. I've used "Given there are no X" steps before, but they > are just stubs to make the scenario read right, ie they simply don't > create anything, rather than destroying existing data. Yes, I also agree with you and Pat. Givens should create the scenario context, not clean the garbage left by others. But I was using it just as an example of "reusing" common Givens (after all it was the only Given in Paul's example app), the same way we do with Whens a Thens. Take this example instead: Given /^there is (?:a|an) (.*)$/ do |thing| @resources ||= [] @resources << thing_to_model(thing).create end Using a model factory like FixturesReplacement you can deal with required data. WDYT? > > The current implementation, > Given /^there are no posties$/ do > Postie.destroy_all > end > > strikes me more of a when step, eg > When /^all posties are destroyed$/ do > Postie.destroy_all > end > > A Before block to destroy the Posties (and any other models) will > probably reduce issues in the long run if Postie began to depend on > another object, and was trapped by a database constraint. > > Ashley > -- Fernando Garc?a Samblas fernando.garcia at the-cocktail.com http://nando.lacoctelera.com The Cocktail C/ Salamanca 17 28020 Madrid +34 91 567 06 05 From mark at mwilden.com Tue Dec 2 17:31:08 2008 From: mark at mwilden.com (Mark Wilden) Date: Tue, 2 Dec 2008 14:31:08 -0800 Subject: [rspec-users] class << self considered harmful... really? In-Reply-To: <937d9d810811301912p21fcce46yadc406fd11896252@mail.gmail.com> References: <10C5B127-27EB-49B1-8C9B-0E8B769E55D4@mattwynne.net> <3c30da400811250954g3e8015c3u9bf8e691cddd4b12@mail.gmail.com> <5E9F0C26-6CC8-48CF-8342-826AE213615E@mattwynne.net> <3c30da400811251014m6fc12e63k466fff46ceae80ad@mail.gmail.com> <20081126132331.GD13628@durance.shot.pl> <3c30da400811260851l6b9dae23g211003c23d2ace56@mail.gmail.com> <937d9d810811301912p21fcce46yadc406fd11896252@mail.gmail.com> Message-ID: <3c30da400812021431y404c8e76oa8bbc6a014b47f5@mail.gmail.com> Here's what The Ruby Programming Language says about this: "In general, it is clearer to define class methods as individual singleton methods without explicitly opening the eigenclass" (p. 258) This is far from a blanket condemnation, and, as with the rest of the book, it's not obvious whether it's Matz or (non-Rubyist) Flanagan who's talking. I don't mean to "open" the discussion again. :) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.mischa at gmail.com Tue Dec 2 18:48:38 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Tue, 2 Dec 2008 17:48:38 -0600 Subject: [rspec-users] stepping across features In-Reply-To: References: Message-ID: James, Hey, actual code might make it easier to help (maybe others disagree), but here's a few things: I'm assuming you're using rails, and has many through. It sounds like you have something like model: Picture (has many pagepictures, has many pages through pactures model; Page (has many pagepictures, has many pictures through pagepictures.) model PagePicture (belongs to page, belongs to picture) (plus some sort of position attribute or something. It sounds like you're testing the pages stuff and the pictures stuff in separate features, but you need both for both features. I might do soemthing like: Given I have a page with a bunch of pictures then in my step definitions do something like Given ... do PagePicture.create!(:position => 3, :picture_id => Picture.make, :page_id => Page.make) end This is using machinist (http://github.com/notahat/machinist/tree/master) blueprints, which save a lot of time in features. I tend to avoid calling steps in other steps, as right now it appears that cucumber does not tell you which step within the step is pending if you have it wrong, but just says that the entire one is pending. I prefer to separate them. If it's something more complex than the above, I might make a method that would do the creation, and then call it from both steps. So I guess that is more like #2 of your question. I'm sure there are much better ways of doing this though...just my strategy so far. M On Tue, Dec 2, 2008 at 2:41 PM, James Byrne wrote: > I am perplexed by a situation that I am creating for myself, probably > out of ignorance. I have two models connected through a join table > which itself contains information related to the join. I am testing the > creation of this join. > > I already have step definitions written for one of the outside models > that include methods to create new records. I say methods because I > have broken down the processing to initializing the model instance, > populating the attributes, and then saving it. > > Now, where I think I may be about to commit a grave error is in the step > definitions for the features relating to the join model. Which path > should I take: > > 1. Call the existing step definitions in the outer model to create a > test instance? or > > 2. Replicate the effect of those existing steps inside the step > definition file for the join model and create test instances of the > outer models completely from within that file. > > Regards, > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tastapod at gmail.com Wed Dec 3 00:44:42 2008 From: tastapod at gmail.com (Dan North) Date: Tue, 2 Dec 2008 23:44:42 -0600 Subject: [rspec-users] Musical Cucumber In-Reply-To: <8d961d900812011415m6652a005o6ba8c5be46b430e8@mail.gmail.com> References: <49345E67.8010507@joesniff.co.uk> <8d961d900812011415m6652a005o6ba8c5be46b430e8@mail.gmail.com> Message-ID: 2008/12/1 aslak hellesoy > > > On Mon, Dec 1, 2008 at 11:00 PM, Joseph Wilk wrote: > >> http://www.youtube.com/watch?v=U3OxKdDxkpg >> >> Sorry, I had to share that :) > > > Thank you! Fantastic. And for those who missed the kitten: > > http://aimee.mychores.co.uk/2008/11/10/post/362/ > Oh wow. Just.. oh wow. Suddenly it was all worth it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From juhat-lists at goraffe.hu Wed Dec 3 03:58:47 2008 From: juhat-lists at goraffe.hu (=?ISO-8859-1?Q?Attila_Juh=E1sz?=) Date: Wed, 3 Dec 2008 09:58:47 +0100 Subject: [rspec-users] Running Rspec from ruby code Message-ID: <6bc3eb9f0812030058n498efbe9hd6229fdbd49d9a15@mail.gmail.com> Hi everyone! First of all I am quite new at the rspec world. I have an idea, but I can't make it work. I would like to run one rspec spec file from a ruby daemon, and get the result back into a string. Is it possible to manage this task? Could you give me some direction? Many thanks, Attila ------ http://Atti.la From lists at ruby-forum.com Wed Dec 3 05:11:13 2008 From: lists at ruby-forum.com (Newman Huang) Date: Wed, 3 Dec 2008 11:11:13 +0100 Subject: [rspec-users] I met a trouble: cannot do a form post to an outside website Message-ID: now i use webrat for cucumber scenario testing. i have a page with a form, which will post to a bank payment gateway. that is,
...
my scenario step script is: == And I press "confirm" == then I got such an error: "No route matches "/pay/blablabla" with {:method=>:post}..." i think webrat or rails ignore the "http://www.abank.com" prefix automatically. and then i wrote a test script == get "http://www.abank.com/.." puts response.body == yes, the test result proves the suspicion. i think it should be handled in the rails testing layer. so, anybody can help me? thanks in advance. -- Posted via http://www.ruby-forum.com/. From ashley.moran at patchspace.co.uk Wed Dec 3 05:35:12 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 3 Dec 2008 10:35:12 +0000 Subject: [rspec-users] Sample App - TDD with Cucumber and RSpec In-Reply-To: References: <4934343A.50106@the-cocktail.com> <09f88f67ad0d9ac99ee28d0f9ee5aa41@ruby-forum.com> Message-ID: On 2 Dec 2008, at 19:25, Pat Maddox wrote: > Given ... > Postie.count.should == 0 > end > > It's just an assertion (in the C sense of the word, not testing). You > should be starting off with a clean slate anyway...but having a couple > assertions before you run can be very helpful for localization. Plus > this step can obviously be reused as a When. Nice idea! That kind of sanity checking can't hurt. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From matt at mattwynne.net Wed Dec 3 06:21:42 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 3 Dec 2008 11:21:42 +0000 Subject: [rspec-users] class << self considered harmful... really? In-Reply-To: <3c30da400812021431y404c8e76oa8bbc6a014b47f5@mail.gmail.com> References: <10C5B127-27EB-49B1-8C9B-0E8B769E55D4@mattwynne.net> <3c30da400811250954g3e8015c3u9bf8e691cddd4b12@mail.gmail.com> <5E9F0C26-6CC8-48CF-8342-826AE213615E@mattwynne.net> <3c30da400811251014m6fc12e63k466fff46ceae80ad@mail.gmail.com> <20081126132331.GD13628@durance.shot.pl> <3c30da400811260851l6b9dae23g211003c23d2ace56@mail.gmail.com> <937d9d810811301912p21fcce46yadc406fd11896252@mail.gmail.com> <3c30da400812021431y404c8e76oa8bbc6a014b47f5@mail.gmail.com> Message-ID: <4E9B0DB4-5DEA-46E4-BFC6-D0AC4456DF0D@mattwynne.net> On 2 Dec 2008, at 22:31, Mark Wilden wrote: > Here's what The Ruby Programming Language says about this: > > "In general, it is clearer to define class methods as individual > singleton methods without explicitly opening the eigenclass" (p. 258) > > This is far from a blanket condemnation, and, as with the rest of > the book, it's not obvious whether it's Matz or (non-Rubyist) > Flanagan who's talking. > > I don't mean to "open" the discussion again. :) Thanks for following up Mark. I suggest that if there's any life left in this thread, it staggers over here for a few more rounds: http://blog.mattwynne.net/2008/12/01/in-defence-of-class/ Matt Wynne http://blog.mattwynne.net http://www.songkick.com From raasdnil at gmail.com Wed Dec 3 06:50:49 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Wed, 3 Dec 2008 22:50:49 +1100 Subject: [rspec-users] Indentation Conventions for Ruby and Cucumber Message-ID: <57a815bf0812030350u6ca51551y8a4f3731260b3273@mail.gmail.com> On Thu, Nov 27, 2008 at 4:28 PM, Aslak Helles?y wrote: > When (if) this thread ends, let's start a discussion about indentation > conventions! > Oh... let the pleasure be mine!... and why wait? _EVERYONE_ knows that the only way to indent ruby code is 2 plain spaces. Tabs are known to be the source of all evil and 4 spaces obviously wastes space and bandwidth... Anyone else who says otherwise is obviously and irrefutably misguided :D Mikel -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Wed Dec 3 09:23:03 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Wed, 3 Dec 2008 14:23:03 +0000 Subject: [rspec-users] stepping across features In-Reply-To: References: Message-ID: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> Perhaps the creation of the join is not something that should be tested by a feature. This sounds to me like an implementation detail that would be better tested by some sort of unit test. So if your features want to have things in them mentioning joins, databases and other such things then you're probably using the wrong tool. Joseph wrote a really good blog post about this sort of stuff http://blog.josephwilk.net/ruby/telling-a-good-story-rspec-stories-from-the-trenches.html HTH Andrew 2008/12/2 James Byrne : > I am perplexed by a situation that I am creating for myself, probably > out of ignorance. I have two models connected through a join table > which itself contains information related to the join. I am testing the > creation of this join. > > I already have step definitions written for one of the outside models > that include methods to create new records. I say methods because I > have broken down the processing to initializing the model instance, > populating the attributes, and then saving it. > > Now, where I think I may be about to commit a grave error is in the step > definitions for the features relating to the join model. Which path > should I take: > > 1. Call the existing step definitions in the outer model to create a > test instance? or > > 2. Replicate the effect of those existing steps inside the step > definition file for the join model and create test instances of the > outer models completely from within that file. > > Regards, > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From apremdas at gmail.com Wed Dec 3 09:27:06 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Wed, 3 Dec 2008 14:27:06 +0000 Subject: [rspec-users] Indentation Conventions for Ruby and Cucumber In-Reply-To: <57a815bf0812030350u6ca51551y8a4f3731260b3273@mail.gmail.com> References: <57a815bf0812030350u6ca51551y8a4f3731260b3273@mail.gmail.com> Message-ID: <88fd8ddc0812030627n7743e635lc49309244ddcc9c8@mail.gmail.com> Oh but cucumber features so want to be idented on the I Scenario: Anonymous user can not duplicate a un-activated account Given I am an anonymous user And a registered user Fred exists When I signup as Fred Then I should see an error Really need to view above with a monspaced font - if its not coming out that way in your mail reader. Andrew 2008/12/3 Mikel Lindsaar : > On Thu, Nov 27, 2008 at 4:28 PM, Aslak Helles?y > wrote: >> >> When (if) this thread ends, let's start a discussion about indentation >> conventions! > > Oh... let the pleasure be mine!... and why wait? > _EVERYONE_ knows that the only way to indent ruby code is 2 plain spaces. > Tabs are known to be the source of all evil and 4 spaces obviously wastes > space and bandwidth... > Anyone else who says otherwise is obviously and irrefutably misguided :D > > Mikel > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Dec 3 10:31:44 2008 From: lists at ruby-forum.com (James Byrne) Date: Wed, 3 Dec 2008 16:31:44 +0100 Subject: [rspec-users] stepping across features In-Reply-To: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> Message-ID: Andrew Premdas wrote: > Perhaps the creation of the join is not something that should be > tested by a feature. This sounds to me like an implementation detail > that would be better tested by some sort of unit test. So if your > features want to have things in them mentioning joins, databases and > other such things then you're probably using the wrong tool. Joseph > wrote a really good blog post about this sort of stuff > > http://blog.josephwilk.net/ruby/telling-a-good-story-rspec-stories-from-the-trenches.html > Thanks for the reference! I have added a link to it from my own attempt at describing how to begin testing with cucumber. I did not show the code because most of it is not written. I am learning as I go with this exercise and no doubt many of these early attempts will need to be revised as I become more proficient. The feature looks like this: Scenario: Add an initial location for a party Given I have a party named "My Test Party" When I add a location for "My Test Party" And I set the "type" to "MAIN" And I set the "description" to "Sole Location" And I set the "effective date" to "1984-11-01" And I set the "superseded date" to "nil" And I provide valid site information And I create the location Then I should find the "MAIN" location for "My Test Party" And location "description" should be "sole location" As you can see, other than the attributes and their expected values, the only implementation detail exposed is that a site is somehow distinct from a location. In this case, the step definitions [When /have a party named "(.*)"/] and [When /provide valid site/] are effectively factory methods that provide a valid model instance of the appropriate type. I was debating with myself where best to locate these methods, either in a step-definition file relating to the model itself, or as distinctly named methods within the location_steps.rb file. Presently, I am proceeding cautiously with the first option of placing these methods with their models, keeping in mind that this may not be what I need to do at all. The main reason being is that the factory methods already contained in the model_steps.rb files are working without problem. I am still not content with some of the verbs that I am using in my features. Particularly those surrounding the process of instantiating a new row to a table. Add, Create, and Commit all seem to possess unfortunate inferences when used in a feature step. -- Posted via http://www.ruby-forum.com/. From ashley.moran at patchspace.co.uk Wed Dec 3 10:53:09 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 3 Dec 2008 15:53:09 +0000 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: <493553BC.8060300@joesniff.co.uk> References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> <493553BC.8060300@joesniff.co.uk> Message-ID: On 2 Dec 2008, at 15:26, Joseph Wilk wrote: > BeforeAll (Before running any feature) is currently possible through > putting something in your env.rb or really any ruby file that gets > required. It will be run once (and before anything else). > I use this to manage ferret/selenium. The before/afters being used > to tell the service to cleanup so we have clean environment for each > test. Could you do the same? > > And Afterall is possible through: at_exit Yeah, I've had to resort to doing this, which makes the end of my env.rb look like this: ####################### # Start everything up # ####################### require 'support/service_controllers' # Note this relies on this file being loaded only once! ServiceControllers.stop_all ServiceControllers.start_all at_exit do ServiceControllers.stop_all end I don't like this though, it's asymmetric. > BeforeFeature sounds like it could be useful for preparing services > for that specific feature and you don't want them running for other > features. I guess currently the only way of achieving this is > separating those features and running them in separate cucumber > runs. This is what I have done with something similar, using -- > profile to run different sets of features. I prefer this (in my > experience so far) as it allows me to re-use my rake tasks for > setting things up and keeps that setup from adding noise to my test > code. I appreciate with mock services your situation is slightly > different. I see what you mean, but it's always useful to run all the features in one run. 'rake features' should be the unambiguous, authoritative decider of whether your code can go live (IMHO). Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From ashley.moran at patchspace.co.uk Wed Dec 3 10:55:04 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 3 Dec 2008 15:55:04 +0000 Subject: [rspec-users] Intermittent Cucumber exception Message-ID: Hi Anyone recognise this exception, and know what causes it to happen occasionally? Thanks Ashley Scenario: new story appears on feed # features/descriptions/ story_notification.feature:12 /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/cucumber/ broadcaster.rb:15:in `write': Bad file descriptor (Errno::EBADF) from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/broadcaster.rb:15:in `puts' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/broadcaster.rb:15:in `__send__' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/broadcaster.rb:15:in `method_missing' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/broadcaster.rb:13:in `each' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/broadcaster.rb:13:in `method_missing' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/formatters/pretty_formatter.rb:107:in `step_failed' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/broadcaster.rb:15:in `__send__' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/broadcaster.rb:15:in `method_missing' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/broadcaster.rb:13:in `each' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/broadcaster.rb:13:in `method_missing' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/executor.rb:122:in `visit_step' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/executor.rb:106:in `visit_regular_step' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/tree/scenario.rb:15:in `accept' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/tree/scenario.rb:11:in `each' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/tree/scenario.rb:11:in `accept' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/executor.rb:87:in `execute_scenario' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/executor.rb:73:in `visit_scenario' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/executor.rb:67:in `visit_regular_scenario' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/tree/feature.rb:57:in `accept' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/tree/feature.rb:53:in `each' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/tree/feature.rb:53:in `accept' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/executor.rb:50:in `visit_feature' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/tree/features.rb:17:in `accept' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/tree/features.rb:17:in `each' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/tree/features.rb:17:in `accept' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/executor.rb:41:in `visit_features' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/cli.rb:167:in `execute!' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ cucumber/cli.rb:11:in `execute' from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/cucumber:6 rake aborted! -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From ashley.moran at patchspace.co.uk Wed Dec 3 11:12:45 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 3 Dec 2008 16:12:45 +0000 Subject: [rspec-users] Intermittent Cucumber exception In-Reply-To: References: Message-ID: <6C1670C0-2A73-4F29-B201-6C1A67003075@patchspace.co.uk> On 3 Dec 2008, at 15:55, Ashley Moran wrote: > Scenario: new story appears on > feed # features/descriptions/ > story_notification.feature:12 > /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/ > cucumber/broadcaster.rb:15:in `write': Bad file descriptor > (Errno::EBADF) > from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/cucumber:6 > rake aborted! I captured it with --trace too, it's started happening more often... from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/cucumber:6 rake aborted! Command failed with status (1): [/opt/local/bin/ruby -I "/opt/local/ lib/rub...] /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:971:in `sh' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:984:in `call' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:984:in `sh' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1072:in `sh' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1007:in `ruby' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1072:in `ruby' /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/lib/cucumber/rake/ task.rb:34:in `define_task' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain' /opt/local/lib/ruby/1.8/monitor.rb:242:in `synchronize' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31 /opt/local/bin/rake:19:in `load' /opt/local/bin/rake:19 -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From josephwilk at joesniff.co.uk Wed Dec 3 11:19:00 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Wed, 03 Dec 2008 16:19:00 +0000 Subject: [rspec-users] Intermittent Cucumber exception In-Reply-To: <6C1670C0-2A73-4F29-B201-6C1A67003075@patchspace.co.uk> References: <6C1670C0-2A73-4F29-B201-6C1A67003075@patchspace.co.uk> Message-ID: <4936B174.7000604@joesniff.co.uk> Ashley Moran wrote: > On 3 Dec 2008, at 15:55, Ashley Moran wrote: >> Scenario: new story appears on >> feed # >> features/descriptions/story_notification.feature:12 >> /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/../lib/cucumber/broadcaster.rb:15:in >> `write': Bad file descriptor (Errno::EBADF) >> from >> /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/cucumber:6 >> rake aborted! > > > I captured it with --trace too, it's started happening more often... > > from /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/bin/cucumber:6 > rake aborted! > Command failed with status (1): [/opt/local/bin/ruby -I > "/opt/local/lib/rub...] > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:971:in `sh' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:984:in `call' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:984:in `sh' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1072:in `sh' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1007:in `ruby' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1072:in `ruby' > /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.1.10/lib/cucumber/rake/task.rb:34:in > `define_task' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in > `invoke_with_call_chain' > /opt/local/lib/ruby/1.8/monitor.rb:242:in `synchronize' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in > `invoke_with_call_chain' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in > `invoke_task' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in > `top_level' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in > `top_level' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in > `standard_exception_handling' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in > `top_level' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in > `standard_exception_handling' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run' > /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31 > /opt/local/bin/rake:19:in `load' > /opt/local/bin/rake:19 > > > Can you share the arguments in the relevant Cucumber rake task? Thanks, -- Joseph Wilk http://blog.josephwilk.net From ben at benmabey.com Wed Dec 3 11:59:08 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 03 Dec 2008 09:59:08 -0700 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> <493553BC.8060300@joesniff.co.uk> Message-ID: <4936BADC.9070606@benmabey.com> Ashley Moran wrote: > > On 2 Dec 2008, at 15:26, Joseph Wilk wrote: > >> BeforeAll (Before running any feature) is currently possible through >> putting something in your env.rb or really any ruby file that gets >> required. It will be run once (and before anything else). >> I use this to manage ferret/selenium. The before/afters being used to >> tell the service to cleanup so we have clean environment for each >> test. Could you do the same? >> >> And Afterall is possible through: at_exit > > Yeah, I've had to resort to doing this, which makes the end of my > env.rb look like this: > > ####################### > # Start everything up # > ####################### > > require 'support/service_controllers' > > # Note this relies on this file being loaded only once! > > ServiceControllers.stop_all > ServiceControllers.start_all > > at_exit do > ServiceControllers.stop_all > end > > I don't like this though, it's asymmetric. > > >> BeforeFeature sounds like it could be useful for preparing services >> for that specific feature and you don't want them running for other >> features. I guess currently the only way of achieving this is >> separating those features and running them in separate cucumber runs. >> This is what I have done with something similar, using --profile to >> run different sets of features. I prefer this (in my experience so >> far) as it allows me to re-use my rake tasks for setting things up >> and keeps that setup from adding noise to my test code. I appreciate >> with mock services your situation is slightly different. > > I see what you mean, but it's always useful to run all the features in > one run. 'rake features' should be the unambiguous, authoritative > decider of whether your code can go live (IMHO). > > Ashley > I agree with Ashley. In the past I have done multiple profiles just as Joseph has suggested. I have then modified my features task to serially run my different feature sets and profiles. With that you do have one task you need to run. However, it would still be very nice if these different profile types, even if not ran as the same process, could be grouped into a single report and given then appearance that it was one large process. I understand the problems and difficulties of doing such a thing, but WDYT? If we think there is enough value in such an aggregate feature set runner/report and we can decide on the details then I would be willing to tackle it. -Ben From ashley.moran at patchspace.co.uk Wed Dec 3 14:01:19 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 3 Dec 2008 19:01:19 +0000 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: <4936BADC.9070606@benmabey.com> References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> <493553BC.8060300@joesniff.co.uk> <4936BADC.9070606@benmabey.com> Message-ID: On 3 Dec 2008, at 16:59, Ben Mabey wrote: > I agree with Ashley. In the past I have done multiple profiles just > as Joseph has suggested. I have then modified my features task to > serially run my different feature sets and profiles. With that you > do have one task you need to run. However, it would still be very > nice if these different profile types, even if not ran as the same > process, could be grouped into a single report and given then > appearance that it was one large process. I understand the problems > and difficulties of doing such a thing, but WDYT? If we think there > is enough value in such an aggregate feature set runner/report and > we can decide on the details then I would be willing to tackle it. Sounds like there's two issues here. One is grouping features into run sets (eg fast-running, slow-running; needs an external service, is self-contained) the other is running features in a certain mode (eg against mock-services, against live services; using HTML interface, using XML interface). One solution to the first problem could be tagging the features/ scenarios: Feature: blah Groups: slow As a... Scenario: blah Groups: twitter web Or something. Maybe? The second problem currently has to be handled as separate Cucumber rake tasks with different --require options to load different steps. I don't have any multi-mode features though, so I haven't had to worry about this yet. I suspect the general problem (given all the potential dimensions you could create) is currently unspecified and the general solution is quite hard... I still think having an authoritative 'rake features' is essential, though. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From ashley.moran at patchspace.co.uk Wed Dec 3 14:02:12 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 3 Dec 2008 19:02:12 +0000 Subject: [rspec-users] Intermittent Cucumber exception In-Reply-To: <4936B174.7000604@joesniff.co.uk> References: <6C1670C0-2A73-4F29-B201-6C1A67003075@patchspace.co.uk> <4936B174.7000604@joesniff.co.uk> Message-ID: <4D9BA62A-2644-4C91-9636-D2B488F42A84@patchspace.co.uk> On 3 Dec 2008, at 16:19, Joseph Wilk wrote: > Can you share the arguments in the relevant Cucumber rake task? That would be this: Cucumber::Rake::Task.new do |t| t.cucumber_opts = "--format pretty" t.step_pattern = "features/steps/**/*.rb" end -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From lists at ruby-forum.com Wed Dec 3 22:04:26 2008 From: lists at ruby-forum.com (James Byrne) Date: Thu, 4 Dec 2008 04:04:26 +0100 Subject: [rspec-users] Cucumber and Rcov Message-ID: <2a83d8efc2bcadfe8ebaf509f47e1562@ruby-forum.com> I am now trying to get rcov to work for me, without much success. I stole the rake task code from the cucumber site: desc "Run all features" task :features => "features:all" task :features => 'db:test:prepare' require 'cucumber/rake/task' #I have to add this -mischa namespace :features do Cucumber::Rake::Task.new(:all) do |t| t.cucumber_opts = "--format pretty" end Cucumber::Rake::Task.new(:cruise) do |t| t.cucumber_opts = "--format pretty --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.txt --format html --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.html" t.rcov = true t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/} t.rcov_opts << %[-o "#{ENV['CC_BUILD_ARTIFACTS']}/features_rcov"] end Cucumber::Rake::Task.new(:rcov) do |t| t.rcov = true t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/} t.rcov_opts << %[-o "features_rcov"] end end To be frank, I haven't a clue about whatever this does. It seems to have little in common with other suggested rake tasks for rcov thaat I have found. In any case, given a cucumber.rake file containign the foregoing, when I run $ rake features:rcov I obtain the same results as when I ran the original rake features task. I need someone to explain to me how to get this piece properly configured and working. -- Posted via http://www.ruby-forum.com/. From f.mischa at gmail.com Wed Dec 3 22:37:58 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Wed, 3 Dec 2008 21:37:58 -0600 Subject: [rspec-users] Cucumber and Rcov In-Reply-To: <2a83d8efc2bcadfe8ebaf509f47e1562@ruby-forum.com> References: <2a83d8efc2bcadfe8ebaf509f47e1562@ruby-forum.com> Message-ID: James, Maybe you are asking something else...but after you type rake feature:rcov there should be a folder in rails root called "features_rcov," which may solve your problem. rake features:rcov open features_rcov/index.html -Mischa On Wed, Dec 3, 2008 at 9:04 PM, James Byrne wrote: > I am now trying to get rcov to work for me, without much success. I > stole the rake task code from the cucumber site: > > desc "Run all features" > task :features => "features:all" > task :features => 'db:test:prepare' > require 'cucumber/rake/task' #I have to add this -mischa > > namespace :features do > Cucumber::Rake::Task.new(:all) do |t| > t.cucumber_opts = "--format pretty" > end > > Cucumber::Rake::Task.new(:cruise) do |t| > t.cucumber_opts = "--format pretty > --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.txt --format html > --out=#{ENV['CC_BUILD_ARTIFACTS']}/features.html" > t.rcov = true > t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/} > t.rcov_opts << %[-o "#{ENV['CC_BUILD_ARTIFACTS']}/features_rcov"] > end > > Cucumber::Rake::Task.new(:rcov) do |t| > t.rcov = true > t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/} > t.rcov_opts << %[-o "features_rcov"] > end > end > > To be frank, I haven't a clue about whatever this does. It seems to > have little in common with other suggested rake tasks for rcov thaat I > have found. > > In any case, given a cucumber.rake file containign the foregoing, when I > run $ rake features:rcov I obtain the same results as when I ran the > original rake features task. I need someone to explain to me how to get > this piece properly configured and working. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Dec 3 22:42:27 2008 From: lists at ruby-forum.com (James Byrne) Date: Thu, 4 Dec 2008 04:42:27 +0100 Subject: [rspec-users] Cucumber and Rcov In-Reply-To: References: <2a83d8efc2bcadfe8ebaf509f47e1562@ruby-forum.com> Message-ID: <0832b3feebe7b3cbc107f4beaeca8e3a@ruby-forum.com> Mischa Fierer wrote: > James, > > Maybe you are asking something else...but after you type rake > feature:rcov > there should be a folder in rails root called "features_rcov," which may > solve your problem. > > rake features:rcov > open features_rcov/index.html > > -Mischa Ahhhhh.... Sometimes I feel so dull. -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Thu Dec 4 01:04:13 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 3 Dec 2008 22:04:13 -0800 Subject: [rspec-users] class << self considered harmful... really? In-Reply-To: <3c30da400811250808r4a66dd41m2d04ff954c4b0641@mail.gmail.com> References: <3c30da400811250808r4a66dd41m2d04ff954c4b0641@mail.gmail.com> Message-ID: <810a540e0812032204u102ec117p986b22207c59cc6a@mail.gmail.com> > 'look at me, ma, I'm opening the eigenclass!' "Honey, if you're going to open your eigenclass, do it in your room." From apremdas at gmail.com Thu Dec 4 01:42:00 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 4 Dec 2008 06:42:00 +0000 Subject: [rspec-users] stepping across features In-Reply-To: References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> Message-ID: <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> It seems to me that there are all sorts of implementation details in this story that could make your tests quite brittle. And the feature is definitiley a programmer writing a test, rather than a customer specifying what they want. Putting on my customer hat Scenario: Add location Given I have a party When I set the location And I view the party Then I should see the location Starting with this you can then deal with other customer scenario's and work out what they mean e.g. Scenario: Change location Scenario: Add multiple locations Scenario: Specify location priorities These may be complex enought to be new features. allowing you to explore meaning and business value e.g. what is the value in prioritising a location, what happens if there are two main locations etc. HTH Andrew 2008/12/3 James Byrne > Andrew Premdas wrote: > > Perhaps the creation of the join is not something that should be > > tested by a feature. This sounds to me like an implementation detail > > that would be better tested by some sort of unit test. So if your > > features want to have things in them mentioning joins, databases and > > other such things then you're probably using the wrong tool. Joseph > > wrote a really good blog post about this sort of stuff > > > > > http://blog.josephwilk.net/ruby/telling-a-good-story-rspec-stories-from-the-trenches.html > > > > Thanks for the reference! I have added a link to it from my own attempt > at describing how to begin testing with cucumber. > > I did not show the code because most of it is not written. I am > learning as I go with this exercise and no doubt many of these early > attempts will need to be revised as I become more proficient. The > feature looks like this: > > Scenario: Add an initial location for a party > > Given I have a party named "My Test Party" > > When I add a location for "My Test Party" > And I set the "type" to "MAIN" > And I set the "description" to "Sole Location" > And I set the "effective date" to "1984-11-01" > And I set the "superseded date" to "nil" > And I provide valid site information > And I create the location > > Then I should find the "MAIN" location for "My Test Party" > And location "description" should be "sole location" > > As you can see, other than the attributes and their expected values, the > only implementation detail exposed is that a site is somehow distinct > from a location. > > In this case, the step definitions [When /have a party named "(.*)"/] > and [When /provide valid site/] are effectively factory methods that > provide a valid model instance of the appropriate type. I was debating > with myself where best to locate these methods, either in a > step-definition file relating to the model itself, or as distinctly > named methods within the location_steps.rb file. > > Presently, I am proceeding cautiously with the first option of placing > these methods with their models, keeping in mind that this may not be > what I need to do at all. The main reason being is that the factory > methods already contained in the model_steps.rb files are working > without problem. > > I am still not content with some of the verbs that I am using in my > features. Particularly those surrounding the process of instantiating a > new row to a table. Add, Create, and Commit all seem to possess > unfortunate inferences when used in a feature step. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Dec 4 02:58:54 2008 From: lists at ruby-forum.com (Sebastian W.) Date: Thu, 4 Dec 2008 08:58:54 +0100 Subject: [rspec-users] The RSpec way of doing this? Need help on validating block Message-ID: <66ff94eefbdd1e73785dedc2ec205a99@ruby-forum.com> Hello, I'm back again with more questions about mocks and how to do good testing in general. Let's say I'm writing this EmailSender class and I want to make it totally awesomely tested with RSpec. Here's how far I've gotten so far: require 'net/smtp' class EmailSender def send_email mailer.start('your.smtp.server', 25) do |smtp| smtp.send_message("Yay! You got an email!", 'your at mail', 'other at mail') end def def mailer Net::SMTP end end describe EmailSender do it "Should use Net::SMTP to send email" es = EmailSender.new es.mailer.should == Net::SMTP MockSMTP = mock("Net::SMTP") def es.mailer MockSMTP end MockSMTP.should_receive(:start).with('your.smtp.server', 25) #but, er...wha? end end So - not sure how to validate the part where "send_message" is called. Is there a recommended way of doing this? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Dec 4 02:59:52 2008 From: lists at ruby-forum.com (Sebastian W.) Date: Thu, 4 Dec 2008 08:59:52 +0100 Subject: [rspec-users] The RSpec way of doing this? Need help on validating block In-Reply-To: <66ff94eefbdd1e73785dedc2ec205a99@ruby-forum.com> References: <66ff94eefbdd1e73785dedc2ec205a99@ruby-forum.com> Message-ID: Yikes, left out the all-important call: > describe EmailSender do > it "Should use Net::SMTP to send email" > es = EmailSender.new > es.mailer.should == Net::SMTP > MockSMTP = mock("Net::SMTP") > def es.mailer > MockSMTP > end > MockSMTP.should_receive(:start).with('your.smtp.server', 25) > #but, er...wha? es.send_email > end > end Sorry about that. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Dec 4 03:07:33 2008 From: lists at ruby-forum.com (Sebastian W.) Date: Thu, 4 Dec 2008 09:07:33 +0100 Subject: [rspec-users] The RSpec way of doing this? Need help on validating block In-Reply-To: References: <66ff94eefbdd1e73785dedc2ec205a99@ruby-forum.com> Message-ID: <529f246294ebf3fba7e808dce10dc1d8@ruby-forum.com> Ha! Don't I feel silly. Just figured it out, I think. Sebastian W. wrote: > Yikes, left out the all-important call: > >> describe EmailSender do >> it "Should use Net::SMTP to send email" >> es = EmailSender.new >> es.mailer.should == Net::SMTP >> MockSMTP = mock("Net::SMTP") >> def es.mailer >> MockSMTP >> end mock_smtp = mock("smtp") MockSMTP.should_receive(:start).with('your.smtp.server', 25).and_yield(mock_smtp) mock_smtp.should_recieve(:send_message).with("Yay! You got an email!", 'your at mail', 'other at mail') > es.send_email >> end >> end Mission accomplished. :P -- Posted via http://www.ruby-forum.com/. From apremdas at gmail.com Thu Dec 4 03:54:49 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 4 Dec 2008 08:54:49 +0000 Subject: [rspec-users] Broken rake tasks Message-ID: <88fd8ddc0812040054q432b832cudc842753b084bb6e@mail.gmail.com> I've got a couple of rake tasks that seem to have broken with rspec 1.1.11. http://pastie.org/330719 The trace I'm getting is /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in `files_to_load': File or directory not found: tc:load (RuntimeError) from /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in `each' from /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in `files_to_load' from /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in `run_examples' from /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in `run' from /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in `register_at_exit_hook' from /usr/bin/rake:19 Now I'm not even sure why spec/runner is running these tasks. Any ideas? All best Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From josephwilk at joesniff.co.uk Thu Dec 4 04:40:02 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Thu, 4 Dec 2008 09:40:02 +0000 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> <493553BC.8060300@joesniff.co.uk> <4936BADC.9070606@benmabey.com> Message-ID: On Wed, Dec 3, 2008 at 7:01 PM, Ashley Moran wrote: > > On 3 Dec 2008, at 16:59, Ben Mabey wrote: > > I agree with Ashley. In the past I have done multiple profiles just as >> Joseph has suggested. I have then modified my features task to serially run >> my different feature sets and profiles. With that you do have one task you >> need to run. However, it would still be very nice if these different >> profile types, even if not ran as the same process, could be grouped into a >> single report and given then appearance that it was one large process. I >> understand the problems and difficulties of doing such a thing, but WDYT? >> If we think there is enough value in such an aggregate feature set >> runner/report and we can decide on the details then I would be willing to >> tackle it. > > I think a nice way to facilitate one report from multiple cucumber runs is useful. I'm currently resorting to 'cat'ing (yuck!) the different Cucumber reports to get one html report in the features rake task. Currently when you pass '--out file' to Cucumber it truncates the file. We could have it open the file for appending. That sounds like a simple solution to forming one report from multiple runs. You would still get the (minor) problem I have when 'cat'ing the files (HTML reports with multiple html heads). >given then appearance that it was one large process. Where you thinking about giving the appearance of one process at the report level or the rake level? >> > > > Sounds like there's two issues here. One is grouping features into run > sets (eg fast-running, slow-running; needs an external service, is > self-contained) the other is running features in a certain mode (eg against > mock-services, against live services; using HTML interface, using XML > interface). > > One solution to the first problem could be tagging the features/scenarios: > > Feature: blah > Groups: slow > As a... > > Scenario: blah > Groups: twitter web > > Or something. Maybe? We currently have an issue on tagging but it will have to wait until Aslak has done his AST magic. http://rspec.lighthouseapp.com/projects/16211/tickets/54-tagging-scenarios -- Joseph Wilk http://blog.josephwilk.net > > > The second problem currently has to be handled as separate Cucumber rake > tasks with different --require options to load different steps. I don't > have any multi-mode features though, so I haven't had to worry about this > yet. I suspect the general problem (given all the potential dimensions you > could create) is currently unspecified and the general solution is quite > hard... > > I still think having an authoritative 'rake features' is essential, though. > > > > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Thu Dec 4 05:04:47 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 4 Dec 2008 11:04:47 +0100 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> <493553BC.8060300@joesniff.co.uk> <4936BADC.9070606@benmabey.com> Message-ID: <8d961d900812040204v69f5529ct6e56415c27e8fa12@mail.gmail.com> On Thu, Dec 4, 2008 at 10:40 AM, Joseph Wilk wrote: > On Wed, Dec 3, 2008 at 7:01 PM, Ashley Moran < > ashley.moran at patchspace.co.uk> wrote: > >> >> On 3 Dec 2008, at 16:59, Ben Mabey wrote: >> >> I agree with Ashley. In the past I have done multiple profiles just as >>> Joseph has suggested. I have then modified my features task to serially run >>> my different feature sets and profiles. With that you do have one task you >>> need to run. However, it would still be very nice if these different >>> profile types, even if not ran as the same process, could be grouped into a >>> single report and given then appearance that it was one large process. I >>> understand the problems and difficulties of doing such a thing, but WDYT? >>> If we think there is enough value in such an aggregate feature set >>> runner/report and we can decide on the details then I would be willing to >>> tackle it. >> >> > I think a nice way to facilitate one report from multiple cucumber runs is > useful. > I think the way to go is to have a YAML formatter that can spit out reports as YAML. Then several YAML reports can be read in. My plan with the AST work is that the AST itself stores the results, so it can be serialised and deserialised. This will make concatenating several reports much easier. > > I'm currently resorting to 'cat'ing (yuck!) the different Cucumber reports > to get one html report in the features rake task. > > Currently when you pass '--out file' to Cucumber it truncates the file. We > could have it open the file for appending. That sounds like a simple > solution to forming one report from multiple runs. > > You would still get the (minor) problem I have when 'cat'ing the files > (HTML reports with multiple html heads). > > > > >given then appearance that it was one large process. > > Where you thinking about giving the appearance of one process at the report > level or the rake level? > > > >>> >> >> >> Sounds like there's two issues here. One is grouping features into run >> sets (eg fast-running, slow-running; needs an external service, is >> self-contained) the other is running features in a certain mode (eg against >> mock-services, against live services; using HTML interface, using XML >> interface). >> >> One solution to the first problem could be tagging the features/scenarios: >> >> Feature: blah >> Groups: slow >> As a... >> >> Scenario: blah >> Groups: twitter web >> >> Or something. Maybe? > > > We currently have an issue on tagging but it will have to wait until Aslak > has done his AST magic. > Just a heads up - planning to get started on this around Dec 15th. > > http://rspec.lighthouseapp.com/projects/16211/tickets/54-tagging-scenarios > > -- > Joseph Wilk > http://blog.josephwilk.net > > >> >> >> The second problem currently has to be handled as separate Cucumber rake >> tasks with different --require options to load different steps. I don't >> have any multi-mode features though, so I haven't had to worry about this >> yet. I suspect the general problem (given all the potential dimensions you >> could create) is currently unspecified and the general solution is quite >> hard... >> >> I still think having an authoritative 'rake features' is essential, >> though. >> > > > > >> >> >> Ashley >> >> -- >> http://www.patchspace.co.uk/ >> http://aviewfromafar.net/ >> >> >> >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Thu Dec 4 05:23:43 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 4 Dec 2008 11:23:43 +0100 Subject: [rspec-users] Cucumber on IronRuby Message-ID: <8d961d900812040223n1284a40cp9c09117fbda0a65a@mail.gmail.com> I just released Cucumber 0.1.12 which has support and examples for IronRuby (Ruby on .NET). http://github.com/aslakhellesoy/cucumber/wikis/ironruby-and-net http://github.com/aslakhellesoy/cucumber/tree/v0.1.12/History.txt It's early days, so if there are any .NET folks out here I'd love some feedback on this. There is also a thread on RubyForum: http://www.ruby-forum.com/topic/172487#756180 Cheers, Aslak -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Thu Dec 4 06:01:54 2008 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 4 Dec 2008 11:01:54 +0000 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: <8d961d900812040204v69f5529ct6e56415c27e8fa12@mail.gmail.com> References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> <493553BC.8060300@joesniff.co.uk> <4936BADC.9070606@benmabey.com> <8d961d900812040204v69f5529ct6e56415c27e8fa12@mail.gmail.com> Message-ID: <9DE2E8F8-E4DF-4628-862A-D3B7D6BDD4B1@mattwynne.net> On 4 Dec 2008, at 10:04, aslak hellesoy wrote: > > We currently have an issue on tagging but it will have to wait > until Aslak has done his AST magic. > > Just a heads up - planning to get started on this around Dec 15th. Sounds intriguing... what does AST mean / stand for? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Thu Dec 4 06:07:07 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 4 Dec 2008 12:07:07 +0100 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: <9DE2E8F8-E4DF-4628-862A-D3B7D6BDD4B1@mattwynne.net> References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> <493553BC.8060300@joesniff.co.uk> <4936BADC.9070606@benmabey.com> <8d961d900812040204v69f5529ct6e56415c27e8fa12@mail.gmail.com> <9DE2E8F8-E4DF-4628-862A-D3B7D6BDD4B1@mattwynne.net> Message-ID: <8d961d900812040307o38669045w1919d1da927d9e68@mail.gmail.com> On Thu, Dec 4, 2008 at 12:01 PM, Matt Wynne wrote: > > On 4 Dec 2008, at 10:04, aslak hellesoy wrote: > > > We currently have an issue on tagging but it will have to wait until >> Aslak has done his AST magic. >> >> Just a heads up - planning to get started on this around Dec 15th. >> > > Sounds intriguing... what does AST mean / stand for? > http://en.wikipedia.org/wiki/Abstract_syntax_tree > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From josephwilk at joesniff.co.uk Thu Dec 4 06:07:30 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Thu, 04 Dec 2008 11:07:30 +0000 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: <9DE2E8F8-E4DF-4628-862A-D3B7D6BDD4B1@mattwynne.net> References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> <493553BC.8060300@joesniff.co.uk> <4936BADC.9070606@benmabey.com> <8d961d900812040204v69f5529ct6e56415c27e8fa12@mail.gmail.com> <9DE2E8F8-E4DF-4628-862A-D3B7D6BDD4B1@mattwynne.net> Message-ID: <4937B9F2.40006@joesniff.co.uk> Matt Wynne wrote: > > On 4 Dec 2008, at 10:04, aslak hellesoy wrote: > >> > We currently have an issue on tagging but it will have to wait >> until Aslak has done his AST magic. >> >> Just a heads up - planning to get started on this around Dec 15th. > > Sounds intriguing... what does AST mean / stand for? Abstract Syntax Tree http://en.wikipedia.org/wiki/Abstract_syntax_tree -- Joseph Wilk http://blog.josephwilk.net > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu Dec 4 08:45:50 2008 From: lists at ruby-forum.com (James Byrne) Date: Thu, 4 Dec 2008 14:45:50 +0100 Subject: [rspec-users] stepping across features In-Reply-To: <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> Message-ID: <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> Andrew Premdas wrote: > It seems to me that there are all sorts of implementation details in > this story that could make your tests quite brittle. And the feature is > definitiley a programmer writing a test, rather than a customer Guilty as charged. > Putting on my customer hat > > Scenario: Add location > Given I have a party > When I set the location > And I view the party > Then I should see the location > > Starting with this you can then deal with other customer scenario's and > work > out what they mean e.g. > > Scenario: Change location > Scenario: Add multiple locations > Scenario: Specify location priorities > > These may be complex enough to be new features. allowing you to > explore meaning and business value e.g. what is the value in > prioritising a location, what happens if there are two main locations > etc. > > HTH Yes. it is most helpful. Thank you very much. -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Thu Dec 4 11:55:26 2008 From: ben at benmabey.com (Ben Mabey) Date: Thu, 04 Dec 2008 09:55:26 -0700 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: <8d961d900812040204v69f5529ct6e56415c27e8fa12@mail.gmail.com> References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> <493553BC.8060300@joesniff.co.uk> <4936BADC.9070606@benmabey.com> <8d961d900812040204v69f5529ct6e56415c27e8fa12@mail.gmail.com> Message-ID: <49380B7E.1090604@benmabey.com> aslak hellesoy wrote: > > > On Thu, Dec 4, 2008 at 10:40 AM, Joseph Wilk > > wrote: > > On Wed, Dec 3, 2008 at 7:01 PM, Ashley Moran > > wrote: > > > On 3 Dec 2008, at 16:59, Ben Mabey wrote: > > I agree with Ashley. In the past I have done multiple > profiles just as Joseph has suggested. I have then > modified my features task to serially run my different > feature sets and profiles. With that you do have one task > you need to run. However, it would still be very nice if > these different profile types, even if not ran as the same > process, could be grouped into a single report and given > then appearance that it was one large process. I > understand the problems and difficulties of doing such a > thing, but WDYT? If we think there is enough value in > such an aggregate feature set runner/report and we can > decide on the details then I would be willing to tackle it. > > > I think a nice way to facilitate one report from multiple cucumber > runs is useful. > > > I think the way to go is to have a YAML formatter that can spit out > reports as YAML. Then several YAML reports can be read in. Yeah, that was actually exactly what I was thinking! > > My plan with the AST work is that the AST itself stores the results, > so it can be serialised and deserialised. This will make concatenating > several reports much easier. Ahh, I see. So the report concatenatenater would just have to load up all of the serialised ASTs and send them to one formatter? So, I'm guessing you want to wait on this until after the AST work is done... I'll open up a ticket in lighthouse for this regardless. -Ben > > > > I'm currently resorting to 'cat'ing (yuck!) the different Cucumber > reports to get one html report in the features rake task. > > Currently when you pass '--out file' to Cucumber it truncates the > file. We could have it open the file for appending. That sounds > like a simple solution to forming one report from multiple runs. > > You would still get the (minor) problem I have when 'cat'ing the > files (HTML reports with multiple html heads). > > > > > >given then appearance that it was one large process. > > Where you thinking about giving the appearance of one process at > the report level or the rake level? > > > > > > > Sounds like there's two issues here. One is grouping features > into run sets (eg fast-running, slow-running; needs an > external service, is self-contained) the other is running > features in a certain mode (eg against mock-services, against > live services; using HTML interface, using XML interface). > > One solution to the first problem could be tagging the > features/scenarios: > > Feature: blah > Groups: slow > As a... > > Scenario: blah > Groups: twitter web > > Or something. Maybe? > > > We currently have an issue on tagging but it will have to wait > until Aslak has done his AST magic. > > > Just a heads up - planning to get started on this around Dec 15th. > > > > http://rspec.lighthouseapp.com/projects/16211/tickets/54-tagging-scenarios > > > > -- > Joseph Wilk > http://blog.josephwilk.net > > > > > The second problem currently has to be handled as separate > Cucumber rake tasks with different --require options to load > different steps. I don't have any multi-mode features though, > so I haven't had to worry about this yet. I suspect the > general problem (given all the potential dimensions you could > create) is currently unspecified and the general solution is > quite hard... > > I still think having an authoritative 'rake features' is > essential, though. > > > > > > > > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > 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 fernando.garcia at the-cocktail.com Thu Dec 4 12:01:35 2008 From: fernando.garcia at the-cocktail.com (=?ISO-8859-1?Q?Fernando_Garc=EDa_Samblas?=) Date: Thu, 04 Dec 2008 18:01:35 +0100 Subject: [rspec-users] Indentation Conventions for Ruby and Cucumber In-Reply-To: <88fd8ddc0812030627n7743e635lc49309244ddcc9c8@mail.gmail.com> References: <57a815bf0812030350u6ca51551y8a4f3731260b3273@mail.gmail.com> <88fd8ddc0812030627n7743e635lc49309244ddcc9c8@mail.gmail.com> Message-ID: <49380CEF.4030208@the-cocktail.com> Andrew Premdas escribi?: > Oh but cucumber features so want to be idented on the I > > Scenario: Anonymous user can not duplicate a un-activated account > Given I am an anonymous user > And a registered user Fred exists > When I signup as Fred > Then I should see an error > > Really need to view above with a monspaced font - if its not coming > out that way in your mail reader. +0.66 :) I like to indent this way, but within a given, when or then block: Scenario: Anonymous user can not duplicate a un-activated account Given I am an anonymous user And a registered user Fred exists When I signup as Fred Then I should see an error Great idea, I love conventions!!! Nando > > Andrew > > 2008/12/3 Mikel Lindsaar >: > > On Thu, Nov 27, 2008 at 4:28 PM, Aslak Helles?y > > > > wrote: > >> > >> When (if) this thread ends, let's start a discussion about indentation > >> conventions! > > > > Oh... let the pleasure be mine!... and why wait? > > _EVERYONE_ knows that the only way to indent ruby code is 2 plain > spaces. > > Tabs are known to be the source of all evil and 4 spaces obviously > wastes > > space and bandwidth... > > Anyone else who says otherwise is obviously and irrefutably misguided :D > > > > Mikel > > > > _______________________________________________ > > 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 -- Fernando Garc?a Samblas fernando.garcia at the-cocktail.com http://nando.lacoctelera.com The Cocktail C/ Salamanca 17 28020 Madrid +34 91 567 06 05 -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Thu Dec 4 12:52:35 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 04 Dec 2008 09:52:35 -0800 Subject: [rspec-users] The RSpec way of doing this? Need help on validating block In-Reply-To: <529f246294ebf3fba7e808dce10dc1d8@ruby-forum.com> (Sebastian W.'s message of "Thu\, 4 Dec 2008 09\:07\:33 +0100") References: <66ff94eefbdd1e73785dedc2ec205a99@ruby-forum.com> <529f246294ebf3fba7e808dce10dc1d8@ruby-forum.com> Message-ID: Glad I could help! "Sebastian W." writes: > Ha! Don't I feel silly. Just figured it out, I think. > > Sebastian W. wrote: >> Yikes, left out the all-important call: >> >>> describe EmailSender do >>> it "Should use Net::SMTP to send email" >>> es = EmailSender.new >>> es.mailer.should == Net::SMTP >>> MockSMTP = mock("Net::SMTP") >>> def es.mailer >>> MockSMTP >>> end > mock_smtp = mock("smtp") > MockSMTP.should_receive(:start).with('your.smtp.server', > 25).and_yield(mock_smtp) > mock_smtp.should_recieve(:send_message).with("Yay! You got an > email!", 'your at mail', > 'other at mail') >> es.send_email >>> end >>> end > > Mission accomplished. :P From aslak.hellesoy at gmail.com Thu Dec 4 13:10:07 2008 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Thu, 4 Dec 2008 19:10:07 +0100 Subject: [rspec-users] Any plans for Before-feature or Before-all steps in Cucumber? In-Reply-To: <49380B7E.1090604@benmabey.com> References: <43209F02-B72C-4AD2-8178-9552AA229708@patchspace.co.uk> <493553BC.8060300@joesniff.co.uk> <4936BADC.9070606@benmabey.com> <8d961d900812040204v69f5529ct6e56415c27e8fa12@mail.gmail.com> <49380B7E.1090604@benmabey.com> Message-ID: <1CC959AF-DD91-4AA9-B04C-22CD209A49D4@gmail.com> > aslak hellesoy wrote: >> >> >> On Thu, Dec 4, 2008 at 10:40 AM, Joseph Wilk > > wrote: >> >> On Wed, Dec 3, 2008 at 7:01 PM, Ashley Moran >> > > wrote: >> >> >> On 3 Dec 2008, at 16:59, Ben Mabey wrote: >> >> I agree with Ashley. In the past I have done multiple >> profiles just as Joseph has suggested. I have then >> modified my features task to serially run my different >> feature sets and profiles. With that you do have one task >> you need to run. However, it would still be very nice if >> these different profile types, even if not ran as the same >> process, could be grouped into a single report and given >> then appearance that it was one large process. I >> understand the problems and difficulties of doing such a >> thing, but WDYT? If we think there is enough value in >> such an aggregate feature set runner/report and we can >> decide on the details then I would be willing to tackle >> it. >> >> >> I think a nice way to facilitate one report from multiple cucumber >> runs is useful. >> >> >> I think the way to go is to have a YAML formatter that can spit out >> reports as YAML. Then several YAML reports can be read in. > > Yeah, that was actually exactly what I was thinking! >> >> My plan with the AST work is that the AST itself stores the >> results, so it can be serialised and deserialised. This will make >> concatenating several reports much easier. > > Ahh, I see. So the report concatenatenater would just have to load > up all of the serialised ASTs and send them to one formatter? So, > I'm guessing you want to wait on this until after the AST work is > done... I'll open up a ticket in lighthouse for this regardless. > Spot on > -Ben > >> >> >> I'm currently resorting to 'cat'ing (yuck!) the different Cucumber >> reports to get one html report in the features rake task. >> >> Currently when you pass '--out file' to Cucumber it truncates the >> file. We could have it open the file for appending. That sounds >> like a simple solution to forming one report from multiple runs. >> >> You would still get the (minor) problem I have when 'cat'ing the >> files (HTML reports with multiple html heads). >> >> >> >> >given then appearance that it was one large process. >> >> Where you thinking about giving the appearance of one process at >> the report level or the rake level? >> >> >> >> >> >> >> Sounds like there's two issues here. One is grouping features >> into run sets (eg fast-running, slow-running; needs an >> external service, is self-contained) the other is running >> features in a certain mode (eg against mock-services, against >> live services; using HTML interface, using XML interface). >> >> One solution to the first problem could be tagging the >> features/scenarios: >> >> Feature: blah >> Groups: slow >> As a... >> >> Scenario: blah >> Groups: twitter web >> >> Or something. Maybe? >> >> >> We currently have an issue on tagging but it will have to wait >> until Aslak has done his AST magic. >> >> >> Just a heads up - planning to get started on this around Dec 15th. >> >> >> http://rspec.lighthouseapp.com/projects/16211/tickets/54-tagging-scenarios >> >> >> >> -- >> Joseph Wilk >> http://blog.josephwilk.net >> >> >> >> The second problem currently has to be handled as separate >> Cucumber rake tasks with different --require options to load >> different steps. I don't have any multi-mode features though, >> so I haven't had to worry about this yet. I suspect the >> general problem (given all the potential dimensions you could >> create) is currently unspecified and the general solution is >> quite hard... >> >> I still think having an authoritative 'rake features' is >> essential, though. >> >> >> >> >> >> >> Ashley >> >> -- http://www.patchspace.co.uk/ >> http://aviewfromafar.net/ >> >> >> >> _______________________________________________ >> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From apremdas at gmail.com Thu Dec 4 13:34:09 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 4 Dec 2008 18:34:09 +0000 Subject: [rspec-users] Rails project as a template for other projects (off topic) Message-ID: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> This is of topic but I have a feeling I might get some useful advice here - hope you don't mind I've created a rails project that I want to use as a basis for other rails project. I was wondering if anyone had any tips on workflow for doing this sort of thing, especially dealing with updating projects as the base project gets improved. My base project might be of interest to people here, its basically Vanilla Rails project with added rspec, cucumber, haml, compass, object_daddy, webrat and restful-authentication (RA). Then the RA stories have been replaced with features which are specifically designed to be simple enough that I can understand them with simple steps as well. The RA forms have been hamlized and made to work properly with webrat (have proper labels) and finally a couple of tweaks have been added so you can login with email (optional) and the remember_me stuff works. I'm using GIT for SCM Anyhow any ideas ? Cheers Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From caius at caius.name Thu Dec 4 13:46:04 2008 From: caius at caius.name (Caius Durling) Date: Thu, 4 Dec 2008 18:46:04 +0000 Subject: [rspec-users] Rails project as a template for other projects (off topic) In-Reply-To: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> References: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> Message-ID: <69D74237-F6C8-4186-9B8B-3894FEC12DFE@caius.name> On 4 Dec 2008, at 18:34, Andrew Premdas wrote: > This is of topic but I have a feeling I might get some useful advice > here - hope you don't mind > > I've created a rails project that I want to use as a basis for other > rails project. I was wondering if anyone had any tips on workflow > for doing this sort of thing, especially dealing with updating > projects as the base project gets improved. > > My base project might be of interest to people here, its basically > > Vanilla Rails project with added rspec, cucumber, haml, compass, > object_daddy, webrat and restful-authentication (RA). Then the RA > stories have been replaced with features which are specifically > designed to be simple enough that I can understand them with simple > steps as well. The RA forms have been hamlized and made to work > properly with webrat (have proper labels) and finally a couple of > tweaks have been added so you can login with email (optional) and > the remember_me stuff works. > > I'm using GIT for SCM > > Anyhow any ideas ? Create a github account and bang it on there. C --- Caius Durling caius at caius.name +44 (0) 7960 268 100 http://caius.name/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part URL: From jim at saturnflyer.com Thu Dec 4 13:50:39 2008 From: jim at saturnflyer.com (Jim Gay) Date: Thu, 4 Dec 2008 13:50:39 -0500 Subject: [rspec-users] Rails project as a template for other projects (off topic) In-Reply-To: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> References: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> Message-ID: <7B6A1B7F-E0F9-4CCE-BB51-5B205C3AC221@saturnflyer.com> On Dec 4, 2008, at 1:34 PM, Andrew Premdas wrote: > This is of topic but I have a feeling I might get some useful advice > here - hope you don't mind > > I've created a rails project that I want to use as a basis for other > rails project. I was wondering if anyone had any tips on workflow > for doing this sort of thing, especially dealing with updating > projects as the base project gets improved. > > My base project might be of interest to people here, its basically > > Vanilla Rails project with added rspec, cucumber, haml, compass, > object_daddy, webrat and restful-authentication (RA). Then the RA > stories have been replaced with features which are specifically > designed to be simple enough that I can understand them with simple > steps as well. The RA forms have been hamlized and made to work > properly with webrat (have proper labels) and finally a couple of > tweaks have been added so you can login with email (optional) and > the remember_me stuff works. > > I'm using GIT for SCM > > Anyhow any ideas ? Anything like Bort? http://github.com/fudgestudios/bort/network From nick at deadorange.com Thu Dec 4 13:59:59 2008 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 4 Dec 2008 13:59:59 -0500 Subject: [rspec-users] Rails project as a template for other projects (off topic) In-Reply-To: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> References: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> Message-ID: <07F674CD-744F-4E35-B0AD-7049BAC9BC8C@deadorange.com> On 2008-12-04, at 13:34, Andrew Premdas wrote: > This is of topic but I have a feeling I might get some useful advice > here - hope you don't mind > > I've created a rails project that I want to use as a basis for other > rails project. I was wondering if anyone had any tips on workflow > for doing this sort of thing, especially dealing with updating > projects as the base project gets improved. > > My base project might be of interest to people here, its basically > > Vanilla Rails project with added rspec, cucumber, haml, compass, > object_daddy, webrat and restful-authentication (RA). Then the RA > stories have been replaced with features which are specifically > designed to be simple enough that I can understand them with simple > steps as well. The RA forms have been hamlized and made to work > properly with webrat (have proper labels) and finally a couple of > tweaks have been added so you can login with email (optional) and > the remember_me stuff works. > > I'm using GIT for SCM > > Anyhow any ideas ? > > Cheers > > Andrew Hi Andrew. This doesn't have to do with one's workflow, but I highly recommend taking a look at Authlogic. It's an incredible authentication system, and IMO, is much better than restful- authentication. As for creating a customised base Rails project, check out Suprails (http://github.com/listrophy/suprails ) and rg (http://github.com/jeremymcanally/rg/). Cheers, Nick From peter.a.jaros at gmail.com Thu Dec 4 14:14:28 2008 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Thu, 4 Dec 2008 14:14:28 -0500 Subject: [rspec-users] Indentation Conventions for Ruby and Cucumber In-Reply-To: <88fd8ddc0812030627n7743e635lc49309244ddcc9c8@mail.gmail.com> References: <57a815bf0812030350u6ca51551y8a4f3731260b3273@mail.gmail.com> <88fd8ddc0812030627n7743e635lc49309244ddcc9c8@mail.gmail.com> Message-ID: <937d9d810812041114q2dee3159pdea219ffff9c241a@mail.gmail.com> On Wed, Dec 3, 2008 at 9:27 AM, Andrew Premdas wrote: > Oh but cucumber features so want to be idented on the I > > Scenario: Anonymous user can not duplicate a un-activated account > Given I am an anonymous user > And a registered user Fred exists > When I signup as Fred > Then I should see an error I have to disagree. I find the jagged margin looks messy. I would never indent other prose this way, so why would I indent my features this way? They're not code, they're prose. They're not written to be parsed, they're written to be read like a story. Peter From mailing_lists at railsnewbie.com Thu Dec 4 14:14:46 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Thu, 4 Dec 2008 14:14:46 -0500 Subject: [rspec-users] Rails project as a template for other projects (off topic) In-Reply-To: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> References: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> Message-ID: <5A95B892-7D27-45E2-9CD8-89BA2F2DB25A@railsnewbie.com> On Dec 4, 2008, at 1:34 PM, Andrew Premdas wrote: > This is of topic but I have a feeling I might get some useful advice > here - hope you don't mind > > I've created a rails project that I want to use as a basis for other > rails project. I was wondering if anyone had any tips on workflow > for doing this sort of thing, especially dealing with updating > projects as the base project gets improved. > > My base project might be of interest to people here, its basically > > Vanilla Rails project with added rspec, cucumber, haml, compass, > object_daddy, webrat and restful-authentication (RA). Then the RA > stories have been replaced with features which are specifically > designed to be simple enough that I can understand them with simple > steps as well. The RA forms have been hamlized and made to work > properly with webrat (have proper labels) and finally a couple of > tweaks have been added so you can login with email (optional) and > the remember_me stuff works. > > I'm using GIT for SCM > > Anyhow any ideas ? Just keep that base repository, and clone it for a new project. If you have updates for the base-repository, then commit there. Git allows you to add and fetch from totally different repositories: git remote add git at my_remote base-project git fetch base-project git merge base-project/master Scott From rick.denatale at gmail.com Thu Dec 4 14:14:47 2008 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 4 Dec 2008 14:14:47 -0500 Subject: [rspec-users] class << self considered harmful... really? In-Reply-To: <810a540e0812032204u102ec117p986b22207c59cc6a@mail.gmail.com> References: <3c30da400811250808r4a66dd41m2d04ff954c4b0641@mail.gmail.com> <810a540e0812032204u102ec117p986b22207c59cc6a@mail.gmail.com> Message-ID: On Thu, Dec 4, 2008 at 1:04 AM, Pat Maddox wrote: > > 'look at me, ma, I'm opening the eigenclass!' > > "Honey, if you're going to open your eigenclass, do it in your room." > And if you keep doing it, you'll go blind! -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RubyRedRick -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Dec 4 14:25:14 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 4 Dec 2008 19:25:14 +0000 Subject: [rspec-users] Rails project as a template for other projects (off topic) In-Reply-To: <7B6A1B7F-E0F9-4CCE-BB51-5B205C3AC221@saturnflyer.com> References: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> <7B6A1B7F-E0F9-4CCE-BB51-5B205C3AC221@saturnflyer.com> Message-ID: <88fd8ddc0812041125i475226ebn70073ad120806fc5@mail.gmail.com> A bit like Bort, but much less stuff in it and much more focused on features and being a platform for bdd. 2008/12/4 Jim Gay > > On Dec 4, 2008, at 1:34 PM, Andrew Premdas wrote: > > This is of topic but I have a feeling I might get some useful advice here >> - hope you don't mind >> >> I've created a rails project that I want to use as a basis for other rails >> project. I was wondering if anyone had any tips on workflow for doing this >> sort of thing, especially dealing with updating projects as the base project >> gets improved. >> >> My base project might be of interest to people here, its basically >> >> Vanilla Rails project with added rspec, cucumber, haml, compass, >> object_daddy, webrat and restful-authentication (RA). Then the RA stories >> have been replaced with features which are specifically designed to be >> simple enough that I can understand them with simple steps as well. The RA >> forms have been hamlized and made to work properly with webrat (have proper >> labels) and finally a couple of tweaks have been added so you can login with >> email (optional) and the remember_me stuff works. >> >> I'm using GIT for SCM >> >> Anyhow any ideas ? >> > > Anything like Bort? > http://github.com/fudgestudios/bort/network > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Dec 4 14:26:00 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 4 Dec 2008 19:26:00 +0000 Subject: [rspec-users] Rails project as a template for other projects (off topic) In-Reply-To: <5A95B892-7D27-45E2-9CD8-89BA2F2DB25A@railsnewbie.com> References: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> <5A95B892-7D27-45E2-9CD8-89BA2F2DB25A@railsnewbie.com> Message-ID: <88fd8ddc0812041126q6be0c4e0g15eab1f45c47708f@mail.gmail.com> Thanks for that, need to work more on my gitfu, will investigate further Andrew 2008/12/4 Scott Taylor > > On Dec 4, 2008, at 1:34 PM, Andrew Premdas wrote: > > This is of topic but I have a feeling I might get some useful advice here >> - hope you don't mind >> >> I've created a rails project that I want to use as a basis for other rails >> project. I was wondering if anyone had any tips on workflow for doing this >> sort of thing, especially dealing with updating projects as the base project >> gets improved. >> >> My base project might be of interest to people here, its basically >> >> Vanilla Rails project with added rspec, cucumber, haml, compass, >> object_daddy, webrat and restful-authentication (RA). Then the RA stories >> have been replaced with features which are specifically designed to be >> simple enough that I can understand them with simple steps as well. The RA >> forms have been hamlized and made to work properly with webrat (have proper >> labels) and finally a couple of tweaks have been added so you can login with >> email (optional) and the remember_me stuff works. >> >> I'm using GIT for SCM >> >> Anyhow any ideas ? >> > > Just keep that base repository, and clone it for a new project. > > If you have updates for the base-repository, then commit there. Git allows > you to add and fetch from totally different repositories: > > git remote add git at my_remote base-project > git fetch base-project > git merge base-project/master > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Dec 4 15:05:19 2008 From: lists at ruby-forum.com (Stephen Veit) Date: Thu, 4 Dec 2008 21:05:19 +0100 Subject: [rspec-users] Using Cucumber with latest Webrat In-Reply-To: <83408847-59A0-4BF1-892C-C440EA1D7E15@saturnflyer.com> References: <91953e7b6ebf063e56dbb38c472c85f3@ruby-forum.com> <8d961d900812020742q3c17c5co93794053f5f8b599@mail.gmail.com> <83408847-59A0-4BF1-892C-C440EA1D7E15@saturnflyer.com> Message-ID: Jim Gay wrote: > On Dec 2, 2008, at 10:42 AM, aslak hellesoy wrote: >> vendor/plugins/rspec >> This occurred at line 4 in webrat_steps.rb >> >> >> I just (1 hour ago) incorporated some recent Cucumber changes from >> Bryan (who writes Webrat) and released cucumber 0.1.11. >> Can you try with the latest release? It should work well with >> Bryan's latest webrat. > > I had the same problem. The fix was to install Webrat as a plugin. > I'll try out the updated versions. I tried with the latest plugins from GitHub for Cucumber and Webrat. It worked fine. Thanks. -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Thu Dec 4 15:41:00 2008 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 4 Dec 2008 15:41:00 -0500 Subject: [rspec-users] NameError when passing a URL helper to a method Message-ID: Hi guys. I just wrote a small spec helper method to DRY up some of my specs, and found that passing a URL helper (Eg: #photos_url) to a method results in a NameError error. I extracted the problem into its own short spec file to isolate it. Any thoughts on what's going on?: http://gist.github.com/32060 Thanks for your help, Nick From apremdas at gmail.com Thu Dec 4 16:33:02 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 4 Dec 2008 21:33:02 +0000 Subject: [rspec-users] Indentation Conventions for Ruby and Cucumber In-Reply-To: <937d9d810812041114q2dee3159pdea219ffff9c241a@mail.gmail.com> References: <57a815bf0812030350u6ca51551y8a4f3731260b3273@mail.gmail.com> <88fd8ddc0812030627n7743e635lc49309244ddcc9c8@mail.gmail.com> <937d9d810812041114q2dee3159pdea219ffff9c241a@mail.gmail.com> Message-ID: <88fd8ddc0812041333l28c63ad7n125b9e56b6d27f4f@mail.gmail.com> Definitely a matter of taste. A few things 1) syntax highlighting seems to make aligning on the I more preferable 2) And's feel like there nested 3) Maybe its my programmers eye reading and looking for matches rather than reading the scenario as a whole Is a feature prose? Seems closer to poetry in layout at least 2008/12/4 Peter Jaros > On Wed, Dec 3, 2008 at 9:27 AM, Andrew Premdas wrote: > > Oh but cucumber features so want to be idented on the I > > > > Scenario: Anonymous user can not duplicate a un-activated account > > Given I am an anonymous user > > And a registered user Fred exists > > When I signup as Fred > > Then I should see an error > > I have to disagree. I find the jagged margin looks messy. I would > never indent other prose this way, so why would I indent my features > this way? They're not code, they're prose. They're not written to be > parsed, they're written to be read like a story. > > Peter > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Dec 4 16:34:18 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 4 Dec 2008 21:34:18 +0000 Subject: [rspec-users] Using Cucumber with latest Webrat In-Reply-To: References: <91953e7b6ebf063e56dbb38c472c85f3@ruby-forum.com> <8d961d900812020742q3c17c5co93794053f5f8b599@mail.gmail.com> <83408847-59A0-4BF1-892C-C440EA1D7E15@saturnflyer.com> Message-ID: <88fd8ddc0812041334p13cf12ddv31bace4123a91fa8@mail.gmail.com> But doesn't work with the webrat gem 2008/12/4 Stephen Veit > Jim Gay wrote: > > On Dec 2, 2008, at 10:42 AM, aslak hellesoy wrote: > >> vendor/plugins/rspec > >> This occurred at line 4 in webrat_steps.rb > >> > >> > >> I just (1 hour ago) incorporated some recent Cucumber changes from > >> Bryan (who writes Webrat) and released cucumber 0.1.11. > >> Can you try with the latest release? It should work well with > >> Bryan's latest webrat. > > > > I had the same problem. The fix was to install Webrat as a plugin. > > I'll try out the updated versions. > > I tried with the latest plugins from GitHub for Cucumber and Webrat. It > worked fine. Thanks. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Dec 4 16:39:30 2008 From: lists at ruby-forum.com (James Byrne) Date: Thu, 4 Dec 2008 22:39:30 +0100 Subject: [rspec-users] stepping across features In-Reply-To: <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> Message-ID: <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> I need a bit of instruction. I have spent the day reading online bloggs, tutorials, and howtos relating to BDD, RSpec and testing. I have also spent several hours going through the cucumber spec/test suites in an attempt to absorb some sense of how best to proceed. I am somewhat nonplussed. Here is my situation. I am the domain expert (together with a few others) and I am the business analyst and I am the systems analyst and I am the coding team. So, I am essentially in the position of having to interview myself (mostly) to write specifications so that I can design a system that I will have to code, myself. I have spent the better part of the last two years learning ruby and rails, taking related courses, investigating, acquiring, installing and learning to use various support tools like Subversion, which I have since replaced with GiT, and Trac project administration system, which I have since replaced with Redmine. I also beat my head against a brick wall trying to get some idea on how to use rspec stories to facilitate my initial foray into TDD which then evolved (for me) into BDD. Along came cucumber and in the space of a few days I have begun to write and run actual tests derived from features that I have described in a cucumber fashion. I have actually written working code driven by feature requirements. Heavens, I have even "refactored" my initial step definitions to remove instance variables and create cross feature steps. I now have rcov reports telling me what tests need to be written for the code I already have. Things seem good. Where do I go from here? At issue for me is really how much detail goes into the features. It was pointed out that the present form of many of my features betray a "programming" bias. I admit to this. My question is: Where does one specify the nitty gritty details of what columns go into what relations that possess what associations with what other relations? Where does one put the descriptions of business rules and algorithms? These are all examples of user driven details to at least some degree. I mean, not every client management system need distinguish between an operating name and a full legal style and yet keep both for the same customer. So this is a detail that I feel should be expressed from the user pov somewhere. Tax calculations and fee discount structures are also areas that need user driven expression. Do these not belong in features too? I can see that features deal with high level stuff. But there is an awful lot of low level details that end users have to specify as well. Even if they do not need to know about database normalization or attribute naming conventions they nonetheless have to express, somewhere, their need to retain full addresses, postal codes of varying format depending on country, telephone numbers, perhaps categorized into meaningful classes, and the like. Where are these requirements expressed if not in features? Presumably one must test to see that the requisite information is retained and retrievable even if exactly how is not explicitly stated in their requirements. I had, at one point, the idea that, at least in the beginning, I would do most of this detail expression in the form of feature steps. The advice I have received has caused to reflect on whether this is a desirable course to take. However, I can see no obvious alternative other than to bury the design requirements in rspec specs or testunit tests, both of which seems to defeat the idea of having users drive the project. Am I missing something obvious here? -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Thu Dec 4 16:43:56 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 4 Dec 2008 16:43:56 -0500 Subject: [rspec-users] Indentation Conventions for Ruby and Cucumber In-Reply-To: <937d9d810812041114q2dee3159pdea219ffff9c241a@mail.gmail.com> References: <57a815bf0812030350u6ca51551y8a4f3731260b3273@mail.gmail.com> <88fd8ddc0812030627n7743e635lc49309244ddcc9c8@mail.gmail.com> <937d9d810812041114q2dee3159pdea219ffff9c241a@mail.gmail.com> Message-ID: <85d99afe0812041343i6f93346dr6a245703634b226b@mail.gmail.com> On Thu, Dec 4, 2008 at 2:14 PM, Peter Jaros wrote: > On Wed, Dec 3, 2008 at 9:27 AM, Andrew Premdas wrote: >> Oh but cucumber features so want to be idented on the I >> >> Scenario: Anonymous user can not duplicate a un-activated account >> Given I am an anonymous user >> And a registered user Fred exists >> When I signup as Fred >> Then I should see an error > > I have to disagree. I find the jagged margin looks messy. I would > never indent other prose this way, so why would I indent my features > this way? They're not code, they're prose. They're not written to be > parsed, they're written to be read like a story. +1 to what Peter said, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From zach.dennis at gmail.com Thu Dec 4 17:06:44 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 4 Dec 2008 17:06:44 -0500 Subject: [rspec-users] NameError when passing a URL helper to a method In-Reply-To: References: Message-ID: <85d99afe0812041406ka146fa9ydb9b41277798caca@mail.gmail.com> On Thu, Dec 4, 2008 at 3:41 PM, Nick Hoffman wrote: > Hi guys. I just wrote a small spec helper method to DRY up some of my specs, > and found that passing a URL helper (Eg: #photos_url) to a method results in > a NameError error. I extracted the problem into its own short spec file to > isolate it. Any thoughts on what's going on?: > http://gist.github.com/32060 foo(properties_url) is being executed in the context of the describe block and not in the instance of an example being run. For example: describe FooController do it "has access to routing methods here" do properties_url end # it doesn't have access out here though, this fails properties_url # your example will fail to foo(properties_url) end -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From nick at deadorange.com Thu Dec 4 17:43:34 2008 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 4 Dec 2008 17:43:34 -0500 Subject: [rspec-users] NameError when passing a URL helper to a method In-Reply-To: <85d99afe0812041406ka146fa9ydb9b41277798caca@mail.gmail.com> References: <85d99afe0812041406ka146fa9ydb9b41277798caca@mail.gmail.com> Message-ID: On 2008-12-04, at 17:06, Zach Dennis wrote: > On Thu, Dec 4, 2008 at 3:41 PM, Nick Hoffman > wrote: >> Hi guys. I just wrote a small spec helper method to DRY up some of >> my specs, >> and found that passing a URL helper (Eg: #photos_url) to a method >> results in >> a NameError error. I extracted the problem into its own short spec >> file to >> isolate it. Any thoughts on what's going on?: >> http://gist.github.com/32060 > > foo(properties_url) is being executed in the context of the describe > block and not in the instance of an example being run. For example: > > describe FooController do > it "has access to routing methods here" do > properties_url > end > > # it doesn't have access out here though, this fails > properties_url > > # your example will fail to > foo(properties_url) > end > -- > Zach Dennis Hi Zach. Thanks for that explanation; it makes a lot of sense. What I'm trying to do is write a spec helper method for DRYing up controller redirect examples. In other words, rather than having the following 4 lines repeated throughout my specs: it 'should redirect to the account page' do do_action response.should redirect_to account_url end I'd like to do this: it_should_redirect_to 'the account page', account_url I've written the method. The only problem is what you explained; #account_url being called from outside of an example. The only solution that I can think of is to do this: before :each do @account_url = account_url end it_should_redirect_to 'the account page', @account_url Are there any alternative solutions? Cheers, Nick From nick at deadorange.com Thu Dec 4 17:49:50 2008 From: nick at deadorange.com (Nick Hoffman) Date: Thu, 4 Dec 2008 17:49:50 -0500 Subject: [rspec-users] NameError when passing a URL helper to a method In-Reply-To: References: <85d99afe0812041406ka146fa9ydb9b41277798caca@mail.gmail.com> Message-ID: On 2008-12-04, at 17:43, Nick Hoffman wrote: > The only solution that I can think of is to do this: > before :each do > @account_url = account_url > end > it_should_redirect_to 'the account page', @account_url Actually, that suggestion above of mine doesn't work. It fails with: You have a nil object when you didn't expect it! The error occurred while evaluating nil.rewrite (eval):17:in `account_url' I thought of it while writing that last email, but didn't test it before hitting send. -Nick From pergesu at gmail.com Thu Dec 4 17:54:26 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 04 Dec 2008 14:54:26 -0800 Subject: [rspec-users] NameError when passing a URL helper to a method In-Reply-To: (Nick Hoffman's message of "Thu\, 4 Dec 2008 15\:41\:00 -0500") References: Message-ID: Nick Hoffman writes: > Hi guys. I just wrote a small spec helper method to DRY up some of my > specs, and found that passing a URL helper (Eg: #photos_url) to a > method results in a NameError error. I extracted the problem into its > own short spec file to isolate it. Any thoughts on what's going on?: > http://gist.github.com/32060 > > Thanks for your help, > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Check out my attempt: http://gist.github.com/32130 I don't know which one is correct. Pat From matt at mattwynne.net Thu Dec 4 17:56:37 2008 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 4 Dec 2008 22:56:37 +0000 Subject: [rspec-users] stepping across features In-Reply-To: <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> Message-ID: <566B438A-1028-4072-AE5C-E0F99CACD218@mattwynne.net> On 4 Dec 2008, at 21:39, James Byrne wrote: > I had, at one point, the idea that, at least in the beginning, I would > do most of this detail expression in the form of feature steps. The > advice I have received has caused to reflect on whether this is a > desirable course to take. However, I can see no obvious alternative > other than to bury the design requirements in rspec specs or testunit > tests, both of which seems to defeat the idea of having users drive > the > project. > > Am I missing something obvious here? You're not, don't worry! This is definitely an emerging practice, and you aren't going to find any 'correct answers'. See this thread for a lengthy discussion on the same topic: > http://www.ruby-forum.com/topic/171444#new FWIW, my view is becoming: if in doubt, put it in the Acceptance Tests. These ATs are proving themselves to be less brittle than my unit tests, and therefore much more valuable. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From matt at mattwynne.net Thu Dec 4 18:17:55 2008 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 4 Dec 2008 23:17:55 +0000 Subject: [rspec-users] cucumber and autotest - running all features? In-Reply-To: <937d9d810812020611t3a9f4c74hc85dae7b55c56a9d@mail.gmail.com> References: <306b6bd9a7f00af8464713c73dc929de@ruby-forum.com> <4ee52ac742558d3aeb2d560fef7b27fe@ruby-forum.com> <937d9d810811301845x29632c37p7ffc80b5537b4450@mail.gmail.com> <5BCECC48-3374-462B-9493-63715A7AEB26@mattwynne.net> <937d9d810812020611t3a9f4c74hc85dae7b55c56a9d@mail.gmail.com> Message-ID: <97C20D7A-8DC1-4169-90EA-F395A6F06FF3@mattwynne.net> On 2 Dec 2008, at 14:11, Peter Jaros wrote: > On Mon, Dec 1, 2008 at 2:50 AM, Matt Wynne wrote: >> >> I've been thinking about a more sophisticated mechanism for this, >> using code >> coverage. If autotest / rspactor was able to record and remember >> the LOC >> covered by each scenario / example, it would be possible to do more >> focussed >> regression testing when a source file was changed. > > It's a clever thought, but you don't know about code which scenarios > *will* depend on in the future. You'd have to manually restart > autotest and have it recalculate all of the mappings. Well. I reckon I would be adding new code under two circumstances: (1) I am refactoring existing code, sprouting out classes etc. (2) I am cutting new code to pass a new, failing, scenario / spec In case (1 - refactoring), I expect that as I move code out of BigFatClass and create ShinyNewClass, I would have to save big_fat_class.rb, which would trigger the tests that cover it. That would then update the coverage mappings to also cover shiny_new_class.rb In case (2 - adding new code, guided by tests), there would be failing tests to re-run which, when run, would hopefully spin up the new code as I write it. The re-run of failing tests could be triggered either manually, or by a trigger that just watched the folders where new source files were likely to crop up. WDYT? Possible? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From pergesu at gmail.com Thu Dec 4 19:56:37 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 04 Dec 2008 16:56:37 -0800 Subject: [rspec-users] NameError when passing a URL helper to a method In-Reply-To: (Nick Hoffman's message of "Thu\, 4 Dec 2008 17\:49\:50 -0500") References: <85d99afe0812041406ka146fa9ydb9b41277798caca@mail.gmail.com> Message-ID: Nick Hoffman writes: > On 2008-12-04, at 17:43, Nick Hoffman wrote: >> The only solution that I can think of is to do this: >> before :each do >> @account_url = account_url >> end >> it_should_redirect_to 'the account page', @account_url > > Actually, that suggestion above of mine doesn't work. It fails with: > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.rewrite > (eval):17:in `account_url' > > I thought of it while writing that last email, but didn't test it > before hitting send. > -Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users It's the same as class Foo @class_instance_variable = "blah" def foo puts @class_instance_variable end end Foo.foo will print nothing, because @class_instance_variable is nil in the object instance. Anyway, I thought of an even cleaner way to do things than using a block, assuming you only care about calling one method: do_something(:blah_url_helper) def do_something(helper_name) send(helper_name) end Pat From mark at mwilden.com Thu Dec 4 20:27:16 2008 From: mark at mwilden.com (Mark Wilden) Date: Thu, 4 Dec 2008 17:27:16 -0800 Subject: [rspec-users] NameError when passing a URL helper to a method In-Reply-To: References: <85d99afe0812041406ka146fa9ydb9b41277798caca@mail.gmail.com> Message-ID: <3c30da400812041727m55cfb8dahd5ecd339c05d57c@mail.gmail.com> On Thu, Dec 4, 2008 at 4:56 PM, Pat Maddox wrote: > class Foo > @class_instance_variable = "blah" > > def foo > puts @class_instance_variable > end > end > > Foo.foo will print nothing, because @class_instance_variable is nil in > the object instance. > I don't know if it matters here, but you can define a class method to return a class instance variable. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Dec 4 21:36:06 2008 From: lists at ruby-forum.com (Pau Cor) Date: Fri, 5 Dec 2008 03:36:06 +0100 Subject: [rspec-users] calling multiline steps from other steps Message-ID: <0fbcf4b98edebc710111e6c010829cf5@ruby-forum.com> What is the syntax for calling multiline steps from other steps? I'd like to do something like this: Given /^I have filled in the form$/ do |details| details.hashes.each |pair| When "I fill in #{pair['field']} with #{pair['value']}" end end Given /^(.*) has filled in the form$/ do |user, details| Given "I am logged in and #{user}" Given "I have filled in the form", details When "I log out" end My feature file would have something like this: Given Joe has filled in the form: | field | value | | x | 1 | | y | 2 | I'd also like to do something like this: Given /^Everything is filled in$/ do Given "Joe has filled in the form: | field | value | | x | 1 | | y | 2 |" end How can I do this? Also, how does it work for multi line strings (""")? Thanks! Paul P.S. Those are contrived examples. -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Thu Dec 4 22:33:19 2008 From: ben at benmabey.com (Ben Mabey) Date: Thu, 04 Dec 2008 20:33:19 -0700 Subject: [rspec-users] calling multiline steps from other steps In-Reply-To: <0fbcf4b98edebc710111e6c010829cf5@ruby-forum.com> References: <0fbcf4b98edebc710111e6c010829cf5@ruby-forum.com> Message-ID: <4938A0FF.5080502@benmabey.com> Pau Cor wrote: > What is the syntax for calling multiline steps from other steps? I'd > like to do something like this: > > Given /^I have filled in the form$/ do |details| > details.hashes.each |pair| > When "I fill in #{pair['field']} with #{pair['value']}" > end > end > > Yes, you can do this. > Given /^(.*) has filled in the form$/ do |user, details| > Given "I am logged in and #{user}" > Given "I have filled in the form", details > When "I log out" > end > My feature file would have something like this: > > Given Joe has filled in the form: > | field | value | > | x | 1 | > | y | 2 | > > > I'd also like to do something like this: > > Given /^Everything is filled in$/ do > Given "Joe has filled in the form: > | field | value | > | x | 1 | > | y | 2 |" > end > > I'm not sure if it works with step tables, so you will just have to experiment and see. Same thing for the multi-line strings.. I'm not sure but that seems more possible that the step table. > How can I do this? Also, how does it work for multi line strings (""")? > > Thanks! > Paul > > P.S. Those are contrived examples. > From peter.a.jaros at gmail.com Thu Dec 4 22:57:02 2008 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Thu, 4 Dec 2008 22:57:02 -0500 Subject: [rspec-users] cucumber and autotest - running all features? In-Reply-To: <97C20D7A-8DC1-4169-90EA-F395A6F06FF3@mattwynne.net> References: <306b6bd9a7f00af8464713c73dc929de@ruby-forum.com> <4ee52ac742558d3aeb2d560fef7b27fe@ruby-forum.com> <937d9d810811301845x29632c37p7ffc80b5537b4450@mail.gmail.com> <5BCECC48-3374-462B-9493-63715A7AEB26@mattwynne.net> <937d9d810812020611t3a9f4c74hc85dae7b55c56a9d@mail.gmail.com> <97C20D7A-8DC1-4169-90EA-F395A6F06FF3@mattwynne.net> Message-ID: <937d9d810812041957w6d273e1by1af9f5c5a16e415c@mail.gmail.com> On Thu, Dec 4, 2008 at 6:17 PM, Matt Wynne wrote: > WDYT? Possible? Possibly. :) That does sound like it might be possible. On the other hand, in practice, I've found that the current implementation works the way I'd want it to at least 95% of the time. Personally, I'm not terribly inclined to do all the work to make it more intelligent. But if you'd like to give it a shot, I'm certainly curious to see if it can work. Peter From lists at ruby-forum.com Fri Dec 5 00:59:22 2008 From: lists at ruby-forum.com (Pau Cor) Date: Fri, 5 Dec 2008 06:59:22 +0100 Subject: [rspec-users] calling multiline steps from other steps In-Reply-To: <4938A0FF.5080502@benmabey.com> References: <0fbcf4b98edebc710111e6c010829cf5@ruby-forum.com> <4938A0FF.5080502@benmabey.com> Message-ID: <994babdadbe81afffff9c23a82d0ac6a@ruby-forum.com> Ben Mabey wrote: > you will just have to > experiment and see. Thanks for the reply! So far all my experiments have failed :/ Anyone else have any ideas? Paul -- Posted via http://www.ruby-forum.com/. From apremdas at gmail.com Fri Dec 5 01:01:44 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 5 Dec 2008 06:01:44 +0000 Subject: [rspec-users] stepping across features In-Reply-To: <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> Message-ID: <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> James, I think this is where the art or craft comes in. Features are a great tool, but being such a great tool I think its very easy to become tempted to overuse them. People in software keeps on looking for the silver bullet. They find something new, overuse it, become frustrated by it, move on to something else and the cycle begins again. From this comes alot of innovation, but also alot of frustration and waste. The second point I'd like to make is that testing is really hard. IMO its much harder than writing functionality so you can expect to struggle. And its not just about actually getting things tested, but its also about - deciding what to implement - deciding what to test - deciding how to test - organising your tests so they communicate your intention clearly - cover your functionality ... (lots more) All software projects are entropic. That is if you don't put a continuous input of energy into them they will become chaotic. You can use features to counter this chaos to add order to your project or you can just use them to test things. If you use them just to test things your missing out though on their fundamental purpose which is to express clearly what the intention of a project is with a secondary benefit of providing a mechanism to execute those intentions and see if they are met. So back to your original question where does all the detail go? Well acceptance tests start from the general and go to the specific, so detail comes further down some sort of heirarchy. Thing is you haven't got a hierarchy yet so you don't know where to put things. I'm in a similar situation with the code I'm working on and its real tempting to start putting in all that detail in the features, but I'd suggest really trying hard to avoid that. Basically if you need detail refactor your feature so that you don't and create new scenarios to deal with the detail only when you have to. In the end you can have most of the detail in your step definitions and use the nesting of steps to build more complex stories. I've put my example app on github. It has a refactoring of the restful-authentication stories following these principles, perhaps it will give you some ideas http://github.com/diabolo/fbrp/tree/master All best Andrew 2008/12/4 James Byrne > I need a bit of instruction. I have spent the day reading online > bloggs, tutorials, and howtos relating to BDD, RSpec and testing. I > have also spent several hours going through the cucumber spec/test > suites in an attempt to absorb some sense of how best to proceed. I am > somewhat nonplussed. > > Here is my situation. I am the domain expert (together with a few > others) and I am the business analyst and I am the systems analyst and I > am the coding team. So, I am essentially in the position of having to > interview myself (mostly) to write specifications so that I can design a > system that I will have to code, myself. > > I have spent the better part of the last two years learning ruby and > rails, taking related courses, investigating, acquiring, installing and > learning to use various support tools like Subversion, which I have > since replaced with GiT, and Trac project administration system, which I > have since replaced with Redmine. I also beat my head against a brick > wall trying to get some idea on how to use rspec stories to facilitate > my initial foray into TDD which then evolved (for me) into BDD. > > Along came cucumber and in the space of a few days I have begun to write > and run actual tests derived from features that I have described in a > cucumber fashion. I have actually written working code driven by > feature requirements. Heavens, I have even "refactored" my initial step > definitions to remove instance variables and create cross feature steps. > I now have rcov reports telling me what tests need to be written for the > code I already have. Things seem good. > > Where do I go from here? At issue for me is really how much detail goes > into the features. It was pointed out that the present form of many of > my features betray a "programming" bias. I admit to this. My question > is: Where does one specify the nitty gritty details of what columns go > into what relations that possess what associations with what other > relations? Where does one put the descriptions of business rules and > algorithms? > > These are all examples of user driven details to at least some degree. > I mean, not every client management system need distinguish between an > operating name and a full legal style and yet keep both for the same > customer. So this is a detail that I feel should be expressed from the > user pov somewhere. Tax calculations and fee discount structures are > also areas that need user driven expression. Do these not belong in > features too? > > I can see that features deal with high level stuff. But there is an > awful lot of low level details that end users have to specify as well. > Even if they do not need to know about database normalization or > attribute naming conventions they nonetheless have to express, > somewhere, their need to retain full addresses, postal codes of varying > format depending on country, telephone numbers, perhaps categorized into > meaningful classes, and the like. Where are these requirements > expressed if not in features? Presumably one must test to see that the > requisite information is retained and retrievable even if exactly how is > not explicitly stated in their requirements. > > I had, at one point, the idea that, at least in the beginning, I would > do most of this detail expression in the form of feature steps. The > advice I have received has caused to reflect on whether this is a > desirable course to take. However, I can see no obvious alternative > other than to bury the design requirements in rspec specs or testunit > tests, both of which seems to defeat the idea of having users drive the > project. > > Am I missing something obvious here? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Dec 5 01:06:11 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 5 Dec 2008 06:06:11 +0000 Subject: [rspec-users] Restful-Authentication features rewrite Message-ID: <88fd8ddc0812042206h8bb582awc4187a3a02bc6e2@mail.gmail.com> I've put up a Rails sample project on github whose main feature is a rewrite of the restful-authentication stories using features and trying to exhibit good practice. I'd love to get some feedback from the group about the features I've written. You can find the project at http://github.com/diabolo/fbrp/tree/master Ideally I'd like the features to be a useful example of something reasonably real world for peeps new to this stuff All best Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Dec 5 01:29:40 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 5 Dec 2008 06:29:40 +0000 Subject: [rspec-users] calling multiline steps from other steps In-Reply-To: <994babdadbe81afffff9c23a82d0ac6a@ruby-forum.com> References: <0fbcf4b98edebc710111e6c010829cf5@ruby-forum.com> <4938A0FF.5080502@benmabey.com> <994babdadbe81afffff9c23a82d0ac6a@ruby-forum.com> Message-ID: <88fd8ddc0812042229r7e0a098ax95a95c4b52cdc7b6@mail.gmail.com> Given /^I have filled in the form$/ do |details| details.hashes.each |pair| Can't see this working because you've got no place to collect details However Given /^I have filled in the form with (.*)$/ do |details| details.hashes.each |pair| would work, but you'd have to do some tricky stuff to get your hash out. ----- Given Joe has filled in the form: | field | value | | x | 1 | | y | 2 | For this to work the step that matches has to collect two thing so really you need Given Joe has filled in foo with bar | field | value | | x | 1 | | y | 2 | and a matcher Given /^Joe has filled in (.*) with (.*)$/ do |field, value| >From that you could try Given /^Form filled in correctly$/ Given "Joe has filled in foo with bar" | field | value | | x | 1 | | y | 2 | but I doubt that would work as I think you need the "More Examples:" statement. Also don't think embedding tables in step definitions is a good idea. ---- You could use convention over configuration to do more filling in with less variables. For example I fill in user forms using just the login name to generate the other fields e.g. login - fred, password - fredpass, email fred at example.com etc. Now a step can take one parameter fred and fill in many details e.g. using webrat When /^I fill in signup details for (.*) $/ do |user| fill_in(:login, :with => user) fill_in(:email, :with => user + '@example.com') fill_in(:password, :with => user + 'pass') fill_in('user[password_confirmation]', :with => user + 'pass') end When I fill in signup details for fred HTH Andrew 2008/12/5 Pau Cor > Ben Mabey wrote: > > you will just have to > > experiment and see. > > Thanks for the reply! > So far all my experiments have failed :/ > > Anyone else have any ideas? > > Paul > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Fri Dec 5 01:43:49 2008 From: ben at benmabey.com (Ben Mabey) Date: Thu, 04 Dec 2008 23:43:49 -0700 Subject: [rspec-users] Restful-Authentication features rewrite In-Reply-To: <88fd8ddc0812042206h8bb582awc4187a3a02bc6e2@mail.gmail.com> References: <88fd8ddc0812042206h8bb582awc4187a3a02bc6e2@mail.gmail.com> Message-ID: <4938CDA5.1050707@benmabey.com> Andrew Premdas wrote: > I've put up a Rails sample project on github whose main feature is a > rewrite of the restful-authentication stories using features and > trying to exhibit good practice. I'd love to get some feedback from > the group about the features I've written. > > You can find the project at http://github.com/diabolo/fbrp/tree/master > > Ideally I'd like the features to be a useful example of something > reasonably real world for peeps new to this stuff > > All best > > Andrew Hey Andrew, First of all, great job! The restful-auth stories and specs are painful to look at so I hope this rewrite eventually replaces the stories in restful-auth proper. Another cool thing about having these features is that you could easily switch over to another authentication system/plugin (like AuthLogic[1]) with the same functionality and run these to prevent regressions. I don't have time to go through everything now but I will try to give you feedback soon via the mailing list or github comments and maybe even pull requests. Again, thanks for doing this! I think having this out there so we can all critique it will foster some good discussion about feature writing guidelines. -Ben 1. http://github.com/binarylogic/authlogic/tree/master From apremdas at gmail.com Fri Dec 5 01:51:49 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 5 Dec 2008 06:51:49 +0000 Subject: [rspec-users] Rails project as a template for other projects (off topic) In-Reply-To: <5A95B892-7D27-45E2-9CD8-89BA2F2DB25A@railsnewbie.com> References: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> <5A95B892-7D27-45E2-9CD8-89BA2F2DB25A@railsnewbie.com> Message-ID: <88fd8ddc0812042251i2c6ecd8bu506dbb88d9d10c8e@mail.gmail.com> Scott Working on this, assuming I have a cloned project 'foo' from my base project base and I'm working on foo. So I implement something new and then think this should be in base any ideas how to manage this. Was thinking maybe of having a base branch which would be the only thing I pushed up to the base project. Any thoughts? Andrew 2008/12/4 Scott Taylor > > On Dec 4, 2008, at 1:34 PM, Andrew Premdas wrote: > > This is of topic but I have a feeling I might get some useful advice here >> - hope you don't mind >> >> I've created a rails project that I want to use as a basis for other rails >> project. I was wondering if anyone had any tips on workflow for doing this >> sort of thing, especially dealing with updating projects as the base project >> gets improved. >> >> My base project might be of interest to people here, its basically >> >> Vanilla Rails project with added rspec, cucumber, haml, compass, >> object_daddy, webrat and restful-authentication (RA). Then the RA stories >> have been replaced with features which are specifically designed to be >> simple enough that I can understand them with simple steps as well. The RA >> forms have been hamlized and made to work properly with webrat (have proper >> labels) and finally a couple of tweaks have been added so you can login with >> email (optional) and the remember_me stuff works. >> >> I'm using GIT for SCM >> >> Anyhow any ideas ? >> > > Just keep that base repository, and clone it for a new project. > > If you have updates for the base-repository, then commit there. Git allows > you to add and fetch from totally different repositories: > > git remote add git at my_remote base-project > git fetch base-project > git merge base-project/master > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Fri Dec 5 01:53:33 2008 From: ben at benmabey.com (Ben Mabey) Date: Thu, 04 Dec 2008 23:53:33 -0700 Subject: [rspec-users] calling multiline steps from other steps In-Reply-To: <88fd8ddc0812042229r7e0a098ax95a95c4b52cdc7b6@mail.gmail.com> References: <0fbcf4b98edebc710111e6c010829cf5@ruby-forum.com> <4938A0FF.5080502@benmabey.com> <994babdadbe81afffff9c23a82d0ac6a@ruby-forum.com> <88fd8ddc0812042229r7e0a098ax95a95c4b52cdc7b6@mail.gmail.com> Message-ID: <4938CFED.1050806@benmabey.com> Andrew Premdas wrote: > Given /^I have filled in the form$/ do |details| > details.hashes.each |pair| > > Can't see this working because you've got no place to collect details > > However > > Given /^I have filled in the form with (.*)$/ do |details| > details.hashes.each |pair| > > would work, but you'd have to do some tricky stuff to get your hash out. > > > but I doubt that would work as I think you need the "More Examples:" > statement. Also don't think embedding tables in step definitions is a > good idea. > Actually, you can embed tables in steps, they are called "Step Tables". :) Read about them here: http://github.com/aslakhellesoy/cucumber/wikis/using-fit-tables-in-a-feature I have used them many times and I find them very handy. I had rolled my own with story runner and so having it built into cucumber makes things very nice. -Ben From aslak.hellesoy at gmail.com Fri Dec 5 02:21:22 2008 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Fri, 5 Dec 2008 08:21:22 +0100 Subject: [rspec-users] cucumber and autotest - running all features? In-Reply-To: <937d9d810812041957w6d273e1by1af9f5c5a16e415c@mail.gmail.com> References: <306b6bd9a7f00af8464713c73dc929de@ruby-forum.com> <4ee52ac742558d3aeb2d560fef7b27fe@ruby-forum.com> <937d9d810811301845x29632c37p7ffc80b5537b4450@mail.gmail.com> <5BCECC48-3374-462B-9493-63715A7AEB26@mattwynne.net> <937d9d810812020611t3a9f4c74hc85dae7b55c56a9d@mail.gmail.com> <97C20D7A-8DC1-4169-90EA-F395A6F06FF3@mattwynne.net> <937d9d810812041957w6d273e1by1af9f5c5a16e415c@mail.gmail.com> Message-ID: <75CA9952-664B-496B-AA6E-0D392FF7F3E9@gmail.com> > On Thu, Dec 4, 2008 at 6:17 PM, Matt Wynne wrote: > >> WDYT? Possible? > > Possibly. :) > > That does sound like it might be possible. On the other hand, in > practice, I've found that the current implementation works the way I'd > want it to at least 95% of the time. Agree. Sounds like a micro optimisation. A little too complex/clever for my liking. > Personally, I'm not terribly > inclined to do all the work to make it more intelligent. But if you'd > like to give it a shot, I'm certainly curious to see if it can work. > > Peter > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Fri Dec 5 02:22:36 2008 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Fri, 5 Dec 2008 08:22:36 +0100 Subject: [rspec-users] calling multiline steps from other steps In-Reply-To: <994babdadbe81afffff9c23a82d0ac6a@ruby-forum.com> References: <0fbcf4b98edebc710111e6c010829cf5@ruby-forum.com> <4938A0FF.5080502@benmabey.com> <994babdadbe81afffff9c23a82d0ac6a@ruby-forum.com> Message-ID: <3C57ED3A-7693-4B5D-9478-ED3940F7F11F@gmail.com> > Ben Mabey wrote: >> you will just have to >> experiment and see. > > Thanks for the reply! > So far all my experiments have failed :/ > > Anyone else have any ideas? > Not possible yet. Please file a ticket. > Paul > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Fri Dec 5 02:24:35 2008 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Fri, 5 Dec 2008 08:24:35 +0100 Subject: [rspec-users] calling multiline steps from other steps In-Reply-To: <994babdadbe81afffff9c23a82d0ac6a@ruby-forum.com> References: <0fbcf4b98edebc710111e6c010829cf5@ruby-forum.com> <4938A0FF.5080502@benmabey.com> <994babdadbe81afffff9c23a82d0ac6a@ruby-forum.com> Message-ID: <14F420DA-73E3-480F-A159-102475E3DDC3@gmail.com> And please link to this thread in the ticket. Nabble or somesuch. > Ben Mabey wrote: >> you will just have to >> experiment and see. > > Thanks for the reply! > So far all my experiments have failed :/ > > Anyone else have any ideas? > > Paul > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Dec 5 02:57:35 2008 From: lists at ruby-forum.com (Newman Huang) Date: Fri, 5 Dec 2008 08:57:35 +0100 Subject: [rspec-users] I met a trouble: cannot do a form post to an outside website In-Reply-To: References: Message-ID: Newman Huang wrote: > now i use webrat for cucumber scenario testing. i have a page with a > form, which will post to a bank payment gateway. that is, > >
> ... > >
> > my scenario step script is: > > == > And I press "confirm" > == > > then I got such an error: > > "No route matches "/pay/blablabla" with {:method=>:post}..." > > i think webrat or rails ignore the "http://www.abank.com" prefix > automatically. and then i wrote a test script > > == > get "http://www.abank.com/.." > puts response.body > == > > yes, the test result proves the suspicion. i think it should be handled > in the rails testing layer. so, anybody can help me? thanks in advance. I solved this problem by hacking webrat's code. walking around the requesting from webrat form, and then use Net::HTTP for a substitutor, require 'net/http' require 'uri' require 'nokogiri' module Webrat class Form def submit if !out_website?(form_action) @session.request_page(form_action, form_method, params) else handle_outwebsite_action(form_action,params) end end def handle_outwebsite_action(form_action,params) #... end end end require it before cucumbing. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Fri Dec 5 04:47:16 2008 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 5 Dec 2008 09:47:16 +0000 Subject: [rspec-users] cucumber and autotest - running all features? In-Reply-To: <75CA9952-664B-496B-AA6E-0D392FF7F3E9@gmail.com> References: <306b6bd9a7f00af8464713c73dc929de@ruby-forum.com> <4ee52ac742558d3aeb2d560fef7b27fe@ruby-forum.com> <937d9d810811301845x29632c37p7ffc80b5537b4450@mail.gmail.com> <5BCECC48-3374-462B-9493-63715A7AEB26@mattwynne.net> <937d9d810812020611t3a9f4c74hc85dae7b55c56a9d@mail.gmail.com> <97C20D7A-8DC1-4169-90EA-F395A6F06FF3@mattwynne.net> <937d9d810812041957w6d273e1by1af9f5c5a16e415c@mail.gmail.com> <75CA9952-664B-496B-AA6E-0D392FF7F3E9@gmail.com> Message-ID: On 5 Dec 2008, at 07:21, Aslak Helles?y wrote: > >> On Thu, Dec 4, 2008 at 6:17 PM, Matt Wynne >> wrote: >> >>> WDYT? Possible? >> >> Possibly. :) >> >> That does sound like it might be possible. On the other hand, in >> practice, I've found that the current implementation works the way >> I'd >> want it to at least 95% of the time. > > Agree. Sounds like a micro optimisation. A little too complex/clever > for my liking. I'll have to give autospec another shot then I guess. I have given up on it as it takes over 7 minutes to 'boot up' with our test suite, and I find it misses too many things it should have run, such that I have to hit CTRL-C and do a complete (7 minute) re-run far more often than I'd like. I also don't trust it before a check-in - it seems to miss things that should have been re-run. I guess this may more be due to our codebase being a bit badly organised so that the conventions autospec relies on aren't always adhered to... > >> Personally, I'm not terribly >> inclined to do all the work to make it more intelligent. But if >> you'd >> like to give it a shot, I'm certainly curious to see if it can work. :) My barrier is reading the coverage.data files, although thinking about it it should be possible to parse the HTML report quite easily... hmmmm.... Matt Wynne http://blog.mattwynne.net http://www.songkick.com From apremdas at gmail.com Fri Dec 5 05:44:56 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 5 Dec 2008 10:44:56 +0000 Subject: [rspec-users] calling multiline steps from other steps In-Reply-To: <4938CFED.1050806@benmabey.com> References: <0fbcf4b98edebc710111e6c010829cf5@ruby-forum.com> <4938A0FF.5080502@benmabey.com> <994babdadbe81afffff9c23a82d0ac6a@ruby-forum.com> <88fd8ddc0812042229r7e0a098ax95a95c4b52cdc7b6@mail.gmail.com> <4938CFED.1050806@benmabey.com> Message-ID: <88fd8ddc0812050244p24ac4c3pcb9ea1ccd2502996@mail.gmail.com> Ooh interesting stuff thanks for that Ben, never got past the scenario tables until now :) Andrew 2008/12/5 Ben Mabey > Andrew Premdas wrote: > >> Given /^I have filled in the form$/ do |details| >> details.hashes.each |pair| >> >> Can't see this working because you've got no place to collect details >> >> However >> >> Given /^I have filled in the form with (.*)$/ do |details| >> details.hashes.each |pair| >> >> would work, but you'd have to do some tricky stuff to get your hash out. >> >> > >> >> but I doubt that would work as I think you need the "More Examples:" >> statement. Also don't think embedding tables in step definitions is a good >> idea. >> >> > Actually, you can embed tables in steps, they are called "Step Tables". :) > Read about them here: > > http://github.com/aslakhellesoy/cucumber/wikis/using-fit-tables-in-a-feature > > I have used them many times and I find them very handy. I had rolled my > own with story runner and so having it built into cucumber makes things very > nice. > > -Ben > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at areacriacoes.com.br Fri Dec 5 08:41:02 2008 From: danielvlopes at areacriacoes.com.br (=?ISO-8859-1?Q?Daniel_Area_Cria=E7=F5es?=) Date: Fri, 5 Dec 2008 11:41:02 -0200 Subject: [rspec-users] proxy associantion on controllers Message-ID: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> Hello, I'm trying learn Rspec but having problems to understand when and how user mocks and stubs. I have a properties_controller with to before_filter actions (check_administrator_role e load_user)... to access index action of properties_controller I need have a params[:user] and this parameter will be used to load ther user in method load_user ... Like bellow: before_filter :check_administrator_role before_filter :load_user # GET /properties def index @properties = @user.properties end private def load_user @user = User.find(params[:user_id]) if @user.nil? flash[:notice] = "Registro não encontrado" redirect_to root_path end end But I don't know how test index and load_user without fixtures, take a look on my specs: describe PropertiesController do def mock_property(stubs={}) @mock_property ||= mock_model(Property, stubs) end before do @current_user = mock_model(User, :id => 1) controller.stub!(:check_administrator_role).and_return(true) @user = mock_model(User, :id=>1) controller.stub!(:load_user).and_return(@user) end describe "responding to GET index" do it "should expose all properties of given user as @properties" do @user.should_receive(:properties).and_return([mock_property]) get :index assigns[:properties].should == [mock_property] end end But I having this error: NoMethodError in 'PropertiesController responding to GET index should expose all properties of given user as @properties' You have a nil object when you didn't expect it! The error occurred while evaluating nil.properties /Users/daniellopes/Trabalhos/luvima/luvima/app/controllers/properties_controller.rb:8:in `index' ./spec/controllers/properties_controller_spec.rb:21: So, how is the right way to mock associated records? Thanks. Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at gmail.com Fri Dec 5 08:42:04 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Fri, 5 Dec 2008 11:42:04 -0200 Subject: [rspec-users] problem to mock association proxy Message-ID: <992995550812050542j17386874x2791cf76a8abd844@mail.gmail.com> Hello, I'm trying learn Rspec but having problems to understand when and how user mocks and stubs. I have a properties_controller with to before_filter actions (check_administrator_role e load_user)... to access index action of properties_controller I need have a params[:user] and this parameter will be used to load ther user in method load_user ... Like bellow: before_filter :check_administrator_role before_filter :load_user # GET /properties def index @properties = @user.properties end private def load_user @user = User.find(params[:user_id]) if @user.nil? flash[:notice] = "Registro não encontrado" redirect_to root_path end end But I don't know how test index and load_user without fixtures, take a look on my specs: describe PropertiesController do def mock_property(stubs={}) @mock_property ||= mock_model(Property, stubs) end before do @current_user = mock_model(User, :id => 1) controller.stub!(:check_administrator_role).and_return(true) @user = mock_model(User, :id=>1) controller.stub!(:load_user).and_return(@user) end describe "responding to GET index" do it "should expose all properties of given user as @properties" do @user.should_receive(:properties).and_return([mock_property]) get :index assigns[:properties].should == [mock_property] end end But I having this error: NoMethodError in 'PropertiesController responding to GET index should expose all properties of given user as @properties' You have a nil object when you didn't expect it! The error occurred while evaluating nil.properties /Users/daniellopes/Trabalhos/luvima/luvima/app/controllers/properties_controller.rb:8:in `index' ./spec/controllers/properties_controller_spec.rb:21: So, how is the right way to mock associated records? Thanks. Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Dec 5 08:58:36 2008 From: lists at ruby-forum.com (Newman Huang) Date: Fri, 5 Dec 2008 14:58:36 +0100 Subject: [rspec-users] proxy associantion on controllers In-Reply-To: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> References: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> Message-ID: try: #@user = User.find(params[:user_id]) User.stub(:find).with(xx).and_return(@user) -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Dec 5 09:02:23 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 5 Dec 2008 08:02:23 -0600 Subject: [rspec-users] proxy associantion on controllers In-Reply-To: References: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> Message-ID: <57c63afe0812050602x30d3fba8pefe7a99d9ccbcbfc@mail.gmail.com> On Fri, Dec 5, 2008 at 7:58 AM, Newman Huang wrote: > > try: > > #@user = User.find(params[:user_id]) > User.stub(:find).with(xx).and_return(@user) Please quote enough of the email to which you are responding to provide enough context so that those of us who read email on our phones can understand. Cheers, David From danielvlopes at gmail.com Fri Dec 5 09:07:37 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Fri, 5 Dec 2008 12:07:37 -0200 Subject: [rspec-users] proxy associantion on controllers In-Reply-To: References: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> Message-ID: <992995550812050607n157692dfkae4772cde9c11d1c@mail.gmail.com> Thanks Newman, I already try this but get strange error: before do @current_user = mock_model(User, :id => 1) controller.stub!(:check_administrator_role).and_return(true) User.stub(:find).with(1).and_return(@user) # <=<=<=<=<=<= end The error: undefined method `stub' for # Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Fri, Dec 5, 2008 at 11:58 AM, Newman Huang wrote: > > try: > > #@user = User.find(params[:user_id]) > User.stub(:find).with(xx).and_return(@user) > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From josephwilk at joesniff.co.uk Fri Dec 5 09:15:55 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Fri, 05 Dec 2008 14:15:55 +0000 Subject: [rspec-users] proxy associantion on controllers In-Reply-To: <992995550812050607n157692dfkae4772cde9c11d1c@mail.gmail.com> References: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> <992995550812050607n157692dfkae4772cde9c11d1c@mail.gmail.com> Message-ID: <4939379B.4030809@joesniff.co.uk> Daniel Lopes wrote: > Thanks Newman, I already try this but get strange error: > > before do > @current_user = mock_model(User, :id => 1) > controller.stub!(:check_administrator_role).and_return(true) > User.stub(:find).with(1).and_return(@user) # <=<=<=<=<=<= Looks like a missing '!': User.stub!(:find).with(1).and_return(@user) # <=<=<=<=<=<= -- Joseph Wilk > end > > The error: > undefined method `stub' for # > > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > On Fri, Dec 5, 2008 at 11:58 AM, Newman Huang > wrote: > > > try: > > #@user = User.find(params[:user_id]) > User.stub(:find).with(xx).and_return(@user) > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > 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 Dec 5 09:16:55 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 5 Dec 2008 08:16:55 -0600 Subject: [rspec-users] proxy associantion on controllers In-Reply-To: <992995550812050607n157692dfkae4772cde9c11d1c@mail.gmail.com> References: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> <992995550812050607n157692dfkae4772cde9c11d1c@mail.gmail.com> Message-ID: <57c63afe0812050616i4ae6e59cq3289a3161c40a4de@mail.gmail.com> On Fri, Dec 5, 2008 at 8:07 AM, Daniel Lopes wrote: > Thanks Newman, I already try this but get strange error: > before do > @current_user = mock_model(User, :id => 1) > controller.stub!(:check_administrator_role).and_return(true) > User.stub(:find).with(1).and_return(@user) # <=<=<=<=<=<= It's stub!, not stub :) Cheers, David > end > The error: > undefined method `stub' for # > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > On Fri, Dec 5, 2008 at 11:58 AM, Newman Huang wrote: >> >> try: >> >> #@user = User.find(params[:user_id]) >> User.stub(:find).with(xx).and_return(@user) >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> 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 jeff.a.talbot at gmail.com Fri Dec 5 09:32:23 2008 From: jeff.a.talbot at gmail.com (Jeff Talbot) Date: Fri, 5 Dec 2008 08:32:23 -0600 Subject: [rspec-users] Database.truncate_all Message-ID: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> There is a seemingly very useful line of code in the cucumber wiki that I'd like to use: After do # Scenario teardown Database.truncate_all end (from http://github.com/aslakhellesoy/cucumber/wikis/migration-from-rspec-stories) But when I run this I get an uninitialized constant error for "Database". Anybody know if/how I can make this call? Is there something I need to require? Is there a different way of doing this now? I have a need to not use transactional_fixtures for a specific suite of tests and I want to clear out the database after every run so my tests are isolated. Thanks, Jeff From danielvlopes at gmail.com Fri Dec 5 10:06:56 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Fri, 5 Dec 2008 13:06:56 -0200 Subject: [rspec-users] proxy associantion on controllers In-Reply-To: <57c63afe0812050616i4ae6e59cq3289a3161c40a4de@mail.gmail.com> References: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> <992995550812050607n157692dfkae4772cde9c11d1c@mail.gmail.com> <57c63afe0812050616i4ae6e59cq3289a3161c40a4de@mail.gmail.com> Message-ID: <992995550812050706v399c87fbt4345c0152a7d16ab@mail.gmail.com> Thanks for help and sorry for insistance but I don't understand aspects on rspec ( I think not understand how we use mocks and stubs): The behavior of my controller is... Before Filter: check_administrator_role load_user So, in this case I want run my before filter methods in before block on rspec, like below: describe PropertiesController do def mock_property(stubs={}) @mock_property ||= mock_model(Property, stubs) end before do @current_user = mock_model(User, :id => 1) <== define a current_user with id 1 controller.stub!(:check_administrator_role).and_return(true) <== and current_user is administrator @params = {:user_id=>1} <== define params User.stub!(:find).with(@params[:user_id]).and_return(@user) <== and now try fetch the user with id 1 end This line will define @user variable, right? User.stub!(:find).with(@params[:user_id]).and_return(@user) But I don't need mock the @user variable to fill it with valid values ( like user_id, name, email and etc ) ? I think @user content is nil and get errors from will_paginate find method for this reason. describe "responding to GET index" do it "should expose all properties of given user as @properties" do @user.should_receive(:properties).and_return([mock_property]) get :index assigns[:properties].should == [mock_property] end end thanks. Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Fri, Dec 5, 2008 at 12:16 PM, David Chelimsky wrote: > On Fri, Dec 5, 2008 at 8:07 AM, Daniel Lopes > wrote: > > Thanks Newman, I already try this but get strange error: > > before do > > @current_user = mock_model(User, :id => 1) > > controller.stub!(:check_administrator_role).and_return(true) > > User.stub(:find).with(1).and_return(@user) # <=<=<=<=<=<= > > It's stub!, not stub :) > > Cheers, > David > > > end > > The error: > > undefined method `stub' for # > > > > Atenciosamente, > > > > Daniel Lopes ? Area Cria??es > > Design, Websites e Sistemas Web > > > > Visite: http://www.areacriacoes.com.br/projects > > http://blog.areacriacoes.com.br/ > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > > * > > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > > > > On Fri, Dec 5, 2008 at 11:58 AM, Newman Huang > wrote: > >> > >> try: > >> > >> #@user = User.find(params[:user_id]) > >> User.stub(:find).with(xx).and_return(@user) > >> -- > >> Posted via http://www.ruby-forum.com/. > >> _______________________________________________ > >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Dec 5 10:47:36 2008 From: lists at ruby-forum.com (James Byrne) Date: Fri, 5 Dec 2008 16:47:36 +0100 Subject: [rspec-users] stepping across features In-Reply-To: <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> Message-ID: <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> Andrew Premdas wrote: > James, ... > > So back to your original question where does all the detail go? Well > acceptance tests start from the general and go to the specific, so > detail comes further down some sort of heirarchy. Thing is you > haven't got a hierarchy yet so you don't know where to put things. ... As I learn best from examples, let us consider a fairly common feature of a business application: Feature: Produce Invoices In Order to: Bill Chargeable Work An Invoicing Clerk Should be able to Produce Invoices To Increase Revenue Scenario: Work Order completed Given work order "X" for client "Y" And work order "X" is completed And work order "X" has "N" unbilled charges And "all" charges have been released for billing When I view work order "X" Then I should see "N" unbilled charges And I should be able to select "all" unbilled charges And I should add "N" charges to a new invoice And the new invoice should have a unique transaction number "Q" And invoice "Q" should have client "Y" as the bill to party ...etc. Scenario: Work Order open Given work order "X" for client "Y" And work order "X" is not complete And work order "X" has "N" unbilled charges And "M" charges have been released for billing When I view the work order Then I should see "M" unbilled charges And I should be able to select "M" unbilled charges ... etc. Now, we have two cases, an open and a closed work order, both producing new invoices. How does one proceed to decompose this to also cover the case where one adds the charges to an existing, open, invoice; or the case where "N" billable charges are listed but only "N"-"M" charges are to be billed? Do you create more scenarios in the existing feature file or create new feature files for these scenarios? If the former then how does one avoid having scenarios that themselves are filled with compound conditional statements; or. is this OK? If the latter, how then does one relate high level feature files with their descendants? Similarly, how much detail goes into the creation of an invoice in this case? Do you break out invoices features into specifying the bill-to party, forms of items to add to the invoice body, payment terms, tax calculations, etc.? Are these individual features? I realize that this is a styling issue but the spectre of Worf/Sapir haunts such choices. -- Posted via http://www.ruby-forum.com/. From apremdas at gmail.com Fri Dec 5 11:42:53 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 5 Dec 2008 16:42:53 +0000 Subject: [rspec-users] stepping across features In-Reply-To: <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> Message-ID: <88fd8ddc0812050842ne7a213xbaa9b75f5837c1ce@mail.gmail.com> Pretty hard for me to comment with so much stuff and so little context. However :) Your telling an epic story involving work orders, charges (unbilled released and billed), invoices and transactions. So what are all these things and what is the business value of them, can we right more focused and simpler scenarios. Perhaps if we do stuff to create work orders we will get steps we can nest so we can create a step like Given a work order with outstanding charges So we get better tools to deal with our more complicated scenarios as we go along Each scenario should be about one thing Work Order Completed has all sorts of things going on with it so the scenario needs to be split up into smaller ones Your feature says its about "producing invoices" yet it seems to be all about work orders You've got lots of assumptions about how things are done, I can almost see the legacy application in front of you. Why should you have to even think about a work order to produce invoices. You have to do some design and thinking to produce good features. Challenge assumptions and try and see things from different view points. For example why can't I just do Given outstanding payments When I visit the make invoices page I should see a list of invoices I can create And then do some other little scenarios to create an invoice etc.. HTH Andrew 2008/12/5 James Byrne > Andrew Premdas wrote: > > James, > ... > > > > So back to your original question where does all the detail go? Well > > acceptance tests start from the general and go to the specific, so > > detail comes further down some sort of heirarchy. Thing is you > > haven't got a hierarchy yet so you don't know where to put things. > ... > > As I learn best from examples, let us consider a fairly common feature > of a business application: > > > Feature: Produce Invoices > In Order to: Bill Chargeable Work > An Invoicing Clerk > Should be able to Produce Invoices > To Increase Revenue > > Scenario: Work Order completed > > Given work order "X" for client "Y" > And work order "X" is completed > And work order "X" has "N" unbilled charges > And "all" charges have been released for billing > When I view work order "X" > Then I should see "N" unbilled charges > And I should be able to select "all" unbilled charges > And I should add "N" charges to a new invoice > And the new invoice should have a unique transaction number "Q" > And invoice "Q" should have client "Y" as the bill to party > ...etc. > > Scenario: Work Order open > > Given work order "X" for client "Y" > And work order "X" is not complete > And work order "X" has "N" unbilled charges > And "M" charges have been released for billing > When I view the work order > Then I should see "M" unbilled charges > And I should be able to select "M" unbilled charges > ... etc. > > > Now, we have two cases, an open and a closed work order, both producing > new invoices. How does one proceed to decompose this to also cover the > case where one adds the charges to an existing, open, invoice; or the > case where "N" billable charges are listed but only "N"-"M" charges are > to be billed? Do you create more scenarios in the existing feature > file or create new feature files for these scenarios? If the former > then how does one avoid having scenarios that themselves are filled with > compound conditional statements; or. is this OK? If the latter, how > then does one relate high level feature files with their descendants? > > Similarly, how much detail goes into the creation of an invoice in this > case? Do you break out invoices features into specifying the bill-to > party, forms of items to add to the invoice body, payment terms, tax > calculations, etc.? Are these individual features? > > I realize that this is a styling issue but the spectre of Worf/Sapir > haunts such choices. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Fri Dec 5 11:47:37 2008 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 5 Dec 2008 11:47:37 -0500 Subject: [rspec-users] Rails project as a template for other projects (off topic) In-Reply-To: <88fd8ddc0812042251i2c6ecd8bu506dbb88d9d10c8e@mail.gmail.com> References: <88fd8ddc0812041034m537460cta8ace230d4140d71@mail.gmail.com> <5A95B892-7D27-45E2-9CD8-89BA2F2DB25A@railsnewbie.com> <88fd8ddc0812042251i2c6ecd8bu506dbb88d9d10c8e@mail.gmail.com> Message-ID: On 2008-12-05, at 01:51, Andrew Premdas wrote: > Scott > > Working on this, assuming I have a cloned project 'foo' from my base > project base and I'm working on foo. So I implement something new > and then think this should be in base any ideas how to manage this. > Was thinking maybe of having a base branch which would be the only > thing I pushed up to the base project. Any thoughts? > > Andrew Hi Andrew. I'd use git-format-patch to generate one or more patches from Project Foo that contain the changes that you want to incorporate into your base project. Then, it's simply a matter of applying those patches to the base project, and sorting out any conflicts. Cheers, Nick From nick at deadorange.com Fri Dec 5 12:55:14 2008 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 5 Dec 2008 12:55:14 -0500 Subject: [rspec-users] proxy associantion on controllers In-Reply-To: <992995550812050706v399c87fbt4345c0152a7d16ab@mail.gmail.com> References: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> <992995550812050607n157692dfkae4772cde9c11d1c@mail.gmail.com> <57c63afe0812050616i4ae6e59cq3289a3161c40a4de@mail.gmail.com> <992995550812050706v399c87fbt4345c0152a7d16ab@mail.gmail.com> Message-ID: <3B041B5A-7378-43EC-A7CD-7E4661F10E94@deadorange.com> On 2008-12-05, at 10:06, Daniel Lopes wrote: > Thanks for help and sorry for insistance but I don't understand > aspects on rspec ( I think not understand how we use mocks and stubs): Hi Daniel. If you're a bit unsure about when to use mocks vs stubs, have a read of this article by Martin Fowler: http://martinfowler.com/articles/mocksArentStubs.html The short version of that article is: -You mock objects: @photo = mock_model Photo -You stub methods: @photo.stub!(:height).and_return(123) > The behavior of my controller is... > Before Filter: > check_administrator_role > load_user Are you using Authlogic? > So, in this case I want run my before filter methods in before block > on rspec, like below: Nope! =) before-filters are called when a controller action is called; they aren't called in your specs' "before" blocks. > describe PropertiesController do > def mock_property(stubs={}) > @mock_property ||= mock_model(Property, stubs) > end > > before do > @current_user = mock_model(User, :id => 1) <== define a > current_user with id 1 > controller.stub!(:check_administrator_role).and_return(true) <== > and current_user is administrator > @params = {:user_id=>1} <== define params > User.stub!(:find).with(@params[:user_id]).and_return(@user) <== > and now try fetch the user with id 1 > end Keep in mind that it's before :each do or before :all do > This line will define @user variable, right? > User.stub!(:find).with(@params[:user_id]).and_return(@user) That line above tells the User class to return @user when #find is called on it with the argument @params[:user_id] . You don't need to create a "params" variable. Eg: before :each do @user = mock_model User controller.stub!(:check_administrator_role).and_return(true) User.stub!(:find).and_return @user end > But I don't need mock the @user variable to fill it with valid > values ( like user_id, name, email and etc ) ? If you want those methods, you'd stub them on @user, like this: @user = mock_model User, :name => 'Bob' or like this: @user = mock_model User # ..some other code here.. @user.stub!(:name).with(no_args).and_return('Bob') > describe "responding to GET index" do > it "should expose all properties of given user as @properties" do > @user.should_receive(:properties).and_return([mock_property]) > get :index > assigns[:properties].should == [mock_property] > end > end That looks about right. -Nick From nick at deadorange.com Fri Dec 5 13:06:00 2008 From: nick at deadorange.com (Nick Hoffman) Date: Fri, 5 Dec 2008 13:06:00 -0500 Subject: [rspec-users] NameError when passing a URL helper to a method In-Reply-To: References: <85d99afe0812041406ka146fa9ydb9b41277798caca@mail.gmail.com> Message-ID: <0CF9BF24-D01A-4B54-94DD-BB7FF8519176@deadorange.com> On 2008-12-04, at 19:56, Pat Maddox wrote: > Nick Hoffman writes: >> On 2008-12-04, at 17:43, Nick Hoffman wrote: >>> The only solution that I can think of is to do this: >>> before :each do >>> @account_url = account_url >>> end >>> it_should_redirect_to 'the account page', @account_url >> >> Actually, that suggestion above of mine doesn't work. It fails with: >> You have a nil object when you didn't expect it! >> The error occurred while evaluating nil.rewrite >> (eval):17:in `account_url' >> >> I thought of it while writing that last email, but didn't test it >> before hitting send. >> -Nick >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > It's the same as > > class Foo > @class_instance_variable = "blah" > > def foo > puts @class_instance_variable > end > end > > Foo.foo will print nothing, because @class_instance_variable is nil in > the object instance. > > Anyway, I thought of an even cleaner way to do things than using a > block, assuming you only care about calling one method: > > do_something(:blah_url_helper) > > def do_something(helper_name) > send(helper_name) > end > > Pat Hi Pat. That's a great suggestion. Here's what I ended up doing: http://gist.github.com/32424 Thanks, Nick From chris at cobaltedge.com Fri Dec 5 14:21:26 2008 From: chris at cobaltedge.com (Christopher Bailey) Date: Fri, 5 Dec 2008 11:21:26 -0800 Subject: [rspec-users] View tests and fragment caching issue Message-ID: <443c240c0812051121g52dcd0a9u7f4633c4108cc758@mail.gmail.com> I hope I'm just missing something obvious here, but I am using fragment caching in a partial for a view. I test this view with an RSpec view test. The particular test is using "real" data (i.e. not mocked objects, etc.). When I run the test, it complains about not knowing of a route for the fragment. The fragment parameter should be that though, a query param, not part of a path, etc. Anyway, here's what I see for the error: No route matches {:action=>"index", :fragment=>"similar_deals"} The partial has the following caching line in it: <% cache({:fragment => 'similar_deals'}, :expires_in => 24.hours) do %> Can someone point me in the right direction for how to deal with this? -- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Dec 5 14:52:06 2008 From: lists at ruby-forum.com (James Byrne) Date: Fri, 5 Dec 2008 20:52:06 +0100 Subject: [rspec-users] stepping across features In-Reply-To: <88fd8ddc0812050842ne7a213xbaa9b75f5837c1ce@mail.gmail.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> <88fd8ddc0812050842ne7a213xbaa9b75f5837c1ce@mail.gmail.com> Message-ID: <51f2f3c0c0cc4ad38c70b2b20c140b33@ruby-forum.com> Andrew Premdas wrote: > Pretty hard for me to comment with so much stuff and so little context. > However :) My messages are quite long enough as it is I am afraid. > about a work order to produce invoices. You have to do some design and > thinking to produce good features. Challenge assumptions and try and see > things from different view points. For example why can't I just do > > Given outstanding payments > When I visit the make invoices page > I should see a list of invoices I can create > > And then do some other little scenarios to create an invoice etc.. > > HTH It always helps to have another point of view. I am grappling with this issue mentally before committing myself to a line of approach. This project is, as you surmise, a conversion of an existing body of work into a new form. It is also anticipated that the existing application will be extended in many areas. The scope of the project encompasses everything from General Ledger down to edi transmission of tax documents to the federal government. I am trying to determine whether the way to control and document this project while focusing programming activity is best served by using BDD features or whether those objectives should be satisfied otherwise and BDD features only used for specific implementation issues. Part of my difficulty is my limited vocabulary for expressing this and part is my want of experience with this form of design and development. My previous experience was with much less sophisticated tools than I am currently using and I am reluctant to turn a scalpel into a screwdriver out of ignorance on my part. On the other hand, if a jack hammer is needed then a scalpel is not of much use. So reworking my earlier effort: Feature: Bill chargeable work In Order To generate income A Billing Clerk Should be able to create invoices To Increase Revenue Scenario: Manual Invoice Release Given billable charges When I visit the create an invoice page Then I should see a list of all billable charges Scenario: Manual Invoice Release by Client Given billable charges When I visit the create an invoice page And I search for client "Y" Then I should see a list of all billable charges only for client "Y" Is this getting closer to what my features should look like? -- Posted via http://www.ruby-forum.com/. From ashley.moran at patchspace.co.uk Fri Dec 5 15:16:32 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 5 Dec 2008 20:16:32 +0000 Subject: [rspec-users] problem to mock association proxy In-Reply-To: <992995550812050542j17386874x2791cf76a8abd844@mail.gmail.com> References: <992995550812050542j17386874x2791cf76a8abd844@mail.gmail.com> Message-ID: On 5 Dec 2008, at 13:42, Daniel Lopes wrote: > NoMethodError in 'PropertiesController responding to GET index > should expose all properties of given user as @properties' > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.properties > /Users/daniellopes/Trabalhos/luvima/luvima/app/controllers/ > properties_controller.rb:8:in `index' > ./spec/controllers/properties_controller_spec.rb:21: > > So, how is the right way to mock associated records? Hi Daniel The error you are seeing is because the assignment to @user happens inside #load_user: the live code never call` `@user = load_user`. As far as possible, you want to avoid modifying objects under test - private methods are only the business of instances of that class. It's much safer in this case to do User.should_receive(:find).and_return(@user) That way, the filter will run as normal. As for the association - it's actually irrelevant what that returns. All you care is that whatever comes out of `@user.properties` is assingned to the view. I tend to use symbols to represent objects (including arrays) that get passed around. For example: describe PropertiesController do # Not needed # def mock_property(stubs={}) # @mock_property ||= mock_model(Property, stubs) # end before do controller.stub!(:check_administrator_role).and_return(true) @user = mock_model(User, :id=>1, :properties => :user_properties) User.stub!(:find).and_return(@user) end describe "responding to GET index" do it "should expose all properties of given user as @properties" do get :index assigns[:properties].should == :user_properties end end end HTH Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From danielvlopes at gmail.com Fri Dec 5 15:19:07 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Fri, 5 Dec 2008 18:19:07 -0200 Subject: [rspec-users] proxy associantion on controllers In-Reply-To: <3B041B5A-7378-43EC-A7CD-7E4661F10E94@deadorange.com> References: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> <992995550812050607n157692dfkae4772cde9c11d1c@mail.gmail.com> <57c63afe0812050616i4ae6e59cq3289a3161c40a4de@mail.gmail.com> <992995550812050706v399c87fbt4345c0152a7d16ab@mail.gmail.com> <3B041B5A-7378-43EC-A7CD-7E4661F10E94@deadorange.com> Message-ID: <992995550812051219i25e673aakad9ab088d8fe4080@mail.gmail.com> Thanks a lot Nick... No, i'm not using Authlogic because already have base project with restful_authentication implemented with activation, roles and etc... and when I look authlogic the project was young, I don't know now. About Martin Fowler post, I already readed... but the problem is because I know the diference between mocks and stubs ( mocks really call the method and it fail return a error, and stubs only return the result without check real method, right? ) but I don't know how use it in RSpec... I'm starting understand now in this post ( my idea is copy this thread and translate to portuguese to help more people)... My doubt about mock and stubs is when I write this: @user = mock_model User => create mock object based on User and put in @user. but when I write the code below, the method User.name will not be called in this moment, but will be called when User class try to call name and will return 'Bob' no matter what the real name method does... is this? @user.stub!(:name).and_return('Bob') About my previous code... I mocked User in instance variable @user but I have will_paginate installed and this bring a strange error when I try: @user.sohuld_receive(:properties).and_return([mock_property]) The error is: 1) NoMethodError in 'PropertiesController responding to GET index should expose all properties of given user as @properties' undefined method `find' for # /Users/daniellopes/Trabalhos/luvima/luvima/vendor/gems/mislav-will_paginate-2.3.6/lib/will_paginate/finder.rb:167:in `method_missing' /Users/daniellopes/Trabalhos/luvima/luvima/app/controllers/properties_controller.rb:61:in `load_user' ./spec/controllers/properties_controller_spec.rb:20: spec/controllers/sessions_controller_spec.rb:102: My spec code is: describe PropertiesController do def mock_property(stubs={}) @mock_property ||= mock_model(Property, stubs) end before :each do @current_user = mock_model(User, :id => 1) controller.stub!(:check_administrator_role).and_return(true) User.stub!(:find).and_return(@user) end describe "responding to GET index" do it "should expose all properties of given user as @properties" do @user.should_receive(:properties).and_return([mock_property]) get :index assigns[:properties].should == [mock_property] end end And my controller code where error refer is: private def load_user @user = User.find(params[:user_id]) if @user.nil? flash[:notice] = "Registro não encontrado" redirect_to root_path end end Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Fri, Dec 5, 2008 at 3:55 PM, Nick Hoffman wrote: > On 2008-12-05, at 10:06, Daniel Lopes wrote: > >> Thanks for help and sorry for insistance but I don't understand aspects on >> rspec ( I think not understand how we use mocks and stubs): >> > > Hi Daniel. If you're a bit unsure about when to use mocks vs stubs, have a > read of this article by Martin Fowler: > http://martinfowler.com/articles/mocksArentStubs.html > > The short version of that article is: > -You mock objects: @photo = mock_model Photo > -You stub methods: @photo.stub!(:height).and_return(123) > > The behavior of my controller is... >> Before Filter: >> check_administrator_role >> load_user >> > > Are you using Authlogic? > > So, in this case I want run my before filter methods in before block on >> rspec, like below: >> > > Nope! =) before-filters are called when a controller action is called; > they aren't called in your specs' "before" blocks. > > describe PropertiesController do >> def mock_property(stubs={}) >> @mock_property ||= mock_model(Property, stubs) >> end >> >> before do >> @current_user = mock_model(User, :id => 1) <== define a current_user >> with id 1 >> controller.stub!(:check_administrator_role).and_return(true) <== and >> current_user is administrator >> @params = {:user_id=>1} <== define params >> User.stub!(:find).with(@params[:user_id]).and_return(@user) <== and now >> try fetch the user with id 1 >> end >> > > Keep in mind that it's > before :each do > or > before :all do > > This line will define @user variable, right? >> User.stub!(:find).with(@params[:user_id]).and_return(@user) >> > > That line above tells the User class to return @user when #find is called > on it with the argument @params[:user_id] . > > You don't need to create a "params" variable. Eg: > > before :each do > @user = mock_model User > controller.stub!(:check_administrator_role).and_return(true) > User.stub!(:find).and_return @user > end > > But I don't need mock the @user variable to fill it with valid values ( >> like user_id, name, email and etc ) ? >> > > If you want those methods, you'd stub them on @user, like this: > @user = mock_model User, :name => 'Bob' > or like this: > @user = mock_model User > # ..some other code here.. > @user.stub!(:name).with(no_args).and_return('Bob') > > describe "responding to GET index" do >> it "should expose all properties of given user as @properties" do >> @user.should_receive(:properties).and_return([mock_property]) >> get :index >> assigns[:properties].should == [mock_property] >> end >> end >> > > That looks about right. > -Nick > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at areacriacoes.com.br Fri Dec 5 15:26:44 2008 From: danielvlopes at areacriacoes.com.br (=?ISO-8859-1?Q?Daniel_Area_Cria=E7=F5es?=) Date: Fri, 5 Dec 2008 18:26:44 -0200 Subject: [rspec-users] problem to mock association proxy In-Reply-To: References: <992995550812050542j17386874x2791cf76a8abd844@mail.gmail.com> Message-ID: <992995550812051226o23ba77c2i1f736d523c2b46ff@mail.gmail.com> Thanks Ashley, now the tests passed... but I want understand one thing: This line is only saying that @properties (assigned[:properties]) have some value ... is that? assigns[:properties].should == :user_properties I can change above to assigns[:properties].should_not be_nill and the semantic value will be the same, right? Thanks... Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Fri, Dec 5, 2008 at 6:16 PM, Ashley Moran wrote: > > On 5 Dec 2008, at 13:42, Daniel Lopes wrote: > > NoMethodError in 'PropertiesController responding to GET index should >> expose all properties of given user as @properties' >> You have a nil object when you didn't expect it! >> The error occurred while evaluating nil.properties >> /Users/daniellopes/Trabalhos/luvima/luvima/app/controllers/properties_controller.rb:8:in >> `index' >> ./spec/controllers/properties_controller_spec.rb:21: >> >> So, how is the right way to mock associated records? >> > > Hi Daniel > > The error you are seeing is because the assignment to @user happens inside > #load_user: the live code never call` `@user = load_user`. As far as > possible, you want to avoid modifying objects under test - private methods > are only the business of instances of that class. It's much safer in this > case to do > > User.should_receive(:find).and_return(@user) > > That way, the filter will run as normal. > > As for the association - it's actually irrelevant what that returns. All > you care is that whatever comes out of `@user.properties` is assingned to > the view. I tend to use symbols to represent objects (including arrays) > that get passed around. For example: > > describe PropertiesController do > > # Not needed > # def mock_property(stubs={}) > # @mock_property ||= mock_model(Property, stubs) > # end > > before do > controller.stub!(:check_administrator_role).and_return(true) > @user = mock_model(User, :id=>1, :properties => :user_properties) > User.stub!(:find).and_return(@user) > end > > describe "responding to GET index" do > it "should expose all properties of given user as @properties" do > get :index > assigns[:properties].should == :user_properties > end > end > > end > > HTH > > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at gmail.com Fri Dec 5 15:31:52 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Fri, 5 Dec 2008 18:31:52 -0200 Subject: [rspec-users] proxy associantion on controllers In-Reply-To: <992995550812051219i25e673aakad9ab088d8fe4080@mail.gmail.com> References: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> <992995550812050607n157692dfkae4772cde9c11d1c@mail.gmail.com> <57c63afe0812050616i4ae6e59cq3289a3161c40a4de@mail.gmail.com> <992995550812050706v399c87fbt4345c0152a7d16ab@mail.gmail.com> <3B041B5A-7378-43EC-A7CD-7E4661F10E94@deadorange.com> <992995550812051219i25e673aakad9ab088d8fe4080@mail.gmail.com> Message-ID: <992995550812051231v31dd6390pe39b4f58c118df71@mail.gmail.com> Ashley Moran gave me help in another post that I open by accident when entries in the group, and now spec passed... But I still would like to understand more about mocks and stubs that I asked in previous email. Thanks again and sorry many emails. Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Fri, Dec 5, 2008 at 6:19 PM, Daniel Lopes wrote: > Thanks a lot Nick... > No, i'm not using Authlogic because already have base project with > restful_authentication implemented with activation, roles and etc... and > when I look authlogic the project was young, I don't know now. > > About Martin Fowler post, I already readed... but the problem is because I > know the diference between mocks and stubs ( mocks really call the method > and it fail return a error, and stubs only return the result without check > real method, right? ) but I don't know how use it in RSpec... > > I'm starting understand now in this post ( my idea is copy this thread and > translate to portuguese to help more people)... My doubt about mock and > stubs is when I write this: > > @user = mock_model User => create mock object based on User and put in > @user. > > but when I write the code below, the method User.name will not be called in > this moment, but will be called when User class try to call name and will > return 'Bob' no matter what the real name method does... is this? > @user.stub!(:name).and_return('Bob') > > > About my previous code... I mocked User in instance variable @user but I > have will_paginate installed and this bring a strange error when I try: > @user.sohuld_receive(:properties).and_return([mock_property]) > > The error is: > > 1) > NoMethodError in 'PropertiesController responding to GET index should > expose all properties of given user as @properties' > undefined method `find' for # > /Users/daniellopes/Trabalhos/luvima/luvima/vendor/gems/mislav-will_paginate-2.3.6/lib/will_paginate/finder.rb:167:in > `method_missing' > /Users/daniellopes/Trabalhos/luvima/luvima/app/controllers/properties_controller.rb:61:in > `load_user' > ./spec/controllers/properties_controller_spec.rb:20: > spec/controllers/sessions_controller_spec.rb:102: > > My spec code is: > > describe PropertiesController do > > def mock_property(stubs={}) > @mock_property ||= mock_model(Property, stubs) > end > > before :each do > @current_user = mock_model(User, :id => 1) > controller.stub!(:check_administrator_role).and_return(true) > User.stub!(:find).and_return(@user) > end > > describe "responding to GET index" do > > it "should expose all properties of given user as @properties" do > @user.should_receive(:properties).and_return([mock_property]) > get :index > assigns[:properties].should == [mock_property] > end > > end > > > And my controller code where error refer is: > > private > def load_user > @user = User.find(params[:user_id]) > if @user.nil? > flash[:notice] = "Registro não encontrado" > redirect_to root_path > end > end > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > On Fri, Dec 5, 2008 at 3:55 PM, Nick Hoffman wrote: > >> On 2008-12-05, at 10:06, Daniel Lopes wrote: >> >>> Thanks for help and sorry for insistance but I don't understand aspects >>> on rspec ( I think not understand how we use mocks and stubs): >>> >> >> Hi Daniel. If you're a bit unsure about when to use mocks vs stubs, have a >> read of this article by Martin Fowler: >> http://martinfowler.com/articles/mocksArentStubs.html >> >> The short version of that article is: >> -You mock objects: @photo = mock_model Photo >> -You stub methods: @photo.stub!(:height).and_return(123) >> >> The behavior of my controller is... >>> Before Filter: >>> check_administrator_role >>> load_user >>> >> >> Are you using Authlogic? >> >> So, in this case I want run my before filter methods in before block on >>> rspec, like below: >>> >> >> Nope! =) before-filters are called when a controller action is called; >> they aren't called in your specs' "before" blocks. >> >> describe PropertiesController do >>> def mock_property(stubs={}) >>> @mock_property ||= mock_model(Property, stubs) >>> end >>> >>> before do >>> @current_user = mock_model(User, :id => 1) <== define a current_user >>> with id 1 >>> controller.stub!(:check_administrator_role).and_return(true) <== and >>> current_user is administrator >>> @params = {:user_id=>1} <== define params >>> User.stub!(:find).with(@params[:user_id]).and_return(@user) <== and >>> now try fetch the user with id 1 >>> end >>> >> >> Keep in mind that it's >> before :each do >> or >> before :all do >> >> This line will define @user variable, right? >>> User.stub!(:find).with(@params[:user_id]).and_return(@user) >>> >> >> That line above tells the User class to return @user when #find is called >> on it with the argument @params[:user_id] . >> >> You don't need to create a "params" variable. Eg: >> >> before :each do >> @user = mock_model User >> controller.stub!(:check_administrator_role).and_return(true) >> User.stub!(:find).and_return @user >> end >> >> But I don't need mock the @user variable to fill it with valid values ( >>> like user_id, name, email and etc ) ? >>> >> >> If you want those methods, you'd stub them on @user, like this: >> @user = mock_model User, :name => 'Bob' >> or like this: >> @user = mock_model User >> # ..some other code here.. >> @user.stub!(:name).with(no_args).and_return('Bob') >> >> describe "responding to GET index" do >>> it "should expose all properties of given user as @properties" do >>> @user.should_receive(:properties).and_return([mock_property]) >>> get :index >>> assigns[:properties].should == [mock_property] >>> end >>> end >>> >> >> That looks about right. >> -Nick >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ashley.moran at patchspace.co.uk Fri Dec 5 15:41:31 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 5 Dec 2008 20:41:31 +0000 Subject: [rspec-users] problem to mock association proxy In-Reply-To: <992995550812051226o23ba77c2i1f736d523c2b46ff@mail.gmail.com> References: <992995550812050542j17386874x2791cf76a8abd844@mail.gmail.com> <992995550812051226o23ba77c2i1f736d523c2b46ff@mail.gmail.com> Message-ID: On 5 Dec 2008, at 20:26, Daniel Area Cria??es wrote: > This line is only saying that @properties (assigned[:properties]) > have some value ... is that? > assigns[:properties].should == :user_properties > > I can change above to assigns[:properties].should_not be_nill and > the semantic value will be the same, right? Ah no, the semantic value is different because this would also pass: def index @properties = "vegetable soup" end Yet that does not implement the same behaviour. When you write a behaviour example, always ask the question "What could I realistically write that could pass this but not give the desired behaviour?" That way you will avoid false confidence in specs where the behaviour could be broken in the future (perhaps during refactoring), but RSpec still reports success. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From danielvlopes at areacriacoes.com.br Fri Dec 5 15:51:20 2008 From: danielvlopes at areacriacoes.com.br (=?ISO-8859-1?Q?Daniel_Area_Cria=E7=F5es?=) Date: Fri, 5 Dec 2008 18:51:20 -0200 Subject: [rspec-users] problem to mock association proxy In-Reply-To: References: <992995550812050542j17386874x2791cf76a8abd844@mail.gmail.com> <992995550812051226o23ba77c2i1f736d523c2b46ff@mail.gmail.com> Message-ID: <992995550812051251yd49ffe9m80927c5751806498@mail.gmail.com> Thanks Ashley, you right. Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Fri, Dec 5, 2008 at 6:41 PM, Ashley Moran wrote: > > On 5 Dec 2008, at 20:26, Daniel Area Cria??es wrote: > > This line is only saying that @properties (assigned[:properties]) have >> some value ... is that? >> assigns[:properties].should == :user_properties >> >> I can change above to assigns[:properties].should_not be_nill and the >> semantic value will be the same, right? >> > > > Ah no, the semantic value is different because this would also pass: > > def index > @properties = "vegetable soup" > end > > Yet that does not implement the same behaviour. > > When you write a behaviour example, always ask the question "What could I > realistically write that could pass this but not give the desired > behaviour?" That way you will avoid false confidence in specs where the > behaviour could be broken in the future (perhaps during refactoring), but > RSpec still reports success. > > > Ashley > > -- > http://www.patchspace.co.uk/ > http://aviewfromafar.net/ > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ashley.moran at patchspace.co.uk Fri Dec 5 15:51:59 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Fri, 5 Dec 2008 20:51:59 +0000 Subject: [rspec-users] proxy associantion on controllers In-Reply-To: <992995550812051231v31dd6390pe39b4f58c118df71@mail.gmail.com> References: <992995550812050541h981b5bblee1272d0f831d949@mail.gmail.com> <992995550812050607n157692dfkae4772cde9c11d1c@mail.gmail.com> <57c63afe0812050616i4ae6e59cq3289a3161c40a4de@mail.gmail.com> <992995550812050706v399c87fbt4345c0152a7d16ab@mail.gmail.com> <3B041B5A-7378-43EC-A7CD-7E4661F10E94@deadorange.com> <992995550812051219i25e673aakad9ab088d8fe4080@mail.gmail.com> <992995550812051231v31dd6390pe39b4f58c118df71@mail.gmail.com> Message-ID: <6A9C24C6-EB5A-4156-964E-5FD1BAA7B2E5@patchspace.co.uk> On 5 Dec 2008, at 20:31, Daniel Lopes wrote: > Ashley Moran gave me help in another post that I open by accident > when entries in the group, and now spec passed... But I still would > like to understand more about mocks and stubs that I asked in > previous email. Yes I just noticed I re-answered a question that was solved hours ago :) Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From srveit at gmail.com Fri Dec 5 16:36:50 2008 From: srveit at gmail.com (Stephen Veit) Date: Fri, 5 Dec 2008 15:36:50 -0600 Subject: [rspec-users] Where to start after writing feature Message-ID: I am trying to develop code from the feature on down. So I created a brand new rails app. It has no models yet. I wrote a feature: Feature: Add tasks In order to track website improvements a user wants to add tasks Scenario: User adds task Given task "Display Group Rules" does not exist When I visit "/tasks/new" And I fill in "Name" with "Display Group Rules" And I fill in "Description" with "Displays links to edit each group rule" And I fill in "CAS Link" with "GroupRulesManager/" And I press "Submit" Then I should end up on the Tasks page And I should see "Task successfully added" And the task "Display Group Rules" should exist I then run: rake db:migrate (this creates my development SQLite3 database) rake db:test:prepare (this creates my development SQLite3 database) rake features (outputs the following:) Feature: Add tasks # features/manage_task.feature In order to track website improvements a user wants to add tasks Scenario: User adds task Given task "Display Group Rules" does not exist When I visit "/tasks/new" And I fill in "Name" with "Display Group Rules" And I fill in "Description" with "Displays links to edit each group rule" And I fill in "CAS Link" with "GroupRulesManager/" And I press "Submit" Then I should end up on the Tasks page And I should see "Task successfully added" And the task "Display Group Rules" should exist 5 steps skipped 4 steps pending You can use these snippets to implement pending steps: Given /^task "Display Group Rules" does not exist$/ do end When /^I visit "\/tasks\/new"$/ do end Then /^I should end up on the Tasks page$/ do end Then /^the task "Display Group Rules" should exist$/ do end My question is where to go from here. Do I implement the four pending steps, e.g: Given /^task "(.+)" does not exist$/ do |name| task = Task.find_by_name(name) task.destroy if task end Or do I run: ./script/generate scaffold_resource task name:string description:text cas_link:string and the rake rspec and fix whatever errors show up there? What are your thoughts? TIA -- Stephen Veit 314-616-9688 -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at gmail.com Fri Dec 5 16:44:59 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Fri, 5 Dec 2008 19:44:59 -0200 Subject: [rspec-users] Where to start after writing feature In-Reply-To: References: Message-ID: <992995550812051344j138fdafbofc3a02f9fb16ce13@mail.gmail.com> I think is better create the step ( it will no work ) and then run script/generate rspec_scaffold Task name:string description:text cas_link:string or if you not using rspec: script/generate scaffold Task name:string description:text cas_link:string Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Fri, Dec 5, 2008 at 7:36 PM, Stephen Veit wrote: > I am trying to develop code from the feature on down. > > So I created a brand new rails app. It has no models yet. I wrote a > feature: > > Feature: Add tasks > In order to track website improvements > a user > wants to add tasks > > Scenario: User adds task > Given task "Display Group Rules" does not exist > When I visit "/tasks/new" > And I fill in "Name" with "Display Group Rules" > And I fill in "Description" with "Displays links to edit each group > rule" > And I fill in "CAS Link" with "GroupRulesManager/" > And I press "Submit" > Then I should end up on the Tasks page > And I should see "Task successfully added" > And the task "Display Group Rules" should exist > > I then run: > > rake db:migrate (this creates my development SQLite3 database) > rake db:test:prepare (this creates my development SQLite3 database) > rake features (outputs the following:) > > Feature: Add tasks # features/manage_task.feature > In order to track website improvements > a user > wants to add tasks > Scenario: User adds task > Given task "Display Group Rules" does not exist > When I visit "/tasks/new" > And I fill in "Name" with "Display Group Rules" > And I fill in "Description" with "Displays links to edit each group > rule" > And I fill in "CAS Link" with "GroupRulesManager/" > And I press "Submit" > Then I should end up on the Tasks page > And I should see "Task successfully added" > And the task "Display Group Rules" should exist > > > 5 steps skipped > 4 steps pending > > You can use these snippets to implement pending steps: > > Given /^task "Display Group Rules" does not exist$/ do > end > > When /^I visit "\/tasks\/new"$/ do > end > > Then /^I should end up on the Tasks page$/ do > end > > Then /^the task "Display Group Rules" should exist$/ do > end > > > My question is where to go from here. Do I implement the four pending > steps, e.g: > > Given /^task "(.+)" does not exist$/ do |name| > task = Task.find_by_name(name) > task.destroy if task > end > > Or do I run: > > ./script/generate scaffold_resource task name:string description:text > cas_link:string > > and the rake rspec and fix whatever errors show up there? > > What are your thoughts? TIA > > -- > Stephen Veit > 314-616-9688 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kero at chello.nl Fri Dec 5 19:04:08 2008 From: kero at chello.nl (Kero van Gelder) Date: Sat, 6 Dec 2008 01:04:08 +0100 Subject: [rspec-users] Cucumber and autospec do not work ? Message-ID: <20081206000408.GF17218@bumblebee.m38c.nl> Hi! I'm not sure this is how cucumber should behave. Should I file one or three tickets at http://rspec.lighthouseapp.com/projects/16211-cucumber ? $ cucumber -v 0.1.12 $ mkdir fresh $ cd fresh $ cucumber cucumber.yml was not found. Please define your 'default' and other profiles in cucumber.yml. Type 'cucumber --help' for usage. $ touch cucumber.yml $ cucumber # bug! should not crash on broken config file /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:146:in `parse_args_from_profile': undefined method `[]' for false:FalseClass (NoMethodError) from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:47:in `parse_options!' from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:20:in `parse' from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:11:in `execute' from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/cucumber:6 from /var/lib/gems/1.8/bin/cucumber:19:in `load' from /var/lib/gems/1.8/bin/cucumber:19 $ echo default: > cucumber.yml $ cucumber # bug! default profile defined but irretrievable Could not find profile: 'default' Defined profiles in cucumber.yml: * default $ echo default: . > cucumber.yml $ vim enlightenment.feature $ cucumber -v # bug! no reason not to use the default profile Ruby files required: Features: $ cucumber -v -i -p default Ruby files required: Features: * ./enlightenment.feature Story: enlightenment # ./enlightenment.feature As a Developer I want to achieve enlightenment So that I can be at peace with my code Scenario: meditation # ./enlightenment.feature:6 When I meditate indefinitely # ./enlightenment.feature:7 Then I achieve enlightenment # ./enlightenment.feature:8 2 steps pending $ __ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From ben at benmabey.com Fri Dec 5 19:14:49 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 05 Dec 2008 17:14:49 -0700 Subject: [rspec-users] Cucumber and autospec do not work ? In-Reply-To: <20081206000408.GF17218@bumblebee.m38c.nl> References: <20081206000408.GF17218@bumblebee.m38c.nl> Message-ID: <4939C3F9.1040705@benmabey.com> Kero van Gelder wrote: > Hi! > > I'm not sure this is how cucumber should behave. > Should I file one or three tickets at http://rspec.lighthouseapp.com/projects/16211-cucumber > ? > Umm... add them separately. I can take at least a couple of them... -Ben > $ cucumber -v > 0.1.12 > > $ mkdir fresh > $ cd fresh > $ cucumber > cucumber.yml was not found. Please define your 'default' and other profiles in cucumber.yml. > Type 'cucumber --help' for usage. > $ touch cucumber.yml > $ cucumber # bug! should not crash on broken config file > /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:146:in `parse_args_from_profile': undefined method `[]' for false:FalseClass (NoMethodError) > from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:47:in `parse_options!' > from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:20:in `parse' > from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:11:in `execute' > from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/cucumber:6 > from /var/lib/gems/1.8/bin/cucumber:19:in `load' > from /var/lib/gems/1.8/bin/cucumber:19 > $ echo default: > cucumber.yml > $ cucumber # bug! default profile defined but irretrievable > Could not find profile: 'default' > > Defined profiles in cucumber.yml: > * default > $ echo default: . > cucumber.yml > $ vim enlightenment.feature > $ cucumber -v # bug! no reason not to use the default profile > Ruby files required: > > Features: > > $ cucumber -v -i -p default > Ruby files required: > > Features: > * ./enlightenment.feature > > Story: enlightenment # ./enlightenment.feature > As a Developer > I want to achieve enlightenment > So that I can be at peace with my code > Scenario: meditation # ./enlightenment.feature:6 > When I meditate indefinitely # ./enlightenment.feature:7 > Then I achieve enlightenment # ./enlightenment.feature:8 > > 2 steps pending > > $ > > > __ > How can I change the world if I can't even change myself? > -- Faithless, Salva Mea > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Dec 5 21:08:52 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 5 Dec 2008 20:08:52 -0600 Subject: [rspec-users] Where to start after writing feature In-Reply-To: References: Message-ID: <57c63afe0812051808n19a05084ybfe2a74ade544b62@mail.gmail.com> On Fri, Dec 5, 2008 at 3:36 PM, Stephen Veit wrote: > I am trying to develop code from the feature on down. > > So I created a brand new rails app. It has no models yet. I wrote a feature: > > Feature: Add tasks > In order to track website improvements > a user > wants to add tasks > > Scenario: User adds task > Given task "Display Group Rules" does not exist > When I visit "/tasks/new" > And I fill in "Name" with "Display Group Rules" > And I fill in "Description" with "Displays links to edit each group > rule" > And I fill in "CAS Link" with "GroupRulesManager/" > And I press "Submit" > Then I should end up on the Tasks page > And I should see "Task successfully added" > And the task "Display Group Rules" should exist > > I then run: > > rake db:migrate (this creates my development SQLite3 database) > rake db:test:prepare (this creates my development SQLite3 database) > rake features (outputs the following:) > > Feature: Add tasks # features/manage_task.feature > In order to track website improvements > a user > wants to add tasks > Scenario: User adds task > Given task "Display Group Rules" does not exist > When I visit "/tasks/new" > And I fill in "Name" with "Display Group Rules" > And I fill in "Description" with "Displays links to edit each group > rule" > And I fill in "CAS Link" with "GroupRulesManager/" > And I press "Submit" > Then I should end up on the Tasks page > And I should see "Task successfully added" > And the task "Display Group Rules" should exist > > > 5 steps skipped > 4 steps pending > > You can use these snippets to implement pending steps: > > Given /^task "Display Group Rules" does not exist$/ do > end > > When /^I visit "\/tasks\/new"$/ do > end > > Then /^I should end up on the Tasks page$/ do > end > > Then /^the task "Display Group Rules" should exist$/ do > end > > > My question is where to go from here. Do I implement the four pending steps, > e.g: > > Given /^task "(.+)" does not exist$/ do |name| > task = Task.find_by_name(name) > task.destroy if task > end > > Or do I run: > > ./script/generate scaffold_resource task name:string description:text > cas_link:string > > and the rake rspec and fix whatever errors show up there? > > What are your thoughts? TIA Hi Stephen, The approach I like to take is to follow the guidance of the system (cucumber + rspec) every step of the way. Right now there are no passing steps, so I'd write the code for the 1st pending step, run the features and find the first thing that is missing or failing. In the example you've provided, I'd very likely write code like what you wrote for the first Given step. I imagine that running that feature would produce an error saying that there is nothing named Task. At that point I've gone in two different directions. The more purist approach would be to create the model at this point - not the scaffold - as that's the only thing you actually need at this moment to progress. I've also made the scaffold at this point. Typically I end up cutting out a bunch of crap I don't need and from time to time I don't clear out all the crap I don't need, discovering later that I've got excess code floating around the system. This is the motivation for avoiding code generation. It's a tradeoff. Either way, once that step is passing (by creating the model or scaffold and then running the migrations), I'd move on to the next step. Just work your way down, one step at a time. As your doing this, if you're using the rspec generators, you'll be generating specs as you go. Any time that you need to actually implement something in the code that is not generated, I'd head to the specs to drive that additional behaviour out at the object level. If you follow this with serious discipline, you'll end up with two concentric cycles that both follow a Red/Green/Refactor cycle, meeting at the Green points. One nice visual analogy for this is a two speed bicycle. The lower gear, the bigger circle, is the Cucumber cycle. You work there until you have a failing step, at which point you shift into high gear, which is the smaller circle, the RSpec cycle. At the point that all specs are passing and the last failing step is now passing, you shift back to low gear (Cucumber) and work there until you have a failing step. Rinse, repeat. This is how I describe this in The RSpec Book, btw, so tell me now if it doesn't make sense :) HTH, David > > -- > Stephen Veit > 314-616-9688 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Fri Dec 5 21:10:57 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 5 Dec 2008 20:10:57 -0600 Subject: [rspec-users] Where to start after writing feature In-Reply-To: <57c63afe0812051808n19a05084ybfe2a74ade544b62@mail.gmail.com> References: <57c63afe0812051808n19a05084ybfe2a74ade544b62@mail.gmail.com> Message-ID: <57c63afe0812051810w6e7b9a61l87c6eda6b415e5ff@mail.gmail.com> On Fri, Dec 5, 2008 at 8:08 PM, David Chelimsky wrote: > On Fri, Dec 5, 2008 at 3:36 PM, Stephen Veit wrote: >> I am trying to develop code from the feature on down. >> >> So I created a brand new rails app. It has no models yet. I wrote a feature: >> >> Feature: Add tasks >> In order to track website improvements >> a user >> wants to add tasks >> >> Scenario: User adds task >> Given task "Display Group Rules" does not exist >> When I visit "/tasks/new" >> And I fill in "Name" with "Display Group Rules" >> And I fill in "Description" with "Displays links to edit each group >> rule" >> And I fill in "CAS Link" with "GroupRulesManager/" >> And I press "Submit" >> Then I should end up on the Tasks page >> And I should see "Task successfully added" >> And the task "Display Group Rules" should exist >> >> I then run: >> >> rake db:migrate (this creates my development SQLite3 database) >> rake db:test:prepare (this creates my development SQLite3 database) >> rake features (outputs the following:) >> >> Feature: Add tasks # features/manage_task.feature >> In order to track website improvements >> a user >> wants to add tasks >> Scenario: User adds task >> Given task "Display Group Rules" does not exist >> When I visit "/tasks/new" >> And I fill in "Name" with "Display Group Rules" >> And I fill in "Description" with "Displays links to edit each group >> rule" >> And I fill in "CAS Link" with "GroupRulesManager/" >> And I press "Submit" >> Then I should end up on the Tasks page >> And I should see "Task successfully added" >> And the task "Display Group Rules" should exist >> >> >> 5 steps skipped >> 4 steps pending >> >> You can use these snippets to implement pending steps: >> >> Given /^task "Display Group Rules" does not exist$/ do >> end >> >> When /^I visit "\/tasks\/new"$/ do >> end >> >> Then /^I should end up on the Tasks page$/ do >> end >> >> Then /^the task "Display Group Rules" should exist$/ do >> end >> >> >> My question is where to go from here. Do I implement the four pending steps, >> e.g: >> >> Given /^task "(.+)" does not exist$/ do |name| >> task = Task.find_by_name(name) >> task.destroy if task >> end >> >> Or do I run: >> >> ./script/generate scaffold_resource task name:string description:text >> cas_link:string >> >> and the rake rspec and fix whatever errors show up there? >> >> What are your thoughts? TIA > > Hi Stephen, > > The approach I like to take is to follow the guidance of the system > (cucumber + rspec) every step of the way. Right now there are no > passing steps, so I'd write the code for the 1st pending step, run the > features and find the first thing that is missing or failing. > > In the example you've provided, I'd very likely write code like what > you wrote for the first Given step. I imagine that running that > feature would produce an error saying that there is nothing named > Task. > > At that point I've gone in two different directions. The more purist > approach would be to create the model at this point - not the scaffold > - as that's the only thing you actually need at this moment to > progress. > > I've also made the scaffold at this point. Typically I end up cutting > out a bunch of crap I don't need and from time to time I don't clear > out all the crap I don't need, discovering later that I've got excess > code floating around the system. This is the motivation for avoiding > code generation. It's a tradeoff. > > Either way, once that step is passing (by creating the model or > scaffold and then running the migrations), I'd move on to the next > step. Just work your way down, one step at a time. > > As your doing this, if you're using the rspec generators, you'll be > generating specs as you go. Any time that you need to actually > implement something in the code that is not generated, I'd head to the > specs to drive that additional behaviour out at the object level. > > If you follow this with serious discipline, you'll end up with two > concentric cycles that both follow a Red/Green/Refactor cycle, meeting > at the Green points. Actually, they're not concentric - one is smaller and completely inside the other, but they meet at one point in the circumference (so they don't share a center). > > One nice visual analogy for this is a two speed bicycle. The lower > gear, the bigger circle, is the Cucumber cycle. You work there until > you have a failing step, at which point you shift into high gear, > which is the smaller circle, the RSpec cycle. At the point that all > specs are passing and the last failing step is now passing, you shift > back to low gear (Cucumber) and work there until you have a failing > step. Rinse, repeat. > > This is how I describe this in The RSpec Book, btw, so tell me now if > it doesn't make sense :) > > HTH, > David > >> >> -- >> Stephen Veit >> 314-616-9688 >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From mark at mwilden.com Fri Dec 5 21:16:45 2008 From: mark at mwilden.com (Mark Wilden) Date: Fri, 5 Dec 2008 18:16:45 -0800 Subject: [rspec-users] 'And' step definition Message-ID: <3c30da400812051816k436f414dva37e6c81b8eb8a70@mail.gmail.com> Can you have an And step in a feature? With this, I get a NoMethodError for 'And': Given /a company named (.+)/ do |name| @company = Company.create!(:name => name) end And /a user named (.+)/ do |name| @user = create_user name end I'm probably missing something really obvious. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Dec 5 21:18:13 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 5 Dec 2008 20:18:13 -0600 Subject: [rspec-users] 'And' step definition In-Reply-To: <3c30da400812051816k436f414dva37e6c81b8eb8a70@mail.gmail.com> References: <3c30da400812051816k436f414dva37e6c81b8eb8a70@mail.gmail.com> Message-ID: <57c63afe0812051818i6a385b5dy164deb0677c39385@mail.gmail.com> On Fri, Dec 5, 2008 at 8:16 PM, Mark Wilden wrote: > Can you have an And step in a feature? With this, I get a NoMethodError for > 'And': > > Given /a company named (.+)/ do |name| > @company = Company.create!(:name => name) > end > > And /a user named (.+)/ do |name| > @user = create_user name > end > > I'm probably missing something really obvious. And is something the grammar allows in scenarios, but it always maps And (and But) to the last type of Given, When or Then. So what you really have here is a Given step that you are invoking with an alias, And, from the Scenario. Cheers, David > > ///ark > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Fri Dec 5 21:55:55 2008 From: lists at ruby-forum.com (James Byrne) Date: Sat, 6 Dec 2008 03:55:55 +0100 Subject: [rspec-users] 'And' step definition In-Reply-To: <3c30da400812051816k436f414dva37e6c81b8eb8a70@mail.gmail.com> References: <3c30da400812051816k436f414dva37e6c81b8eb8a70@mail.gmail.com> Message-ID: <924c5e2c1cb4c70207a8184904cddefa@ruby-forum.com> Mark Wilden wrote: > Can you have an And step in a feature? With this, I get a NoMethodError > for > 'And': > > Given /a company named (.+)/ do |name| > @company = Company.create!(:name => name) > end > > And /a user named (.+)/ do |name| > @user = create_user name > end > > I'm probably missing something really obvious. > > ///ark Given, When, Then and And in a feature file are all calls to the same code. You can map any of these in a feature file to a matcher prefaced with any of Given, When and Then in a step definitions file. My current practice is to only use When in the step definitions file as it reads (for me) more naturally. So, in the step definitions file, if you have: When /a company named (.+)/ do |name| @company = Company.create!(:name => name) end When /a user named (.+)/ do |name| @user = create_user name end While in the feature file you can have: Scenario Given a company named Acme And a company named Pinnacle When a user named Smith Then a company named Zenith And a user named Doe and all of these will match one of the two step definitions given above. -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Fri Dec 5 22:28:52 2008 From: mark at mwilden.com (Mark Wilden) Date: Fri, 5 Dec 2008 19:28:52 -0800 Subject: [rspec-users] 'And' step definition In-Reply-To: <924c5e2c1cb4c70207a8184904cddefa@ruby-forum.com> References: <3c30da400812051816k436f414dva37e6c81b8eb8a70@mail.gmail.com> <924c5e2c1cb4c70207a8184904cddefa@ruby-forum.com> Message-ID: <3c30da400812051928k71eb6ec0g5442cd999087e529@mail.gmail.com> Thanks for your replies, David and James. I figured as much, actually, since you wouldn't want to have some And steps in your definition file and some Given steps. I was led astray by "Inside a step_definitions.rb file, steps (which strictly speaking should always be called step definitions) refers to the * matcher* methods, given exactly the same names (Given, When, Then, or And), each provided with a matcher regexp that corresponds to one or more feature steps" in James's backgrounder. Maybe I misunderstood it. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Fri Dec 5 22:41:56 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 05 Dec 2008 20:41:56 -0700 Subject: [rspec-users] Cucumber and autospec do not work ? In-Reply-To: <20081206000408.GF17218@bumblebee.m38c.nl> References: <20081206000408.GF17218@bumblebee.m38c.nl> Message-ID: <4939F484.2020700@benmabey.com> Kero van Gelder wrote: > Hi! > > I'm not sure this is how cucumber should behave. > Should I file one or three tickets at http://rspec.lighthouseapp.com/projects/16211-cucumber > ? > > $ cucumber -v > 0.1.12 > > $ mkdir fresh > $ cd fresh > $ cucumber > cucumber.yml was not found. Please define your 'default' and other profiles in cucumber.yml. > Type 'cucumber --help' for usage. > $ touch cucumber.yml > $ cucumber # bug! should not crash on broken config file > /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:146:in `parse_args_from_profile': undefined method `[]' for false:FalseClass (NoMethodError) > from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:47:in `parse_options!' > from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:20:in `parse' > from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:11:in `execute' > from /var/lib/gems/1.8/gems/cucumber-0.1.12/bin/cucumber:6 > from /var/lib/gems/1.8/bin/cucumber:19:in `load' > from /var/lib/gems/1.8/bin/cucumber:19 > $ echo default: > cucumber.yml > $ cucumber # bug! default profile defined but irretrievable > Could not find profile: 'default' > > Defined profiles in cucumber.yml: > * default > $ echo default: . > cucumber.yml > $ vim enlightenment.feature > $ cucumber -v # bug! no reason not to use the default profile > Ruby files required: > > Features: > > $ cucumber -v -i -p default > Ruby files required: > > Features: > * ./enlightenment.feature > > Story: enlightenment # ./enlightenment.feature > As a Developer > I want to achieve enlightenment > So that I can be at peace with my code > Scenario: meditation # ./enlightenment.feature:6 > When I meditate indefinitely # ./enlightenment.feature:7 > Then I achieve enlightenment # ./enlightenment.feature:8 > > 2 steps pending > > $ > > > __ > How can I change the world if I can't even change myself? > -- Faithless, Salva Mea > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Hey Kero, I have added th tickets for you and am working on fixes for them. Although, I think the last one needs to be discussed more so please add your thoughts to that ticket. http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/117-cli-crashes-with-blank-cucumberyml http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/118-confusing-error-message-with-blank-default-profile-defined http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/119-not-using-default-profile-when-expected -Ben From lists at ruby-forum.com Sat Dec 6 00:18:52 2008 From: lists at ruby-forum.com (Song Lee) Date: Sat, 6 Dec 2008 06:18:52 +0100 Subject: [rspec-users] MockExpectationError Message-ID: no matter how I try to stub! it still showing this error I have the following in my spec Profile.stub!(:new).and_return(@profile = mock_model(Profile)) Then (rdb:1) @profile.stub!(:user) #, @name="Pr ofile_1300">>, @args_expectation=#], @match_any_args=true>, @args_to_yield=[], @method_block=nil, @sy mbol_to_throw=nil, @expected_received_count=:any, @error_generator=#, @name="Profile_1300">> (rdb:1) @profile.user = 3 Spec::Mocks::MockExpectationError Exception: Mock 'Profile_1300' received unexpe cted message :user= with (3) .......... Try many variations of stub!, stub!..with, should_recieve, etc nothing works I'm using rspec and rspec-rails version 1.1.11 -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Sat Dec 6 01:21:32 2008 From: mark at mwilden.com (Mark Wilden) Date: Fri, 5 Dec 2008 22:21:32 -0800 Subject: [rspec-users] MockExpectationError In-Reply-To: References: Message-ID: <3c30da400812052221q3af0222aqc1fc8e4a75781485@mail.gmail.com> On Fri, Dec 5, 2008 at 9:18 PM, Song Lee wrote: > Profile.stub!(:new).and_return(@profile = mock_model(Profile)) > > (rdb:1) @profile.user = 3 > Spec::Mocks::MockExpectationError Exception: Mock 'Profile_1300' > received unexpected message :user= with (3) > You're stubbing :user when you need to stub :user= ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Sat Dec 6 01:32:20 2008 From: mark at mwilden.com (Mark Wilden) Date: Fri, 5 Dec 2008 22:32:20 -0800 Subject: [rspec-users] Database.truncate_all In-Reply-To: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> References: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> Message-ID: <3c30da400812052232i620146c8xa88ac8f9745d91ea@mail.gmail.com> On Fri, Dec 5, 2008 at 6:32 AM, Jeff Talbot wrote: > There is a seemingly very useful line of code in the cucumber wiki > that I'd like to use: > > After do > # Scenario teardown > Database.truncate_all > end > That's just an example of some code you might call in an After. A little lower, you see TempFileManager.clean_up which also looks like non-Rails/Cucumber code. A simple way to achieve the former would be class Database def self.truncate TheModel.destroy_all TheOtherModel.destroy_all # etc end end destroy_all isn't exactly the same as SQL TRUNCATE, but it might serve your purpose. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sat Dec 6 01:52:50 2008 From: lists at ruby-forum.com (Song Lee) Date: Sat, 6 Dec 2008 07:52:50 +0100 Subject: [rspec-users] MockExpectationError In-Reply-To: <3c30da400812052221q3af0222aqc1fc8e4a75781485@mail.gmail.com> References: <3c30da400812052221q3af0222aqc1fc8e4a75781485@mail.gmail.com> Message-ID: <93a0c0d4a349259ee42c23dfdea7ceaf@ruby-forum.com> yes indeed, thanks -- Posted via http://www.ruby-forum.com/. From david at digitalronin.com Sat Dec 6 05:47:21 2008 From: david at digitalronin.com (David Salgado) Date: Sat, 6 Dec 2008 10:47:21 +0000 Subject: [rspec-users] Database.truncate_all In-Reply-To: <3c30da400812052232i620146c8xa88ac8f9745d91ea@mail.gmail.com> References: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> <3c30da400812052232i620146c8xa88ac8f9745d91ea@mail.gmail.com> Message-ID: <8c90cb7d0812060247s4de22917h168fcbc12c814206@mail.gmail.com> ISTR that "destroy_all" will instantiate each object, before destroying it. If you just want to clean the database, I think "delete_all" is the one you want (it just does a "delete from [table]", if memory serves), and should be a lot quicker. David 2008/12/6 Mark Wilden : > On Fri, Dec 5, 2008 at 6:32 AM, Jeff Talbot wrote: >> >> There is a seemingly very useful line of code in the cucumber wiki >> that I'd like to use: >> >> After do >> # Scenario teardown >> Database.truncate_all >> end > > That's just an example of some code you might call in an After. A little > lower, you see > > TempFileManager.clean_up > > which also looks like non-Rails/Cucumber code. > > A simple way to achieve the former would be > > class Database > def self.truncate > TheModel.destroy_all > TheOtherModel.destroy_all > # etc > end > end > > destroy_all isn't exactly the same as SQL TRUNCATE, but it might serve your > purpose. > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From kero at chello.nl Sat Dec 6 06:13:47 2008 From: kero at chello.nl (Kero van Gelder) Date: Sat, 6 Dec 2008 12:13:47 +0100 Subject: [rspec-users] Cucumber and autospec do not work ? In-Reply-To: <4939F484.2020700@benmabey.com> References: <20081206000408.GF17218@bumblebee.m38c.nl> <4939F484.2020700@benmabey.com> Message-ID: <20081206111347.GG17218@bumblebee.m38c.nl> > I have added th tickets for you and am working on fixes for them. > Although, I think the last one needs to be discussed more so please add > your thoughts to that ticket. > > http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/117-cli-crashes-with-blank-cucumberyml > http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/118-confusing-error-message-with-blank-default-profile-defined > http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/119-not-using-default-profile-when-expected Thank you! Comment added to 119 Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From kero at chello.nl Sat Dec 6 07:04:46 2008 From: kero at chello.nl (Kero van Gelder) Date: Sat, 6 Dec 2008 13:04:46 +0100 Subject: [rspec-users] Autospec does not work w/ cucumber features? Message-ID: <20081206120446.GH17218@bumblebee.m38c.nl> Hi! And now for the second part of the subject of my previous mails :) $ cat cucumber.yml default: . autotest: -v . autotest-all: -v -f progress . $ cucumber -i . -f progress PP Pending Scenarios: 1) enlightenment (meditation) $ AUTOFEATURE=true autospec # bug! prompt returns immediately, ZenTest gem not a dependency? a warning that autotest was not found would be nice. $ sudo gem install ZenTest Successfully installed ZenTest-3.11.0 1 gem installed Installing ri documentation for ZenTest-3.11.0... Installing RDoc documentation for ZenTest-3.11.0... $ AUTOFEATURE=true autospec ^CInterrupt a second time to quit ^C it just does not do anything at all... and I haven't had any luck with earlier versions of cucumber, either. Nor does autospec become more active when I have implemented some features already. afaik I did everything mentioned in http://github.com/aslakhellesoy/cucumber/wikis/autotest-integration any ideas? NB: where to file the autospec/autotest warning missing bug; rspec plain? rspec-cucumber? Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From raasdnil at gmail.com Sat Dec 6 07:25:54 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Sat, 6 Dec 2008 23:25:54 +1100 Subject: [rspec-users] Indentation Conventions for Ruby and Cucumber In-Reply-To: <85d99afe0812041343i6f93346dr6a245703634b226b@mail.gmail.com> References: <57a815bf0812030350u6ca51551y8a4f3731260b3273@mail.gmail.com> <88fd8ddc0812030627n7743e635lc49309244ddcc9c8@mail.gmail.com> <937d9d810812041114q2dee3159pdea219ffff9c241a@mail.gmail.com> <85d99afe0812041343i6f93346dr6a245703634b226b@mail.gmail.com> Message-ID: <57a815bf0812060425t25f2f3d9j2c5674f141323093@mail.gmail.com> On Thu, Dec 4, 2008 at 1:27 AM, Andrew Premdas wrote: > Oh but cucumber features so want to be idented on the I > > Scenario: Anonymous user can not duplicate a un-activated account > Given I am an anonymous user > And a registered user Fred exists > When I signup as Fred > Then I should see an error > > Really need to view above with a monspaced font - if its not coming out > that way in your mail reader. > The problem with that however is that it is not compliant with Internationalization standards... Not to mention it would then naturally bias someone toward using an enforced I. What if I didn't want to use an "I", but an "it" say, in terms of an API that is being talked to by another system... -- http://lindsaar.net/ Rails, RSpec and Life blog.... -------------- next part -------------- An HTML attachment was scrubbed... URL: From raasdnil at gmail.com Sat Dec 6 07:28:39 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Sat, 6 Dec 2008 23:28:39 +1100 Subject: [rspec-users] RSpec and 1.9 Compatibility Message-ID: <57a815bf0812060428t608c19f3m2e5170f53f4c9bfb@mail.gmail.com> OK... I am making a mail library that is taking advantage of the new things in 1.9, mainly encoding and the new regex goodness. However, RSpec is not jiggy with it right now on 1.9... so I'm going to try and scratch an itch here. Has anyone started on this? I've started in terms of getting RSpec and it's dependencies to run the specs working and it is proving fun :) If anyone has already trail-blazed some of this, it would be good to collaborate a bit so I can get a leg up. Otherwise, I'll start from scratch. Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog.... -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat Dec 6 11:31:52 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 6 Dec 2008 10:31:52 -0600 Subject: [rspec-users] RSpec and 1.9 Compatibility In-Reply-To: <57a815bf0812060428t608c19f3m2e5170f53f4c9bfb@mail.gmail.com> References: <57a815bf0812060428t608c19f3m2e5170f53f4c9bfb@mail.gmail.com> Message-ID: <57c63afe0812060831i30c45034yd11c6dde272d0eb9@mail.gmail.com> On Sat, Dec 6, 2008 at 6:28 AM, Mikel Lindsaar wrote: > OK... I am making a mail library that is taking advantage of the new things > in 1.9, mainly encoding and the new regex goodness. > However, RSpec is not jiggy with it right now on 1.9... so I'm going to try > and scratch an itch here. > Has anyone started on this? I've started in terms of getting RSpec and it's > dependencies to run the specs working and it is proving fun :) If anyone > has already trail-blazed some of this, it would be good to collaborate a bit > so I can get a leg up. > Otherwise, I'll start from scratch. > > Mikel Check out http://rspec.lighthouseapp.com/projects/5645-rspec/tickets?q=tagged%3A%22ruby19%22+state%3Aopen&filter= There are a couple of open tickets including patches that haven't quite worked out yet. Cheers, and TIA, David > -- > http://lindsaar.net/ > Rails, RSpec and Life blog.... > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sat Dec 6 12:00:49 2008 From: lists at ruby-forum.com (Antonio Faust45) Date: Sat, 6 Dec 2008 18:00:49 +0100 Subject: [rspec-users] Update RSpec but have a problem! Message-ID: Hi people! I run rake spec ** Invoke spec (first_time, not_needed) and specs not started! What that's mean? Thanks! -- Posted via http://www.ruby-forum.com/. From mark at mwilden.com Sat Dec 6 12:13:13 2008 From: mark at mwilden.com (Mark Wilden) Date: Sat, 6 Dec 2008 09:13:13 -0800 Subject: [rspec-users] Database.truncate_all In-Reply-To: <8c90cb7d0812060247s4de22917h168fcbc12c814206@mail.gmail.com> References: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> <3c30da400812052232i620146c8xa88ac8f9745d91ea@mail.gmail.com> <8c90cb7d0812060247s4de22917h168fcbc12c814206@mail.gmail.com> Message-ID: <3c30da400812060913u759f5dact1b8231feaac4798d@mail.gmail.com> On Sat, Dec 6, 2008 at 2:47 AM, David Salgado wrote: > ISTR that "destroy_all" will instantiate each object, before > destroying it. If you just want to clean the database, I think > "delete_all" is the one you want (it just does a "delete from > [table]", if memory serves), and should be a lot quicker. > Yes, you're right. I always get those mixed up. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Sat Dec 6 12:28:34 2008 From: ben at benmabey.com (Ben Mabey) Date: Sat, 06 Dec 2008 10:28:34 -0700 Subject: [rspec-users] Database.truncate_all In-Reply-To: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> References: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> Message-ID: <493AB642.5000209@benmabey.com> Jeff Talbot wrote: > There is a seemingly very useful line of code in the cucumber wiki > that I'd like to use: > > After do > # Scenario teardown > Database.truncate_all > end > > (from http://github.com/aslakhellesoy/cucumber/wikis/migration-from-rspec-stories) > > But when I run this I get an uninitialized constant error for "Database". > > Anybody know if/how I can make this call? Is there something I need to > require? Is there a different way of doing this now? I have a need to > not use transactional_fixtures for a specific suite of tests and I > want to clear out the database after every run so my tests are > isolated. > > Thanks, > Jeff > As pointed out this was just an example. For ideas on how to implement such a method you can read this previous thread about it: http://www.mail-archive.com/rspec-users at rubyforge.org/msg06597.html -Ben From peter.a.jaros at gmail.com Sat Dec 6 14:16:38 2008 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Sat, 6 Dec 2008 14:16:38 -0500 Subject: [rspec-users] cucumber and autotest - running all features? In-Reply-To: References: <306b6bd9a7f00af8464713c73dc929de@ruby-forum.com> <4ee52ac742558d3aeb2d560fef7b27fe@ruby-forum.com> <937d9d810811301845x29632c37p7ffc80b5537b4450@mail.gmail.com> <5BCECC48-3374-462B-9493-63715A7AEB26@mattwynne.net> <937d9d810812020611t3a9f4c74hc85dae7b55c56a9d@mail.gmail.com> <97C20D7A-8DC1-4169-90EA-F395A6F06FF3@mattwynne.net> <937d9d810812041957w6d273e1by1af9f5c5a16e415c@mail.gmail.com> <75CA9952-664B-496B-AA6E-0D392FF7F3E9@gmail.com> Message-ID: <937d9d810812061116nb2339a0u4255dbea9bdd3000@mail.gmail.com> On Fri, Dec 5, 2008 at 4:47 AM, Matt Wynne wrote: > I'll have to give autospec another shot then I guess. I have given up on it > as it takes over 7 minutes to 'boot up' with our test suite, and I find it > misses too many things it should have run, such that I have to hit CTRL-C > and do a complete (7 minute) re-run far more often than I'd like. I also > don't trust it before a check-in - it seems to miss things that should have > been re-run. It certainly can take a while to boot up, but that's necessary: it really has to run the whole suite the first time to be sure everything is passing. It might be nice to have an option to skip that if you're sure everything passes when you start. You shouldn't be using Ctrl-C to restart autospec very often; at least, I almost never do. I find that the work I'm doing very rarely regresses other scenarios, and it's not a problem not to notice until the current features are finished and the whole suite runs. Typically, in my workflow, I have a branch which adds a new feature or scenario. I commit filling out a scenario and the step definitions to make them no longer pending in one commit. Then I commit spec examples and the come which makes them pass in logical chunks until the scenario passes. Once it passes, the whole suite runs again automatically, and I see if I've broken anything. If I have, I fix it then. When I get the "all green", I can fill out a new scenario and start the cycle again. I think of these as "micro-iterations", since I reevaluate the direction I'm going in between these iterations. A bunch of these micro-iterations together form an "iteration" in he Agile/XP sense, where I've built something I can show to the client/customer/boss again for feedback. At this point I can merge my branch into master or another longer-running branch. Because of this workflow, I'm ok with committing code with broken features, and even broken specs if they're not related to what I've been doing. At the end of a micro-iteration, though, everything needs to pass. > I guess this may more be due to our codebase being a bit badly organised so > that the conventions autospec relies on aren't always adhered to... Yeah, that can be a killer. If you have your own conventions, though (and you should), you can modify the mappings in your .autotest file to match. See the Autotest#add_mapping rdoc for more info. Peter From peter.a.jaros at gmail.com Sat Dec 6 14:57:36 2008 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Sat, 6 Dec 2008 14:57:36 -0500 Subject: [rspec-users] Autospec does not work w/ cucumber features? In-Reply-To: <20081206120446.GH17218@bumblebee.m38c.nl> References: <20081206120446.GH17218@bumblebee.m38c.nl> Message-ID: <937d9d810812061157n1ed1c33ax2d7d5d7083f746a3@mail.gmail.com> On Sat, Dec 6, 2008 at 7:04 AM, Kero van Gelder wrote: > $ AUTOFEATURE=true autospec # bug! prompt returns immediately, ZenTest gem not a dependency? a warning that autotest was not found would be nice. Huh. The autospec command comes from RSpec; do you have this issue without setting AUTOFEATURE=true? Peter From peter.a.jaros at gmail.com Sat Dec 6 15:08:17 2008 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Sat, 6 Dec 2008 15:08:17 -0500 Subject: [rspec-users] Update RSpec but have a problem! In-Reply-To: References: Message-ID: <937d9d810812061208j2b437bd6mfa0cc25231abcda9@mail.gmail.com> On Sat, Dec 6, 2008 at 12:00 PM, Antonio Faust45 wrote: > rake spec > ** Invoke spec (first_time, not_needed) > and specs not started! Oh! I' having the same problem and I just solved it! Well, half-solved it. Rake, like make, operates on files. If you say "make somebinary" make will run certain command expecting that they will build the file "somebinary". It knows which source files that file depends on, so if "somebinary" exists and is newer than the files it depends on it won't bother to run the commands. It's already the newest version. Rake is usually used for bits of script, and not to build files. However, it can be used much like make. Here's what's going on. Rake doesn't know about a task named "spec". It *does* know about a *directory* named "spec" though, and it will try to "build" it. It doesn't seem to depend on anything, though, so the task is marked "not_needed". It's like trying to build "somebinary" when make knows it's already up-to-date. So that explains the silent treatment. But why don't you have a spec task? That, you'll have to figure out for yourself. Is this a Rails project? If so, look for a lib/tasks/rspec.rake file. If not, look in your Rakefile. If you don't have a :spec task defined in there, there's your problem! :) Peter From lists at ruby-forum.com Sat Dec 6 16:59:32 2008 From: lists at ruby-forum.com (Antonio Faust45) Date: Sat, 6 Dec 2008 22:59:32 +0100 Subject: [rspec-users] Update RSpec but have a problem! In-Reply-To: <937d9d810812061208j2b437bd6mfa0cc25231abcda9@mail.gmail.com> References: <937d9d810812061208j2b437bd6mfa0cc25231abcda9@mail.gmail.com> Message-ID: Thanks Pit! -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat Dec 6 17:10:14 2008 From: lists at ruby-forum.com (James Byrne) Date: Sat, 6 Dec 2008 23:10:14 +0100 Subject: [rspec-users] 'And' step definition In-Reply-To: <3c30da400812051928k71eb6ec0g5442cd999087e529@mail.gmail.com> References: <3c30da400812051816k436f414dva37e6c81b8eb8a70@mail.gmail.com> <924c5e2c1cb4c70207a8184904cddefa@ruby-forum.com> <3c30da400812051928k71eb6ec0g5442cd999087e529@mail.gmail.com> Message-ID: Mark Wilden wrote: > Thanks for your replies, David and James. I figured as much, actually, > since > you wouldn't want to have some And steps in your definition file and > some > Given steps. > > I was led astray by "Inside a step_definitions.rb file, steps (which > strictly speaking should always be called step definitions) refers to > the * > matcher* methods, given exactly the same names (Given, When, Then, or > And), > each provided with a matcher regexp that corresponds to one or more > feature > steps" in James's backgrounder. Maybe I misunderstood it. > That aspect of cucumber, that Given == When == Then, is elaborated later in the article but I have added further clarification at that point as well. -- Posted via http://www.ruby-forum.com/. From kero at chello.nl Sat Dec 6 18:36:18 2008 From: kero at chello.nl (Kero van Gelder) Date: Sun, 7 Dec 2008 00:36:18 +0100 Subject: [rspec-users] Autospec does not work w/ cucumber features? In-Reply-To: <937d9d810812061157n1ed1c33ax2d7d5d7083f746a3@mail.gmail.com> References: <20081206120446.GH17218@bumblebee.m38c.nl> <937d9d810812061157n1ed1c33ax2d7d5d7083f746a3@mail.gmail.com> Message-ID: <20081206233618.GA5616@bumblebee.m38c.nl> > > $ AUTOFEATURE=true autospec # bug! prompt returns immediately, ZenTest gem not a dependency? a warning that autotest was not found would be nice. > > Huh. The autospec command comes from RSpec; do you have this issue > without setting AUTOFEATURE=true? Yup. But as I only have features, I would not expect it to do anything in that case ;) Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From ben at benmabey.com Sat Dec 6 19:36:30 2008 From: ben at benmabey.com (Ben Mabey) Date: Sat, 06 Dec 2008 17:36:30 -0700 Subject: [rspec-users] Autospec does not work w/ cucumber features? In-Reply-To: <20081206233618.GA5616@bumblebee.m38c.nl> References: <20081206120446.GH17218@bumblebee.m38c.nl> <937d9d810812061157n1ed1c33ax2d7d5d7083f746a3@mail.gmail.com> <20081206233618.GA5616@bumblebee.m38c.nl> Message-ID: <493B1A8E.7080002@benmabey.com> Kero van Gelder wrote: >>> $ AUTOFEATURE=true autospec # bug! prompt returns immediately, ZenTest gem not a dependency? a warning that autotest was not found would be nice. >>> >> Huh. The autospec command comes from RSpec; do you have this issue >> without setting AUTOFEATURE=true? >> > > Yup. > > But as I only have features, I would not expect it > to do anything in that case ;) > > Bye, > Kero. > Perhaps the problem is related to that.. if you add a spec or two what happens? -Ben From apremdas at gmail.com Sun Dec 7 02:21:45 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Sun, 7 Dec 2008 07:21:45 +0000 Subject: [rspec-users] stepping across features In-Reply-To: <51f2f3c0c0cc4ad38c70b2b20c140b33@ruby-forum.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> <88fd8ddc0812050842ne7a213xbaa9b75f5837c1ce@mail.gmail.com> <51f2f3c0c0cc4ad38c70b2b20c140b33@ruby-forum.com> Message-ID: <88fd8ddc0812062321r14591fffk32fbea980da77d5f@mail.gmail.com> Yup, very much so IMO 2008/12/5 James Byrne > Andrew Premdas wrote: > > Pretty hard for me to comment with so much stuff and so little context. > > However :) > > My messages are quite long enough as it is I am afraid. > > > about a work order to produce invoices. You have to do some design and > > thinking to produce good features. Challenge assumptions and try and see > > things from different view points. For example why can't I just do > > > > Given outstanding payments > > When I visit the make invoices page > > I should see a list of invoices I can create > > > > And then do some other little scenarios to create an invoice etc.. > > > > HTH > > It always helps to have another point of view. I am grappling with this > issue mentally before committing myself to a line of approach. This > project is, as you surmise, a conversion of an existing body of work > into a new form. It is also anticipated that the existing application > will be extended in many areas. The scope of the project encompasses > everything from General Ledger down to edi transmission of tax documents > to the federal government. > > I am trying to determine whether the way to control and document this > project while focusing programming activity is best served by using BDD > features or whether those objectives should be satisfied otherwise and > BDD features only used for specific implementation issues. Part of my > difficulty is my limited vocabulary for expressing this and part is my > want of experience with this form of design and development. My > previous experience was with much less sophisticated tools than I am > currently using and I am reluctant to turn a scalpel into a screwdriver > out of ignorance on my part. On the other hand, if a jack hammer is > needed then a scalpel is not of much use. > > So reworking my earlier effort: > > Feature: Bill chargeable work > In Order To generate income > A Billing Clerk > Should be able to create invoices > To Increase Revenue > > Scenario: Manual Invoice Release > Given billable charges > When I visit the create an invoice page > Then I should see a list of all billable charges > > Scenario: Manual Invoice Release by Client > Given billable charges > When I visit the create an invoice page > And I search for client "Y" > Then I should see a list of all billable charges only for client "Y" > > Is this getting closer to what my features should look like? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Sun Dec 7 02:30:10 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Sun, 7 Dec 2008 07:30:10 +0000 Subject: [rspec-users] Indentation Conventions for Ruby and Cucumber In-Reply-To: <57a815bf0812060425t25f2f3d9j2c5674f141323093@mail.gmail.com> References: <57a815bf0812030350u6ca51551y8a4f3731260b3273@mail.gmail.com> <88fd8ddc0812030627n7743e635lc49309244ddcc9c8@mail.gmail.com> <937d9d810812041114q2dee3159pdea219ffff9c241a@mail.gmail.com> <85d99afe0812041343i6f93346dr6a245703634b226b@mail.gmail.com> <57a815bf0812060425t25f2f3d9j2c5674f141323093@mail.gmail.com> Message-ID: <88fd8ddc0812062330o55b1dba9pb5a0ecd119df099b@mail.gmail.com> Original post was somewhat flippant :) To be more precise. This style is "aligning on the first letter of the second word" and basically is treating the first word as a label and the rest as content, and using indentation to differentiate (hopefully clearly) Andrew 2008/12/6 Mikel Lindsaar > On Thu, Dec 4, 2008 at 1:27 AM, Andrew Premdas wrote: > >> Oh but cucumber features so want to be idented on the I >> >> Scenario: Anonymous user can not duplicate a un-activated account >> Given I am an anonymous user >> And a registered user Fred exists >> When I signup as Fred >> Then I should see an error >> >> Really need to view above with a monspaced font - if its not coming out >> that way in your mail reader. >> > > The problem with that however is that it is not compliant with > Internationalization standards... > > Not to mention it would then naturally bias someone toward using an > enforced I. > > What if I didn't want to use an "I", but an "it" say, in terms of an API > that is being talked to by another system... > > -- > http://lindsaar.net/ > Rails, RSpec and Life blog.... > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Sun Dec 7 02:49:07 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Sun, 7 Dec 2008 07:49:07 +0000 Subject: [rspec-users] Where to start after writing feature In-Reply-To: References: Message-ID: <88fd8ddc0812062349u58e7e9u556c1d6944c2bfd9@mail.gmail.com> +1 to Davids advice But first I would analyse the feature I've written. Some of the things I'd think about include 1) The use of the word task - its not very precise 2) The assumptions made in my story and whether I'm ready to make these yet a) That a task will have a name b) That only English users will be using this page c) That people will now what a CAS link is ... 3) The brittleness of what I've written - what will change and how will I have to modify what I've done So my initial scenario might be When I create a new improvement I should see a confirmation and my second scenario might be Given there are some improvements I should be able to view improvements Finally have a think about whether this feature is actually important enough to be doing first. HTH 2008/12/5 Stephen Veit > I am trying to develop code from the feature on down. > > So I created a brand new rails app. It has no models yet. I wrote a > feature: > > Feature: Add tasks > In order to track website improvements > a user > wants to add tasks > > Scenario: User adds task > Given task "Display Group Rules" does not exist > When I visit "/tasks/new" > And I fill in "Name" with "Display Group Rules" > And I fill in "Description" with "Displays links to edit each group > rule" > And I fill in "CAS Link" with "GroupRulesManager/" > And I press "Submit" > Then I should end up on the Tasks page > And I should see "Task successfully added" > And the task "Display Group Rules" should exist > > I then run: > > rake db:migrate (this creates my development SQLite3 database) > rake db:test:prepare (this creates my development SQLite3 database) > rake features (outputs the following:) > > Feature: Add tasks # features/manage_task.feature > In order to track website improvements > a user > wants to add tasks > Scenario: User adds task > Given task "Display Group Rules" does not exist > When I visit "/tasks/new" > And I fill in "Name" with "Display Group Rules" > And I fill in "Description" with "Displays links to edit each group > rule" > And I fill in "CAS Link" with "GroupRulesManager/" > And I press "Submit" > Then I should end up on the Tasks page > And I should see "Task successfully added" > And the task "Display Group Rules" should exist > > > 5 steps skipped > 4 steps pending > > You can use these snippets to implement pending steps: > > Given /^task "Display Group Rules" does not exist$/ do > end > > When /^I visit "\/tasks\/new"$/ do > end > > Then /^I should end up on the Tasks page$/ do > end > > Then /^the task "Display Group Rules" should exist$/ do > end > > > My question is where to go from here. Do I implement the four pending > steps, e.g: > > Given /^task "(.+)" does not exist$/ do |name| > task = Task.find_by_name(name) > task.destroy if task > end > > Or do I run: > > ./script/generate scaffold_resource task name:string description:text > cas_link:string > > and the rake rspec and fix whatever errors show up there? > > What are your thoughts? TIA > > -- > Stephen Veit > 314-616-9688 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeff.a.talbot at gmail.com Sun Dec 7 11:51:22 2008 From: jeff.a.talbot at gmail.com (Jeff Talbot) Date: Sun, 7 Dec 2008 10:51:22 -0600 Subject: [rspec-users] Database.truncate_all In-Reply-To: <493AB642.5000209@benmabey.com> References: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> <493AB642.5000209@benmabey.com> Message-ID: <69f72d390812070851i3ab62d01t98c037e6a0db01fd@mail.gmail.com> Cool. Thanks, guys. On Sat, Dec 6, 2008 at 11:28 AM, Ben Mabey wrote: > Jeff Talbot wrote: >> >> There is a seemingly very useful line of code in the cucumber wiki >> that I'd like to use: >> >> After do >> # Scenario teardown >> Database.truncate_all >> end >> >> (from >> http://github.com/aslakhellesoy/cucumber/wikis/migration-from-rspec-stories) >> >> But when I run this I get an uninitialized constant error for "Database". >> >> Anybody know if/how I can make this call? Is there something I need to >> require? Is there a different way of doing this now? I have a need to >> not use transactional_fixtures for a specific suite of tests and I >> want to clear out the database after every run so my tests are >> isolated. >> >> Thanks, >> Jeff >> > > As pointed out this was just an example. For ideas on how to implement such > a method you can read this previous thread about it: > http://www.mail-archive.com/rspec-users at rubyforge.org/msg06597.html > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tero at tilus.net Sun Dec 7 12:56:20 2008 From: tero at tilus.net (Tero Tilus) Date: Sun, 7 Dec 2008 19:56:20 +0200 Subject: [rspec-users] Database.truncate_all In-Reply-To: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> References: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> Message-ID: <20081207175620.GD24040@uivelo.tilus.net> 2008-12-05 08:32, Jeff Talbot: > I want to clear out the database after every run so my tests are > isolated. Maybe a minor detail, but I'd suggest you clear out the db _before_ each run. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ From lists at ruby-forum.com Sun Dec 7 13:43:20 2008 From: lists at ruby-forum.com (James Byrne) Date: Sun, 7 Dec 2008 19:43:20 +0100 Subject: [rspec-users] Where to start after writing feature In-Reply-To: <88fd8ddc0812062349u58e7e9u556c1d6944c2bfd9@mail.gmail.com> References: <88fd8ddc0812062349u58e7e9u556c1d6944c2bfd9@mail.gmail.com> Message-ID: Andrew Premdas wrote: > > So my initial scenario might be > > When I create a new improvement > I should see a confirmation > > and my second scenario might be > > Given there are some improvements > I should be able to view improvements > > Finally have a think about whether this feature is actually important > enough > to be doing first. The question arises, how does one tell what is important enough to begin with? I am trying to form a robust mental pattern for employing BDD and I keep running up against the tension between what I already believe to be necessary to provide from my prior knowledge and what point to begin with in features to cause this to be expressed. The examples that I have found regarding how to use BDD features run the gamut from specifying model attributes and data normalization to macro statements of the form: Given I have a web application When I visit the application url Then I should see a welcome message And I should see a sign in request etc. So, the question I have is: Given I have an application design document When I specify the design using BDD Then I should first begin with ?????? -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Sun Dec 7 14:07:17 2008 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 7 Dec 2008 19:07:17 +0000 Subject: [rspec-users] Database.truncate_all In-Reply-To: <20081207175620.GD24040@uivelo.tilus.net> References: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> <20081207175620.GD24040@uivelo.tilus.net> Message-ID: On 7 Dec 2008, at 17:56, Tero Tilus wrote: > 2008-12-05 08:32, Jeff Talbot: >> I want to clear out the database after every run so my tests are >> isolated. > > Maybe a minor detail, but I'd suggest you clear out the db _before_ > each run. I respectfully disagree :) If I need this done, I can run rake db:test:prepare I think the tests should clean up after themselves. As you can see from the thread Ben linked to, it's pretty easy to watch what ActiveRecord is doing, and truncate all the tables that have been touched during a scenario. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Sun Dec 7 14:20:41 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 7 Dec 2008 20:20:41 +0100 Subject: [rspec-users] Database.truncate_all In-Reply-To: References: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> <20081207175620.GD24040@uivelo.tilus.net> Message-ID: <8d961d900812071120k7b390b46r13ebcba8074653a6@mail.gmail.com> On Sun, Dec 7, 2008 at 8:07 PM, Matt Wynne wrote: > On 7 Dec 2008, at 17:56, Tero Tilus wrote: > > 2008-12-05 08:32, Jeff Talbot: >> >>> I want to clear out the database after every run so my tests are >>> isolated. >>> >> >> Maybe a minor detail, but I'd suggest you clear out the db _before_ >> each run. >> > > I respectfully disagree :) > I respectfully disagree :-) Two reasons: Firstly, this quickly leads to coupled tests. If test N+1 only passes if test N cleans up, test N+1 will fail if run in isolation. Secondly, if each test cleans up after itself, you can't manually look at the database to figure out why a test fails - there is no data! Aslak > > If I need this done, I can run rake db:test:prepare > > I think the tests should clean up after themselves. > > As you can see from the thread Ben linked to, it's pretty easy to watch > what ActiveRecord is doing, and truncate all the tables that have been > touched during a scenario. > > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Sun Dec 7 14:32:08 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Sun, 7 Dec 2008 19:32:08 +0000 Subject: [rspec-users] Where to start after writing feature In-Reply-To: References: <88fd8ddc0812062349u58e7e9u556c1d6944c2bfd9@mail.gmail.com> Message-ID: <88fd8ddc0812071132v58266fabwb08f111c29cc4e2b@mail.gmail.com> "There are two ways of constructing a software design: One way is to make it so simple that there are no obvious deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult" C. A. R. Hoare, Professor of Computing, Oxford University (and inventor of the quicksort algorithm No one said its easy :) 2008/12/7 James Byrne > Andrew Premdas wrote: > > > > So my initial scenario might be > > > > When I create a new improvement > > I should see a confirmation > > > > and my second scenario might be > > > > Given there are some improvements > > I should be able to view improvements > > > > Finally have a think about whether this feature is actually important > > enough > > to be doing first. > > The question arises, how does one tell what is important enough to begin > with? I am trying to form a robust mental pattern for employing BDD and > I keep running up against the tension between what I already believe to > be necessary to provide from my prior knowledge and what point to begin > with in features to cause this to be expressed. The examples that I > have found regarding how to use BDD features run the gamut from > specifying model attributes and data normalization to macro statements > of the form: > > Given I have a web application > When I visit the application url > Then I should see a welcome message > And I should see a sign in request > > etc. > > So, the question I have is: > > Given I have an application design document > When I specify the design using BDD > Then I should first begin with ?????? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Sun Dec 7 15:09:33 2008 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 7 Dec 2008 20:09:33 +0000 Subject: [rspec-users] Database.truncate_all In-Reply-To: <8d961d900812071120k7b390b46r13ebcba8074653a6@mail.gmail.com> References: <69f72d390812050632hbb41bdayae4ae1ca5ae9f4b4@mail.gmail.com> <20081207175620.GD24040@uivelo.tilus.net> <8d961d900812071120k7b390b46r13ebcba8074653a6@mail.gmail.com> Message-ID: <377BEF58-8E6E-431F-8BA1-48B84EDE754F@mattwynne.net> On 7 Dec 2008, at 19:20, aslak hellesoy wrote: > > > On Sun, Dec 7, 2008 at 8:07 PM, Matt Wynne wrote: > On 7 Dec 2008, at 17:56, Tero Tilus wrote: > > 2008-12-05 08:32, Jeff Talbot: > I want to clear out the database after every run so my tests are > isolated. > > Maybe a minor detail, but I'd suggest you clear out the db _before_ > each run. > > I respectfully disagree :) > > I respectfully disagree :-) Two reasons: > > Firstly, this quickly leads to coupled tests. If test N+1 only > passes if test N cleans up, test N+1 will fail if run in isolation. I think you misunderstand me. All our cucumber tests automatically clean up the database after each scenario is run. No chance of nasty coupling nonsense, but they do all assume that they'll start with an empty database. > Secondly, if each test cleans up after itself, you can't manually > look at the database to figure out why a test fails - there is no > data! Good point - I never thought of that! I just think a cleanup *before* a run would have to be more indiscriminate, and therefor slower. Our strategy of keeping a list of tables touched during a scenario then truncating them in the After do block has worked very well for us. YMMV of course :) > Aslak > > > If I need this done, I can run rake db:test:prepare > > I think the tests should clean up after themselves. > > As you can see from the thread Ben linked to, it's pretty easy to > watch what ActiveRecord is doing, and truncate all the tables that > have been touched during a scenario. > > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > > _______________________________________________ > 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 Matt Wynne http://blog.mattwynne.net http://www.songkick.com From tastapod at gmail.com Sun Dec 7 15:37:54 2008 From: tastapod at gmail.com (Dan North) Date: Sun, 7 Dec 2008 14:37:54 -0600 Subject: [rspec-users] Where to start after writing feature In-Reply-To: <88fd8ddc0812071132v58266fabwb08f111c29cc4e2b@mail.gmail.com> References: <88fd8ddc0812062349u58e7e9u556c1d6944c2bfd9@mail.gmail.com> <88fd8ddc0812071132v58266fabwb08f111c29cc4e2b@mail.gmail.com> Message-ID: Hooray! I've been looking for a reference for that quote for years! Thanks Andrew. 2008/12/7 Andrew Premdas > "There are two ways of constructing a software design: One way is to make > it so simple that there are no obvious deficiencies, and the other way is to > make it so complicated that there are no obvious deficiencies. The first > method is far more difficult" > > C. A. R. Hoare, Professor of Computing, Oxford University (and inventor of > the quicksort algorithm > > No one said its easy :) > > > 2008/12/7 James Byrne > >> Andrew Premdas wrote: >> > >> > So my initial scenario might be >> > >> > When I create a new improvement >> > I should see a confirmation >> > >> > and my second scenario might be >> > >> > Given there are some improvements >> > I should be able to view improvements >> > >> > Finally have a think about whether this feature is actually important >> > enough >> > to be doing first. >> >> The question arises, how does one tell what is important enough to begin >> with? I am trying to form a robust mental pattern for employing BDD and >> I keep running up against the tension between what I already believe to >> be necessary to provide from my prior knowledge and what point to begin >> with in features to cause this to be expressed. The examples that I >> have found regarding how to use BDD features run the gamut from >> specifying model attributes and data normalization to macro statements >> of the form: >> >> Given I have a web application >> When I visit the application url >> Then I should see a welcome message >> And I should see a sign in request >> >> etc. >> >> So, the question I have is: >> >> Given I have an application design document >> When I specify the design using BDD >> Then I should first begin with ?????? >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Dec 7 16:27:51 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 7 Dec 2008 15:27:51 -0600 Subject: [rspec-users] View tests and fragment caching issue In-Reply-To: <443c240c0812051121g52dcd0a9u7f4633c4108cc758@mail.gmail.com> References: <443c240c0812051121g52dcd0a9u7f4633c4108cc758@mail.gmail.com> Message-ID: <57c63afe0812071327r515c662ewab49c7103ab61861@mail.gmail.com> On Fri, Dec 5, 2008 at 1:21 PM, Christopher Bailey wrote: > I hope I'm just missing something obvious here, but I am using fragment > caching in a partial for a view. I test this view with an RSpec view test. > The particular test is using "real" data (i.e. not mocked objects, etc.). > When I run the test, it complains about not knowing of a route for the > fragment. The fragment parameter should be that though, a query param, not > part of a path, etc. Anyway, here's what I see for the error: > No route matches {:action=>"index", :fragment=>"similar_deals"} > The partial has the following caching line in it: > <% cache({:fragment => 'similar_deals'}, :expires_in => 24.hours) do %> > Can someone point me in the right direction for how to deal with this? Seems like this is a deficiency in rspec-rails. Would you mind posting this to http://rspec.lighthouseapp.com? Thx > -- > Christopher Bailey > Cobalt Edge LLC > http://cobaltedge.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Sun Dec 7 16:30:08 2008 From: lists at ruby-forum.com (James Byrne) Date: Sun, 7 Dec 2008 22:30:08 +0100 Subject: [rspec-users] stepping across features In-Reply-To: <88fd8ddc0812062321r14591fffk32fbea980da77d5f@mail.gmail.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> <88fd8ddc0812050842ne7a213xbaa9b75f5837c1ce@mail.gmail.com> <51f2f3c0c0cc4ad38c70b2b20c140b33@ruby-forum.com> <88fd8ddc0812062321r14591fffk32fbea980da77d5f@mail.gmail.com> Message-ID: <20881a4cead6714e35fe9e175f4bd012@ruby-forum.com> Andrew Premdas wrote: > Yup, very much so IMO > > 2008/12/5 James Byrne Bear with me. I am trying to see how one thing leads to another. Say I have written: Scenario: Manual Invoice Release by Client Given 4 billable charges for client "Y" When I visit the create an invoice page And I search for charges belonging to client "Y" Then I should see a list of 4 billable charges only for client "Y" This explicitly expresses the idea of a client. Now, I already have an idea of how I want to treat a client but I want to have the emerging features drive that expression. So in my step definitions file should I write something along the lines of: When /visit the create an invoice page/ do visits "/invoices/new" end When /search for (\d+) charges belonging to client "(.*)"/ do |b,c| # TODO: create a client c # TODO: create b charges for client c fill_in("Client Name", :with => c) click_button("Find Charges") # TODO: my_client = Client.find_by_name(c) # TODO: visit "/clients/#{my_client.id}/charges/billable" end When /see a list of all (.*) only for client (.*)/ do |what,who| ... end Now, the sixty-four thousand dollar question, what feature or features should be expressed next? The invoice? -- Posted via http://www.ruby-forum.com/. From apremdas at gmail.com Mon Dec 8 08:38:01 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 8 Dec 2008 13:38:01 +0000 Subject: [rspec-users] stepping across features In-Reply-To: <20881a4cead6714e35fe9e175f4bd012@ruby-forum.com> References: <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> <88fd8ddc0812050842ne7a213xbaa9b75f5837c1ce@mail.gmail.com> <51f2f3c0c0cc4ad38c70b2b20c140b33@ruby-forum.com> <88fd8ddc0812062321r14591fffk32fbea980da77d5f@mail.gmail.com> <20881a4cead6714e35fe9e175f4bd012@ruby-forum.com> Message-ID: <88fd8ddc0812080538p77bc48d5j25c33c3e06610a89@mail.gmail.com> Well assuming its correct to start simple & general start the feature without the concept of the client Scenario: Manual Invoice Release Given 4 billable charges When I visit the pending invoices page Then I should see ... (not sure what you should see) Now think about those charges, who do they come into existence. What are they. Also think about the name of the page your are visiting - is it pending invoices? TIp: When writing the step don't use - visits "/invoices/new" - use visits "invoice_new_path". Use named routes and let the routing names REST and resources define where you go, and think about what you want to implement If you now deal with your charges, you will probably get to the stage very quickly where you can't avoid clients. So then you do the very simplest general thing for clients. Generally all I'm doing here is questioning anything that is not central to the scenario and anything that is specific. Each of these things represents an assumption. FInding these assumptions and eliminating them will give you something thats so simple and general that it becomes obvious (with practice) that you can start. Then take baby steps adding new scenario's or new whole features to bring back extra things as it becomes imperative for you to do so. Because you have already done the simple things you should have the tools you need (existing steps and object creators) for your next feature. Each step you take is an iteration giving feedback and transforming information you know from the unknown/implicit to the concrete. So before you rush onto the next step think about what you've learnt, what you now know. This will help you take the next step. Finally every time you find that the baby step you are taking is actually more like a giant leap (or actually anything other than the smallest of steps) STOP! Then start again questioning what is not central and what is not specific. HTH Andrew 2008/12/7 James Byrne > Andrew Premdas wrote: > > Yup, very much so IMO > > > > 2008/12/5 James Byrne > > Bear with me. I am trying to see how one thing leads to another. Say I > have written: > > Scenario: Manual Invoice Release by Client > Given 4 billable charges for client "Y" > When I visit the create an invoice page > And I search for charges belonging to client "Y" > Then I should see a list of 4 billable charges only for client "Y" > > This explicitly expresses the idea of a client. Now, I already have an > idea of how I want to treat a client but I want to have the emerging > features drive that expression. So in my step definitions file should I > write something along the lines of: > > When /visit the create an invoice page/ do > visits "/invoices/new" > end > > When /search for (\d+) charges belonging to client "(.*)"/ do |b,c| > # TODO: create a client c > # TODO: create b charges for client c > fill_in("Client Name", :with => c) > click_button("Find Charges") > # TODO: my_client = Client.find_by_name(c) > # TODO: visit "/clients/#{my_client.id}/charges/billable" > end > > When /see a list of all (.*) only for client (.*)/ do |what,who| > ... > end > > Now, the sixty-four thousand dollar question, what feature or features > should be expressed next? The invoice? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Mon Dec 8 08:38:35 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 8 Dec 2008 13:38:35 +0000 Subject: [rspec-users] Where to start after writing feature In-Reply-To: References: <88fd8ddc0812062349u58e7e9u556c1d6944c2bfd9@mail.gmail.com> <88fd8ddc0812071132v58266fabwb08f111c29cc4e2b@mail.gmail.com> Message-ID: <88fd8ddc0812080538m1c6e851k2738f3e6b7fc0eae@mail.gmail.com> Your very welcome :) 2008/12/7 Dan North > Hooray! I've been looking for a reference for that quote for years! Thanks > Andrew. > > > 2008/12/7 Andrew Premdas > > "There are two ways of constructing a software design: One way is to make >> it so simple that there are no obvious deficiencies, and the other way is to >> make it so complicated that there are no obvious deficiencies. The first >> method is far more difficult" >> >> C. A. R. Hoare, Professor of Computing, Oxford University (and inventor of >> the quicksort algorithm >> >> No one said its easy :) >> >> >> 2008/12/7 James Byrne >> >>> Andrew Premdas wrote: >>> > >>> > So my initial scenario might be >>> > >>> > When I create a new improvement >>> > I should see a confirmation >>> > >>> > and my second scenario might be >>> > >>> > Given there are some improvements >>> > I should be able to view improvements >>> > >>> > Finally have a think about whether this feature is actually important >>> > enough >>> > to be doing first. >>> >>> The question arises, how does one tell what is important enough to begin >>> with? I am trying to form a robust mental pattern for employing BDD and >>> I keep running up against the tension between what I already believe to >>> be necessary to provide from my prior knowledge and what point to begin >>> with in features to cause this to be expressed. The examples that I >>> have found regarding how to use BDD features run the gamut from >>> specifying model attributes and data normalization to macro statements >>> of the form: >>> >>> Given I have a web application >>> When I visit the application url >>> Then I should see a welcome message >>> And I should see a sign in request >>> >>> etc. >>> >>> So, the question I have is: >>> >>> Given I have an application design document >>> When I specify the design using BDD >>> Then I should first begin with ?????? >>> >>> -- >>> Posted via http://www.ruby-forum.com/. >>> _______________________________________________ >>> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon Dec 8 11:56:24 2008 From: lists at ruby-forum.com (James Byrne) Date: Mon, 8 Dec 2008 17:56:24 +0100 Subject: [rspec-users] stepping across features In-Reply-To: <88fd8ddc0812080538p77bc48d5j25c33c3e06610a89@mail.gmail.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> <88fd8ddc0812050842ne7a213xbaa9b75f5837c1ce@mail.gmail.com> <51f2f3c0c0cc4ad38c70b2b20c140b33@ruby-forum.com> <88fd8ddc0812062321r14591fffk32fbea980da77d5f@mail.gmail.com> <20881a4cead6714e35fe9e175f4bd012@ruby-forum.com> <88fd8ddc0812080538p77bc48d5j25c33c3e06610a89@mail.gmail.com> Message-ID: <3596fd71bafc8628505f9eacf691a957@ruby-forum.com> Andrew Premdas wrote: > > TIp: When writing the step don't use - visits "/invoices/new" - use > visits "invoice_new_path". Use named routes and let the routing names > REST and resources define where you go, and think about what you want > to implement This advice is really helpful. I was reading the section on routing in "The Rails Way" last night, and it came to me that perhaps I had overlooked the essence of what I was really trying to accomplish. That I was so fixated on the code yet to be produced at the detail level that I had missed the boat with respect to how the users would treat the application as a whole. I concluded that I really needed to see the new application, and the features that I had to write, in terms of resources. Then, given the resource name, the requisite information would be exposed. This in turn would expose the requirements needed to assemble that information from data, and from those assembly requirements would come the code requirements. However, I was, until I read your reply, still thinking in terms of "/application/clients/:myclient/workorders/:id/charges/:billable" instead of client_workorder_charges_path(@client, at client.workorders,"billable") or however that is supposed to be expressed. > > If you now deal with your charges, you will probably get to the stage > very quickly where you can't avoid clients. So then you do the very > simplest general thing for clients. It is impossible to undo the past. We have already invested a considerable amount of energy and time into determining how we wish to express the concept of a client as a transient role of some persistent entity rather than as an artifact in itself. But, that said, I am beginning to see that this can be set aside in the early stages. > > Finally every time you find that the baby step you are taking is > actually more like a giant leap (or actually anything other than > the smallest of steps) STOP! Then start again questioning what > is not central and what is not specific. > > HTH Very helpful. I expect that as I gather my wits regarding BDD that this advice will prove even more valuable. I tried a little bit of this out on one of the end users and I was surprised at the responses that I obtained. In consequence, this is what I contemplate beginning with. Feature: A web based business application In Order To: Conduct Business Any Authorized User Should Access the Business Application via http To reduce costs Scenario: The Application has a home page Given an application accessible by http And I am not signed in When I browse to the url "/" on the application host Then I should see a welcome message And I should see a sign on request message And I should see a sign on link And I should see a contact us link And I should see ... Scenario: The Application has a sign on page Given I am on the home page And I am not signed in When I select the sign on link Then I should see the sign on page And the protocol should be https And I should see a text entry for user name And I should see a text entry for password And I should see a sign on action selector Scenario: User Signs On Successfully Given I am on the sign on page And I am not signed in And I have a user named "myuser" And the user named "myuser" has a password of "myuserpassword" When I provide a user name "myuser" And I provide a password "myuserpassword" And I select the sign on action Then I should see a sign on success message And I should see the users home page Scenario: User Sign On Fails - wrong password ... Scenario: User Sign On Fails - no such user ... Scenario: User Sign On Fails - more than 3 attempts in 20 seconds ... Then we have identified a new feature, the user home page. Also, one can foresee that additional scenarios are required, like "User Signs in >From a Secured Resource" where following a successful sign in the user is redirected back to the resource that they originally requested. On the users home page we discover the resources accessible by that user are listed. From those resources the next layer of features become exposed, and so on. Is this getting closer to the mark or am I moving around the target but not quite getting it? -- Posted via http://www.ruby-forum.com/. From rupert at rupespad.com Mon Dec 8 12:56:07 2008 From: rupert at rupespad.com (Rupert Voelcker) Date: Mon, 8 Dec 2008 17:56:07 +0000 Subject: [rspec-users] uber-rcov for both cucumber & rspec Message-ID: <52138110812080956n3f5357ack28740a267be8e0c9@mail.gmail.com> I've had a quick look at the rake tasks for rspec and cucumber (and rcov), but not having payed with rake very much I can't at the moment get my head around what I need to do so am hoping for some guidance.... What I want is an uber-rcov task which will run all my features and all my specs using rcov so I can get a picture of overall coverage for my cucumber stories and rspec specs after they all have run (rather than separately). Should such a thing be possible and does anyone have a rake ask that does this - failing that any pointers muchly appreciated. Thanks Rupert From philodespotos at gmail.com Mon Dec 8 14:07:38 2008 From: philodespotos at gmail.com (Kyle Hargraves) Date: Mon, 8 Dec 2008 13:07:38 -0600 Subject: [rspec-users] uber-rcov for both cucumber & rspec In-Reply-To: <52138110812080956n3f5357ack28740a267be8e0c9@mail.gmail.com> References: <52138110812080956n3f5357ack28740a267be8e0c9@mail.gmail.com> Message-ID: <60f3810c0812081107g53da6c68jb09429e3676993af@mail.gmail.com> On Mon, Dec 8, 2008 at 11:56 AM, Rupert Voelcker wrote: > I've had a quick look at the rake tasks for rspec and cucumber (and > rcov), but not having payed with rake very much I can't at the moment > get my head around what I need to do so am hoping for some > guidance.... > > What I want is an uber-rcov task which will run all my features and > all my specs using rcov so I can get a picture of overall coverage for > my cucumber stories and rspec specs after they all have run (rather > than separately). > > Should such a thing be possible and does anyone have a rake ask that > does this - failing that any pointers muchly appreciated. I don't have a rake task you could just drop in place, but rcov provides the --aggregate option to facilitate merging the coverage results of multiple test suites. k From pergesu at gmail.com Mon Dec 8 15:31:11 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 08 Dec 2008 12:31:11 -0800 Subject: [rspec-users] Indentation Conventions for Ruby and Cucumber In-Reply-To: <88fd8ddc0812062330o55b1dba9pb5a0ecd119df099b@mail.gmail.com> (Andrew Premdas's message of "Sun\, 7 Dec 2008 07\:30\:10 +0000") References: <57a815bf0812030350u6ca51551y8a4f3731260b3273@mail.gmail.com> <88fd8ddc0812030627n7743e635lc49309244ddcc9c8@mail.gmail.com> <937d9d810812041114q2dee3159pdea219ffff9c241a@mail.gmail.com> <85d99afe0812041343i6f93346dr6a245703634b226b@mail.gmail.com> <57a815bf0812060425t25f2f3d9j2c5674f141323093@mail.gmail.com> <88fd8ddc0812062330o55b1dba9pb5a0ecd119df099b@mail.gmail.com> Message-ID: I think that's ugly. Better to use syntax highlighting in an editor, imo. Pat "Andrew Premdas" writes: > Original post was somewhat flippant :) > > To be more precise. This style is > > "aligning on the first letter of the second word" > > and basically is treating the first word as a label and the rest as content, and using indentation to differentiate (hopefully clearly) > > Andrew > > 2008/12/6 Mikel Lindsaar > > On Thu, Dec 4, 2008 at 1:27 AM, Andrew Premdas wrote: > > Oh but cucumber features so want to be idented on the I > > Scenario: Anonymous user can not duplicate a un-activated account > Given I am an anonymous user > And a registered user Fred exists > When I signup as Fred > Then I should see an error > > Really need to view above with a monspaced font - if its not coming out that way in your mail reader. > > The problem with that however is that it is not compliant with Internationalization standards... > > Not to mention it would then naturally bias someone toward using an enforced I. > > What if I didn't want to use an "I", but an "it" say, in terms of an API that is being talked to by another system... > > -- > http://lindsaar.net/ > Rails, RSpec and Life blog.... > > _______________________________________________ > 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 Mon Dec 8 15:32:22 2008 From: pergesu at gmail.com (Pat Maddox) Date: Mon, 08 Dec 2008 12:32:22 -0800 Subject: [rspec-users] Where to start after writing feature In-Reply-To: <88fd8ddc0812062349u58e7e9u556c1d6944c2bfd9@mail.gmail.com> (Andrew Premdas's message of "Sun\, 7 Dec 2008 07\:49\:07 +0000") References: <88fd8ddc0812062349u58e7e9u556c1d6944c2bfd9@mail.gmail.com> Message-ID: In the future, if you're going to +1 his advice could you please include it in your email? I have to go searching for it now. Pat "Andrew Premdas" writes: > +1 to Davids advice > > But first I would analyse the feature I've written. Some of the things I'd think about include > > 1) The use of the word task - its not very precise > 2) The assumptions made in my story and whether I'm ready to make these yet > > a) That a task will have a name > b) That only English users will be using this page > c) That people will now what a CAS link is > ... > > 3) The brittleness of what I've written - what will change and how will I have to modify what I've done > > So my initial scenario might be > > When I create a new improvement > I should see a confirmation > > and my second scenario might be > > Given there are some improvements > I should be able to view improvements > > Finally have a think about whether this feature is actually important enough to be doing first. > > HTH > > 2008/12/5 Stephen Veit > > I am trying to develop code from the feature on down. > > So I created a brand new rails app. It has no models yet. I wrote a feature: > > Feature: Add tasks > In order to track website improvements > a user > wants to add tasks > > Scenario: User adds task > Given task "Display Group Rules" does not exist > When I visit "/tasks/new" > And I fill in "Name" with "Display Group Rules" > And I fill in "Description" with "Displays links to edit each group rule" > And I fill in "CAS Link" with "GroupRulesManager/" > And I press "Submit" > Then I should end up on the Tasks page > And I should see "Task successfully added" > And the task "Display Group Rules" should exist > > I then run: > > rake db:migrate (this creates my development SQLite3 database) > rake db:test:prepare (this creates my development SQLite3 database) > rake features (outputs the following:) > > Feature: Add tasks # features/manage_task.feature > In order to track website improvements > a user > wants to add tasks > Scenario: User adds task > Given task "Display Group Rules" does not exist > When I visit "/tasks/new" > And I fill in "Name" with "Display Group Rules" > And I fill in "Description" with "Displays links to edit each group rule" > And I fill in "CAS Link" with "GroupRulesManager/" > And I press "Submit" > Then I should end up on the Tasks page > And I should see "Task successfully added" > And the task "Display Group Rules" should exist > > 5 steps skipped > 4 steps pending > > You can use these snippets to implement pending steps: > > Given /^task "Display Group Rules" does not exist$/ do > end > > When /^I visit "\/tasks\/new"$/ do > end > > Then /^I should end up on the Tasks page$/ do > end > > Then /^the task "Display Group Rules" should exist$/ do > end > > My question is where to go from here. Do I implement the four pending steps, e.g: > > Given /^task "(.+)" does not exist$/ do |name| > task = Task.find_by_name(name) > task.destroy if task > end > > Or do I run: > > ./script/generate scaffold_resource task name:string description:text cas_link:string > > and the rake rspec and fix whatever errors show up there? > > What are your thoughts? TIA > > -- > Stephen Veit > 314-616-9688 > > _______________________________________________ > 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 lists at ruby-forum.com Mon Dec 8 16:12:06 2008 From: lists at ruby-forum.com (James Byrne) Date: Mon, 8 Dec 2008 22:12:06 +0100 Subject: [rspec-users] Where to start after writing feature In-Reply-To: References: <88fd8ddc0812062349u58e7e9u556c1d6944c2bfd9@mail.gmail.com> Message-ID: <94cfa7af1968f63801e4885257223a6f@ruby-forum.com> Pat Maddox wrote: > In the future, if you're going to +1 his advice could you please include > it in your email? I have to go searching for it now. > > Pat > > "Andrew Premdas" writes: http://www.ruby-forum.com/topic/172701. Third from the top. Regards, -- Posted via http://www.ruby-forum.com/. From lenny at aps.org Mon Dec 8 16:31:29 2008 From: lenny at aps.org (Lenny Marks) Date: Mon, 8 Dec 2008 16:31:29 -0500 Subject: [rspec-users] ArgumentError mystery with jruby/rspec-1.1.11 Message-ID: <4DD7A591-4B03-4407-911F-512D5FCB1293@aps.org> I just got bitten by a strange issue with rspec-1.1.11 and jruby 1.1.3-1.1.6RC1. I'd love to know what the problem was if anyone has any ideas. It's almost as if, rspec didn't like something about this particular class since substituting others worked fine. It does work with Rspec edge so I guess its not too important. Hopefully if anyone else runs into this they'll hit upon this. -lenny # reproduce.rb require './spring.jar' describe "test with spring" do it "should not raise ArgumentError" do Java ::org.springframework.context.support.ClassPathXmlApplicationContext # line 7 end end > jruby-1.1.3/bin/jruby -v -S spec -v jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-12-08 rev 6586) [x86_64- java] rspec 1.1.11 > jruby-1.1.3/bin/jruby -S spec -fs -b reproduce.rb test with spring - should not raise ArgumentError (ERROR - 1) 1) ArgumentError in 'test with spring should not raise ArgumentError' ArgumentError /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/extensions/ main.rb:23:in `describe' /home/jis/compsvc/lenny/tmp/x/./reproduce.rb:7: /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_methods.rb:81:in `instance_eval' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_methods.rb:81:in `eval_block' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_methods.rb:15:in `execute' /Users/Shared/eds_test/share/jruby-1.1.3/lib/ruby/1.8/timeout.rb:48:in `timeout' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_methods.rb:12:in `execute' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_group_methods.rb:245:in `execute_examples' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_group_methods.rb:244:in `each' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_group_methods.rb:244:in `execute_examples' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_group_methods.rb:141:in `run' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/ example_group_runner.rb:22:in `run' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/ example_group_runner.rb:21:in `each' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/ example_group_runner.rb:21:in `run' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/ options.rb:115:in `run_examples' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/ command_line.rb:10:in `run' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/bin/spec:4: /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/bin/spec:19:in `load' /Users/Shared/eds_test/share/jruby-1.1.3/bin/spec:19: /jruby-1.1.3/bin/jruby -v rspec/bin/spec -v jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-12-08 rev 6586) [x86_64- java] rspec 1.1.11.1 > jruby-1.1.3/bin/jruby rspec/bin/spec -fs reproduce.rb test with spring - should not raise ArgumentError Finished in 0.329 seconds 1 example, 0 failures From apremdas at gmail.com Mon Dec 8 18:20:43 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 8 Dec 2008 23:20:43 +0000 Subject: [rspec-users] stepping across features In-Reply-To: <3596fd71bafc8628505f9eacf691a957@ruby-forum.com> References: <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> <88fd8ddc0812050842ne7a213xbaa9b75f5837c1ce@mail.gmail.com> <51f2f3c0c0cc4ad38c70b2b20c140b33@ruby-forum.com> <88fd8ddc0812062321r14591fffk32fbea980da77d5f@mail.gmail.com> <20881a4cead6714e35fe9e175f4bd012@ruby-forum.com> <88fd8ddc0812080538p77bc48d5j25c33c3e06610a89@mail.gmail.com> <3596fd71bafc8628505f9eacf691a957@ruby-forum.com> Message-ID: <88fd8ddc0812081520t681465b5ue638874c655a0214@mail.gmail.com> Glad to be of some use. I think you're getting stuff, and your questions are helping me get stuff and clarify some thoughts as well so thankyou for that. 2008/12/8 James Byrne > Andrew Premdas wrote: > > > > TIp: When writing the step don't use - visits "/invoices/new" - use > > visits "invoice_new_path". Use named routes and let the routing names > > REST and resources define where you go, and think about what you want > > to implement > > This advice is really helpful. I was reading the section on routing in > "The Rails Way" last night, and it came to me that perhaps I had > overlooked the essence of what I was really trying to accomplish. That > I was so fixated on the code yet to be produced at the detail level that > I had missed the boat with respect to how the users would treat the > application as a whole. I concluded that I really needed to see the new > application, and the features that I had to write, in terms of > resources. Then, given the resource name, the requisite information > would be exposed. This in turn would expose the requirements needed to > assemble that information from data, and from those assembly > requirements would come the code requirements. > > However, I was, until I read your reply, still thinking in terms of > "/application/clients/:myclient/workorders/:id/charges/:billable" > instead of > client_workorder_charges_path(@client, at client.workorders,"billable") or > however that is supposed to be expressed. > > > > > If you now deal with your charges, you will probably get to the stage > > very quickly where you can't avoid clients. So then you do the very > > simplest general thing for clients. > > It is impossible to undo the past. We have already invested a > considerable amount of energy and time into determining how we wish to > express the concept of a client as a transient role of some persistent > entity rather than as an artifact in itself. But, that said, I am > beginning to see that this can be set aside in the early stages. > > > > > Finally every time you find that the baby step you are taking is > > actually more like a giant leap (or actually anything other than > > the smallest of steps) STOP! Then start again questioning what > > is not central and what is not specific. > > > > HTH > > Very helpful. I expect that as I gather my wits regarding BDD that this > advice will prove even more valuable. > > I tried a little bit of this out on one of the end users and I was > surprised at the responses that I obtained. In consequence, this is > what I contemplate beginning with. > > Feature: A web based business application > In Order To: Conduct Business > Any Authorized User > Should Access the Business Application via http > To reduce costs > > Scenario: The Application has a home page > Given an application accessible by http > And I am not signed in > When I browse to the url "/" on the application host > Then I should see a welcome message > And I should see a sign on request message > And I should see a sign on link > And I should see a contact us link > And I should see ... > > Scenario: The Application has a sign on page > Given I am on the home page > And I am not signed in > When I select the sign on link > Then I should see the sign on page > And the protocol should be https > And I should see a text entry for user name > And I should see a text entry for password > And I should see a sign on action selector > > Scenario: User Signs On Successfully > Given I am on the sign on page > And I am not signed in > And I have a user named "myuser" > And the user named "myuser" has a password of "myuserpassword" > When I provide a user name "myuser" > And I provide a password "myuserpassword" > And I select the sign on action > Then I should see a sign on success message > And I should see the users home page > > Scenario: User Sign On Fails - wrong password > ... > Scenario: User Sign On Fails - no such user > ... > Scenario: User Sign On Fails - more than 3 attempts in 20 seconds > ... > > Then we have identified a new feature, the user home page. Also, one > can foresee that additional scenarios are required, like "User Signs in > >From a Secured Resource" where following a successful sign in the user > is redirected back to the resource that they originally requested. On > the users home page we discover the resources accessible by that user > are listed. From those resources the next layer of features become > exposed, and so on. > > Is this getting closer to the mark or am I moving around the target but > not quite getting it? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Mon Dec 8 18:25:32 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 8 Dec 2008 23:25:32 +0000 Subject: [rspec-users] Where to start after writing feature In-Reply-To: References: <88fd8ddc0812062349u58e7e9u556c1d6944c2bfd9@mail.gmail.com> Message-ID: <88fd8ddc0812081525l15fa83bds50a15113fb685a8b@mail.gmail.com> Ok sorry bout that, perils of using gmail I guess... 2008/12/8 Pat Maddox > In the future, if you're going to +1 his advice could you please include > it in your email? I have to go searching for it now. > > Pat > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alberto.perdomo at aentos.es Mon Dec 8 18:37:15 2008 From: alberto.perdomo at aentos.es (Alberto Perdomo) Date: Mon, 8 Dec 2008 23:37:15 +0000 Subject: [rspec-users] Restful Authentication and Cucumber In-Reply-To: <9253E67A-D69D-4482-BA03-180DDE1536C5@mattwynne.net> References: <944a03770811271538s4367d84an5ad41d8c90b86c6a@mail.gmail.com> <9253E67A-D69D-4482-BA03-180DDE1536C5@mattwynne.net> Message-ID: <7c628d690812081537q5bde176fk3ef3ea21822004b9@mail.gmail.com> Hi Andrei, >>> This is the step: >>> >>> Given /I am logged in as a user/ do >>> @current_user = Factory.define :user do |u| >>> u.name 'the user' >>> u.email 'erdoss at gmail.com' >>> u.login 'the_login' >>> u.password 'password' >>> u.password_confirmation 'password' >>> end >>> visits "/login" >>> fills_in("login", :with => "the_login") >>> fills_in("password", :with => "password") >>> clicks_button("Log in") >>> end you can simplify the code to activate the user. This is my step definition for login: When /^i login$/ do user = Factory(:user) user.register! user.activate! fill_in("username", :with => user.login) fill_in("password", :with => user.password) click_button("Login") end This is my factory code in test/factories.rb Factory.define :user do |u| u.login 'user' u.password 'password' u.password_confirmation 'password' u.email 'test at example.com' end I think i saw a fork of factory_girl somewhere that supported before and after hooks so you could actually call the register and activate methods after save from within the factory definition code. This way your steps and other tests would be much cleaner. I will look further into it. Cheers, Alberto. From alberto.perdomo at aentos.es Mon Dec 8 19:03:33 2008 From: alberto.perdomo at aentos.es (Alberto Perdomo) Date: Tue, 9 Dec 2008 00:03:33 +0000 Subject: [rspec-users] Stories, permissions, authorization rules etc. Message-ID: <7c628d690812081603h3a0d3a82w2c9a6c6edeaf274@mail.gmail.com> Hi, my team and i have come to the point where we have defined a whole bunch of stories for an application. Almost all of the actions (besides login, etc.) should *not* be accesible if not logged in. Almost all of the actions require a specific user role. So, my question is. How do you put that in stories? I have come up with these different options: 1) In each story, e.g. 'Add a new issue', 'Comment issue', etc. you define a few extra scenarios more or less like this: Scenario: Permission denied if not logged in Given i am not logged in When i visit 'issues/new' I should see Permission denied And i should not see 'Add Issue' Scenario: Permission denied if role not developer Given i am logged in And my role is not developer When i visit 'issues/new' I should see Permission denied And i should not see 'Add Issue' ... 2) You could write a separate story (or multiple separate stories) just for the matter of describing permissions and authorizarion rules. 3) You could just write scenarios for the role requirements (like 1) and leave the logged_in scenario out, giving for granted that you are going to make all actions inaccesible without logging in. I prefer option 1 although it feels not DRY. I think explicit stories are good, and such important things as permissions etc. should not be left out. My mates argue that there has to be a better solutions than taking 50 stories and adding 2 o 3 scenarios that look more or less the same to each of them. I don't like 2 because it breaks the granularity of the stories. Stories should be more or less independant from each other. If you decide not to implement a specific story then you would have to edit again the permissions story. Also the permissions story will not pass until you have implemented all the scenarios = until you have implemented all the actions involved. I don't like 3 because it is against testing philosophy.You should not rely on the memory of humans. That's one of the reasons to write stories. Theoretically you could write something like a scenario that goes through all your app routes and checks if they are accessible. So tell me. How do you do such things? Do you have any other approaches? It's important to us from a cucumber/rspec perspective (how do you test it?) but also from a requirements perspective (where do you write down that part when gathering the user stories?). Cheers! Alberto. From jonathan at parkerhill.com Tue Dec 9 02:50:47 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 9 Dec 2008 02:50:47 -0500 Subject: [rspec-users] Stories, permissions, authorization rules etc. In-Reply-To: <7c628d690812081603h3a0d3a82w2c9a6c6edeaf274@mail.gmail.com> References: <7c628d690812081603h3a0d3a82w2c9a6c6edeaf274@mail.gmail.com> Message-ID: I usually assume my scenario user has been Given permission and instead, I do the authorization testing in the controller specs with shared behaviors, for example, it_should_behave_like "a login required action" it_should_behave_like "a manager authorized action" That said, I also might have a story where a user with the wrong permissions pokes around, but this is not a full coverage test at all. Its more for verifying how the app responds, with redirects or a message to the user, login prompt, etc. --linoj On Dec 8, 2008, at 7:03 PM, Alberto Perdomo wrote: > Hi, > > my team and i have come to the point where we have defined a whole > bunch of stories for an application. > Almost all of the actions (besides login, etc.) should *not* be > accesible if not logged in. > Almost all of the actions require a specific user role. > > So, my question is. How do you put that in stories? > I have come up with these different options: > > 1) In each story, e.g. 'Add a new issue', 'Comment issue', etc. you > define a few extra scenarios more or less like this: > > Scenario: Permission denied if not logged in > Given i am not logged in > When i visit 'issues/new' > I should see Permission denied > And i should not see 'Add Issue' > > Scenario: Permission denied if role not developer > Given i am logged in > And my role is not developer > When i visit 'issues/new' > I should see Permission denied > And i should not see 'Add Issue' > > ... > > 2) You could write a separate story (or multiple separate stories) > just for the matter of describing permissions and authorizarion rules. > > 3) You could just write scenarios for the role requirements (like 1) > and leave the logged_in scenario out, giving for granted that you are > going to make all actions inaccesible without logging in. > > I prefer option 1 although it feels not DRY. I think explicit stories > are good, and such important things as permissions etc. should not be > left out. My mates argue that there has to be a better solutions than > taking 50 stories and adding 2 o 3 scenarios that look more or less > the same to each of them. > > I don't like 2 because it breaks the granularity of the stories. > Stories should be more or less independant from each other. If you > decide not to implement a specific story then you would have to edit > again the permissions story. Also the permissions story will not pass > until you have implemented all the scenarios = until you have > implemented all the actions involved. > > I don't like 3 because it is against testing philosophy.You should not > rely on the memory of humans. That's one of the reasons to write > stories. Theoretically you could write something like a scenario that > goes through all your app routes and checks if they are accessible. > > So tell me. > How do you do such things? > Do you have any other approaches? > It's important to us from a cucumber/rspec perspective (how do you > test it?) but also from a requirements perspective (where do you write > down that part when gathering the user stories?). > > Cheers! > Alberto. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From apremdas at gmail.com Tue Dec 9 03:52:21 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Tue, 9 Dec 2008 08:52:21 +0000 Subject: [rspec-users] Stories, permissions, authorization rules etc. In-Reply-To: <7c628d690812081603h3a0d3a82w2c9a6c6edeaf274@mail.gmail.com> References: <7c628d690812081603h3a0d3a82w2c9a6c6edeaf274@mail.gmail.com> Message-ID: <88fd8ddc0812090052k71b67c50wbb636595202af258@mail.gmail.com> You can improve the features you've given by 1. use named routes not url's 2. not checking for not seeing specific things 3. A combined step with a more examples table Given I am logged in as a developer 4. having a general policy for what happens when access fails and testing that e.g. routing back to home page or where you came from 5. An uber combined step with a funky step matcher where the step definition would go through all the Roles and visit x with each one testing for an error Given I am not a logged in developer I should get an error when I visit x '5' seems pretty ugly to me, but maybe in this case its bearable. Making the features as simple as possible should reduce the resistance to their repitition As to the issue of using stories for coverage, I guess a balance has to be struck which is very dependent on business needs. If there are specific business rules that need to be enforced for a role then make that explicit in features. If the business rule is much more general and their are lots of role/access combinations then maybe do this in a more unit test way i.e. not in features 2008/12/9 Alberto Perdomo > Hi, > > my team and i have come to the point where we have defined a whole > bunch of stories for an application. > Almost all of the actions (besides login, etc.) should *not* be > accesible if not logged in. > Almost all of the actions require a specific user role. > > So, my question is. How do you put that in stories? > I have come up with these different options: > > 1) In each story, e.g. 'Add a new issue', 'Comment issue', etc. you > define a few extra scenarios more or less like this: > > Scenario: Permission denied if not logged in > Given i am not logged in > When i visit 'issues/new' > I should see Permission denied > And i should not see 'Add Issue' > > Scenario: Permission denied if role not developer > Given i am logged in > And my role is not developer > When i visit 'issues/new' > I should see Permission denied > And i should not see 'Add Issue' > > ... > > 2) You could write a separate story (or multiple separate stories) > just for the matter of describing permissions and authorizarion rules. > > 3) You could just write scenarios for the role requirements (like 1) > and leave the logged_in scenario out, giving for granted that you are > going to make all actions inaccesible without logging in. > > I prefer option 1 although it feels not DRY. I think explicit stories > are good, and such important things as permissions etc. should not be > left out. My mates argue that there has to be a better solutions than > taking 50 stories and adding 2 o 3 scenarios that look more or less > the same to each of them. > > I don't like 2 because it breaks the granularity of the stories. > Stories should be more or less independant from each other. If you > decide not to implement a specific story then you would have to edit > again the permissions story. Also the permissions story will not pass > until you have implemented all the scenarios = until you have > implemented all the actions involved. > > I don't like 3 because it is against testing philosophy.You should not > rely on the memory of humans. That's one of the reasons to write > stories. Theoretically you could write something like a scenario that > goes through all your app routes and checks if they are accessible. > > So tell me. > How do you do such things? > Do you have any other approaches? > It's important to us from a cucumber/rspec perspective (how do you > test it?) but also from a requirements perspective (where do you write > down that part when gathering the user stories?). > > Cheers! > Alberto. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Tue Dec 9 04:43:57 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 9 Dec 2008 10:43:57 +0100 Subject: [rspec-users] Cucumber fat client Message-ID: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> Hi folks, Cucumber has become popular a lot quicker than I had anticipated. Still, with its plain text nature it is still limited to programmers (in most teams). I want to close the gap between customers/product owners/business analysts and programmers, and I'm convinced that a fat client is needed to achieve this. Something that lets people browse, edit and run features inside a friendly user interface. So I'm asking you - what would this user interface be like? How do people want to access it and use it? Cheers, Aslak -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Tue Dec 9 05:12:31 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 9 Dec 2008 11:12:31 +0100 Subject: [rspec-users] Wanna make the Cucumber Logo? Message-ID: <8d961d900812090212o43cc402cnd07c252d144c7724@mail.gmail.com> Check this out: http://github.com/aslakhellesoy/cucumber/wikis/logo-contest Aslak -------------- next part -------------- An HTML attachment was scrubbed... URL: From baz at madeofstone.net Tue Dec 9 05:47:37 2008 From: baz at madeofstone.net (Rahoul Baruah) Date: Tue, 9 Dec 2008 10:47:37 +0000 Subject: [rspec-users] Cucumber fat client In-Reply-To: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> Message-ID: <3FE7305D-06F1-47E6-87FE-6F05FFC2F3B7@madeofstone.net> On 9 Dec 2008, at 09:43, aslak hellesoy wrote: > So I'm asking you - what would this user interface be like? How do > people want to access it > and use it? I was considering writing (but will probably never have time for) a simple writeboard/wiki-style site that is linked to a git repository. So you point the app at a clone of your git repository's features folder, people can browse the folder, edit a feature in the browser (and view the history) and then push them straight back into the repo. (I noticed someone else had posted a writeboard-based system earlier too) B Rahoul Baruah Web design and development: http://www.3hv.co.uk/ Nottingham Forest: http://www.eighteensixtyfive.co.uk/ Serious Rails Hosting: http://www.brightbox.co.uk/ Lifecast: http://www.madeofstone.net/ From aidy.lewis at googlemail.com Tue Dec 9 05:56:05 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Tue, 9 Dec 2008 10:56:05 +0000 Subject: [rspec-users] Cucumber fat client In-Reply-To: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> Message-ID: <7ac2300c0812090256h270ac76n801cb6785a21d85c@mail.gmail.com> Hi Aslak, Below are my manager's recommendations: "If you take a look at Twist, Thoughtworks have already done the hard work in gleaning the requirements for this. Something Twist like would be well received. http://studios.thoughtworks.com/twist-agile-test-automation Their implementation is eclipse based." Thanks Aidy 2008/12/9 aslak hellesoy : > Hi folks, > > Cucumber has become popular a lot quicker than I had anticipated. > Still, with its plain text nature it is still limited to programmers (in > most teams). > > I want to close the gap between customers/product owners/business analysts > and programmers, > and I'm convinced that a fat client is needed to achieve this. Something > that lets people > browse, edit and run features inside a friendly user interface. > > So I'm asking you - what would this user interface be like? How do people > want to access it > and use it? > > Cheers, > Aslak > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Tue Dec 9 06:15:10 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 9 Dec 2008 12:15:10 +0100 Subject: [rspec-users] Cucumber fat client In-Reply-To: <3FE7305D-06F1-47E6-87FE-6F05FFC2F3B7@madeofstone.net> References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <3FE7305D-06F1-47E6-87FE-6F05FFC2F3B7@madeofstone.net> Message-ID: <8d961d900812090315j18ec2bd3g2247ce16f3b930a3@mail.gmail.com> On Tue, Dec 9, 2008 at 11:47 AM, Rahoul Baruah wrote: > > On 9 Dec 2008, at 09:43, aslak hellesoy wrote: > > So I'm asking you - what would this user interface be like? How do people >> want to access it >> and use it? >> > > > I was considering writing (but will probably never have time for) a simple > writeboard/wiki-style site that is linked to a git repository. > > So you point the app at a clone of your git repository's features folder, > people can browse the folder, edit a feature in the browser (and view the > history) and then push them straight back into the repo. > > (I noticed someone else had posted a writeboard-based system earlier too) > Yes, it's called Remote Feature: http://github.com/aslakhellesoy/cucumber/wikis/related-tools http://github.com/mhennemeyer/remote_feature/tree/master Aslak > > B > > Rahoul Baruah > Web design and development: http://www.3hv.co.uk/ > Nottingham Forest: http://www.eighteensixtyfive.co.uk/ > Serious Rails Hosting: http://www.brightbox.co.uk/ > Lifecast: http://www.madeofstone.net/ > > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivorpaul at gmail.com Tue Dec 9 06:29:51 2008 From: ivorpaul at gmail.com (Ivor Paul) Date: Tue, 9 Dec 2008 13:29:51 +0200 Subject: [rspec-users] testing call to super in rails helper Message-ID: Hi I have the following code: def will_paginate(items, options = {}) options = options.merge(:container => true, :class => 'paging') super(items, options) end I am curious about how to test that the call to super is infact being called with the added options. I have this it 'should call super on will_paginate' do helper.stub!(:will_paginate).with([], {:container => true, :class => 'paging'}).and_return(true) helper.should_receive(:will_paginate).with([], {:container => true, :class => 'paging'}) helper.will_paginate([]) end But it fails as will_paginate is called with [] before being called with ([], {:container => true, :class => 'paging'}) I am relatively new to rspec, but trying to learn more - if there is a blog post on how to deal with these situations, please point me in the right direction. Help much appreciated. Ivor -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Tue Dec 9 09:45:08 2008 From: nick at deadorange.com (Nick Hoffman) Date: Tue, 9 Dec 2008 09:45:08 -0500 Subject: [rspec-users] testing call to super in rails helper In-Reply-To: References: Message-ID: <510294CC-7696-491A-BFAC-81F4986B51B1@deadorange.com> On 2008-12-09, at 06:29, Ivor Paul wrote: > Hi > > I have the following code: > > def will_paginate(items, options = {}) > options = options.merge(:container => true, :class => 'paging') > super(items, options) > end > > I am curious about how to test that the call to super is infact > being called with the added options. > > I have this > > it 'should call super on will_paginate' do > helper.stub!(:will_paginate).with([], {:container => > true, :class => 'paging'}).and_return(true) > helper.should_receive(:will_paginate).with([], {:container => > true, :class => 'paging'}) > helper.will_paginate([]) > end > > But it fails as will_paginate is called with [] before being called > with ([], {:container => true, :class => 'paging'}) > > I am relatively new to rspec, but trying to learn more - if there is > a blog post on how to deal with these situations, please point me in > the right direction. > > Help much appreciated. > > Ivor G'day Ivor. See this thread for details: http://www.ruby-forum.com/topic/151744 -Nick From shingler at gmail.com Tue Dec 9 09:52:58 2008 From: shingler at gmail.com (steven shingler) Date: Tue, 9 Dec 2008 14:52:58 +0000 Subject: [rspec-users] Cucumber fat client In-Reply-To: <8d961d900812090315j18ec2bd3g2247ce16f3b930a3@mail.gmail.com> References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <3FE7305D-06F1-47E6-87FE-6F05FFC2F3B7@madeofstone.net> <8d961d900812090315j18ec2bd3g2247ce16f3b930a3@mail.gmail.com> Message-ID: Hey Aslak, Doesn't this sound a bit like your Kipling project, which we spoke about at QCon London, back in March? ;) (http://gitorious.org/projects/kipling) I think it would be a great app to have, which would work well inside a web browser, rather than a fat client that customers and managers have to download...? >From my recollection, you were wanting to keep Kipling quite sparse and text based, in contrast to the Thoughtworks product which Aidy mentioned in this thread. I would be interested in getting involved with this, if I could be helpful in any way :) Steven On Tue, Dec 9, 2008 at 11:15 AM, aslak hellesoy wrote: > > > On Tue, Dec 9, 2008 at 11:47 AM, Rahoul Baruah wrote: > >> >> On 9 Dec 2008, at 09:43, aslak hellesoy wrote: >> >> So I'm asking you - what would this user interface be like? How do people >>> want to access it >>> and use it? >>> >> >> >> I was considering writing (but will probably never have time for) a simple >> writeboard/wiki-style site that is linked to a git repository. >> >> So you point the app at a clone of your git repository's features folder, >> people can browse the folder, edit a feature in the browser (and view the >> history) and then push them straight back into the repo. >> >> (I noticed someone else had posted a writeboard-based system earlier too) >> > > Yes, it's called Remote Feature: > http://github.com/aslakhellesoy/cucumber/wikis/related-tools > http://github.com/mhennemeyer/remote_feature/tree/master > > Aslak > > >> >> B >> >> Rahoul Baruah >> Web design and development: http://www.3hv.co.uk/ >> Nottingham Forest: http://www.eighteensixtyfive.co.uk/ >> Serious Rails Hosting: http://www.brightbox.co.uk/ >> Lifecast: http://www.madeofstone.net/ >> >> >> >> >> >> >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Tue Dec 9 10:11:41 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 9 Dec 2008 16:11:41 +0100 Subject: [rspec-users] Cucumber fat client In-Reply-To: References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <3FE7305D-06F1-47E6-87FE-6F05FFC2F3B7@madeofstone.net> <8d961d900812090315j18ec2bd3g2247ce16f3b930a3@mail.gmail.com> Message-ID: <8d961d900812090711u1ce3b034r54b3c15f698cd617@mail.gmail.com> On Tue, Dec 9, 2008 at 3:52 PM, steven shingler wrote: > Hey Aslak, > > Doesn't this sound a bit like your Kipling project, which we spoke about at > QCon London, back in March? ;) > > (http://gitorious.org/projects/kipling) > A little bit, but the idea with Kipling was to make something similar to ThoughtWorks Mingle or Pivotal Tracker, which are tools to manage stories, iterations, estimates, burndown etc. My goal with a fat Cucumber client is different (although it clearly intersects): * Browse features * Edit features * Run features So I'm thinking more along the lines of Fitnesse, but with a more business-friendly UI, and focus on Cucumber (of course). Essentially - I want this to be primarily a tool that replaces TextMate and the CLI for editing and running features, and not so much a Scrum/XP planning tool. And the target audience is not us programmers (most of us are happy in TM/CLI) - it's the non-techies that know Word and Excel only (and are experts in their business' domain). Aslak > I think it would be a great app to have, which would work well inside a web > browser, rather than a fat client that customers and managers have to > download...? > > From my recollection, you were wanting to keep Kipling quite sparse and > text based, in contrast to the Thoughtworks product which Aidy mentioned in > this thread. > > I would be interested in getting involved with this, if I could be helpful > in any way :) > > Steven > > > On Tue, Dec 9, 2008 at 11:15 AM, aslak hellesoy wrote: > >> >> >> On Tue, Dec 9, 2008 at 11:47 AM, Rahoul Baruah wrote: >> >>> >>> On 9 Dec 2008, at 09:43, aslak hellesoy wrote: >>> >>> So I'm asking you - what would this user interface be like? How do >>>> people want to access it >>>> and use it? >>>> >>> >>> >>> I was considering writing (but will probably never have time for) a >>> simple writeboard/wiki-style site that is linked to a git repository. >>> >>> So you point the app at a clone of your git repository's features folder, >>> people can browse the folder, edit a feature in the browser (and view the >>> history) and then push them straight back into the repo. >>> >>> (I noticed someone else had posted a writeboard-based system earlier too) >>> >> >> Yes, it's called Remote Feature: >> http://github.com/aslakhellesoy/cucumber/wikis/related-tools >> http://github.com/mhennemeyer/remote_feature/tree/master >> >> Aslak >> >> >>> >>> B >>> >>> Rahoul Baruah >>> Web design and development: http://www.3hv.co.uk/ >>> Nottingham Forest: http://www.eighteensixtyfive.co.uk/ >>> Serious Rails Hosting: http://www.brightbox.co.uk/ >>> Lifecast: http://www.madeofstone.net/ >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Tue Dec 9 10:17:08 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 9 Dec 2008 15:17:08 +0000 Subject: [rspec-users] Cucumber fat client In-Reply-To: <8d961d900812090711u1ce3b034r54b3c15f698cd617@mail.gmail.com> References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <3FE7305D-06F1-47E6-87FE-6F05FFC2F3B7@madeofstone.net> <8d961d900812090315j18ec2bd3g2247ce16f3b930a3@mail.gmail.com> <8d961d900812090711u1ce3b034r54b3c15f698cd617@mail.gmail.com> Message-ID: <1F0D0F5F-76B5-421E-A87B-DF863411401B@mattwynne.net> On 9 Dec 2008, at 15:11, aslak hellesoy wrote: > On Tue, Dec 9, 2008 at 3:52 PM, steven shingler > wrote: > Hey Aslak, > > Doesn't this sound a bit like your Kipling project, which we spoke > about at QCon London, back in March? ;) > > (http://gitorious.org/projects/kipling) > > A little bit, but the idea with Kipling was to make something > similar to ThoughtWorks Mingle or Pivotal Tracker, which are tools > to manage stories, iterations, estimates, burndown etc. > > My goal with a fat Cucumber client is different (although it clearly > intersects): > * Browse features > * Edit features > * Run features I think that some kind of autocomplete / syntax highlighting that understands the currently-implemented set of step matchers would be really useful too - I already find myself wondering whether I've already implemented a step as I write the scenario. > So I'm thinking more along the lines of Fitnesse, but with a more > business-friendly UI, and focus on Cucumber (of course). > > Essentially - I want this to be primarily a tool that replaces > TextMate and the CLI for editing and running features, and not so > much a Scrum/XP planning tool. And the target audience is not us > programmers (most of us are happy in TM/CLI) - it's the non-techies > that know Word and Excel only (and are experts in their business' > domain). It would be good if it could integrate into a a planning tool though - offer an API that returned the number of Running Tested Features, etc. > I think it would be a great app to have, which would work well > inside a web browser, rather than a fat client that customers and > managers have to download...? +1 Matt Wynne http://blog.mattwynne.net http://www.songkick.com From ben at benmabey.com Tue Dec 9 11:51:44 2008 From: ben at benmabey.com (Ben Mabey) Date: Tue, 09 Dec 2008 09:51:44 -0700 Subject: [rspec-users] Cucumber fat client In-Reply-To: References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <3FE7305D-06F1-47E6-87FE-6F05FFC2F3B7@madeofstone.net> <8d961d900812090315j18ec2bd3g2247ce16f3b930a3@mail.gmail.com> Message-ID: <493EA220.7030406@benmabey.com> steven shingler wrote: > Hey Aslak, > > Doesn't this sound a bit like your Kipling project, which we spoke > about at QCon London, back in March? ;) > > (http://gitorious.org/projects/kipling) > > I think it would be a great app to have, which would work well inside > a web browser, rather than a fat client that customers and managers > have to download...? +1, I think keeping it in the browser will work well for most situations. One option is to make it a flex app and could then be used as a stand-alone Air app. WDYT? I have been thinking about the requirements for such a project and I think having it git-powered would be great. Having the stakeholder to be able to edit features and have the changes show up in a remote branch automatically would be a great feature IMO. If it is powered off of git we also get versioning and a lot of other stuff for free. (I would recommend watching Scott Chacoon's presentation on using git in this way from ruby conf: http://rubyconf2008.confreaks.com/using-git-in-ruby-applications.html) Anyways, thats my two cents. I would argue that most business people these days are just as, if not more, comfortable in a browser than they are in Excel as long as the UI is good. Of course, having clients for both would be ideal. :) -Ben > > From my recollection, you were wanting to keep Kipling quite sparse > and text based, in contrast to the Thoughtworks product which Aidy > mentioned in this thread. > > I would be interested in getting involved with this, if I could be > helpful in any way :) > > Steven > > > On Tue, Dec 9, 2008 at 11:15 AM, aslak hellesoy > > wrote: > > > > On Tue, Dec 9, 2008 at 11:47 AM, Rahoul Baruah > > wrote: > > > On 9 Dec 2008, at 09:43, aslak hellesoy wrote: > > So I'm asking you - what would this user interface be > like? How do people want to access it > and use it? > > > > I was considering writing (but will probably never have time > for) a simple writeboard/wiki-style site that is linked to a > git repository. > > So you point the app at a clone of your git repository's > features folder, people can browse the folder, edit a feature > in the browser (and view the history) and then push them > straight back into the repo. > > (I noticed someone else had posted a writeboard-based system > earlier too) > > > Yes, it's called Remote Feature: > http://github.com/aslakhellesoy/cucumber/wikis/related-tools > http://github.com/mhennemeyer/remote_feature/tree/master > > Aslak > > > > B > > Rahoul Baruah > Web design and development: http://www.3hv.co.uk/ > Nottingham Forest: http://www.eighteensixtyfive.co.uk/ > Serious Rails Hosting: http://www.brightbox.co.uk/ > Lifecast: http://www.madeofstone.net/ > > > > > > > _______________________________________________ > 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 josephwilk at joesniff.co.uk Tue Dec 9 11:47:19 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Tue, 09 Dec 2008 16:47:19 +0000 Subject: [rspec-users] Cucumber fat client In-Reply-To: <1F0D0F5F-76B5-421E-A87B-DF863411401B@mattwynne.net> References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <3FE7305D-06F1-47E6-87FE-6F05FFC2F3B7@madeofstone.net> <8d961d900812090315j18ec2bd3g2247ce16f3b930a3@mail.gmail.com> <8d961d900812090711u1ce3b034r54b3c15f698cd617@mail.gmail.com> <1F0D0F5F-76B5-421E-A87B-DF863411401B@mattwynne.net> Message-ID: <493EA117.5030208@joesniff.co.uk> Matt Wynne wrote: > > On 9 Dec 2008, at 15:11, aslak hellesoy wrote: > >> On Tue, Dec 9, 2008 at 3:52 PM, steven shingler >> wrote: >> Hey Aslak, >> >> Doesn't this sound a bit like your Kipling project, which we spoke >> about at QCon London, back in March? ;) >> >> (http://gitorious.org/projects/kipling) >> >> A little bit, but the idea with Kipling was to make something similar >> to ThoughtWorks Mingle or Pivotal Tracker, which are tools to manage >> stories, iterations, estimates, burndown etc. >> >> My goal with a fat Cucumber client is different (although it clearly >> intersects): >> * Browse features >> * Edit features >> * Run features > > I think that some kind of autocomplete / syntax highlighting that > understands the currently-implemented set of step matchers would be > really useful too - I already find myself wondering whether I've > already implemented a step as I write the scenario. > >> So I'm thinking more along the lines of Fitnesse, but with a more >> business-friendly UI, and focus on Cucumber (of course). >> >> Essentially - I want this to be primarily a tool that replaces >> TextMate and the CLI for editing and running features, and not so >> much a Scrum/XP planning tool. And the target audience is not us >> programmers (most of us are happy in TM/CLI) - it's the non-techies >> that know Word and Excel only (and are experts in their business' >> domain). > > It would be good if it could integrate into a a planning tool though - > offer an API that returned the number of Running Tested Features, etc. > >> I think it would be a great app to have, which would work well inside >> a web browser, rather than a fat client that customers and managers >> have to download...? > Running like a web based application through something like like Adobe Air or Mozilla Prisim would be nice. (Though these are reliant on downloading plugins). > +1 > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tim at pivotib.com Tue Dec 9 11:57:21 2008 From: tim at pivotib.com (Tim Glen) Date: Tue, 9 Dec 2008 11:57:21 -0500 Subject: [rspec-users] Cucumber fat client In-Reply-To: <493EA220.7030406@benmabey.com> References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <3FE7305D-06F1-47E6-87FE-6F05FFC2F3B7@madeofstone.net> <8d961d900812090315j18ec2bd3g2247ce16f3b930a3@mail.gmail.com> <493EA220.7030406@benmabey.com> Message-ID: <5AB586B9-E0C4-4B4D-8D24-F847496B7059@pivotib.com> >> I think it would be a great app to have, which would work well >> inside a web browser, rather than a fat client that customers and >> managers have to download...? > +1, I think keeping it in the browser will work well for most > situations. One option is to make it a flex app and could then be > used as a stand-alone Air app. WDYT? > > I have been thinking about the requirements for such a project and I > think having it git-powered would be great. Having the stakeholder > to be able to edit features and have the changes show up in a remote > branch automatically would be a great feature IMO. If it is powered > off of git we also get versioning and a lot of other stuff for > free. (I would recommend watching Scott Chacoon's presentation on > using git in this way from ruby conf: http://rubyconf2008.confreaks.com/using-git-in-ruby-applications.html) > > Anyways, thats my two cents. I would argue that most business > people these days are just as, if not more, comfortable in a browser > than they are in Excel as long as the UI is good. Of course, having > clients for both would be ideal. :) +1 to having it in browser as the first priority. People are more and more comfortable all the time in their browsers. Personally, I'm not sure I would want it tied to git explicitly - we haven't quite made that jump at work yet. On the other hand, it should be easy to put hooks into it to auto-commit changes to pretty much any type of repository. -tim From lists at ruby-forum.com Tue Dec 9 14:06:26 2008 From: lists at ruby-forum.com (James Byrne) Date: Tue, 9 Dec 2008 20:06:26 +0100 Subject: [rspec-users] Test for a gem/plugin? Message-ID: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> I have decided that for now I am going to use the authlogic gem to provide authentication for the project I am creating. The question arises, since authentication is a user feature request and since it is to be satisfied through the use of a gem (not a plugin) then should one test for the availability of the gem or not? Secondly, given that a gem is providing the authentication logic (and is not my code which therefore should not be tested by me) then what should one test for with respect to the specific implementation? The existence of particular attributes? The existence of a users model? Does one write step definitions (assuming rspec) like: When /users are authenticated/ do #TODO: This does not work even when the model class exists. User.should exist end When /authentication by authlogic/ do #TODO: Find out how to test for a loaded gem within an application end -- Posted via http://www.ruby-forum.com/. From ivorpaul at gmail.com Tue Dec 9 17:18:55 2008 From: ivorpaul at gmail.com (Ivor Paul) Date: Wed, 10 Dec 2008 00:18:55 +0200 Subject: [rspec-users] testing call to super in rails helper In-Reply-To: <510294CC-7696-491A-BFAC-81F4986B51B1@deadorange.com> References: <510294CC-7696-491A-BFAC-81F4986B51B1@deadorange.com> Message-ID: Thanks Nick the first approach seems the best for my situation. Appreciate the response Ivor On Tue, Dec 9, 2008 at 4:45 PM, Nick Hoffman wrote: > On 2008-12-09, at 06:29, Ivor Paul wrote: > >> Hi >> >> I have the following code: >> >> def will_paginate(items, options = {}) >> options = options.merge(:container => true, :class => 'paging') >> super(items, options) >> end >> >> I am curious about how to test that the call to super is infact being >> called with the added options. >> >> I have this >> >> it 'should call super on will_paginate' do >> helper.stub!(:will_paginate).with([], {:container => true, :class => >> 'paging'}).and_return(true) >> helper.should_receive(:will_paginate).with([], {:container => true, >> :class => 'paging'}) >> helper.will_paginate([]) >> end >> >> But it fails as will_paginate is called with [] before being called with >> ([], {:container => true, :class => 'paging'}) >> >> I am relatively new to rspec, but trying to learn more - if there is a >> blog post on how to deal with these situations, please point me in the right >> direction. >> >> Help much appreciated. >> >> Ivor >> > > G'day Ivor. See this thread for details: > http://www.ruby-forum.com/topic/151744 > > -Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at ekenosen.net Tue Dec 9 17:19:08 2008 From: nick at ekenosen.net (nicholas a. evans) Date: Tue, 9 Dec 2008 17:19:08 -0500 Subject: [rspec-users] a custom progress bar formatter Message-ID: <276ff9870812091419t238fb160na118430419395ee1@mail.gmail.com> I've always been a little bit bemused by the default ruby test/unit and rspec output. Basically, what I want is a progress bar and that any errors and warnings be displayed immediately. I also want warnings to be printed for slow specs. When using color, I want the entire progress bar printed in green if everything is good, yellow if there has been a warning, and red if there has been an error. And then I remembered that rspec makes it super easy to write your own custom formatter. So I did. :-) http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/ Let me know what you think. Is this useful to anyone? Any ideas for improvements? -- Nick From pergesu at gmail.com Tue Dec 9 18:09:13 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 09 Dec 2008 15:09:13 -0800 Subject: [rspec-users] a custom progress bar formatter In-Reply-To: <276ff9870812091419t238fb160na118430419395ee1@mail.gmail.com> (nicholas a. evans's message of "Tue\, 9 Dec 2008 17\:19\:08 -0500") References: <276ff9870812091419t238fb160na118430419395ee1@mail.gmail.com> Message-ID: "nicholas a. evans" writes: > I've always been a little bit bemused by the default ruby test/unit and > rspec output. Basically, what I want is a progress bar and that any > errors and warnings be displayed immediately. I also want warnings to be > printed for slow specs. When using color, I want the entire progress bar > printed in green if everything is good, yellow if there has been a > warning, and red if there has been an error. > > And then I remembered that rspec makes it super easy to write your own > custom formatter. So I did. :-) > > http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/ > > Let me know what you think. Is this useful to anyone? Any ideas for > improvements? Cool idea! Pat From zach.dennis at gmail.com Tue Dec 9 20:28:37 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 9 Dec 2008 20:28:37 -0500 Subject: [rspec-users] a custom progress bar formatter In-Reply-To: <276ff9870812091419t238fb160na118430419395ee1@mail.gmail.com> References: <276ff9870812091419t238fb160na118430419395ee1@mail.gmail.com> Message-ID: <85d99afe0812091728y6cfb71a7m5daf78854dff7d45@mail.gmail.com> On Tue, Dec 9, 2008 at 5:19 PM, nicholas a. evans wrote: > I've always been a little bit bemused by the default ruby test/unit and > rspec output. Basically, what I want is a progress bar and that any > errors and warnings be displayed immediately. I also want warnings to be > printed for slow specs. When using color, I want the entire progress bar > printed in green if everything is good, yellow if there has been a > warning, and red if there has been an error. > > And then I remembered that rspec makes it super easy to write your own > custom formatter. So I did. :-) > > http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/ Pictures are worth a thousands word, can you post a screenshot on the blog post? > > Let me know what you think. Is this useful to anyone? Any ideas for > improvements? > > -- > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From avdi at avdi.org Tue Dec 9 22:40:36 2008 From: avdi at avdi.org (Avdi Grimm) Date: Tue, 9 Dec 2008 22:40:36 -0500 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 Message-ID: I contributed an article on BDD and RSpec to the Ruby Advent Calendar 2008, going over some of the rules I've collected for interpreting what your specs say about your design. It can be found here: http://advent2008.hackruby.com/past/2008/12/10/listening_to_your_specs/ -- Avdi Home: http://avdi.org Developer Blog: http://avdi.org/devblog/ Twitter: http://twitter.com/avdi Journal: http://avdi.livejournal.com From ivorpaul at gmail.com Wed Dec 10 05:08:33 2008 From: ivorpaul at gmail.com (Ivor Paul) Date: Wed, 10 Dec 2008 12:08:33 +0200 Subject: [rspec-users] assigns variable maintaining state across request? Message-ID: Hi I found that if I set assigns[:variables] in a spec, the value is maintained in subsequent specs. Example rails helper method: def return_at_variable @variable end Specs: #this passes obviously it 'should return true if assigns[:variable] is true' do assigns[:variable] = true helper.return_at_variable.should be_true end #this does not pass it 'should return nil becasue assigns[:variable] is not set' do helper.return_at_variable.should be_nil end '' FAILED expected nil? to return true, got false In this case both tests pass: it 'should return true if assigns[:variable] is true' do assigns[:variable] = true helper.return_at_variable.should be_true end it 'should return nil becasue assigns[:variable] is not set' do helper.return_at_variable.should be_true end Getting around this is simple enough - by just clearing/declaring the assigs[:variables] where ever I need to, but I am wondering if this is normal behaviour? Regards Ivor -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Dec 10 08:05:18 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 10 Dec 2008 07:05:18 -0600 Subject: [rspec-users] assigns variable maintaining state across request? In-Reply-To: References: Message-ID: <57c63afe0812100505x2994d4b9y78e40bb354073fab@mail.gmail.com> On Wed, Dec 10, 2008 at 4:08 AM, Ivor Paul wrote: > Hi > > I found that if I set assigns[:variables] in a spec, the value is maintained > in subsequent specs. > > Example > > rails helper method: > > def return_at_variable > @variable > end > > Specs: > > #this passes obviously > it 'should return true if assigns[:variable] is true' do > assigns[:variable] = true > helper.return_at_variable.should be_true > end > > #this does not pass > it 'should return nil becasue assigns[:variable] is not set' do > helper.return_at_variable.should be_nil > end > > '' FAILED > expected nil? to return true, got false > > In this case both tests pass: > > it 'should return true if assigns[:variable] is true' do > assigns[:variable] = true > helper.return_at_variable.should be_true > end > > it 'should return nil becasue assigns[:variable] is not set' do > helper.return_at_variable.should be_true > end > > Getting around this is simple enough - by just clearing/declaring the > assigs[:variables] where ever I need to, but I am wondering if this is > normal behaviour? Nope. Please file a ticket at http://rspec.lighthouseapp.com. Thanks, David > > Regards > Ivor > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From nick at ekenosen.net Wed Dec 10 08:48:54 2008 From: nick at ekenosen.net (nicholas a. evans) Date: Wed, 10 Dec 2008 08:48:54 -0500 Subject: [rspec-users] a custom progress bar formatter In-Reply-To: <85d99afe0812091728y6cfb71a7m5daf78854dff7d45@mail.gmail.com> References: <276ff9870812091419t238fb160na118430419395ee1@mail.gmail.com> <85d99afe0812091728y6cfb71a7m5daf78854dff7d45@mail.gmail.com> Message-ID: <276ff9870812100548vca52a03ted1071b285629fbd@mail.gmail.com> On Tue, Dec 9, 2008 at 8:28 PM, Zach Dennis wrote: > On Tue, Dec 9, 2008 at 5:19 PM, nicholas a. evans wrote: >> And then I remembered that rspec makes it super easy to write your own >> custom formatter. So I did. :-) >> >> http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/ > > Pictures are worth a thousands word, can you post a screenshot on the > blog post? So true, so true. Unfortunately, a static image doesn't really show off the progress bar very well. So I figured out how to make a screencast and upload it to google video. The blog post has been updated with both screenshot and screencast. -- Nick From matt at mattwynne.net Wed Dec 10 09:54:02 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 10 Dec 2008 14:54:02 +0000 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> Message-ID: <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> On 9 Dec 2008, at 19:06, James Byrne wrote: > I have decided that for now I am going to use the authlogic gem to > provide authentication for the project I am creating. The question > arises, since authentication is a user feature request and since it is > to be satisfied through the use of a gem (not a plugin) then should > one > test for the availability of the gem or not? > > Secondly, given that a gem is providing the authentication logic > (and is > not my code which therefore should not be tested by me) then what > should > one test for with respect to the specific implementation? The > existence > of particular attributes? The existence of a users model? > > Does one write step definitions (assuming rspec) like: > > When /users are authenticated/ do > #TODO: This does not work even when the model class exists. > User.should exist > end > > When /authentication by authlogic/ do > #TODO: Find out how to test for a loaded gem within an application > end If you're working at the level of Cucumber features, I would stay well away from implementation details like the particular technology you're using for authentication. Remember this is called Behaviour Driven Development[1] for a reason. You're focussing on specifying the desired *behaviour* of the system. How you chose to satisfy the user's need for that behaviour is an entirely separate matter. A large benefit of having Acceptance Tests, IMO, is that you could radically change your implementation under the hood, such as switching to a different authentication mechanism, and the features would still be valid. You might have to code up some of your steps a little differently, but as long as the users want the same thing from the system, the features should not have to change in the slightest. [1]http://dannorth.net/introducing-bdd Matt Wynne http://blog.mattwynne.net http://www.songkick.com From erdoss at gmail.com Wed Dec 10 10:28:12 2008 From: erdoss at gmail.com (Andrei Erdoss) Date: Wed, 10 Dec 2008 17:28:12 +0200 Subject: [rspec-users] Rspec and RJS - form.reset Message-ID: Hello, I couldn't find much info on this. How do you rspec this: page.form.reset("tag_form") I looked in the have_rjs source code and I can't find anything on form reset. Thanks, -- Andrei -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Dec 10 11:04:44 2008 From: lists at ruby-forum.com (James Byrne) Date: Wed, 10 Dec 2008 17:04:44 +0100 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> Message-ID: <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> Matt Wynne wrote: > On 9 Dec 2008, at 19:06, James Byrne wrote: > >> should >> >> When /authentication by authlogic/ do >> #TODO: Find out how to test for a loaded gem within an application >> end > > If you're working at the level of Cucumber features, I would stay well > away from implementation details like the particular technology you're > using for authentication. > The features for this simply say something along the lines of: Scenario: Application has known users Given that the application has users When the user signs on Then the user is authenticated > Remember this is called Behaviour Driven Development[1] for a reason. > You're focussing on specifying the desired *behaviour* of the system. > How you chose to satisfy the user's need for that behaviour is an > entirely separate matter. Nonetheless, in the step definitions I must test the behaviour in a fashion which first drives and then confirms the implementation details. If the chosen implementation depends upon a third party plugin or gem then surely one should test for its provision? What is the alternative? Write tests to test that gems behaviour? Does that not violate TDD/BDD standard of only testing your own code? > > A large benefit of having Acceptance Tests, IMO, is that you could > radically change your implementation under the hood, such as switching > to a different authentication mechanism, and the features would still > be valid. You might have to code up some of your steps a little > differently, but as long as the users want the same thing from the > system, the features should not have to change in the slightest. > If the implementation changed then the step definitions must change to suit, must they not? One is, in the end, only testing what one actually does or wishes done. I do not see how in this case any implementation change would necessitate revising the features given above. If we were implementing our own authentication system then clearly more features or scenarios might be specified but the existing ones need not change. > [1]http://dannorth.net/introducing-bdd Read, re-read, and re-re-read. Nonetheless, it is possible to become dogmatic over such things. There is a considerable, and growing, body of opinion that so-called acceptance testing is suitable for many, possibly, all levels of application implementation. That the key to understanding when to use AT really lies in a flexible interpretation of the role of user. This is, as has been pointed out to me many times, an evolving art. The imaginary end user of any non-trivial application is actually an assemblage of disparate roles, many of which consciously do not overlap. Some of those users are the system administrators which tend to the day to day background maintenance tasks, some of which are automated and some of which are not. Some of the application users are, in truth, the implementors themselves. Not all features are of concern to all users/roles. Why should some users be denied the use of features and BDD as a tool for their own concerns simply because they are writing the code? It seems to me an artificial, and logically insupportable, distinction to make. While I am still a novice with much of this specific technology (TDD/BDD/Ruby/Rails) I have had a lot of experience, much of it bad, with overly rigid, and often misinformed, interpretation and employment of design methodologies. The quest for the silver bullet has led many teams down methodological dead ends, whereas a more flexible use of the same tool might have produced a beneficial outcome. What I have come up with is this, for now: When /has known users/ do # If we have known users then they must be stored somewhere my_user = User.new end When /user logs in/ do # If a user signs on then they do it here visits login_path end When /user signs on/ do When "user logs in" end When /user "(.*)" is authenticated/ do |u| # We use Authlogic for authentication so just test that gem is loaded assert defined?("Authlogic") end -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Dec 10 11:26:31 2008 From: lists at ruby-forum.com (James Byrne) Date: Wed, 10 Dec 2008 17:26:31 +0100 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> Message-ID: James Byrne wrote: Of course, the last example should have been: When /user is authenticated/ do # We use Authlogic for authentication so just test that gem is loaded assert defined?("Authlogic") end -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Wed Dec 10 11:36:01 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 10 Dec 2008 11:36:01 -0500 Subject: [rspec-users] stepping across features In-Reply-To: <3596fd71bafc8628505f9eacf691a957@ruby-forum.com> References: <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> <88fd8ddc0812050842ne7a213xbaa9b75f5837c1ce@mail.gmail.com> <51f2f3c0c0cc4ad38c70b2b20c140b33@ruby-forum.com> <88fd8ddc0812062321r14591fffk32fbea980da77d5f@mail.gmail.com> <20881a4cead6714e35fe9e175f4bd012@ruby-forum.com> <88fd8ddc0812080538p77bc48d5j25c33c3e06610a89@mail.gmail.com> <3596fd71bafc8628505f9eacf691a957@ruby-forum.com> Message-ID: <85d99afe0812100836t4c5bdd48ge0ad184e7abd8f8f@mail.gmail.com> On Mon, Dec 8, 2008 at 11:56 AM, James Byrne wrote: > Andrew Premdas wrote: >> >> TIp: When writing the step don't use - visits "/invoices/new" - use >> visits "invoice_new_path". Use named routes and let the routing names >> REST and resources define where you go, and think about what you want >> to implement > > This advice is really helpful. I was reading the section on routing in > "The Rails Way" last night, and it came to me that perhaps I had > overlooked the essence of what I was really trying to accomplish. That > I was so fixated on the code yet to be produced at the detail level that > I had missed the boat with respect to how the users would treat the > application as a whole. I concluded that I really needed to see the new > application, and the features that I had to write, in terms of > resources. Then, given the resource name, the requisite information > would be exposed. This in turn would expose the requirements needed to > assemble that information from data, and from those assembly > requirements would come the code requirements. > > However, I was, until I read your reply, still thinking in terms of > "/application/clients/:myclient/workorders/:id/charges/:billable" > instead of > client_workorder_charges_path(@client, at client.workorders,"billable") or > however that is supposed to be expressed. > >> >> If you now deal with your charges, you will probably get to the stage >> very quickly where you can't avoid clients. So then you do the very >> simplest general thing for clients. > > It is impossible to undo the past. We have already invested a > considerable amount of energy and time into determining how we wish to > express the concept of a client as a transient role of some persistent > entity rather than as an artifact in itself. But, that said, I am > beginning to see that this can be set aside in the early stages. > >> >> Finally every time you find that the baby step you are taking is >> actually more like a giant leap (or actually anything other than >> the smallest of steps) STOP! Then start again questioning what >> is not central and what is not specific. >> >> HTH > > Very helpful. I expect that as I gather my wits regarding BDD that this > advice will prove even more valuable. > > I tried a little bit of this out on one of the end users and I was > surprised at the responses that I obtained. In consequence, this is > what I contemplate beginning with. > > Feature: A web based business application > In Order To: Conduct Business > Any Authorized User > Should Access the Business Application via http > To reduce costs > > Scenario: The Application has a home page > Given an application accessible by http > And I am not signed in > When I browse to the url "/" on the application host > Then I should see a welcome message > And I should see a sign on request message > And I should see a sign on link > And I should see a contact us link > And I should see ... This scenario is mixing what should be in a view spec with what should in a scenario. For example, I think your scenario wants to be "Anonymous visitors are welcomed to the site" Given I am an anonymous visitor When I browse to "/" Then I should see the welcome message: Howdy hey guy! All of the other "I should see" steps you have don't really have anything to do with the goal of welcoming the visitor to the site. IMO, these are candidates for view specs since they are ensuring the lower level details of certain pages are intact. > > Scenario: The Application has a sign on page > Given I am on the home page > And I am not signed in > When I select the sign on link > Then I should see the sign on page > And the protocol should be https > And I should see a text entry for user name > And I should see a text entry for password > And I should see a sign on action selector This scenario has the same problem. If you just have a scenario for signing on (in) to the site wouldn't that force you to build a sign on page for that to work? > > Scenario: User Signs On Successfully > Given I am on the sign on page > And I am not signed in > And I have a user named "myuser" > And the user named "myuser" has a password of "myuserpassword" > When I provide a user name "myuser" > And I provide a password "myuserpassword" > And I select the sign on action > Then I should see a sign on success message > And I should see the users home page How about.... Given there is a user with the login 'myuser' and password 'mypassword' When I sign in to site with the login 'myuser' and the password 'mypassword' Then I should see the success message: You've signed in! It makes it so much clearer IMO. This makes scenario communicate what is valuable, and leaving out the additional clutter. Leave the lower things like "filling in text fields" to the step definition themselves. In your steps, communicate the what you're doing, and leave the how you're doing it to the step definitions. For example, you're signing/logging in. That's the what. The how is filling in two text fields and clicking a button. > Scenario: User Sign On Fails - wrong password > ... > Scenario: User Sign On Fails - no such user > ... > Scenario: User Sign On Fails - more than 3 attempts in 20 seconds > ... > > Then we have identified a new feature, the user home page. Also, one > can foresee that additional scenarios are required, like "User Signs in > >From a Secured Resource" where following a successful sign in the user > is redirected back to the resource that they originally requested. I don't think the "user home page" is a feature, but I bet there is something on the home page that makes it valuable. What is that? That is most likely your feature. When writing that feature and its scenarios don't focus on the user home page. Focus on what's really valuable. If there are things that need to be on the user home page which are tedious details that don't really pertain to the feature, then use a view spec. For example, in our application we always show a navigation partial for every page. Based on what part of the site you're in it will show a different partial, ie; "fiscal/navigation", "hierarchy/navigation", "operations/navigation", etc. Using features/scenarios to ensure every page rendered the right navigation is the wrong place to do it. So we wrote some shared examples... shared_examples_for "a page that has fiscal navigation" do # ... end Then we'd write view specs that used these shared examples to ensure the tedious details of the page were taking care of. Features/scenarios will cover most of the common things like clicking major navigational links, filling out and submitting forms, etc. However, webapps usually have a bunch of other components which may not be linked to "doing" something, or there may be more than one path, or things may need to show up on more than one page. When you need to add something like this to the UI that doesn't fit in a scenario then write a view spec for it. This allows you to keep the high level behaviour in the features/scenarios and the lower level details about the pages in view specs. However, don't feel like you need to write a view spec for everything on the page. If you have form with text fields and a button, and you have a scenario that uses it, then don't feel like you have to write a view spec for those. But if you need to go in and add a "cancel" link on the form and it's not doing anything special that requires a scenario, write a view spec and ensure the cancel link exists (but feel free to ignore the the things the scenario is already covering). How does this all sound to you? > On > the users home page we discover the resources accessible by that user > are listed. From those resources the next layer of features become > exposed, and so on. > > Is this getting closer to the mark or am I moving around the target but > not quite getting it? You're getting there. If anyone asks you are triangulating the target so you can determine exactly where it lies. To a certain extent, we all are. =) -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From ashley.moran at patchspace.co.uk Wed Dec 10 12:13:59 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Wed, 10 Dec 2008 17:13:59 +0000 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> Message-ID: On 10 Dec 2008, at 16:04, James Byrne wrote: > Nonetheless, in the step definitions I must test the behaviour in a > fashion which first drives and then confirms the implementation > details. This is not the path to BDD, it's the path to state-based testing. Matt has already explained this well: "How you chose to satisfy the user's need for that behaviour is an entirely separate matter. A large benefit of having Acceptance Tests, IMO, is that you could radically change your implementation under the hood, such as switching to a different authentication mechanism, and the features would still be valid." I'm guessing the customer for this project didn't ask for AuthLogic, they asked for part of the app to be protected. You should only write acceptance tests for things these users care about. > If the chosen implementation depends upon a third party plugin or gem > then surely one should test for its provision? What is the > alternative? > Write tests to test that gems behaviour? Does that not violate TDD/ > BDD > standard of only testing your own code? Don't confuse library code with code you write to use this library. The AuthLogic config in your app is code too, and it adds behaviours to your app. The fact there are 10, 100 or 10,000 lines of code behind it is irrelevant. There's two attitudes you can take in spec files: write specs that your code calls some library, or write specs that describe the behaviour that library provides. For example (the following is rushed, contrived code but illustrates the idea): class Sorter def initialize(array) @array = array end def sort array.sort end end now when you spec @array = [5,9,6,1,4] @sorter = Sorter.new(@array) are you going to write @array.should_receive(:sort) or @sorter.sort.should == [1,4,5,6,9] ? I believe that in this case, the second option is more valuble: you can change the implementation to sort other collections. In the first case, you could refactor the code without breaking the existing spec. This is important: *The ability to refactor code without breaking the specs is one of the major sources of value in the specs*. This lets you reduce technical debt with no risk to your app. If you rely on the implementation in your spec, you have to change the spec, and therefore you have no guarantee that the behaviour your users *asked for* still works. The definition of refactoring is changing the implementation of code without changing its behaviour (and by extension its specs). Without this constant your code will be fragile. As a extreme, albeit small, example- a while back I took the code for a presentation I gave[1] and changed the app framework from Ramaze to Merb (it only took about 10 mins). Because the specs all ran across the public HTML interface, there was no visible difference. If the feature steps relied on the implementation this wouldn't have been possible. I use Celerity[2] instead of Webrat and write all steps across an app's public interface for this reason. > The imaginary end user of any non-trivial application is actually an > assemblage of disparate roles, many of which consciously do not > overlap. > Some of those users are the system administrators which tend to the > day > to day background maintenance tasks, some of which are automated and > some of which are not. Some of the application users are, in truth, > the > implementors themselves. This is fine, but you should still write acceptance tests from the perspective of the user. If the user is a shell script, drive your app on the command line. If the user is a human, drive it over the visible interface. But do you really have any users that access your app code directly? Hope this gives another perspective on the subject. Ashley [1] http://aviewfromafar.net/2008/10/2/geekup-sheffield-vi-from-specification-to-success [2] http://celerity.rubyforge.org/ -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From lists at ruby-forum.com Wed Dec 10 12:40:03 2008 From: lists at ruby-forum.com (James Byrne) Date: Wed, 10 Dec 2008 18:40:03 +0100 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> Message-ID: <3a6a61c3f79340b7536c36741c1f11e3@ruby-forum.com> Ashley Moran wrote: > > Don't confuse library code with code you write to use this library. > The AuthLogic config in your app is code too, and it adds behaviours > to your app. The fact there are 10, 100 or 10,000 lines of code > behind it is irrelevant. So, if I understand you correctly, then I should write features somewhat like this: Scenario: A known user signs in successfully Given a known user "myuser" with a password "myuserpassword" When user "myuser" signs on with a password "myuserpassword" Then user "myuser" is authenticated And the user sees a sign in success message Scenario: A known user does not sign in successfully Given a known user "myuser" with a password "myuserpassword" When user "myuser" signs in with a password "anotherpassword" Then user "myuser" is not authenticated And the user sees a sign in failure message And the user sees the sign in page And I should simply not worry about what is provided by authlogic, other than the requisite behaviour as exhibited in this application. > > Hope this gives another perspective on the subject. > I am still grappling with the entire concept. A "perspective" graces what I as yet possess with too much dignity. Thanks. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Wed Dec 10 13:08:23 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 10 Dec 2008 18:08:23 +0000 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> Message-ID: On 10 Dec 2008, at 16:26, James Byrne wrote: > James Byrne wrote: > Of course, the last example should have been: > > When /user is authenticated/ do > # We use Authlogic for authentication so just test that gem is loaded > assert defined?("Authlogic") > end To verify that the user has been authenticated, why not try something like Then /I should see that I am logged in/ do user = User.first response.should include_text "welcome, #{user.username}" end This is much less coupled to your implementation, though it does assume that the 'I' referred to in the step is the only User in your database, or at least happens to be the first one. I'll leave it as a exercise to the reader to work around that one. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From erdoss at gmail.com Wed Dec 10 13:27:55 2008 From: erdoss at gmail.com (Andrei Erdoss) Date: Wed, 10 Dec 2008 20:27:55 +0200 Subject: [rspec-users] rspecing rjs - form.reset('form') Message-ID: Hello, > > I couldn't find much info on this. > > How do you rspec this: page.form.reset("form") > > I looked in the have_rjs source code and I can't find anything on form > reset. > > Thanks, > > -- > Andrei > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Dec 10 15:46:58 2008 From: lists at ruby-forum.com (James Byrne) Date: Wed, 10 Dec 2008 21:46:58 +0100 Subject: [rspec-users] stepping across features In-Reply-To: <85d99afe0812100836t4c5bdd48ge0ad184e7abd8f8f@mail.gmail.com> References: <88fd8ddc0812030623v2c89d417y27d4cff45c5954f7@mail.gmail.com> <88fd8ddc0812032242x2a3ca7e1gabf6721d6398e845@mail.gmail.com> <229613d24298f42d5bfeab84875a8ec1@ruby-forum.com> <1880f5287c2c2d77632cba6f6514475c@ruby-forum.com> <88fd8ddc0812042201p11ed248eg188a88a02550ab66@mail.gmail.com> <004b9cdb6323586c733b2a39d9ffe4d1@ruby-forum.com> <88fd8ddc0812050842ne7a213xbaa9b75f5837c1ce@mail.gmail.com> <51f2f3c0c0cc4ad38c70b2b20c140b33@ruby-forum.com> <88fd8ddc0812062321r14591fffk32fbea980da77d5f@mail.gmail.com> <20881a4cead6714e35fe9e175f4bd012@ruby-forum.com> <88fd8ddc0812080538p77bc48d5j25c33c3e06610a89@mail.gmail.com> <3596fd71bafc8628505f9eacf691a957@ruby-forum.com> <85d99afe0812100836t4c5bdd48ge0ad184e7abd8f8f@mail.gmail.com> Message-ID: Zach Dennis wrote: > > You're getting there. If anyone asks you are triangulating the target > so you can determine exactly where it lies. To a certain extent, we > all are. =) I think that I am reaching the stage where I am oscillating between over and under specifying. I am trying this stuff out as I go and no doubt am leaving artifacts that will be the source of amusement when I finally do "get it". It really is not that hard a concept to grasp, in general. As always, it is in the details of actual employment that the troubles lie. Every bit of advice that I have received on this thread, and the two related ones on this list, is greatly appreciated and valued. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Wed Dec 10 16:11:38 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 10 Dec 2008 16:11:38 -0500 Subject: [rspec-users] Stories, permissions, authorization rules etc. In-Reply-To: <88fd8ddc0812090052k71b67c50wbb636595202af258@mail.gmail.com> References: <7c628d690812081603h3a0d3a82w2c9a6c6edeaf274@mail.gmail.com> <88fd8ddc0812090052k71b67c50wbb636595202af258@mail.gmail.com> Message-ID: <85d99afe0812101311s207068d6r2a368a78055e27f@mail.gmail.com> On Tue, Dec 9, 2008 at 3:52 AM, Andrew Premdas wrote: > You can improve the features you've given by > > 1. use named routes not url's > 2. not checking for not seeing specific things > 3. A combined step with a more examples table > Given I am logged in as a developer #3 is what I do. It works great, > 4. having a general policy for what happens when access fails and testing > that e.g. routing back to home page or where you came from > > 5. An uber combined step with a funky step matcher where the step definition > would go through all the Roles and visit x with each one testing for an > error > Given I am not a logged in developer I should get an error when I > visit x > > '5' seems pretty ugly to me, but maybe in this case its bearable. > > Making the features as simple as possible should reduce the resistance to > their repitition > > As to the issue of using stories for coverage, I guess a balance has to be > struck which is very dependent on business needs. If there are specific > business rules that need to be enforced for a role then make that explicit > in features. If the business rule is much more general and their are lots of > role/access combinations then maybe do this in a more unit test way i.e. not > in features > > > 2008/12/9 Alberto Perdomo >> >> Hi, >> >> my team and i have come to the point where we have defined a whole >> bunch of stories for an application. >> Almost all of the actions (besides login, etc.) should *not* be >> accesible if not logged in. >> Almost all of the actions require a specific user role. >> >> So, my question is. How do you put that in stories? >> I have come up with these different options: >> >> 1) In each story, e.g. 'Add a new issue', 'Comment issue', etc. you >> define a few extra scenarios more or less like this: >> >> Scenario: Permission denied if not logged in >> Given i am not logged in >> When i visit 'issues/new' >> I should see Permission denied >> And i should not see 'Add Issue' >> >> Scenario: Permission denied if role not developer >> Given i am logged in >> And my role is not developer >> When i visit 'issues/new' >> I should see Permission denied >> And i should not see 'Add Issue' >> >> ... >> >> 2) You could write a separate story (or multiple separate stories) >> just for the matter of describing permissions and authorizarion rules. >> >> 3) You could just write scenarios for the role requirements (like 1) >> and leave the logged_in scenario out, giving for granted that you are >> going to make all actions inaccesible without logging in. >> >> I prefer option 1 although it feels not DRY. I think explicit stories >> are good, and such important things as permissions etc. should not be >> left out. My mates argue that there has to be a better solutions than >> taking 50 stories and adding 2 o 3 scenarios that look more or less >> the same to each of them. >> >> I don't like 2 because it breaks the granularity of the stories. >> Stories should be more or less independant from each other. If you >> decide not to implement a specific story then you would have to edit >> again the permissions story. Also the permissions story will not pass >> until you have implemented all the scenarios = until you have >> implemented all the actions involved. >> >> I don't like 3 because it is against testing philosophy.You should not >> rely on the memory of humans. That's one of the reasons to write >> stories. Theoretically you could write something like a scenario that >> goes through all your app routes and checks if they are accessible. >> >> So tell me. >> How do you do such things? >> Do you have any other approaches? >> It's important to us from a cucumber/rspec perspective (how do you >> test it?) but also from a requirements perspective (where do you write >> down that part when gathering the user stories?). >> >> Cheers! >> Alberto. >> _______________________________________________ >> 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 > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From johnm at psynix.com Wed Dec 10 18:36:10 2008 From: johnm at psynix.com (John Meredith) Date: Thu, 11 Dec 2008 09:36:10 +1000 Subject: [rspec-users] Oddness with fieldnames containing an underscore Message-ID: <89D40BE1-E3D2-4FCB-986F-112FB553ABC3@psynix.com> Hi all, I'm not sure if this is a cucumber or webrat thing given that I only starting tinkering with both last night for the first time (testing newb as well), but I've come across an oddity when trying to write a scenario to create a user. Scenario: Register new user Given I am on the new user page And I fill in "login" with "fredf" And I fill in "password" with "somepassword" And I fill in "password_confirmation" with "somepassword" And I select "Mr" from "title" And I fill in "given_names" with "Fred" And I fill in "surname" with "Flintstone" And I fill in "email" with "fredf at rocks.com" And I press "Create" Then there should be 1 more user When I 'rake features' it halts at the password_confirmation line... Scenario: Register new user # features/ manage_users.feature:16 Given I am on the new user page # features/ step_definitions/user_steps.rb:5 And I fill in "login" with "johnm" # features/ step_definitions/webrat_steps.rb:12 And I fill in "password" with "Lmmsoht" # features/ step_definitions/webrat_steps.rb:12 And I fill in "password_confirmation" with "Lmmsoht" # features/ step_definitions/webrat_steps.rb:12 Could not find field: "password_confirmation" (Webrat::NotFoundError) The test passes if I prepend "user_" to the field name ie. "user_password_confirmation". Same applies to the 'given_names' field. Is this a bug or am I making an incorrect assumption on how things are supposed to work? TIA, JohnM -- "I'm not dumb. I just have a command of thoroughly useless information" - Calvin & Hobbes From apremdas at gmail.com Wed Dec 10 19:57:21 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 11 Dec 2008 00:57:21 +0000 Subject: [rspec-users] Oddness with fieldnames containing an underscore In-Reply-To: <89D40BE1-E3D2-4FCB-986F-112FB553ABC3@psynix.com> References: <89D40BE1-E3D2-4FCB-986F-112FB553ABC3@psynix.com> Message-ID: <88fd8ddc0812101657o2e680193n3f95f5505e539126@mail.gmail.com> Probably not a bug, if you look at the id's of the fields your matching by viewing source in your browser you'll see that they have an id that begins with 'user'. So when webrat fails to match on the label text it then tries to match on the id. You can use the debugger to step into the webrat code and see this yourself if you want HTH 2008/12/10 John Meredith > Hi all, > > I'm not sure if this is a cucumber or webrat thing given that I only > starting tinkering with both last night for the first time (testing newb as > well), but I've come across an oddity when trying to write a scenario to > create a user. > > Scenario: Register new user > Given I am on the new user page > And I fill in "login" with "fredf" > And I fill in "password" with "somepassword" > And I fill in "password_confirmation" with "somepassword" > And I select "Mr" from "title" > And I fill in "given_names" with "Fred" > And I fill in "surname" with "Flintstone" > And I fill in "email" with "fredf at rocks.com" > And I press "Create" > Then there should be 1 more user > > When I 'rake features' it halts at the password_confirmation line... > > Scenario: Register new user # > features/manage_users.feature:16 > Given I am on the new user page # > features/step_definitions/user_steps.rb:5 > And I fill in "login" with "johnm" # > features/step_definitions/webrat_steps.rb:12 > And I fill in "password" with "Lmmsoht" # > features/step_definitions/webrat_steps.rb:12 > And I fill in "password_confirmation" with "Lmmsoht" # > features/step_definitions/webrat_steps.rb:12 > Could not find field: "password_confirmation" (Webrat::NotFoundError) > > The test passes if I prepend "user_" to the field name ie. > "user_password_confirmation". Same applies to the 'given_names' field. > > Is this a bug or am I making an incorrect assumption on how things are > supposed to work? > > TIA, > > JohnM > > -- > > "I'm not dumb. I just have a command of thoroughly useless information" > - Calvin & Hobbes > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corntrace at gmail.com Wed Dec 10 22:12:02 2008 From: corntrace at gmail.com (Kai Fu) Date: Thu, 11 Dec 2008 11:12:02 +0800 Subject: [rspec-users] The TODO note in rspec files can't be shown in "rake notes" Message-ID: Hello, I've written a "TODO" comment in a xxx_controller_spec.rb. When I run the "rake notes" command, it doesn't appear in the output, while other notes written in the "app" dir are shown correctly. Could someone tell me how to fix this? Whether I should hack the rails rake code? Thanks! -- regards, Kai Fu Material Science and Engineering Huazhong University of Science and Technology Wuhan E-mail: corntrace at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From zuperinfinite at gmail.com Thu Dec 11 02:07:16 2008 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Thu, 11 Dec 2008 08:07:16 +0100 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: References: Message-ID: <8E936A01-BE12-411E-92F8-DD1CE4505628@gmail.com> On 10 dec 2008, at 04:40, Avdi Grimm wrote: > I contributed an article on BDD and RSpec to the Ruby Advent Calendar > 2008, going over some of the rules I've collected for interpreting > what your specs say about your design. It can be found here: > http://advent2008.hackruby.com/past/2008/12/10/ > listening_to_your_specs/ Great article! Found a lot of good practices here, especially the @it example. thanks a bunch, bartz From apremdas at gmail.com Thu Dec 11 02:53:48 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 11 Dec 2008 07:53:48 +0000 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: <3a6a61c3f79340b7536c36741c1f11e3@ruby-forum.com> References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> <3a6a61c3f79340b7536c36741c1f11e3@ruby-forum.com> Message-ID: <88fd8ddc0812102353l74df7e79h35c48874ed0be128@mail.gmail.com> I put a starter application with a bunch of features to test authorisation code implemented by Restful Authentication on Github a few days ago. In theory you could apply these features directly to your Authlogic implementation. http://github.com/diabolo/fbrp/tree/master All best Andrew 2008/12/10 James Byrne > Ashley Moran wrote: > > > > > Don't confuse library code with code you write to use this library. > > The AuthLogic config in your app is code too, and it adds behaviours > > to your app. The fact there are 10, 100 or 10,000 lines of code > > behind it is irrelevant. > > So, if I understand you correctly, then I should write features somewhat > like this: > > Scenario: A known user signs in successfully > Given a known user "myuser" with a password "myuserpassword" > When user "myuser" signs on with a password "myuserpassword" > Then user "myuser" is authenticated > And the user sees a sign in success message > > Scenario: A known user does not sign in successfully > Given a known user "myuser" with a password "myuserpassword" > When user "myuser" signs in with a password "anotherpassword" > Then user "myuser" is not authenticated > And the user sees a sign in failure message > And the user sees the sign in page > > And I should simply not worry about what is provided by authlogic, other > than the requisite behaviour as exhibited in this application. > > > > > > Hope this gives another perspective on the subject. > > > > I am still grappling with the entire concept. A "perspective" graces > what I as yet possess with too much dignity. > > Thanks. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cwdinfo at gmail.com Thu Dec 11 03:26:04 2008 From: cwdinfo at gmail.com (s.ross) Date: Thu, 11 Dec 2008 00:26:04 -0800 Subject: [rspec-users] rspecing rjs - form.reset('form') In-Reply-To: References: Message-ID: On Dec 10, 2008, at 10:27 AM, Andrei Erdoss wrote: > Hello, > > I couldn't find much info on this. > > How do you rspec this: page.form.reset("form") > > I looked in the have_rjs source code and I can't find anything on > form reset. > > Thanks, > > -- > Andrei I tend not to use rjs much, but what I suspect you are looking for is the response to contain a particular snippet of Javascript. So, it might look sort of like: it "should send Javascript to reset the form" do post :action_that_resets_the_form response.should have_text(/$('form').reset()/) end Does this sound like what you are looking for? From ashley.moran at patchspace.co.uk Thu Dec 11 05:31:08 2008 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Thu, 11 Dec 2008 10:31:08 +0000 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: <3a6a61c3f79340b7536c36741c1f11e3@ruby-forum.com> References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> <3a6a61c3f79340b7536c36741c1f11e3@ruby-forum.com> Message-ID: <010D0C11-DAB7-415D-9044-D0939AC4FFB1@patchspace.co.uk> On 10 Dec 2008, at 17:40, James Byrne wrote: > So, if I understand you correctly, then I should write features > somewhat > like this: > > Scenario: A known user signs in successfully > Given a known user "myuser" with a password "myuserpassword" > When user "myuser" signs on with a password "myuserpassword" > Then user "myuser" is authenticated > And the user sees a sign in success message > > Scenario: A known user does not sign in successfully > Given a known user "myuser" with a password "myuserpassword" > When user "myuser" signs in with a password "anotherpassword" > Then user "myuser" is not authenticated > And the user sees a sign in failure message > And the user sees the sign in page > > And I should simply not worry about what is provided by authlogic, > other > than the requisite behaviour as exhibited in this application. That's how I (and many others here) tackle it. But there's no need for the steps Then user "myuser" is authenticated and Then user "myuser" is not authenticated because these don't describe behaviour, they describe state. The "sign in message" steps are what you really want. And you can implement these as Matt described. Since you've written steps that create the user (preferably through the app itself!), you could extend the step like this Given a known user "Mr Known User" with credentials "myuser" : "myuserpassword" Then you already have the name to verify if you want to display a personalised message. (On the other hand, putting too much data in the steps gets cumbersome; I tend to write them more like this: Scenario: A known user signs in successfully Given I am a registered user When I sign on with the correct credentials Then I should see a sign in success message Even if internally I call out to steps more like the ones you wrote as examples. Hope that doesn't muddy the waters though. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ From apremdas at gmail.com Thu Dec 11 06:48:52 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 11 Dec 2008 11:48:52 +0000 Subject: [rspec-users] Nosy controller specs Message-ID: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> Looking at generated controller specs we tend to get something like describe PostsController do describe "handling GET /posts" do before(:each) do @post = mock_model(Post) Post.stub!(:find).and_return([@post]) end def do_get get :index end ... it "should find all posts" do Post.should_receive(:find).with(:all).and_return([@post]) do_get end Now this last spec "should find all posts" is nosy is far as I'm concerned in that its specifying how the model should get all the posts (i.e. white box testing) rather than checking the result i.e. that its got @post back. So now if I change the model so that "all posts" is for example "all posts in last year" because there is a new business rule that we don't show posts over a year old then my controller spec fails. Now it seems to me that I should only have to change my model specs when I make this sort of change, this implementation details is none of the controllers business So a couple of things 1) Am I right about this? 2) If so is there a better way to still use the mock for speed but not be nosy 3) Should the default controller generators be re-written TIA -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Dec 11 06:52:28 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 11 Dec 2008 11:52:28 +0000 Subject: [rspec-users] Using resource_controller (make_resourceful etc) and testing them Message-ID: <88fd8ddc0812110352v581e3099x8754924df3087f90@mail.gmail.com> Hi all, Trying to get some opinions about the use of such plugins and in particular about how they test, and how we test with them. Can they work well with BDD or do they do to much magic and create difficulties for features and tests TIA -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Dec 11 07:33:32 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 11 Dec 2008 12:33:32 +0000 Subject: [rspec-users] Nosy controller specs In-Reply-To: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> Message-ID: <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> Looking at this a bit further, it seems in Rails controllers decide how things are got from Models i.e. by calling a class Method. I sort of forgot this for a bit. So with this pattern the testing is correct in reflecting the design of Rails. Still, with my OO purist hat on, it feels like this responsibility should be in the model not in the controller, and that Rails has got it wrong here (fat controllers). Do other ruby frameworks take a different approach? 2008/12/11 Andrew Premdas > Looking at generated controller specs we tend to get something like > > describe PostsController do > describe "handling GET /posts" do > > before(:each) do > @post = mock_model(Post) > Post.stub!(:find).and_return([@post]) > end > > def do_get > get :index > end > ... > > it "should find all posts" do > Post.should_receive(:find).with(:all).and_return([@post]) > do_get > end > > Now this last spec "should find all posts" is nosy is far as I'm concerned > in that its specifying how the model should get all the posts (i.e. white > box testing) rather than checking the result i.e. that its got @post back. > So now if I change the model so that "all posts" is for example "all posts > in last year" because there is a new business rule that we don't show posts > over a year old then my controller spec fails. Now it seems to me that I > should only have to change my model specs when I make this sort of change, > this implementation details is none of the controllers business > > So a couple of things > > 1) Am I right about this? > 2) If so is there a better way to still use the mock for speed but not be > nosy > 3) Should the default controller generators be re-written > > TIA > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivorpaul at gmail.com Thu Dec 11 08:42:25 2008 From: ivorpaul at gmail.com (Ivor Paul) Date: Thu, 11 Dec 2008 15:42:25 +0200 Subject: [rspec-users] testing rails mailers Message-ID: Hi Guys I am trying to spec some rails mailers. The only info I found was this post http://kpumuk.info/ruby-on-rails/testing-mailers-with-rspec/ by Dmytro Shteflyuk. I am hoping there is somewhat more on the topic - could someone point me towards a resource where I can find more? Regards Ivor From dchelimsky at gmail.com Thu Dec 11 10:02:45 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 11 Dec 2008 09:02:45 -0600 Subject: [rspec-users] The TODO note in rspec files can't be shown in "rake notes" In-Reply-To: References: Message-ID: <57c63afe0812110702u5fc43acbw9a3a01215152fc2b@mail.gmail.com> On Wed, Dec 10, 2008 at 9:12 PM, Kai Fu wrote: > Hello, > > I've written a "TODO" comment in a xxx_controller_spec.rb. When I run the > "rake notes" command, it doesn't appear in the output, while other notes > written in the "app" dir are shown correctly. > > Could someone tell me how to fix this? Whether I should hack the rails rake > code? I imagine you'd have to hack either rails or RSpec code to support this. I haven't looked. If you find the solution in RSpec, please feel free to submit a patch to http://rspec.lighthouseapp.com. Cheers, David > > Thanks! > > -- > regards, > Kai Fu > > Material Science and Engineering > Huazhong University of Science and Technology > Wuhan > E-mail: corntrace at gmail.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Thu Dec 11 10:19:59 2008 From: lists at ruby-forum.com (James Byrne) Date: Thu, 11 Dec 2008 16:19:59 +0100 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: <010D0C11-DAB7-415D-9044-D0939AC4FFB1@patchspace.co.uk> References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> <3a6a61c3f79340b7536c36741c1f11e3@ruby-forum.com> <010D0C11-DAB7-415D-9044-D0939AC4FFB1@patchspace.co.uk> Message-ID: <903b175615b7db273b2f4c6451150df9@ruby-forum.com> Ashley Moran wrote: > > Then you already have the name to verify if you want to display a > personalised message. (On the other hand, putting too much data in > the steps gets cumbersome; I tend to write them more like this: > > Scenario: A known user signs in successfully > Given I am a registered user > When I sign on with the correct credentials > Then I should see a sign in success message > > Even if internally I call out to steps more like the ones you wrote as > examples. Hope that doesn't muddy the waters though. I believe that I am gaining some insight into how this is all meant to pull together. One of the difficulties I face is that different people evidently have significantly different philosophies about how and what to test (surprise, surprise, surprise!). As I am coming at this from the pov of someone who has had no prior experience with this approach, and whose training in it to date has been entirely theoretical in nature, I find this somewhat confusing. At the moment I tend to see cucumber features as my sole method of testing, an approach that I realize is not favoured by many. I began learning cucumber by writing a set of fairly low level functional tests following the template generated by cucumber. Now, based on the advice I have received here, I am trying a much smaller scale approach and generating a few very high level features. However, in the back of my mind I still consider that eventually I will specify much of the implementation detail, model attributes, data normalization routines, input limits, and so forth as feature steps somewhere. Experience will eventually teach me whether that approach is sustainable or not. I presently have in mind two distinct types of tests/features that I wish to represent. The first is the end user type of feature writing which conforms generally to the analysis of system requirements. The second set of features will be more like functional tests, that exercise the implementation details. My expression of the second type of features, the functional tests, are probably what is generating the greatest controversy. Some practitioners evidently see BDD features more or less as a pure analytical tool. They expect that functional and unit tests will be conducted mostly in a "traditional" manner, via test unit or rspec or similar testing framework. With this approach there is no need, or desire, that features elaborate great detail regarding implementation since that is done elsewhere. The dichotomy between feature steps and step definitions is another point of confusion for me. Take your reference to "if internally I call out to steps more like the ones you wrote." Does this refer to feature "Steps" or to step definition "Steps". I suspect the latter. In that case one can imagine that step definitions become rather more elaborate structures. Some step definitions perhaps even assume the appearance and role of rspec specs and have only a remotely dependent relationship to any feature step. It is in these obscure details that much of my confusion arises. Perhaps I have inferred your meaning correctly, perhaps I have totally misunderstood it. Regardless of which is true, doubt remains. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Dec 11 10:39:51 2008 From: lists at ruby-forum.com (Jamie Dyer) Date: Thu, 11 Dec 2008 16:39:51 +0100 Subject: [rspec-users] Disabling rspec when using autotest Message-ID: <8e17566a8f77706a76dfc59f5c64ffa8@ruby-forum.com> Hi, I'm trying to get autotest working with an existing rails project. When I run the autotest command in the rails root I get the following error: loading autotest/rails_rspec Autotest style autotest/rails_rspec doesn't seem to exist. Aborting. The rails app itself isn't using rspec (we are using Test::Unit/shoulda/mocha) and has no spec folder and the rspec plugin is not installed in vendor/plugins. The rails app is using several plugins that have rspec tests which I assume is the reason for the error. Is there something I can put in an .autotest file in the rails app to disable rspec completely? Thanks Jamie -- Posted via http://www.ruby-forum.com/. From andy at obtiva.com Thu Dec 11 11:29:00 2008 From: andy at obtiva.com (Andy Maleh) Date: Thu, 11 Dec 2008 10:29:00 -0600 Subject: [rspec-users] Glimmer's Got BDD through RSpec and SWTBot Message-ID: <620ca2c40812110829x7369045csbe60ca481a32028c@mail.gmail.com> Just wanted to report that I successfully got a Glimmer desktop application tested through RSpec Cucumber Story Runner with the help of SWTBot. Check out my report about it here: Glimmer's Got BDD through RSpec and SWTBot ( http://andymaleh.blogspot.com/2008/12/glimmers-got-bdd-through-rspec-and.html ) Thanks to Aslak and David for providing help when needed. Andy Maleh http://andymaleh.blogspot.com http://www.eclipse.org/glimmer -- //Obtiva - Agility Applied. Software Delivered. www.obtiva.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Thu Dec 11 11:32:56 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 11 Dec 2008 11:32:56 -0500 Subject: [rspec-users] Glimmer's Got BDD through RSpec and SWTBot In-Reply-To: <620ca2c40812110829x7369045csbe60ca481a32028c@mail.gmail.com> References: <620ca2c40812110829x7369045csbe60ca481a32028c@mail.gmail.com> Message-ID: <85d99afe0812110832r6ed71c37l4bfbf569fc4db82c@mail.gmail.com> On Thu, Dec 11, 2008 at 11:29 AM, Andy Maleh wrote: > Just wanted to report that I successfully got a Glimmer desktop application > tested through RSpec Cucumber Story Runner with the help of SWTBot. > Check out my report about it here: > Glimmer's Got BDD through RSpec and SWTBot > (http://andymaleh.blogspot.com/2008/12/glimmers-got-bdd-through-rspec-and.html) > Very cool. Thanks for sharing, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Thu Dec 11 11:45:06 2008 From: lists at ruby-forum.com (Jamie Dyer) Date: Thu, 11 Dec 2008 17:45:06 +0100 Subject: [rspec-users] Disabling rspec when using autotest In-Reply-To: <8e17566a8f77706a76dfc59f5c64ffa8@ruby-forum.com> References: <8e17566a8f77706a76dfc59f5c64ffa8@ruby-forum.com> Message-ID: <199a185fa2ddf65f349d93f3a832b49d@ruby-forum.com> I found the culprit, subdomain-fu has lib/autotest and a spec folder, I removed both and its now running. Jamie -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Thu Dec 11 12:37:45 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 11 Dec 2008 18:37:45 +0100 Subject: [rspec-users] Glimmer's Got BDD through RSpec and SWTBot In-Reply-To: <620ca2c40812110829x7369045csbe60ca481a32028c@mail.gmail.com> References: <620ca2c40812110829x7369045csbe60ca481a32028c@mail.gmail.com> Message-ID: <8d961d900812110937qfa7f8e6y43f30b0387e2c6ad@mail.gmail.com> On Thu, Dec 11, 2008 at 5:29 PM, Andy Maleh wrote: > Just wanted to report that I successfully got a Glimmer desktop application > tested through RSpec Cucumber Story Runner with the help of SWTBot. > > Check out my report about it here: > Glimmer's Got BDD through RSpec and SWTBot > ( > http://andymaleh.blogspot.com/2008/12/glimmers-got-bdd-through-rspec-and.html > ) > > Thanks to Aslak and David for providing help when needed. > That's awesome Andy. Care to edit http://github.com/aslakhellesoy/cucumber/wikis/jruby-and-java if you have some Cucumber/Java source to show? Aslak > > Andy Maleh > http://andymaleh.blogspot.com > http://www.eclipse.org/glimmer > > -- > //Obtiva - Agility Applied. Software Delivered. > www.obtiva.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Thu Dec 11 12:36:34 2008 From: mark at mwilden.com (Mark Wilden) Date: Thu, 11 Dec 2008 09:36:34 -0800 Subject: [rspec-users] Nosy controller specs In-Reply-To: <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> Message-ID: <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> On Thu, Dec 11, 2008 at 4:33 AM, Andrew Premdas wrote: > >> it "should find all posts" do >> Post.should_receive(:find).with(:all).and_return([@post]) >> do_get >> end >> >> Now this last spec "should find all posts" is nosy is far as I'm concerned >> in that its specifying how the model should get all the posts (i.e. white >> box testing) rather than checking the result i.e. that its got @post back. >> So now if I change the model so that "all posts" is for example "all posts >> in last year" because there is a new business rule that we don't show posts >> over a year old then my controller spec fails. > > I think this is probably correct as is. When specing a controller, it's correct BDD to specify how it interacts with other objects. If the controller itself wants all posts in the last year, it's OK to test that. The fact that only this year's posts are of interest is a presentation issue - it's not an essential characteristic of the data. It's not the model's job to decide that all clients should get back posts in the last year, and hence that's what its find method should return. All business rules don't reside in the model. As soon as you say "we don't SHOW posts over a year," you're talking about a presentation rule, not a model rule. Controllers mediate between data and screen - they're responsible for getting the data to be shown. That code should exist in the controller and be tested there. On the other hand, the controller should not necessarily be responsible for defining what constitutes "all posts in the last year." That should very likely be a named scope. This is all just my humble opinion, of course, and might be utter rubbish in any particular real world situation. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Thu Dec 11 13:19:12 2008 From: ben at benmabey.com (Ben Mabey) Date: Thu, 11 Dec 2008 11:19:12 -0700 Subject: [rspec-users] Using resource_controller (make_resourceful etc) and testing the In-Reply-To: <88fd8ddc0812110352v581e3099x8754924df3087f90@mail.gmail.com> References: <88fd8ddc0812110352v581e3099x8754924df3087f90@mail.gmail.com> Message-ID: <494159A0.3030408@benmabey.com> Andrew Premdas wrote: > Hi all, > > Trying to get some opinions about the use of such plugins and in > particular about how they test, and how we test with them. Can they > work well with BDD or do they do to much magic and create difficulties > for features and tests > > TIA > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Hey Andrew, Controllers using such plugins should not pose any difficulty wrapping features around them at all. How are they any different from any other controller from the request point-of-view? My current thinking on the matter is this: Use features, but skip the controller specs. The features verify the actual behaviour of them alongside the rest of the stack and provide me with the best confidence that I'm using the plugin correctly and giving the end-users the functionality that the app needs to. I don't see controller specs adding any additional value at this point. We would simply be testing the plugin's code over and over again... There is also no design benefit from mocking/stubbing the plugins code either. That is what I have been doing for all the standard RESTful actions. If I ever need to vary from the basic behaviour that is provided from the plugins then I then start adding controller specs for that deviating behaviour. At which point I will stub out what I need to to make the plugin work. HTH, Ben From pergesu at gmail.com Thu Dec 11 13:23:10 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 11 Dec 2008 10:23:10 -0800 Subject: [rspec-users] Nosy controller specs In-Reply-To: <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> (Mark Wilden's message of "Thu\, 11 Dec 2008 09\:36\:34 -0800") References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> Message-ID: "Mark Wilden" writes: > On Thu, Dec 11, 2008 at 4:33 AM, Andrew Premdas wrote: > > it "should find all posts" do > Post.should_receive(:find).with(:all).and_return([@post]) > do_get > end > > Now this last spec "should find all posts" is nosy is far as I'm concerned in that its specifying how the model should get all the > posts (i.e. white box testing) rather than checking the result i.e. that its got @post back. So now if I change the model so that > "all posts" is for example "all posts in last year" because there is a new business rule that we don't show posts over a year old > then my controller spec fails. > > I think this is probably correct as is. > > When specing a controller, it's correct BDD to specify how it interacts with other objects. If the controller itself wants all posts in the > last year, it's OK to test that. The fact that only this year's posts are of interest is a presentation issue - it's not an essential > characteristic of the data. It's not the model's job to decide that all clients should get back posts in the last year, and hence that's > what its find method should return. > > All business rules don't reside in the model. As soon as you say "we don't SHOW posts over a year," you're talking about a presentation > rule, not a model rule. Controllers mediate between data and screen - they're responsible for getting the data to be shown. That code should > exist in the controller and be tested there. > > On the other hand, the controller should not necessarily be responsible for defining what constitutes "all posts in the last year." That > should very likely be a named scope. > > This is all just my humble opinion, of course, and might be utter rubbish in any particular real world situation. > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users I agree with this. You generally don't want to screw with the meaning of AR::Base.find. That's really only for situations where you want some uniform, transparent behavior (acts_as_versioned, acts_as_paranoid, etc). The view shouldn't really care about this stuff either...it should just take a list of posts and display them. It's up to the controller to ask the model for what it wants to push to the view. So your finder can be something like Post.since(1.year.ago) or whatever. Andrew, I've noticed a theme in your posts that suggests you feel you needn't ever change controller specs. That's just not true. Models are a distilled representation of the domain, and controllers give meaning to it in the context of the application you're working on. Models are what your app *is* and controllers are what your app *does*. When you change what your app does, you're going to have to change some specs and production code along with it. Keep in mind that if you went with a state-based test, you would *still* have to modify the controller spec. It wouldn't be good enough to expect a post to be displayed. You'd have to create a post with a created_at of over a year ago, and one within the last year, and expect that the former is not shown while the latter is. Also, I'd like to point out that if you *really* wanted Post.find(:all) to only return posts in the last year, you wouldn't actually have to change the controller spec :) You would just have to write a model spec for that behavior. Pat From pergesu at gmail.com Thu Dec 11 13:55:41 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 11 Dec 2008 10:55:41 -0800 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> (James Byrne's message of "Wed\, 10 Dec 2008 17\:04\:44 +0100") References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> Message-ID: James Byrne writes: > Matt Wynne wrote: >> On 9 Dec 2008, at 19:06, James Byrne wrote: >> >>> should >>> >>> When /authentication by authlogic/ do >>> #TODO: Find out how to test for a loaded gem within an application >>> end >> >> If you're working at the level of Cucumber features, I would stay well >> away from implementation details like the particular technology you're >> using for authentication. >> > > The features for this simply say something along the lines of: > > Scenario: Application has known users > Given that the application has users > When the user signs on > Then the user is authenticated WTBV? (Where's the business value (I totally made that up, but I'm gonna stick with it :)) On its own, being authenticated doesn't have any business value. Authentication only *enhances* business value. Consider a feature that lets me manage finances. That has some business value. Then we ensure that only authenticated users may manage their finances, which means we can charge people for the service - enhancing the business value that already exists. >> Remember this is called Behaviour Driven Development[1] for a reason. >> You're focussing on specifying the desired *behaviour* of the system. >> How you chose to satisfy the user's need for that behaviour is an >> entirely separate matter. > > Nonetheless, in the step definitions I must test the behaviour in a > fashion which first drives and then confirms the implementation > details. I don't understand this. Your features/specs drive the implementation, but they confirm the *behavior*. > If the chosen implementation depends upon a third party plugin or gem > then surely one should test for its provision? What is the alternative? > Write tests to test that gems behaviour? I would specify my app's behavior, not the gem's. And I certainly wouldn't test that the gem is there. If it's not, then my code is going to blow up anyway! Instead, write features that specify *what* you want from your application. Given a user named 'padillac' When I log in as 'padillac' Then I should see 'Hello, padillac!' And I should see 'Edit your account' How you handle this - whether it's restful_authentication, authlogic, or roll-your-own - doesn't matter. >> A large benefit of having Acceptance Tests, IMO, is that you could >> radically change your implementation under the hood, such as switching >> to a different authentication mechanism, and the features would still >> be valid. You might have to code up some of your steps a little >> differently, but as long as the users want the same thing from the >> system, the features should not have to change in the slightest. >> > > If the implementation changed then the step definitions must change to > suit, must they not? It depends on the level at which you've written your step definitions. If you've written them to hit the outer-most interface, for example using webrat in a rails app, then no, you wouldn't need to change the definitions. If you wrote them at a lower level, creating a user and adding his id to the session, then there's a chance you would have to change them. The key is writing the features themselves at a level of abstraction that *completely* hides the implementation. That way you can change your code and step definitions freely. What you're left with is a balancing act, deciding which implementation details can force changes to your step definitions. If you write the definitions at a low level, accessing the model directly, you'll likely need to change them when the definitions change. On the other hand, if you write them at a higher level, there's the real possibility that minor changes to your app code will necessitate changes to your step definitions. Consider the following step definition: When /^I log in as '(.*)'$/ do |username| visits login_url fills_in 'Username', :with => username fills_in 'Password', :with => 'password' end If you change the template to read 'Login' instead of 'Username' for the username field, the step definition is going to have to change. So you have to evaluate each piece of your app, figure out what's likely to change, determine the upfront and maintenance costs of writing step definitions at varying levels of abstraction, and make a decision. Then be thankful that you're not building a bridge, because even if you get it wrong, the cost of fixing your mistake is relatively cheap :) > Not all features are of concern to all users/roles. Why should some > users be denied the use of features and BDD as a tool for their own > concerns simply because they are writing the code? It seems to me an > artificial, and logically insupportable, distinction to make. I don't understand what you mean by this. Which users are "denied the use of features and BDD?" Could you please elaborate for me? > When /user "(.*)" is authenticated/ do |u| > # We use Authlogic for authentication so just test that gem is loaded > assert defined?("Authlogic") > end WTBV?! :) Pat From pergesu at gmail.com Thu Dec 11 14:03:50 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 11 Dec 2008 11:03:50 -0800 Subject: [rspec-users] Using resource_controller (make_resourceful etc) and testing the In-Reply-To: <494159A0.3030408@benmabey.com> (Ben Mabey's message of "Thu\, 11 Dec 2008 11\:19\:12 -0700") References: <88fd8ddc0812110352v581e3099x8754924df3087f90@mail.gmail.com> <494159A0.3030408@benmabey.com> Message-ID: Ben Mabey writes: > Andrew Premdas wrote: >> Hi all, >> >> Trying to get some opinions about the use of such plugins and in >> particular about how they test, and how we test with them. Can they >> work well with BDD or do they do to much magic and create >> difficulties for features and tests >> >> TIA >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > >My current thinking on the matter is this: Use features, but skip the >controller specs. The features verify the actual behaviour of them >alongside the rest of the stack and provide me with the best confidence >that I'm using the plugin correctly and giving the end-users the >functionality that the app needs to. I don't see controller specs >adding any additional value at this point. We would simply be testing >the plugin's code over and over again... There is also no design >benefit from mocking/stubbing the plugins code either. +2 Pat From apremdas at gmail.com Thu Dec 11 14:28:47 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 11 Dec 2008 19:28:47 +0000 Subject: [rspec-users] Nosy controller specs In-Reply-To: <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> Message-ID: <88fd8ddc0812111128r353bdd0aq234008e9ab7a81ce@mail.gmail.com> Mark, Thanks for your reply. As you say controllers should not be responsible for defining things, but in Rails this is exactly what they do, they formulate queries using class methods like find_by_xxx. Personally I think Rails is somewhat confused or perhaps lax in defining Controller responsibilities compared to many MVC frameworks and particularly to the underlying concept of MVC. As for this years posts being a presentation issue that depends. If the request came from a view i.e. I'd like to see post for 2001 then the controller should pass parameters to the model so it can return the correct things. On the other hand if last years posts represent a specific business concept something perphaps like AuditablePosts, then the model could/should represent this as a seperate resource. In Rails all business rules don't generally reside in the model, but maybe they should! IMO of course :) 2008/12/11 Mark Wilden > On Thu, Dec 11, 2008 at 4:33 AM, Andrew Premdas wrote: > >> >>> it "should find all posts" do >>> Post.should_receive(:find).with(:all).and_return([@post]) >>> do_get >>> end >>> >>> Now this last spec "should find all posts" is nosy is far as I'm >>> concerned in that its specifying how the model should get all the posts >>> (i.e. white box testing) rather than checking the result i.e. that its got >>> @post back. So now if I change the model so that "all posts" is for example >>> "all posts in last year" because there is a new business rule that we don't >>> show posts over a year old then my controller spec fails. >> >> > I think this is probably correct as is. > > When specing a controller, it's correct BDD to specify how it interacts > with other objects. If the controller itself wants all posts in the last > year, it's OK to test that. The fact that only this year's posts are of > interest is a presentation issue - it's not an essential characteristic of > the data. It's not the model's job to decide that all clients should get > back posts in the last year, and hence that's what its find method should > return. > > All business rules don't reside in the model. As soon as you say "we don't > SHOW posts over a year," you're talking about a presentation rule, not a > model rule. Controllers mediate between data and screen - they're > responsible for getting the data to be shown. That code should exist in the > controller and be tested there. > > On the other hand, the controller should not necessarily be responsible for > defining what constitutes "all posts in the last year." That should very > likely be a named scope. > > This is all just my humble opinion, of course, and might be utter rubbish > in any particular real world situation. > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Thu Dec 11 14:54:44 2008 From: mark at mwilden.com (Mark Wilden) Date: Thu, 11 Dec 2008 11:54:44 -0800 Subject: [rspec-users] Nosy controller specs In-Reply-To: <88fd8ddc0812111128r353bdd0aq234008e9ab7a81ce@mail.gmail.com> References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> <88fd8ddc0812111128r353bdd0aq234008e9ab7a81ce@mail.gmail.com> Message-ID: <3c30da400812111154x47a07cc9u5b7e0e4355284a8b@mail.gmail.com> On Thu, Dec 11, 2008 at 11:28 AM, Andrew Premdas wrote: > As you say controllers should not be responsible for defining things, but > in Rails this is exactly what they do, they formulate queries using class > methods like find_by_xxx. Personally I think Rails is somewhat confused or > perhaps lax in defining Controller responsibilities compared to many MVC > frameworks and particularly to the underlying concept of MVC. When I was talking about defining things, I meant that the controller should request "this year's posts," but shouldn't define what that means (calendar year? fiscal year? which calendar? which timezone?). Put it another way - if there was a button on the view labeled "View this year's posts", it would be appropriate for the controller to call the this_years_posts method on the model, right? I was just extending that thinking to what the controller displays by default. But it's not cut and dried. Pat mentioned things like acts_as_paranoid which controllers certainly should not be concerned with. > As for this years posts being a presentation issue that depends. If the > request came from a view i.e. I'd like to see post for 2001 then the > controller should pass parameters to the model so it can return the correct > things. Don't most requests come from views? I mean, you got to this page via a user gesture of some kind. (Parenthetically, I consider views the most important part of a web app - if the right thing is displayed to the right user at the right time, it doesn't matter if it's generated by a herd of monkeys.) > On the other hand if last years posts represent a specific business concept > something perphaps like AuditablePosts, then the model could/should > represent this as a seperate resource. That sounds good. But the controller would still have to decide to display AuditablePosts on that page (and might display UnauditablePosts on another page). Again, it would know what result set - in domain terms - it wants to display. It shouldn't care about how the model defines that result set. I appreciate the opportunity to grope my way through my opinions on this subject. :) ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Dec 11 15:02:54 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 11 Dec 2008 20:02:54 +0000 Subject: [rspec-users] Nosy controller specs In-Reply-To: References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> Message-ID: <88fd8ddc0812111202s48d5b75dw1d3ff448e12f81b2@mail.gmail.com> Pat, Thanks for reply. The one year ago thing was a really bad example. Using your terminilogy it looks like a rule that changes what my app does. But I was talking about a change in what the app is; i.e. a business rule. I definitely don't want to have business rules in controllers. From my viewpoint in MVC the controller is a conduit that allows the business domain encapsulated by the model to be presented in views and in reverse allows interaction with views to communicate with the model. In Rails though its very easy for the business domain to creep into the controller. I'm beggining to think that Rails got this wrong. Perhaps it should have specified a restrictive api between the model and the controller, I've been thinking of something like get_collection get_object get_new_object By giving completely open access to anything in the model including all classes its real easy for controllers to get real messy. I think the emergence of Presenters as well as skinny controllers is symptomatic of that problem With a resource based approach the controller really should only be requesting resources or more accurately representations of resources. It shouldn't be creating/specifying representations of resources. That is outside the responsibility of a controller. Again using your terminology REST restricts what an application does by using a standard set of verbs to do things. Now in Rails we can pollute this by putting all sorts of stuff in our restful methods, but really we shouldn't. Instead we should use the expressivness of what 'is' to get our functionality. If we do this then our controllers can be ultra skinny and our controller specs should be much less brittle. To change what our app 'does' we then add new routes, controllers and views to show a different representation from our model but still using our standard verbs. If controllers only use the restrictive api I've suggested and we combine this with a 'presenter' layer (when required) on top of our model. then controller specs really can be very straightforward and focus on their key responsibilities which are getting something and controlling i.e. routes. I'll try and give a better example. In my business domain I have products and some of these products have refills which are also products. Generally when I want to look at all products I don't want to see the refills. This is because the refills are bought and specified through their product. So using tags when I want to find 'all' products I'll actually do the following bizzarre thing Product.find_tagged_with('refill', :exclude => 'refill') Now generally in Rails this will be done in my controllers index method, and with rspecs scaffold code we'd mock Product and test that this method was called the correct way. So as my call has changed from Product.find(:all) to this new call I have to change my controller spec. Now changing what all products means has nothing to do with controllers and everything to do with models. What my controller should have done is called Product.get_collection. Then when I change my definition of what get_collection does then yes I have to update my model spec, but that makes sense, and my controller and its specs remain the same. I don't see controller specs as being fixed, but I do think they should only need to change when something a controller is responsible for changes. Generally this is routing - controlling where we go - which is fundamentally how web applications do things. Anyhow hope that makes sense and once again thanks for the input much appreciated Andrew 2008/12/11 Pat Maddox > "Mark Wilden" writes: > > > On Thu, Dec 11, 2008 at 4:33 AM, Andrew Premdas > wrote: > > > > it "should find all posts" do > > Post.should_receive(:find).with(:all).and_return([@post]) > > do_get > > end > > > > Now this last spec "should find all posts" is nosy is far as I'm > concerned in that its specifying how the model should get all the > > posts (i.e. white box testing) rather than checking the result > i.e. that its got @post back. So now if I change the model so that > > "all posts" is for example "all posts in last year" because there > is a new business rule that we don't show posts over a year old > > then my controller spec fails. > > > > I think this is probably correct as is. > > > > When specing a controller, it's correct BDD to specify how it interacts > with other objects. If the controller itself wants all posts in the > > last year, it's OK to test that. The fact that only this year's posts are > of interest is a presentation issue - it's not an essential > > characteristic of the data. It's not the model's job to decide that all > clients should get back posts in the last year, and hence that's > > what its find method should return. > > > > All business rules don't reside in the model. As soon as you say "we > don't SHOW posts over a year," you're talking about a presentation > > rule, not a model rule. Controllers mediate between data and screen - > they're responsible for getting the data to be shown. That code should > > exist in the controller and be tested there. > > > > On the other hand, the controller should not necessarily be responsible > for defining what constitutes "all posts in the last year." That > > should very likely be a named scope. > > > > This is all just my humble opinion, of course, and might be utter rubbish > in any particular real world situation. > > > > ///ark > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > I agree with this. You generally don't want to screw with the meaning > of AR::Base.find. That's really only for situations where you want some > uniform, transparent behavior (acts_as_versioned, acts_as_paranoid, > etc). > > The view shouldn't really care about this stuff either...it should just > take a list of posts and display them. > > It's up to the controller to ask the model for what it wants to push to > the view. So your finder can be something like Post.since(1.year.ago) > or whatever. > > Andrew, I've noticed a theme in your posts that suggests you feel you > needn't ever change controller specs. That's just not true. Models > are a distilled representation of the domain, and controllers give > meaning to it in the context of the application you're working on. > Models are what your app *is* and controllers are what your app *does*. > When you change what your app does, you're going to have to change some > specs and production code along with it. > > Keep in mind that if you went with a state-based test, you would *still* > have to modify the controller spec. It wouldn't be good enough to > expect a post to be displayed. You'd have to create a post with a > created_at of over a year ago, and one within the last year, and expect > that the former is not shown while the latter is. > > Also, I'd like to point out that if you *really* wanted Post.find(:all) > to only return posts in the last year, you wouldn't actually have to > change the controller spec :) You would just have to write a model spec > for that behavior. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Dec 11 15:12:17 2008 From: lists at ruby-forum.com (James Byrne) Date: Thu, 11 Dec 2008 21:12:17 +0100 Subject: [rspec-users] Test for a gem/plugin? In-Reply-To: References: <433fb9d5feeb9495e474b973908627ce@ruby-forum.com> <2C85E0FE-0D62-461D-AE46-67F0D072935D@mattwynne.net> <63d211e4ce22816200ed2c0833c6eedb@ruby-forum.com> Message-ID: <9f64125360680c90fd9d82b76665ce70@ruby-forum.com> Pat Maddox wrote: >> >> Scenario: Application has known users >> Given that the application has users >> When the user signs on >> Then the user is authenticated > > WTBV? > > (Where's the business value (I totally made that up, but I'm gonna stick > with it :)) I like it too. That said, regulatory compliance and financial security are two that come to mind. And, yes, I and my users consider that both represent real business value. I am not trying to put forth a design philosophy. I am trying to discover what techniques experienced BDD practitioners consider useful and what they do not. My ignorance may lead me into astoundingly poor conclusions at times but, I am willing to bear the resulting ridicule if in the process I learn that which I should have realized. Fortunately, ridicule has been noteworthy by its absence and the knowledge revealed by respondents quite illuminating. I am beginning to see that there exists a wide range of acceptable practices gathered under the rubric of BDD. At the beginning I acquired the idea that step definitions were tied to feature steps N:1. Now I gather, perhaps incorrectly, that step definitions might replace discrete tests/specifications in frameworks like TestUnit and RSpec without the need for a directly corresponding feature step, N:N where N >= 0 Maybe that is my problem. Perhaps I am trying too hard to use features for everything. I really do not want to scatter my tests over hell's half acre. I do not wish to have some tests under ./test, others under ./spec and still others under ./features. I do not want to have three different rake tasks to run all the tests. I do not want to integrate rcov results from one test suite with the results from another. I do not wish to expend time on integrating test suites with one another. So, given all of these desires, perhaps I am considering features in a way that is considerably less than optimal. On the other hand, given that the rspec and testunit matchers are available in step definitions, is there any harm in using step definitions in place of specs and unit tests? In the absence of any other method, one could imagine I suppose a feature step that simply invokes that portion of the step definitions test suite that is not tied otherwise to any other feature step. -- Posted via http://www.ruby-forum.com/. From andy at obtiva.com Thu Dec 11 15:18:53 2008 From: andy at obtiva.com (Andy Maleh) Date: Thu, 11 Dec 2008 14:18:53 -0600 Subject: [rspec-users] Glimmer's Got BDD through RSpec and SWTBot In-Reply-To: <8d961d900812110937qfa7f8e6y43f30b0387e2c6ad@mail.gmail.com> References: <620ca2c40812110829x7369045csbe60ca481a32028c@mail.gmail.com> <8d961d900812110937qfa7f8e6y43f30b0387e2c6ad@mail.gmail.com> Message-ID: <620ca2c40812111218g2df9d862p85029959db41cf88@mail.gmail.com> I added a link to the blog post at the bottom. I'll update the WIKI page again once I post my next blog post about the source-code and technical details of how Cucumber was used with Glimmer via JRuby. Andy On Thu, Dec 11, 2008 at 11:37 AM, aslak hellesoy wrote: > > > On Thu, Dec 11, 2008 at 5:29 PM, Andy Maleh wrote: > >> Just wanted to report that I successfully got a Glimmer desktop >> application tested through RSpec Cucumber Story Runner with the help of >> SWTBot. >> >> Check out my report about it here: >> Glimmer's Got BDD through RSpec and SWTBot >> ( >> http://andymaleh.blogspot.com/2008/12/glimmers-got-bdd-through-rspec-and.html >> ) >> >> Thanks to Aslak and David for providing help when needed. >> > > That's awesome Andy. Care to edit > http://github.com/aslakhellesoy/cucumber/wikis/jruby-and-java if you have > some Cucumber/Java source to show? > > Aslak > > >> >> Andy Maleh >> http://andymaleh.blogspot.com >> http://www.eclipse.org/glimmer >> >> -- >> //Obtiva - Agility Applied. Software Delivered. >> www.obtiva.com >> >> _______________________________________________ >> 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 > -- //Obtiva - Agility Applied. Software Delivered. www.obtiva.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Dec 11 15:34:15 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 11 Dec 2008 20:34:15 +0000 Subject: [rspec-users] Nosy controller specs In-Reply-To: <3c30da400812111154x47a07cc9u5b7e0e4355284a8b@mail.gmail.com> References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> <88fd8ddc0812111128r353bdd0aq234008e9ab7a81ce@mail.gmail.com> <3c30da400812111154x47a07cc9u5b7e0e4355284a8b@mail.gmail.com> Message-ID: <88fd8ddc0812111234r50e83b7by7b433d98337e2763@mail.gmail.com> We're actually getting pretty close to saying the same thing here, though my use of language is causing some confusion. The two sorts of requests I was talking about where a view request and a request by the business for a specific rule to be implemented. If there were AuditablePosts the controller wouldn't decide what display it could decide where to route (well actually the Dispatcher but you get my drift) because this new resource would have its own controller as its a seperate business entity. A controller really shouldn't be choosing between model entities, you wouldn't do this would you? def index if params[:auditable] @posts = AuditablePosts.find(:all) else @posts = Posts.find(:all) end end but we often end up with def index if params[:auditable] @posts = Posts.find_auditable else @posts = Posts.find(:all) end end which really isn't much different. You mentioned something like def index if params[:auditable] @posts = Posts.get_auditable_posts else @posts = Posts.find(:all) end end which I think is better. However I kind of think we should have def index @posts = Posts.get_collection(params) or have two resources and two controllers, and not have anything inbetween. Andrew 2008/12/11 Mark Wilden > On Thu, Dec 11, 2008 at 11:28 AM, Andrew Premdas wrote: > > >> As you say controllers should not be responsible for defining things, but >> in Rails this is exactly what they do, they formulate queries using class >> methods like find_by_xxx. Personally I think Rails is somewhat confused or >> perhaps lax in defining Controller responsibilities compared to many MVC >> frameworks and particularly to the underlying concept of MVC. > > > When I was talking about defining things, I meant that the controller > should request "this year's posts," but shouldn't define what that means > (calendar year? fiscal year? which calendar? which timezone?). Put it > another way - if there was a button on the view labeled "View this year's > posts", it would be appropriate for the controller to call the > this_years_posts method on the model, right? I was just extending that > thinking to what the controller displays by default. But it's not cut and > dried. Pat mentioned things like acts_as_paranoid which controllers > certainly should not be concerned with. > > >> As for this years posts being a presentation issue that depends. If the >> request came from a view i.e. I'd like to see post for 2001 then the >> controller should pass parameters to the model so it can return the correct >> things. > > > Don't most requests come from views? I mean, you got to this page via a > user gesture of some kind. (Parenthetically, I consider views the most > important part of a web app - if the right thing is displayed to the right > user at the right time, it doesn't matter if it's generated by a herd of > monkeys.) > > >> On the other hand if last years posts represent a specific business >> concept something perphaps like AuditablePosts, then the model could/should >> represent this as a seperate resource. > > > That sounds good. But the controller would still have to decide to display > AuditablePosts on that page (and might display UnauditablePosts on another > page). Again, it would know what result set - in domain terms - it wants to > display. It shouldn't care about how the model defines that result set. > > I appreciate the opportunity to grope my way through my opinions on this > subject. :) > > ///ark > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Dec 11 15:47:59 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Thu, 11 Dec 2008 20:47:59 +0000 Subject: [rspec-users] Using resource_controller (make_resourceful etc) and testing the In-Reply-To: <494159A0.3030408@benmabey.com> References: <88fd8ddc0812110352v581e3099x8754924df3087f90@mail.gmail.com> <494159A0.3030408@benmabey.com> Message-ID: <88fd8ddc0812111247i6232f126ye591dbb2cd2084c3@mail.gmail.com> Thanks for that Ben most helpful. 2008/12/11 Ben Mabey > Andrew Premdas wrote: > >> Hi all, >> >> Trying to get some opinions about the use of such plugins and in >> particular about how they test, and how we test with them. Can they work >> well with BDD or do they do to much magic and create difficulties for >> features and tests >> >> TIA >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > Hey Andrew, > Controllers using such plugins should not pose any difficulty wrapping > features around them at all. How are they any different from any other > controller from the request point-of-view? My current thinking on the > matter is this: Use features, but skip the controller specs. The features > verify the actual behaviour of them alongside the rest of the stack and > provide me with the best confidence that I'm using the plugin correctly and > giving the end-users the functionality that the app needs to. I don't see > controller specs adding any additional value at this point. We would simply > be testing the plugin's code over and over again... There is also no design > benefit from mocking/stubbing the plugins code either. > That is what I have been doing for all the standard RESTful actions. If I > ever need to vary from the basic behaviour that is provided from the plugins > then I then start adding controller specs for that deviating behaviour. At > which point I will stub out what I need to to make the plugin work. > HTH, > Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Thu Dec 11 18:03:08 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 11 Dec 2008 15:03:08 -0800 Subject: [rspec-users] Nosy controller specs In-Reply-To: <88fd8ddc0812111234r50e83b7by7b433d98337e2763@mail.gmail.com> (Andrew Premdas's message of "Thu\, 11 Dec 2008 20\:34\:15 +0000") References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> <88fd8ddc0812111128r353bdd0aq234008e9ab7a81ce@mail.gmail.com> <3c30da400812111154x47a07cc9u5b7e0e4355284a8b@mail.gmail.com> <88fd8ddc0812111234r50e83b7by7b433d98337e2763@mail.gmail.com> Message-ID: "Andrew Premdas" writes: > We're actually getting pretty close to saying the same thing here, though my use of language is causing some confusion. The two sorts of > requests I was talking about where a view request and a request by the business for a specific rule to be implemented. > > If there were AuditablePosts the controller wouldn't decide what display it could decide where to route (well actually the Dispatcher but > you get my drift) because this new resource would have its own controller as its a seperate business entity. > > A controller really shouldn't be choosing between model entities, you wouldn't do this would you? > > def index > if params[:auditable] > @posts = AuditablePosts.find(:all) > else > @posts = Posts.find(:all) > end > end I don't see why not. In fact, something I like to do is def index @posts = repository.find :all end def repository params[:auditable] ? Post.auditable : Post end :O Makes a lot of sense to me. The controller's basic job is to get some stuff from the model and give it to the view. If the "get some stuff" requires parameterization, fine by me. Of course, there are plenty of ways you can structure your code. You can use query params (and take advantage of routes to make it look like a clean URL...hey, you're still RESTful!) or a new action (again, still RESTful), or create a whole new controller for it. That's another reason why REST is sweet from web app development perspective - stick to a consistent URL scheme, and you can refactor the app beneath it however you want. Pat From zach.dennis at gmail.com Thu Dec 11 18:04:36 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 11 Dec 2008 18:04:36 -0500 Subject: [rspec-users] Using resource_controller (make_resourceful etc) and testing the In-Reply-To: <494159A0.3030408@benmabey.com> References: <88fd8ddc0812110352v581e3099x8754924df3087f90@mail.gmail.com> <494159A0.3030408@benmabey.com> Message-ID: <85d99afe0812111504n1f44a471k7c8531fd58dbb4b9@mail.gmail.com> On Thu, Dec 11, 2008 at 1:19 PM, Ben Mabey wrote: > Andrew Premdas wrote: >> >> Hi all, >> >> Trying to get some opinions about the use of such plugins and in >> particular about how they test, and how we test with them. Can they work >> well with BDD or do they do to much magic and create difficulties for >> features and tests >> >> TIA >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > Hey Andrew, > Controllers using such plugins should not pose any difficulty wrapping > features around them at all. How are they any different from any other > controller from the request point-of-view? My current thinking on the > matter is this: Use features, but skip the controller specs. The features > verify the actual behaviour of them alongside the rest of the stack and > provide me with the best confidence that I'm using the plugin correctly and > giving the end-users the functionality that the app needs to. I don't see > controller specs adding any additional value at this point. We would simply > be testing the plugin's code over and over again... There is also no design > benefit from mocking/stubbing the plugins code either. > That is what I have been doing for all the standard RESTful actions. If I > ever need to vary from the basic behaviour that is provided from the plugins > then I then start adding controller specs for that deviating behaviour. At > which point I will stub out what I need to to make the plugin work. +1 -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From pergesu at gmail.com Thu Dec 11 18:15:57 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 11 Dec 2008 15:15:57 -0800 Subject: [rspec-users] Nosy controller specs In-Reply-To: <88fd8ddc0812111202s48d5b75dw1d3ff448e12f81b2@mail.gmail.com> (Andrew Premdas's message of "Thu\, 11 Dec 2008 20\:02\:54 +0000") References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> <88fd8ddc0812111202s48d5b75dw1d3ff448e12f81b2@mail.gmail.com> Message-ID: "Andrew Premdas" writes: > Pat, > > Thanks for reply. The one year ago thing was a really bad > example. Using your terminilogy it looks like a rule that changes what > my app does. But I was talking about a change in what the app is; > i.e. a business rule. > > I definitely don't want to have business rules in controllers. From my > viewpoint in MVC the controller is a conduit that allows the business > domain encapsulated by the model to be presented in views and in > reverse allows interaction with views to communicate with the > model. In Rails though its very easy for the business domain to creep > into the controller. I'm beggining to think that Rails got this > wrong. Perhaps it should have specified a restrictive api between the > model and the controller, I've been thinking of something like > > get_collection > get_object > get_new_object You do.... find(:all), find(id) and new(attributes) > By giving completely open access to anything in the model including > all classes its real easy for controllers to get real messy. I think > the emergence of Presenters as well as skinny controllers is > symptomatic of that problem Oh. I'm a software libertarian. Arguments for locking stuff down are NEVER going to fly with me. Look, Ruby is a very powerful language. As Spiderman teaches us, with great power comes great responsibility. Just because stuff can get messy doesn't mean we need to lock down the language or framework. It means we need to be good developers, inventing useful conventions and abstractions. Do you know the secret to having a clean controller? Don't write one! Use something like make_resourceful. > I'll try and give a better example. In my business domain I have > products and some of these products have refills which are also > products. Generally when I want to look at all products I don't want > to see the refills. This is because the refills are bought and > specified through their product. So using tags when I want to find > 'all' products I'll actually do the following bizzarre thing > > Product.find_tagged_with('refill', :exclude => 'refill') > > Now generally in Rails this will be done in my controllers index > method, and with rspecs scaffold code we'd mock Product and test that > this method was called the correct way. So as my call has changed from > Product.find(:all) to this new call I have to change my controller > spec. Well, yeah. You're asking for a different thing now. You need to verify that somehow. Either you use mock objects to expect a different method call, or you write an expectation that you should see one product and not another. > Now changing what all products means has nothing to do with > controllers and everything to do with models. What my controller > should have done is called Product.get_collection. Then when I change > my definition of what get_collection does then yes I have to update my > model spec, but that makes sense, and my controller and its specs > remain the same. If you really, really want that, why not just change Product.find(:all) to return something different? Same thing. I don't like it, but same thing :) I think you're overlooking the fact that all of this stuff must occur in context. As in "show me all the products" is a straightforward statement, yes, but is missing some info. As you yourself have stated, "all" can mean something different than "every single record which exists in our system." The clearest way to represent these contextual differences, in my experience, is to create an intention-revealing method and use that. Pat From mark at mwilden.com Thu Dec 11 21:01:55 2008 From: mark at mwilden.com (Mark Wilden) Date: Thu, 11 Dec 2008 18:01:55 -0800 Subject: [rspec-users] rspec_rails and spec_server Message-ID: <3c30da400812111801x13e0f208x7e1dff5a64765f4@mail.gmail.com> Just in case anyone can just short-circuit this, I upgraded to Rails 2.2.2 and RSpec-rails 1.1.11, and now when I run 'spec --drb foo.spec' I get an error because spec_server is trying to call ActiveRecord::Base.active_connections, which seems to be gone in 2.2.2. Anyone know anything? (druby://127.0.0.1:8989) /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in `method_missing_without_paginate': undefined local variable or method `active_connections' for ActiveRecord::Base:Class (NameError) from (druby://127.0.0.1:8989) /opt/local/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.6/lib/will_paginate/finder.rb:167:in `method_missing' from (druby://127.0.0.1:8989) script/spec_server:19:in `clear_reloadable_connections!' from (druby://127.0.0.1:8989) /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:158:in `cleanup_application' from (druby://127.0.0.1:8989) script/spec_server:29:in `run' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/drb_command_line.rb:13:in `run' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/option_parser.rb:184:in `parse_drb' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/option_parser.rb:124:in `order!' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:202:in `options' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:7:in `run' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 from /opt/local/bin/spec:19:in `load' from /opt/local/bin/spec:19 -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Dec 11 23:48:46 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 12 Dec 2008 04:48:46 +0000 Subject: [rspec-users] Nosy controller specs In-Reply-To: References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> <88fd8ddc0812111202s48d5b75dw1d3ff448e12f81b2@mail.gmail.com> Message-ID: <88fd8ddc0812112048j4b03a42bq259dc976990133bf@mail.gmail.com> 2008/12/11 Pat Maddox writes > "Andrew Premdas" writes: > > > Pat, > > > > Thanks for reply. The one year ago thing was a really bad > > example. Using your terminilogy it looks like a rule that changes what > > my app does. But I was talking about a change in what the app is; > > i.e. a business rule. > > > > I definitely don't want to have business rules in controllers. From my > > viewpoint in MVC the controller is a conduit that allows the business > > domain encapsulated by the model to be presented in views and in > > reverse allows interaction with views to communicate with the > > model. In Rails though its very easy for the business domain to creep > > into the controller. I'm beggining to think that Rails got this > > wrong. Perhaps it should have specified a restrictive api between the > > model and the controller, I've been thinking of something like > > > > get_collection > > get_object > > get_new_object > > You do.... find(:all), find(id) and new(attributes) > > > > By giving completely open access to anything in the model including > > all classes its real easy for controllers to get real messy. I think > > the emergence of Presenters as well as skinny controllers is > > symptomatic of that problem > > Oh. I'm a software libertarian. Arguments for locking stuff down are > NEVER going to fly with me. > > Look, Ruby is a very powerful language. As Spiderman teaches us, with > great power comes great responsibility. Just because stuff can get > messy doesn't mean we need to lock down the language or framework. It > means we need to be good developers, inventing useful conventions and > abstractions. > I'm looking to find better conventions (for me) to use the power of rails responsibly. But probably I'm betraying my Java/C++ heritage by using the word rules instead of convention In the design of any web framework and in Rails lots of rules/conventions exist about what you can do and where you can do things. For example Rails is quite happy to restrict what you can access in views by default. > > Do you know the secret to having a clean controller? Don't write one! > Use something like make_resourceful. > > Thats exactly what I'm looking at. The trouble with these is that the how of object retrieval ends up buried in 'magic' code somewhere, so when you need to change things you end up having to overload something somewhat obscure in the controller, and then having to test this overloading occurs in a controller spec. For example using resource_controller and the example below I'd end up with something like class ProductsController < ResourceController::Base private def collection @collection ||= end_of_association_chain.find_tagged_with('refill', :exclude => 'refill') end end end This sort of code isn't very intuitive and (for me) it feels as though its in the wrong place > > > I'll try and give a better example. In my business domain I have > > products and some of these products have refills which are also > > products. Generally when I want to look at all products I don't want > > to see the refills. This is because the refills are bought and > > specified through their product. So using tags when I want to find > > 'all' products I'll actually do the following bizzarre thing > > > > Product.find_tagged_with('refill', :exclude => 'refill') > > > > Now generally in Rails this will be done in my controllers index > > method, and with rspecs scaffold code we'd mock Product and test that > > this method was called the correct way. So as my call has changed from > > Product.find(:all) to this new call I have to change my controller > > spec. > > Well, yeah. You're asking for a different thing now. You need to > verify that somehow. Either you use mock objects to expect a different > method call, or you write an expectation that you should see one product > and not another. > > > > Now changing what all products means has nothing to do with > > controllers and everything to do with models. What my controller > > should have done is called Product.get_collection. Then when I change > > my definition of what get_collection does then yes I have to update my > > model spec, but that makes sense, and my controller and its specs > > remain the same. > > If you really, really want that, why not just change Product.find(:all) > to return something different? Same thing. I don't like it, but same > thing :) Because I don't like it either its really ugly, and its far to clever for me > > I think you're overlooking the fact that all of this stuff must occur in > context. As in "show me all the products" is a straightforward > statement, yes, but is missing some info. As you yourself have stated, > "all" can mean something different than "every single record which > exists in our system." The clearest way to represent these contextual > differences, in my experience, is to create an intention-revealing > method and use that. > The point I'm making is that this intention should be expressed clearly in the model, whereas currently its expressed in the controller. > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Thanks for providing lots of input, its been most interesting Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From hayafirst at gmail.com Fri Dec 12 00:01:51 2008 From: hayafirst at gmail.com (Yi Wen) Date: Thu, 11 Dec 2008 23:01:51 -0600 Subject: [rspec-users] Nosy controller specs In-Reply-To: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> Message-ID: yeah, instead of using Post.find(:all) in your controller, use a method like Post.all_posts, or some names like that. Then in the controller spec, you go: Post.should_receive(:all_posts) and leave the implementation detail of this method to the Post model. Technically speaking, this all_posts more belongs to Service layer though. Yi On Thu, Dec 11, 2008 at 5:48 AM, Andrew Premdas wrote: > Looking at generated controller specs we tend to get something like > > describe PostsController do > describe "handling GET /posts" do > > before(:each) do > @post = mock_model(Post) > Post.stub!(:find).and_return([@post]) > end > > def do_get > get :index > end > ... > > it "should find all posts" do > Post.should_receive(:find).with(:all).and_return([@post]) > do_get > end > > Now this last spec "should find all posts" is nosy is far as I'm concerned > in that its specifying how the model should get all the posts (i.e. white > box testing) rather than checking the result i.e. that its got @post back. > So now if I change the model so that "all posts" is for example "all posts > in last year" because there is a new business rule that we don't show posts > over a year old then my controller spec fails. Now it seems to me that I > should only have to change my model specs when I make this sort of change, > this implementation details is none of the controllers business > > So a couple of things > > 1) Am I right about this? > 2) If so is there a better way to still use the mock for speed but not be > nosy > 3) Should the default controller generators be re-written > > TIA > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erdoss at gmail.com Fri Dec 12 01:10:54 2008 From: erdoss at gmail.com (Andrei Erdoss) Date: Fri, 12 Dec 2008 08:10:54 +0200 Subject: [rspec-users] rspecing rjs - form.reset('form') In-Reply-To: References: Message-ID: Thank you for your help. I still need a bit of help on calling have_text correctly. I tried your version and it failed. Then I tried a couple of variations of this: response.should have_text(/$('Form').reset(\"tag_form\")/) but I got this error message: expected /$('Form').reset(\"tag_form\")/, got "Element.update(\"tag_list\", \"\");\nElement.toggle(\"add_tag\");\nElement.toggle(\"new_tag\");\nForm.reset(\"tag_form\");" Also tried: response.should have_text(/Form.reset(\"tag_form\")/) That also failed. Any ideas? On Thu, Dec 11, 2008 at 10:26 AM, s.ross wrote: > On Dec 10, 2008, at 10:27 AM, Andrei Erdoss wrote: > > Hello, >> >> I couldn't find much info on this. >> >> How do you rspec this: page.form.reset("form") >> >> I looked in the have_rjs source code and I can't find anything on form >> reset. >> >> Thanks, >> >> -- >> Andrei >> > > I tend not to use rjs much, but what I suspect you are looking for is the > response to contain a particular snippet of Javascript. So, it might look > sort of like: > > it "should send Javascript to reset the form" do > post :action_that_resets_the_form > response.should have_text(/$('form').reset()/) > end > > Does this sound like what you are looking for? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Andrei Erdoss -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Fri Dec 12 01:20:58 2008 From: pergesu at gmail.com (Pat Maddox) Date: Thu, 11 Dec 2008 22:20:58 -0800 Subject: [rspec-users] Nosy controller specs In-Reply-To: <88fd8ddc0812112048j4b03a42bq259dc976990133bf@mail.gmail.com> (Andrew Premdas's message of "Fri\, 12 Dec 2008 04\:48\:46 +0000") References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> <88fd8ddc0812111202s48d5b75dw1d3ff448e12f81b2@mail.gmail.com> <88fd8ddc0812112048j4b03a42bq259dc976990133bf@mail.gmail.com> Message-ID: "Andrew Premdas" writes: > 2008/12/11 Pat Maddox writes >> The clearest way to represent these contextual differences, in my >> experience, is to create an intention-revealing method and use that. > > The point I'm making is that this intention should be expressed > clearly in the model, whereas currently its expressed in the > controller. What? No. I said create methods with intention-revealing names. That means stuff like Post.since or Account.audited or Product.non_refillable. That absolutely is expressing the intent in the model, and calling it from the controller, which is what you want. Pat From cwdinfo at gmail.com Fri Dec 12 02:07:51 2008 From: cwdinfo at gmail.com (s.ross) Date: Thu, 11 Dec 2008 23:07:51 -0800 Subject: [rspec-users] rspecing rjs - form.reset('form') In-Reply-To: References: Message-ID: <881F4738-9C5C-4ACD-85FB-081D1051D44C@gmail.com> What you are looking for is the string: Form.reset("tag_form") Ignore the escaping backslashes in the output from the matcher. To tell have_text that it can appear anyplace in the body of the response, use the regex /Form.reset("tag_form")/ in your call to have_text. So, this should work: response.should have_text(/Form.reset("tag_form")/) Hope this works for you. Oh, and you might want to branch out and make sure that the content-type is text/javascript. -s On Dec 11, 2008, at 10:10 PM, Andrei Erdoss wrote: > Thank you for your help. I still need a bit of help on calling > have_text correctly. > > I tried your version and it failed. Then I tried a couple of > variations of this: > > response.should have_text(/$('Form').reset(\"tag_form\")/) but I got > this error message: > > expected /$('Form').reset(\"tag_form\")/, got > "Element.update(\"tag_list\", \"\");\nElement.toggle(\"add_tag\"); > \nElement.toggle(\"new_tag\");\nForm.reset(\"tag_form\");" > > Also tried: > > response.should have_text(/Form.reset(\"tag_form\")/) That also > failed. Any ideas? > > On Thu, Dec 11, 2008 at 10:26 AM, s.ross wrote: > On Dec 10, 2008, at 10:27 AM, Andrei Erdoss wrote: > > Hello, > > I couldn't find much info on this. > > How do you rspec this: page.form.reset("form") > > I looked in the have_rjs source code and I can't find anything on > form reset. > > Thanks, > > -- > Andrei > > I tend not to use rjs much, but what I suspect you are looking for > is the response to contain a particular snippet of Javascript. So, > it might look sort of like: > > it "should send Javascript to reset the form" do > post :action_that_resets_the_form > response.should have_text(/$('form').reset()/) > end > > Does this sound like what you are looking for? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > Andrei Erdoss > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Dec 12 03:33:24 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 12 Dec 2008 08:33:24 +0000 Subject: [rspec-users] Nosy controller specs In-Reply-To: References: <88fd8ddc0812110348t2c91d7e2ge6ca9695d9f19880@mail.gmail.com> <88fd8ddc0812110433k76eb42dcsec64796474a6a9d4@mail.gmail.com> <3c30da400812110936hf39e23elfa3f881cad1964b5@mail.gmail.com> <88fd8ddc0812111202s48d5b75dw1d3ff448e12f81b2@mail.gmail.com> <88fd8ddc0812112048j4b03a42bq259dc976990133bf@mail.gmail.com> Message-ID: <88fd8ddc0812120033w399ec301jf169db3a991a845e@mail.gmail.com> I was agreeing! I wasn't saying that what you were saying there wasn't expressing the intent in the model, I was saying that my long ramble was saying the same thing roughly, and that this differs from the standard approach in rails of using ActiveRecord:Base class methods directly. Apologies for not making that clear - I find email such a challenging form of communication at times :) Andrew 2008/12/12 Pat Maddox > "Andrew Premdas" writes: > > 2008/12/11 Pat Maddox writes > >> The clearest way to represent these contextual differences, in my > >> experience, is to create an intention-revealing method and use that. > > > > The point I'm making is that this intention should be expressed > > clearly in the model, whereas currently its expressed in the > > controller. > > What? No. I said create methods with intention-revealing names. That > means stuff like Post.since or Account.audited or > Product.non_refillable. That absolutely is expressing the intent in the > model, and calling it from the controller, which is what you want. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Fri Dec 12 13:30:18 2008 From: mark at mwilden.com (Mark Wilden) Date: Fri, 12 Dec 2008 10:30:18 -0800 Subject: [rspec-users] rspec_rails and spec_server In-Reply-To: <3c30da400812111801x13e0f208x7e1dff5a64765f4@mail.gmail.com> References: <3c30da400812111801x13e0f208x7e1dff5a64765f4@mail.gmail.com> Message-ID: <3c30da400812121030k5b853a31t85920c8cef5a0295@mail.gmail.com> Andreas's patch at http://rspec.lighthouseapp.com/attachments/69957/0001-Fixed-spec_server-to-work-with-Rails-2.2.2.patchseems to fix this. ///ark On Thu, Dec 11, 2008 at 6:01 PM, Mark Wilden wrote: > Just in case anyone can just short-circuit this, I upgraded to Rails 2.2.2 > and RSpec-rails 1.1.11, and now when I run 'spec --drb foo.spec' I get an > error because spec_server is trying to call > ActiveRecord::Base.active_connections, which seems to be gone in 2.2.2. > > Anyone know anything? > > (druby://127.0.0.1:8989) > /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in > `method_missing_without_paginate': undefined local variable or method > `active_connections' for ActiveRecord::Base:Class (NameError) > from (druby://127.0.0.1:8989) > /opt/local/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.6/lib/will_paginate/finder.rb:167:in > `method_missing' > from (druby://127.0.0.1:8989) script/spec_server:19:in > `clear_reloadable_connections!' > from (druby://127.0.0.1:8989) > /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:158:in > `cleanup_application' > from (druby://127.0.0.1:8989) script/spec_server:29:in `run' > from > /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/drb_command_line.rb:13:in > `run' > from > /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/option_parser.rb:184:in > `parse_drb' > from > /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/option_parser.rb:124:in > `order!' > from > /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:202:in > `options' > from > /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/runner/command_line.rb:7:in > `run' > from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/bin/spec:4 > from /opt/local/bin/spec:19:in `load' > from /opt/local/bin/spec:19 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at gmail.com Fri Dec 12 14:57:07 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Fri, 12 Dec 2008 17:57:07 -0200 Subject: [rspec-users] Problem when testing controllers Message-ID: <992995550812121157y6315c6efm139e890c691ddc83@mail.gmail.com> I'm having troubles to test methods on controllers, specially this method: def update @property = @user.properties.find(params[:id]) if params[:property][:owner_id].blank? @owner = Owner.create_from_user(@user) @property.owner = @owner end if @property.update_attributes(params[:property]) flash[:notice] = 'Imóvel atualizado com sucesso.' redirect_to user_property_path(@user) else render :action => "edit" end end This method is pretty standard, except for the line ==> if params[:property][:owner_id].blank? In my spec file I try this: it "should expose the requested property as @property" do @property = mock_model(Property, :owner=>:owner, :owner= =>:owner, :update_attributes => true) Property.stub!(:find).and_return(@property) Owner.stub!(:create_from_user) put :update, :id => "1" assigns(:property).should equal(@property) end But get this error: The error occurred while evaluating nil.[] The problem is params and I don't know how is the best way to simulete params hash ... Anyone can help? Thanks. Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Fri Dec 12 15:16:04 2008 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 12 Dec 2008 12:16:04 -0800 Subject: [rspec-users] Problem when testing controllers In-Reply-To: <992995550812121157y6315c6efm139e890c691ddc83@mail.gmail.com> (Daniel Lopes's message of "Fri\, 12 Dec 2008 17\:57\:07 -0200") References: <992995550812121157y6315c6efm139e890c691ddc83@mail.gmail.com> Message-ID: "Daniel Lopes" writes: > I'm having troubles to test methods on controllers, specially this method: > > def update > @property = @user.properties.find(params[:id]) > > if params[:property][:owner_id].blank? > @owner = Owner.create_from_user(@user) > @property.owner = @owner > end > > if @property.update_attributes(params[:property]) > flash[:notice] = 'Imóvel atualizado com sucesso.' > redirect_to user_property_path(@user) > else > render :action => "edit" > end > end > > This method is pretty standard, except for the line ==> if params[:property][:owner_id].blank? > > In my spec file I try this: > > it "should expose the requested property as @property" do > @property = mock_model(Property, :owner=>:owner, :owner= =>:owner, :update_attributes => true) > Property.stub!(:find).and_return(@property) > Owner.stub!(:create_from_user) > > put :update, :id => "1" > assigns(:property).should equal(@property) > end > > But get this error: > The error occurred while evaluating nil.[] > > The problem is params and I don't know how is the best way to simulete params hash ... Hi, you need to pass the param in the put: put :update, :id => "11", :property => {:owner_id => "123"} and when you want to check for the blank one, you just have to pass in an empty property hash: put :update, :id => "11", :property => {} This way params[:property][:owner_id] will return nil. Pat From danielvlopes at areacriacoes.com.br Fri Dec 12 15:32:28 2008 From: danielvlopes at areacriacoes.com.br (=?ISO-8859-1?Q?Daniel_Area_Cria=E7=F5es?=) Date: Fri, 12 Dec 2008 18:32:28 -0200 Subject: [rspec-users] Problem when testing controllers In-Reply-To: References: <992995550812121157y6315c6efm139e890c691ddc83@mail.gmail.com> Message-ID: <992995550812121232p1169dc51y568bcdccc8705911@mail.gmail.com> Thanks, now it's looks obivious. :D Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Fri, Dec 12, 2008 at 6:16 PM, Pat Maddox wrote: > "Daniel Lopes" writes: > > > I'm having troubles to test methods on controllers, specially this > method: > > > > def update > > @property = @user.properties.find(params[:id]) > > > > if params[:property][:owner_id].blank? > > @owner = Owner.create_from_user(@user) > > @property.owner = @owner > > end > > > > if @property.update_attributes(params[:property]) > > flash[:notice] = 'Imóvel atualizado com sucesso.' > > redirect_to user_property_path(@user) > > else > > render :action => "edit" > > end > > end > > > > This method is pretty standard, except for the line ==> if > params[:property][:owner_id].blank? > > > > In my spec file I try this: > > > > it "should expose the requested property as @property" do > > @property = mock_model(Property, :owner=>:owner, :owner= > =>:owner, :update_attributes => true) > > Property.stub!(:find).and_return(@property) > > Owner.stub!(:create_from_user) > > > > put :update, :id => "1" > > assigns(:property).should equal(@property) > > end > > > > But get this error: > > The error occurred while evaluating nil.[] > > > > The problem is params and I don't know how is the best way to simulete > params hash ... > > Hi, you need to pass the param in the put: > > put :update, :id => "11", :property => {:owner_id => "123"} > > and when you want to check for the blank one, you just have to pass in > an empty property hash: > > put :update, :id => "11", :property => {} > > This way params[:property][:owner_id] will return nil. > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Fri Dec 12 15:39:57 2008 From: stevemolitor at gmail.com (Steve Molitor) Date: Fri, 12 Dec 2008 14:39:57 -0600 Subject: [rspec-users] cucumber features HTML output bug with more than 100 steps Message-ID: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> I'm having the following problem: With the format as html, the output of cucumber stops coloring successful steps green after step #100. This last line in the HTML is: Steps 101 -n are colored grey. The tag is not closed but all steps are displayed. When running with 'format --pretty' everything works fine and all steps are colored green. This is happening with jruby 1.1.4 on OS X and RedHat Linux. Any ideas? Could this be a bug? Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Fri Dec 12 16:07:16 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Fri, 12 Dec 2008 22:07:16 +0100 Subject: [rspec-users] cucumber features HTML output bug with more than 100 steps In-Reply-To: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> References: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> Message-ID: <8d961d900812121307p584e7a77jcc5bec6820a4b414@mail.gmail.com> On Fri, Dec 12, 2008 at 9:39 PM, Steve Molitor wrote: > I'm having the following problem: > > With the format as html, the output of cucumber stops coloring successful > steps green after step #100. This last line in the HTML is: > > > > Steps 101 -n are colored grey. The tag is not closed but all steps > are displayed. When running with 'format --pretty' everything works fine > and all steps are colored green. This is happening with jruby 1.1.4 on OS X > and RedHat Linux. > > Any ideas? Could this be a bug? > It could. Please raise a ticket and attach the generated HTML. http://github.com/aslakhellesoy/cucumber/wikis/get-in-touch Aslak > > Steve > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kero at chello.nl Fri Dec 12 16:54:04 2008 From: kero at chello.nl (Kero van Gelder) Date: Fri, 12 Dec 2008 22:54:04 +0100 Subject: [rspec-users] Autospec does not work w/ cucumber features? In-Reply-To: <493B1A8E.7080002@benmabey.com> References: <20081206120446.GH17218@bumblebee.m38c.nl> <937d9d810812061157n1ed1c33ax2d7d5d7083f746a3@mail.gmail.com> <20081206233618.GA5616@bumblebee.m38c.nl> <493B1A8E.7080002@benmabey.com> Message-ID: <20081212215404.GE5616@bumblebee.m38c.nl> >>>> $ AUTOFEATURE=true autospec # bug! prompt returns immediately, ZenTest gem not a dependency? a warning that autotest was not found would be nice. >>>> >>> Huh. The autospec command comes from RSpec; do you have this issue >>> without setting AUTOFEATURE=true? >> >> Yup. >> >> But as I only have features, I would not expect it >> to do anything in that case ;) > > Perhaps the problem is related to that.. if you add a spec or two what > happens? Nope! I've been looking for the "default directory setup" for quite a while. It's not documented as such, but suggested at http://github.com/aslakhellesoy/cucumber/wikis/migration-from-rspec-stories And behold! $ autospec (Not running features. To run features in autotest, set AUTOFEATURE=true.) $ AUTOFEATURE=true autospec loading autotest/cucumber cucumber features --format progress --format autotest --color --out /tmp/autotest-cucumber20081212-23416-1vlymnp-0 ................ cucumber features --format progress --format autotest --color --out /tmp/autotest-cucumber20081212-23416-njhy50-0 ................ Actually, just making a ./features directory is already enough... What is clearly a bug, is that the suggested cucumber.yml profiles autotest and autotest-all, when they include the directory to -r require and the directory with the features, are not picked up by autospec. To file under rspec, I suppose: http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/134-autospec-does-not-pick-up-profiles Bye, Kero. ___ How can I change the world if I can't even change myself? -- Faithless, Salva Mea From seatmanu at gmail.com Fri Dec 12 18:55:02 2008 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Fri, 12 Dec 2008 15:55:02 -0800 Subject: [rspec-users] cucumber custom formatters In-Reply-To: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> References: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> Message-ID: <88709F25-5D0E-44A4-9950-A4FCFA9CAB76@gmail.com> Hi So I built a custom formatter as the default html provided seems to lack few information (like number of scenarios that passed,failed, skipped ..) I cannot seem to load my custom scenario I called it my_formatter.rb and class is MyFormatter. I tried cucumber -r my_formatter mytest.feature I tried cucumber -r my mytest.feature and no matter what I am getting the help menu with invalid format... also, is there a place to understand all the available hooks and order they are called? Looking at the html, pretty and progress , I can see a lot of available hooks with some that requires to call an accept method... Any ideas? Thanks Emmanuel From aslak.hellesoy at gmail.com Fri Dec 12 19:06:13 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 13 Dec 2008 01:06:13 +0100 Subject: [rspec-users] cucumber custom formatters In-Reply-To: <88709F25-5D0E-44A4-9950-A4FCFA9CAB76@gmail.com> References: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> <88709F25-5D0E-44A4-9950-A4FCFA9CAB76@gmail.com> Message-ID: <8d961d900812121606s44c18183kaef59b56d6e926b4@mail.gmail.com> On Sat, Dec 13, 2008 at 12:55 AM, Emmanuel Pinault wrote: > Hi > > So I built a custom formatter as the default html provided seems to lack > few information (like number of scenarios that passed,failed, skipped ..) > > I cannot seem to load my custom scenario > > I called it my_formatter.rb and class is MyFormatter. > > I tried cucumber -r my_formatter mytest.feature > I tried cucumber -r my mytest.feature > > and no matter what I am getting the help menu with invalid format... > Is the explanation of --format not clear? Have you tried: cucumber -r my_formatter -f MyFormatter mytest.feature > also, is there a place to understand all the available hooks and order they > are called? Looking at the html, pretty and progress , I can see a lot of > available hooks with some that requires to call an accept method... > What do you mean by hooks? This? http://github.com/aslakhellesoy/cucumber/wikis/hooks #accept is part of the internal API to traverse the internal structure of features. It's using the visitor pattern. Are you familiar with that? Aslak > > Any ideas? > > Thanks > > Emmanuel > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From seatmanu at gmail.com Fri Dec 12 19:22:01 2008 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Fri, 12 Dec 2008 16:22:01 -0800 Subject: [rspec-users] cucumber custom formatters In-Reply-To: <8d961d900812121606s44c18183kaef59b56d6e926b4@mail.gmail.com> References: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> <88709F25-5D0E-44A4-9950-A4FCFA9CAB76@gmail.com> <8d961d900812121606s44c18183kaef59b56d6e926b4@mail.gmail.com> Message-ID: <949447AB-70B9-4E53-9832-2F85017D3C76@gmail.com> > > Is the explanation of --format not clear? Have you tried: > > cucumber -r my_formatter -f MyFormatter mytest.feature Yes, I tried that too and it is not working still. I started to digg in the cli.rb and clearly there is a registration process happening in the build_formatter_broadcaster. But somehow it is not finding my formatter .. trying to debug it more > > > > also, is there a place to understand all the available hooks and > order they are called? Looking at the html, pretty and progress , I > can see a lot of available hooks with some that requires to call an > accept method... > > What do you mean by hooks? This? http://github.com/aslakhellesoy/cucumber/wikis/hooks Sorry I should have been more clear about the hooks.. I meant the formatter hooks. I see the main one used in the pretty_formatter and that are called by the executor. But It seems in the html_formatter that you are even using some other hook (likely those are called during the tree parsing ... just a guess) but cannot see all the one that are available and when. I am actually writing formatter to understand the order of calls. > > > #accept is part of the internal API to traverse the internal > structure of features. It's using the visitor pattern. Are you > familiar with that? Yes I am and notice you use that pattern but I am not familiar with treetop. But seems a bit complicated for a custom reporter to have to mess with that. the HTML Report clearly will break without those calls at the right place... so a simple diagram would hel understanding how calls are made. Once I am able to rrun that custom report, I can try to make one and send it to you to add to the wiki Thanks Emmannuel > > Aslak > > > Any ideas? > > Thanks > > Emmanuel > > _______________________________________________ > 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From seatmanu at gmail.com Fri Dec 12 19:37:05 2008 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Fri, 12 Dec 2008 16:37:05 -0800 Subject: [rspec-users] cucumber custom formatters In-Reply-To: <949447AB-70B9-4E53-9832-2F85017D3C76@gmail.com> References: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> <88709F25-5D0E-44A4-9950-A4FCFA9CAB76@gmail.com> <8d961d900812121606s44c18183kaef59b56d6e926b4@mail.gmail.com> <949447AB-70B9-4E53-9832-2F85017D3C76@gmail.com> Message-ID: OK, I think I figured out the problem. I had the following module Cucumber module Formatters class MyFormatter As soon I as removed it from that module, then it started to work. I am not seeing different call and steps in the visitor printing ... maybe a nice simple example of create a formatter would have helped :) thanks Emmanuek On Fri, Dec 12, 2008 at 4:22 PM, Emmanuel Pinault wrote: > > Is the explanation of --format not clear? Have you tried: > > cucumber -r my_formatter -f MyFormatter mytest.feature > > Yes, I tried that too and it is not working still. I started to digg in the > cli.rb and clearly there is a registration process happening in the > build_formatter_broadcaster. > But somehow it is not finding my formatter .. trying to debug it more > > > >> >> also, is there a place to understand all the available hooks and order >> they are called? Looking at the html, pretty and progress , I can see a lot >> of available hooks with some that requires to call an accept method... > > What do you mean by hooks? This? > http://github.com/aslakhellesoy/cucumber/wikis/hooks > > Sorry I should have been more clear about the hooks.. I meant the formatter > hooks. I see the main one used in the pretty_formatter and that are called > by the executor. But It seems in the html_formatter that you are even using > some other hook (likely those are called during the tree parsing ... just a > guess) but cannot see all the one that are available and when. I am actually > writing formatter to understand the order of calls. > > > #accept is part of the internal API to traverse the internal structure of > features. It's using the visitor pattern. Are you familiar with that? > > Yes I am and notice you use that pattern but I am not familiar with > treetop. But seems a bit complicated for a custom reporter to have to mess > with that. the HTML Report clearly will break without those calls at the > right place... > so a simple diagram would hel understanding how calls are made. Once I am > able to rrun that custom report, I can try to make one and send it to you to > add to the wiki > Thanks > Emmannuel > > Aslak > >> >> Any ideas? >> >> Thanks >> >> Emmanuel >> >> _______________________________________________ >> 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 Fri Dec 12 19:41:16 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 13 Dec 2008 01:41:16 +0100 Subject: [rspec-users] cucumber custom formatters In-Reply-To: <949447AB-70B9-4E53-9832-2F85017D3C76@gmail.com> References: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> <88709F25-5D0E-44A4-9950-A4FCFA9CAB76@gmail.com> <8d961d900812121606s44c18183kaef59b56d6e926b4@mail.gmail.com> <949447AB-70B9-4E53-9832-2F85017D3C76@gmail.com> Message-ID: <8d961d900812121641j6b4f0712pba81adccd5cb1d6c@mail.gmail.com> On Sat, Dec 13, 2008 at 1:22 AM, Emmanuel Pinault wrote: > > Is the explanation of --format not clear? Have you tried: > > cucumber -r my_formatter -f MyFormatter mytest.feature > > > Yes, I tried that too and it is not working still. I started to digg in the > cli.rb and clearly there is a registration process happening in the > build_formatter_broadcaster. > But somehow it is not finding my formatter .. trying to debug it more > > > > > >> also, is there a place to understand all the available hooks and order >> they are called? Looking at the html, pretty and progress , I can see a lot >> of available hooks with some that requires to call an accept method... >> > > What do you mean by hooks? This? > http://github.com/aslakhellesoy/cucumber/wikis/hooks > > > Sorry I should have been more clear about the hooks.. I meant the formatter > hooks. I see the main one used in the pretty_formatter and that are called > by the executor. But It seems in the html_formatter that you are even using > some other hook (likely those are called during the tree parsing ... just a > guess) but cannot see all the one that are available and when. I am actually > writing formatter to understand the order of calls. > > > > #accept is part of the internal API to traverse the internal structure of > features. It's using the visitor pattern. Are you familiar with that? > > Yes I am and notice you use that pattern but I am not familiar with > treetop. But seems a bit complicated for a custom reporter to have to mess > with that. the > You're right. And one of my first goals is to make it simpler. I started to investigate a new internal design for Cucumber today that will make several things easier - among them custom formatters. More info as I make progress. Aslak > HTML Report clearly will break without those calls at the right place... > so a simple diagram would hel understanding how calls are made. Once I am > able to rrun that custom report, I can try to make one and send it to you to > add to the wiki > > Thanks > > Emmannuel > > > Aslak > > >> >> Any ideas? >> >> Thanks >> >> Emmanuel >> >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Fri Dec 12 19:42:35 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 13 Dec 2008 01:42:35 +0100 Subject: [rspec-users] cucumber custom formatters In-Reply-To: References: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> <88709F25-5D0E-44A4-9950-A4FCFA9CAB76@gmail.com> <8d961d900812121606s44c18183kaef59b56d6e926b4@mail.gmail.com> <949447AB-70B9-4E53-9832-2F85017D3C76@gmail.com> Message-ID: <8d961d900812121642k154f21bft1184fefd67aaef5d@mail.gmail.com> On Sat, Dec 13, 2008 at 1:37 AM, Emmanuel Pinault wrote: > OK, I think I figured out the problem. > > I had the following > > module Cucumber > module Formatters > class MyFormatter > > > As soon I as removed it from that module, then it started to work. I > am not seeing different call and steps in the visitor printing ... > maybe a nice simple example of create a formatter would have helped > :) > Did you try -f Cucumber::Formatters::MyFormatter ? That should have worked. > > thanks > > Emmanuek > > On Fri, Dec 12, 2008 at 4:22 PM, Emmanuel Pinault > wrote: > > > > Is the explanation of --format not clear? Have you tried: > > > > cucumber -r my_formatter -f MyFormatter mytest.feature > > > > Yes, I tried that too and it is not working still. I started to digg in > the > > cli.rb and clearly there is a registration process happening in the > > build_formatter_broadcaster. > > But somehow it is not finding my formatter .. trying to debug it more > > > > > > > >> > >> also, is there a place to understand all the available hooks and order > >> they are called? Looking at the html, pretty and progress , I can see a > lot > >> of available hooks with some that requires to call an accept method... > > > > What do you mean by hooks? This? > > http://github.com/aslakhellesoy/cucumber/wikis/hooks > > > > Sorry I should have been more clear about the hooks.. I meant the > formatter > > hooks. I see the main one used in the pretty_formatter and that are > called > > by the executor. But It seems in the html_formatter that you are even > using > > some other hook (likely those are called during the tree parsing ... just > a > > guess) but cannot see all the one that are available and when. I am > actually > > writing formatter to understand the order of calls. > > > > > > #accept is part of the internal API to traverse the internal structure of > > features. It's using the visitor pattern. Are you familiar with that? > > > > Yes I am and notice you use that pattern but I am not familiar with > > treetop. But seems a bit complicated for a custom reporter to have to > mess > > with that. the HTML Report clearly will break without those calls at the > > right place... > > so a simple diagram would hel understanding how calls are made. Once I am > > able to rrun that custom report, I can try to make one and send it to you > to > > add to the wiki > > Thanks > > Emmannuel > > > > Aslak > > > >> > >> Any ideas? > >> > >> Thanks > >> > >> Emmanuel > >> > >> _______________________________________________ > >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From seatmanu at gmail.com Fri Dec 12 21:04:36 2008 From: seatmanu at gmail.com (Emmanuel Pinault) Date: Fri, 12 Dec 2008 18:04:36 -0800 Subject: [rspec-users] cucumber custom formatters In-Reply-To: <8d961d900812121642k154f21bft1184fefd67aaef5d@mail.gmail.com> References: <3e21ad60812121239i45cf1fb7ia6c82b21e67f9833@mail.gmail.com> <88709F25-5D0E-44A4-9950-A4FCFA9CAB76@gmail.com> <8d961d900812121606s44c18183kaef59b56d6e926b4@mail.gmail.com> <949447AB-70B9-4E53-9832-2F85017D3C76@gmail.com> <8d961d900812121642k154f21bft1184fefd67aaef5d@mail.gmail.com> Message-ID: <3665EE60-FF71-454A-A037-5F5D09888915@gmail.com> > > > Did you try -f Cucumber::Formatters::MyFormatter ? > That should have worked. > Yep works as well. Now that I have all the different possible hooks printed and ordering of events,. I can work on creating my template :) If you are interested I ll send you some of the improvments. I am using a combination of rspec and cucumber as both have good information style but could be improved slightly Emmanuel > > thanks > > Emmanuek > > On Fri, Dec 12, 2008 at 4:22 PM, Emmanuel Pinault > wrote: > > > > Is the explanation of --format not clear? Have you tried: > > > > cucumber -r my_formatter -f MyFormatter mytest.feature > > > > Yes, I tried that too and it is not working still. I started to > digg in the > > cli.rb and clearly there is a registration process happening in the > > build_formatter_broadcaster. > > But somehow it is not finding my formatter .. trying to debug it > more > > > > > > > >> > >> also, is there a place to understand all the available hooks and > order > >> they are called? Looking at the html, pretty and progress , I can > see a lot > >> of available hooks with some that requires to call an accept > method... > > > > What do you mean by hooks? This? > > http://github.com/aslakhellesoy/cucumber/wikis/hooks > > > > Sorry I should have been more clear about the hooks.. I meant the > formatter > > hooks. I see the main one used in the pretty_formatter and that > are called > > by the executor. But It seems in the html_formatter that you are > even using > > some other hook (likely those are called during the tree > parsing ... just a > > guess) but cannot see all the one that are available and when. I > am actually > > writing formatter to understand the order of calls. > > > > > > #accept is part of the internal API to traverse the internal > structure of > > features. It's using the visitor pattern. Are you familiar with > that? > > > > Yes I am and notice you use that pattern but I am not familiar with > > treetop. But seems a bit complicated for a custom reporter to have > to mess > > with that. the HTML Report clearly will break without those calls > at the > > right place... > > so a simple diagram would hel understanding how calls are made. > Once I am > > able to rrun that custom report, I can try to make one and send it > to you to > > add to the wiki > > Thanks > > Emmannuel > > > > Aslak > > > >> > >> Any ideas? > >> > >> Thanks > >> > >> Emmanuel > >> > >> _______________________________________________ > >> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Sat Dec 13 15:58:59 2008 From: stevemolitor at gmail.com (Steve Molitor) Date: Sat, 13 Dec 2008 14:58:59 -0600 Subject: [rspec-users] Reuse of Cucumber Features Message-ID: <3e21ad60812131258y795a2577o8efe569d30f9a757@mail.gmail.com> What's the best way to handle a requirement that shows up as a sub-requirement requirement in other features? For example let's say users can enter dates in various forms throughout my application. There is one set of global rules specifying the formats in which dates may be entered, and how they are interpreted. I put that in one feature. In various other features, like 'Create new patient', one can enter dates, like the patient's birth date. I want to do something like 'and the date entry shall follow the normal rules' but I'm not sure how to do that in an example driven way, without copying and pasting from other features. Does my question make sense? Any suggestions? Thanks. Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.mischa at gmail.com Sat Dec 13 21:21:00 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Sat, 13 Dec 2008 20:21:00 -0600 Subject: [rspec-users] testing rails mailers In-Reply-To: References: Message-ID: I found this useful: http://madhatted.com/2008/7/10/rspec-real-world-testing On Thu, Dec 11, 2008 at 7:42 AM, Ivor Paul wrote: > Hi Guys > > I am trying to spec some rails mailers. > > The only info I found was this post > http://kpumuk.info/ruby-on-rails/testing-mailers-with-rspec/ > by Dmytro Shteflyuk. > > I am hoping there is somewhat more on the topic - could someone point > me towards a resource where I can find more? > > Regards > Ivor > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivorpaul at gmail.com Sun Dec 14 08:39:32 2008 From: ivorpaul at gmail.com (Ivor Paul) Date: Sun, 14 Dec 2008 15:39:32 +0200 Subject: [rspec-users] testing rails mailers In-Reply-To: References: Message-ID: thanks a lot! This looks great. On Sun, Dec 14, 2008 at 4:21 AM, Mischa Fierer wrote: > I found this useful: > http://madhatted.com/2008/7/10/rspec-real-world-testing > > > On Thu, Dec 11, 2008 at 7:42 AM, Ivor Paul wrote: >> >> Hi Guys >> >> I am trying to spec some rails mailers. >> >> The only info I found was this post >> http://kpumuk.info/ruby-on-rails/testing-mailers-with-rspec/ >> by Dmytro Shteflyuk. >> >> I am hoping there is somewhat more on the topic - could someone point >> me towards a resource where I can find more? >> >> Regards >> Ivor >> _______________________________________________ >> 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 matt at mattwynne.net Sun Dec 14 09:41:57 2008 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 14 Dec 2008 14:41:57 +0000 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <3e21ad60812131258y795a2577o8efe569d30f9a757@mail.gmail.com> References: <3e21ad60812131258y795a2577o8efe569d30f9a757@mail.gmail.com> Message-ID: <4681BB0F-DB6F-4C6A-BB6F-B2BF5F3E3EDD@mattwynne.net> On 13 Dec 2008, at 20:58, Steve Molitor wrote: > What's the best way to handle a requirement that shows up as a sub- > requirement requirement in other features? For example let's say > users can enter dates in various forms throughout my application. > There is one set of global rules specifying the formats in which > dates may be entered, and how they are interpreted. I put that in > one feature. In various other features, like 'Create new patient', > one can enter dates, like the patient's birth date. I want to do > something like 'and the date entry shall follow the normal rules' > but I'm not sure how to do that in an example driven way, without > copying and pasting from other features. > > Does my question make sense? Any suggestions? Do you know that you can call steps within steps? http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ Is that what you're looking for? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From stevemolitor at gmail.com Sun Dec 14 12:15:54 2008 From: stevemolitor at gmail.com (Steve Molitor) Date: Sun, 14 Dec 2008 11:15:54 -0600 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <4681BB0F-DB6F-4C6A-BB6F-B2BF5F3E3EDD@mattwynne.net> References: <3e21ad60812131258y795a2577o8efe569d30f9a757@mail.gmail.com> <4681BB0F-DB6F-4C6A-BB6F-B2BF5F3E3EDD@mattwynne.net> Message-ID: <3e21ad60812140915g3329e15bl92fbe1706aa1b3c7@mail.gmail.com> Thanks -- that gets me closer. Here's an example. Let's say I have two features, 'Create new patient' and 'Create new incident'. To create a new patient you have to enter a valid birth date. To create a new patient you must enter a valid birth date. To create a new incident you must enter a valid incident date. The rules for date entry are the same: Feature: Date entry Scenario: Invalid month When I fill in the date value with "13/01/2000" I should see "Invalid date..." Scenario: Invalid year (not 4 digits) When I fill in the date value with "13/01/00" I should see "Invalid date..." Scenario: Separate with slashes (ok) When I fill in the date value with "01/13/2000" I should see "valid date..." Scenario: Separate with dashes (ok) When I fill in the date value with "01-13-2000" I should see "valid date..." .... etc.... Given the above, how should I write the 'create new patient' and 'create new incident' features? I don't want to copy and paste all the date related scenarios, but I do want to specify (and test) that the patient birth date and incident date fields conform to the general date rules. Here's how the 'create new patient' and 'create new incident' features would look with some copy and pasting: Feature: Create new Patient Scenario: Enter invalid birth date Given I fill in "birth date" with "13/01/2000" And I fill in "patient name" with "Sam Smith" When I press "Save" I should see "Invalid birth date '13/01/2000'" Scenario: Enter valid birth date, valid name Given I fill in "birth date" with "01/13/2000" And I fill in "patient name" with "Sam Smith" When I press "Save" I should see "Patient Created Successfully" Scenario: Enter valid birth date with dashses..... ------- Feature: Create new Incident Scenario: Enter invalid incident date Given I fill in "incident" with "13/01/2000" And I fill in "supervisor" with "Sam Smith" When I press "Save" I should see "Invalid incident date '13/01/2000'" Scenario: Enter valid incident date, valid supervisor Given I fill in "incident date" with "01/13/2000" And I fill in "supervisor" with "Sam Smith" When I press "Save" I should see "Incident Created Successfully" Scenario: Enter valid incident date with dashes.... ----- Am I making sense? I want to specify the date in the features, as there may be extra requirements like birth dates can not be in the future in addition to the generic date requirements. And I want to validate that the form checks for valid dates, displays the appropriate error message when invalid, and uses the common rules for parsing. But I don't want to copy and paste those scenarios in every feature. I think reusing steps as you mention is probably the solution but I'm stuck on how to word it and put it together in my case. Steve On Sun, Dec 14, 2008 at 8:41 AM, Matt Wynne wrote: > > On 13 Dec 2008, at 20:58, Steve Molitor wrote: > > What's the best way to handle a requirement that shows up as a >> sub-requirement requirement in other features? For example let's say users >> can enter dates in various forms throughout my application. There is one >> set of global rules specifying the formats in which dates may be entered, >> and how they are interpreted. I put that in one feature. In various other >> features, like 'Create new patient', one can enter dates, like the patient's >> birth date. I want to do something like 'and the date entry shall follow >> the normal rules' but I'm not sure how to do that in an example driven way, >> without copying and pasting from other features. >> >> Does my question make sense? Any suggestions? >> > > Do you know that you can call steps within steps? > http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ > > Is that what you're looking for? > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Sun Dec 14 12:24:55 2008 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 14 Dec 2008 17:24:55 +0000 Subject: [rspec-users] Cucumber fat client In-Reply-To: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> Message-ID: On 9 Dec 2008, at 09:43, aslak hellesoy wrote: > Hi folks, > > Cucumber has become popular a lot quicker than I had anticipated. > Still, with its plain text nature it is still limited to programmers > (in most teams). > > I want to close the gap between customers/product owners/business > analysts and programmers, > and I'm convinced that a fat client is needed to achieve this. > Something that lets people > browse, edit and run features inside a friendly user interface. > > So I'm asking you - what would this user interface be like? How do > people want to access it > and use it? We have a person filling the 'Product Owner' role who is completely non-technical. I think it would be nice if there was a way for her to be able to do this: * fire up the client * choose 'open project' * enter the URL to the git repo where the project lives * then see a nice overview of all the features * be able to print off features for taking to meetings, reading on the train etc, nicely formatted * be able to edit features and easily push the changes back to the git repo To me, this is more important than being able to run them. I don't think non-techie users need to be able to run features as they won't be able to do anything about it when they inevitably fail. I also hate the idea of having to set up Ruby, gems etc on a non-techie person's computer. It's better, IMO, if the tool makes it easy for them to push their changes into a git repo where they can either be swept into the main dev fork / branch, or automatically run using CI, et etc. So that's where I think the focus of such a tool should be - browsing, reviewing and editing features rather than executing them, and with some SCM integration to make all that easier for non-techies. I do think that eventually the ability to run features will become important too, but I would like to see this side of the problem solved first. Obviously there's a dependency on git in what I'm suggesting, but I'm sure it would be easy enough to plug in other SCMs if that was popular enough. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From pergesu at gmail.com Sun Dec 14 13:41:54 2008 From: pergesu at gmail.com (Pat Maddox) Date: Sun, 14 Dec 2008 10:41:54 -0800 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: <3e21ad60812140915g3329e15bl92fbe1706aa1b3c7@mail.gmail.com> (Steve Molitor's message of "Sun\, 14 Dec 2008 11\:15\:54 -0600") References: <3e21ad60812131258y795a2577o8efe569d30f9a757@mail.gmail.com> <4681BB0F-DB6F-4C6A-BB6F-B2BF5F3E3EDD@mattwynne.net> <3e21ad60812140915g3329e15bl92fbe1706aa1b3c7@mail.gmail.com> Message-ID: Hi Steve, I likely would only write two scenarios, one for a valid date and one for an invalid one. Then I would write object-level specs to determine what a valid date is. Extract this to a validator that you can reuse throughout your model. If it's important that you write features for each potential invalid date format (because you want to communicate them with the customer) then I would write a feature file similar to what you show...but it would be focused only on the date, I wouldn't mention patients or incidents at all. Date entry seems to be an important concept in your application, so I would write one feature that specifies how I expect date entry to work, and then I can just write valid/invalid dates for patient and incident features. Same idea as the first paragraph, but using features instead of specs. Pat "Steve Molitor" writes: > Thanks -- that gets me closer. Here's an example. Let's say I have two features, 'Create new patient' and 'Create new incident'. To > create a new patient you have to enter a valid birth date. To create a new patient you must enter a valid birth date. To create a new > incident you must enter a valid incident date. The rules for date entry are the same: > > Feature: Date entry > > Scenario: Invalid month > When I fill in the date value with "13/01/2000" > I should see "Invalid date..." > > Scenario: Invalid year (not 4 digits) > When I fill in the date value with "13/01/00" > I should see "Invalid date..." > > Scenario: Separate with slashes (ok) > When I fill in the date value with "01/13/2000" > I should see "valid date..." > > Scenario: Separate with dashes (ok) > When I fill in the date value with "01-13-2000" > I should see "valid date..." > > .... etc.... > > Given the above, how should I write the 'create new patient' and 'create new incident' features? I don't want to copy and paste all the > date related scenarios, but I do want to specify (and test) that the patient birth date and incident date fields conform to the general date > rules. Here's how the 'create new patient' and 'create new incident' features would look with some copy and pasting: > > Feature: Create new Patient > > Scenario: Enter invalid birth date > Given I fill in "birth date" with "13/01/2000" > And I fill in "patient name" with "Sam Smith" > When I press "Save" > I should see "Invalid birth date '13/01/2000'" > > Scenario: Enter valid birth date, valid name > Given I fill in "birth date" with "01/13/2000" > And I fill in "patient name" with "Sam Smith" > When I press "Save" > I should see "Patient Created Successfully" > > Scenario: Enter valid birth date with dashses..... > ------- > > Feature: Create new Incident > > Scenario: Enter invalid incident date > Given I fill in "incident" with "13/01/2000" > And I fill in "supervisor" with "Sam Smith" > When I press "Save" > I should see "Invalid incident date '13/01/2000'" > > Scenario: Enter valid incident date, valid supervisor > Given I fill in "incident date" with "01/13/2000" > And I fill in "supervisor" with "Sam Smith" > When I press "Save" > I should see "Incident Created Successfully" > > Scenario: Enter valid incident date with dashes.... > ----- > > Am I making sense? I want to specify the date in the features, as there may be extra requirements like birth dates can not be in the future > in addition to the generic date requirements. And I want to validate that the form checks for valid dates, displays the appropriate error > message when invalid, and uses the common rules for parsing. But I don't want to copy and paste those scenarios in every feature. I think > reusing steps as you mention is probably the solution but I'm stuck on how to word it and put it together in my case. > > Steve > > On Sun, Dec 14, 2008 at 8:41 AM, Matt Wynne wrote: > > On 13 Dec 2008, at 20:58, Steve Molitor wrote: > > What's the best way to handle a requirement that shows up as a sub-requirement requirement in other features? For example let's say > users can enter dates in various forms throughout my application. There is one set of global rules specifying the formats in which > dates may be entered, and how they are interpreted. I put that in one feature. In various other features, like 'Create new > patient', one can enter dates, like the patient's birth date. I want to do something like 'and the date entry shall follow the > normal rules' but I'm not sure how to do that in an example driven way, without copying and pasting from other features. > > Does my question make sense? Any suggestions? > > Do you know that you can call steps within steps? > http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ > > Is that what you're looking for? > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > 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 mike.gaffney at asolutions.com Sun Dec 14 13:49:54 2008 From: mike.gaffney at asolutions.com (mike.gaffney) Date: Sun, 14 Dec 2008 12:49:54 -0600 Subject: [rspec-users] Cucumber fat client In-Reply-To: References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> Message-ID: <49455552.9070509@asolutions.com> Why not make a web client that manipulates git based projects in the background? I've been messing around with Grit and doing things like this lately for http://rdocul.us a site I run and it is very easy to do. If everything is in a standard location you could just add a project via an administrative page and it would be cloned in the background, then they could: browse all specs (just a filesystem listing) edit and save specs (git add, commit, push) look at a history on a given spec (log) look at the history of all changes to the specs (log on a path) merge changes / conflicts the only thing that would be hard at all would be the conflict resolution from if/when a normal git user update a spec. -Mike Matt Wynne wrote: > > On 9 Dec 2008, at 09:43, aslak hellesoy wrote: > >> Hi folks, >> >> Cucumber has become popular a lot quicker than I had anticipated. >> Still, with its plain text nature it is still limited to programmers >> (in most teams). >> >> I want to close the gap between customers/product owners/business >> analysts and programmers, >> and I'm convinced that a fat client is needed to achieve this. >> Something that lets people >> browse, edit and run features inside a friendly user interface. >> >> So I'm asking you - what would this user interface be like? How do >> people want to access it >> and use it? > > We have a person filling the 'Product Owner' role who is completely > non-technical. > > I think it would be nice if there was a way for her to be able to do this: > * fire up the client > * choose 'open project' > * enter the URL to the git repo where the project lives > * then see a nice overview of all the features > * be able to print off features for taking to meetings, reading on > the train etc, nicely formatted > * be able to edit features and easily push the changes back to the > git repo > > To me, this is more important than being able to run them. I don't think > non-techie users need to be able to run features as they won't be able > to do anything about it when they inevitably fail. I also hate the idea > of having to set up Ruby, gems etc on a non-techie person's computer. > It's better, IMO, if the tool makes it easy for them to push their > changes into a git repo where they can either be swept into the main dev > fork / branch, or automatically run using CI, et etc. > > So that's where I think the focus of such a tool should be - browsing, > reviewing and editing features rather than executing them, and with some > SCM integration to make all that easier for non-techies. I do think that > eventually the ability to run features will become important too, but I > would like to see this side of the problem solved first. > > Obviously there's a dependency on git in what I'm suggesting, but I'm > sure it would be easy enough to plug in other SCMs if that was popular > enough. > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From drnic at mocra.com Sun Dec 14 21:44:45 2008 From: drnic at mocra.com (Dr Nic) Date: Sun, 14 Dec 2008 18:44:45 -0800 (PST) Subject: [rspec-users] Cucumber: Fix for Textmate syntax highlighting In-Reply-To: <790E5AA0-356D-4FD1-96B6-52A0FE08AA9E@patchspace.co.uk> References: <0F61A7F9-3FCE-4209-B2AA-DC48B370A4F5@mattwynne.net> <790E5AA0-356D-4FD1-96B6-52A0FE08AA9E@patchspace.co.uk> Message-ID: <30b87082-413b-4931-829d-f97ef949f4b7@v39g2000pro.googlegroups.com> I've added Given/When/Then as valid methods to take regexp as an argument to my Ruby.tmbundle, if its helpful (via bjeanes) http://github.com/drnic/ruby-tmbundle Commit: http://github.com/drnic/ruby-tmbundle/commit/2cff40d43dd65aad3d8cd050654823db6d7517cb Cheers Nic On Nov 15, 2:13?am, Ashley Moran wrote: > On Nov 14, 2008, at 3:25 pm, Matt Wynne wrote: > > > It's ?been bugging me for a while that a lot of the regular ? > > expressions in my step matchers look ugly inTextMatebecause it ? > > doesn't recognise them. > > > I patched the Ruby tmbundle with a fix. If this bugs you too, you ? > > can pull down my Ruby.tmbundle from here: > >http://github.com/mattwynne/textmate-bundles/tree/master > > > Or has somebody already solved this problem some other way? > > I've always stuck %r in front of the regex: > > ? ?Given %r/blah/ > > But I'd prefer a better fix! > > Ashley > > --http://www.patchspace.co.uk/http://aviewfromafar.net/ > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From aidy.lewis at googlemail.com Mon Dec 15 06:30:27 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Mon, 15 Dec 2008 11:30:27 +0000 Subject: [rspec-users] Where to put Cucumber Utilities? Message-ID: <7ac2300c0812150330h25c0e291w3d37470e6c3cf05b@mail.gmail.com> Hi, I use Watir\Firewatir with Cucumber. I previously used a framework that object modelled the A-U-T; so each HTML page would be a class and each object a method: this improved readability. We came to the conclusion that this was over-engineering, slow and boring; so I annihilated the object model. However, there are utilities I still need for all sites e.g. class DownloadedInternetFiles def delete require 'fileutils' cache = "C:\\Documents and Settings\\#{ENV['USERNAME']}\\Local Settings\\Temporary Internet Files" cookies = "C:\\Documents and Settings\\#{ENV['USERNAME']}\\Cookies" FileUtils.rm_rf cache FileUtils.rm_rf cookies end end Not sure where to put things like this. There are Helpers, but this seems a little procedural to me. Any thoughts? Aidy From aslak.hellesoy at gmail.com Mon Dec 15 06:36:04 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 15 Dec 2008 12:36:04 +0100 Subject: [rspec-users] Where to put Cucumber Utilities? In-Reply-To: <7ac2300c0812150330h25c0e291w3d37470e6c3cf05b@mail.gmail.com> References: <7ac2300c0812150330h25c0e291w3d37470e6c3cf05b@mail.gmail.com> Message-ID: <8d961d900812150336w12cedbd6kf7a8a14f782bc88@mail.gmail.com> On Mon, Dec 15, 2008 at 12:30 PM, aidy lewis wrote: > Hi, > > I use Watir\Firewatir with Cucumber. I previously used a framework > that object modelled the A-U-T; so each HTML page would be a class and > each object a method: this improved readability. > > We came to the conclusion that this was over-engineering, slow and > boring; so I annihilated the object model. > > However, there are utilities I still need for all sites e.g. > > class DownloadedInternetFiles > def delete > require 'fileutils' > cache = "C:\\Documents and Settings\\#{ENV['USERNAME']}\\Local > Settings\\Temporary Internet Files" > cookies = "C:\\Documents and Settings\\#{ENV['USERNAME']}\\Cookies" > FileUtils.rm_rf cache > FileUtils.rm_rf cookies > end > end > > Not sure where to put things like this. There are Helpers, but this > seems a little procedural to me. > > Any thoughts? > You can put them in any directory that holds Ruby files that Cucumber loads. For example features/support Aslak > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zuperinfinite at gmail.com Mon Dec 15 07:53:44 2008 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Mon, 15 Dec 2008 13:53:44 +0100 Subject: [rspec-users] Cucumber fat client In-Reply-To: <49455552.9070509@asolutions.com> References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <49455552.9070509@asolutions.com> Message-ID: On 14-dec-2008, at 19:49, mike.gaffney wrote: > Why not make a web client that manipulates git based projects in > the background? I've been messing around with Grit and doing things > like this lately for http://rdocul.us a site I run and it is very > easy to do. If everything is in a standard location you could just > add a project via an administrative page and it would be cloned in > the background, then they could: > > browse all specs (just a filesystem listing) > edit and save specs (git add, commit, push) > look at a history on a given spec (log) > look at the history of all changes to the specs (log on a path) > merge changes / conflicts Correct me if I'm wrong (and I probably missed something), but why do you and some others in this thread want users to actually edit a feature? That's going to wreck havoc with steps that won't match anymore, breaking features, and therefore making the client angry. WDYT? bartz > Matt Wynne wrote: >> On 9 Dec 2008, at 09:43, aslak hellesoy wrote: >>> Hi folks, >>> >>> Cucumber has become popular a lot quicker than I had anticipated. >>> Still, with its plain text nature it is still limited to >>> programmers (in most teams). >>> >>> I want to close the gap between customers/product owners/business >>> analysts and programmers, >>> and I'm convinced that a fat client is needed to achieve this. >>> Something that lets people >>> browse, edit and run features inside a friendly user interface. >>> >>> So I'm asking you - what would this user interface be like? How >>> do people want to access it >>> and use it? >> We have a person filling the 'Product Owner' role who is >> completely non-technical. >> I think it would be nice if there was a way for her to be able to >> do this: >> * fire up the client >> * choose 'open project' >> * enter the URL to the git repo where the project lives >> * then see a nice overview of all the features >> * be able to print off features for taking to meetings, >> reading on the train etc, nicely formatted >> * be able to edit features and easily push the changes back to >> the git repo >> To me, this is more important than being able to run them. I don't >> think non-techie users need to be able to run features as they >> won't be able to do anything about it when they inevitably fail. I >> also hate the idea of having to set up Ruby, gems etc on a non- >> techie person's computer. It's better, IMO, if the tool makes it >> easy for them to push their changes into a git repo where they can >> either be swept into the main dev fork / branch, or automatically >> run using CI, et etc. >> So that's where I think the focus of such a tool should be - >> browsing, reviewing and editing features rather than executing >> them, and with some SCM integration to make all that easier for >> non-techies. I do think that eventually the ability to run >> features will become important too, but I would like to see this >> side of the problem solved first. >> Obviously there's a dependency on git in what I'm suggesting, but >> I'm sure it would be easy enough to plug in other SCMs if that was >> popular enough. >> Matt Wynne >> http://blog.mattwynne.net >> http://www.songkick.com >> _______________________________________________ >> 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 matt at mattwynne.net Tue Dec 16 03:42:17 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 16 Dec 2008 08:42:17 +0000 Subject: [rspec-users] Cucumber fat client In-Reply-To: References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <49455552.9070509@asolutions.com> Message-ID: On 15 Dec 2008, at 12:53, Bart Zonneveld wrote: > > On 14-dec-2008, at 19:49, mike.gaffney wrote: > >> Why not make a web client that manipulates git based projects in >> the background? I've been messing around with Grit and doing things >> like this lately for http://rdocul.us a site I run and it is very >> easy to do. If everything is in a standard location you could just >> add a project via an administrative page and it would be cloned in >> the background, then they could: >> >> browse all specs (just a filesystem listing) >> edit and save specs (git add, commit, push) >> look at a history on a given spec (log) >> look at the history of all changes to the specs (log on a path) >> merge changes / conflicts > > Correct me if I'm wrong (and I probably missed something), but why > do you and some others in this thread want users to actually edit a > feature? > That's going to wreck havoc with steps that won't match anymore, > breaking features, and therefore making the client angry. > > WDYT? > bartz What else would they want to do though that would add much value? My thinking now is that I would perhaps have the customers working on a different branch of the code, which was still built in CI but failed with a 'softer' noise, to indicate that there was new work to do. We'd expect the build for this branch would be 'broken' most of the time. As developers, we could then pull in the commits from this branch (almost like a todo list) and get to work on the new or changed features. Is that making any sense? Matt Wynne http://blog.mattwynne.net http://www.songkick.com From apremdas at gmail.com Tue Dec 16 05:54:08 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Tue, 16 Dec 2008 10:54:08 +0000 Subject: [rspec-users] Reuse of Cucumber Features In-Reply-To: References: <3e21ad60812131258y795a2577o8efe569d30f9a757@mail.gmail.com> <4681BB0F-DB6F-4C6A-BB6F-B2BF5F3E3EDD@mattwynne.net> <3e21ad60812140915g3329e15bl92fbe1706aa1b3c7@mail.gmail.com> Message-ID: <88fd8ddc0812160254p7c076e49p5938e8f5d3b3993d@mail.gmail.com> +lots :) Generally when we have problems with features its because we are trying to do to much at once. So in your case date entry is being complicated by different contexts, birth and incident. One of the tennents of BDD is to write the simplest thing you can to make you feature pass. I think another one should be "first of all write the simplest scenarios". So taking one of your examples Scenario: Enter Valid Incident When I fill incident correctly I should recieve a confirmation Then your incident step can be something like When /^I fill incident correctly$/ do fill_in("incident[name]", :with => ... ... end If you wanted to specify validation in features you could do a step like When /^I fill incident correctly except$/ do |field| When "I fill in incident correctly" fill_in("incident[#{field}]", :with => '' end now you can create new features like Scenario: Enter Valid Incident with no date When I fill incident correctly except date I should recieve an error With a bit more trickery you could have When I fill incident correctly except date which is xxx Taking this approach you can build incrementally quite complex validation features whilst stll keeping each scenario simple and focused on one thing. Whether you should do this with features or put this detail somewhere else is another question entirely. On another point with dates have you considered international issues. All the dates you've given in your example are valid (technically) there just not in the format you prefer. Also consider that the invalidity of dates might be context dependant e.g. an incident date in the future, an appointment in the past. HTH Andrew 2008/12/14 Pat Maddox > Hi Steve, > > I likely would only write two scenarios, one for a valid date and one > for an invalid one. Then I would write object-level specs to determine > what a valid date is. Extract this to a validator that you can reuse > throughout your model. > > If it's important that you write features for each potential invalid > date format (because you want to communicate them with the customer) > then I would write a feature file similar to what you show...but it > would be focused only on the date, I wouldn't mention patients or > incidents at all. Date entry seems to be an important concept in your > application, so I would write one feature that specifies how I expect > date entry to work, and then I can just write valid/invalid dates for > patient and incident features. Same idea as the first paragraph, but > using features instead of specs. > > Pat > > > "Steve Molitor" writes: > > > Thanks -- that gets me closer. Here's an example. Let's say I have two > features, 'Create new patient' and 'Create new incident'. To > > create a new patient you have to enter a valid birth date. To create a > new patient you must enter a valid birth date. To create a new > > incident you must enter a valid incident date. The rules for date entry > are the same: > > > > Feature: Date entry > > > > Scenario: Invalid month > > When I fill in the date value with "13/01/2000" > > I should see "Invalid date..." > > > > Scenario: Invalid year (not 4 digits) > > When I fill in the date value with "13/01/00" > > I should see "Invalid date..." > > > > Scenario: Separate with slashes (ok) > > When I fill in the date value with "01/13/2000" > > I should see "valid date..." > > > > Scenario: Separate with dashes (ok) > > When I fill in the date value with "01-13-2000" > > I should see "valid date..." > > > > .... etc.... > > > > Given the above, how should I write the 'create new patient' and 'create > new incident' features? I don't want to copy and paste all the > > date related scenarios, but I do want to specify (and test) that the > patient birth date and incident date fields conform to the general date > > rules. Here's how the 'create new patient' and 'create new incident' > features would look with some copy and pasting: > > > > Feature: Create new Patient > > > > Scenario: Enter invalid birth date > > Given I fill in "birth date" with "13/01/2000" > > And I fill in "patient name" with "Sam Smith" > > When I press "Save" > > I should see "Invalid birth date '13/01/2000'" > > > > Scenario: Enter valid birth date, valid name > > Given I fill in "birth date" with "01/13/2000" > > And I fill in "patient name" with "Sam Smith" > > When I press "Save" > > I should see "Patient Created Successfully" > > > > Scenario: Enter valid birth date with dashses..... > > ------- > > > > Feature: Create new Incident > > > > Scenario: Enter invalid incident date > > Given I fill in "incident" with "13/01/2000" > > And I fill in "supervisor" with "Sam Smith" > > When I press "Save" > > I should see "Invalid incident date '13/01/2000'" > > > > Scenario: Enter valid incident date, valid supervisor > > Given I fill in "incident date" with "01/13/2000" > > And I fill in "supervisor" with "Sam Smith" > > When I press "Save" > > I should see "Incident Created Successfully" > > > > Scenario: Enter valid incident date with dashes.... > > ----- > > > > Am I making sense? I want to specify the date in the features, as there > may be extra requirements like birth dates can not be in the future > > in addition to the generic date requirements. And I want to validate > that the form checks for valid dates, displays the appropriate error > > message when invalid, and uses the common rules for parsing. But I don't > want to copy and paste those scenarios in every feature. I think > > reusing steps as you mention is probably the solution but I'm stuck on > how to word it and put it together in my case. > > > > Steve > > > > On Sun, Dec 14, 2008 at 8:41 AM, Matt Wynne wrote: > > > > On 13 Dec 2008, at 20:58, Steve Molitor wrote: > > > > What's the best way to handle a requirement that shows up as a > sub-requirement requirement in other features? For example let's say > > users can enter dates in various forms throughout my application. > There is one set of global rules specifying the formats in which > > dates may be entered, and how they are interpreted. I put that > in one feature. In various other features, like 'Create new > > patient', one can enter dates, like the patient's birth date. I > want to do something like 'and the date entry shall follow the > > normal rules' but I'm not sure how to do that in an example > driven way, without copying and pasting from other features. > > > > Does my question make sense? Any suggestions? > > > > Do you know that you can call steps within steps? > > http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/ > > > > Is that what you're looking for? > > > > Matt Wynne > > http://blog.mattwynne.net > > http://www.songkick.com > > > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zuperinfinite at gmail.com Tue Dec 16 05:59:09 2008 From: zuperinfinite at gmail.com (Bart Zonneveld) Date: Tue, 16 Dec 2008 11:59:09 +0100 Subject: [rspec-users] Cucumber fat client In-Reply-To: References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <49455552.9070509@asolutions.com> Message-ID: <65E538FB-6CDA-4D17-9A42-017C878300DE@gmail.com> On 16-dec-2008, at 9:42, Matt Wynne wrote: > > On 15 Dec 2008, at 12:53, Bart Zonneveld wrote: > >> >> On 14-dec-2008, at 19:49, mike.gaffney wrote: >> >>> Why not make a web client that manipulates git based projects in >>> the background? I've been messing around with Grit and doing >>> things like this lately for http://rdocul.us a site I run and it >>> is very easy to do. If everything is in a standard location you >>> could just add a project via an administrative page and it would >>> be cloned in the background, then they could: >>> >>> browse all specs (just a filesystem listing) >>> edit and save specs (git add, commit, push) >>> look at a history on a given spec (log) >>> look at the history of all changes to the specs (log on a path) >>> merge changes / conflicts >> >> Correct me if I'm wrong (and I probably missed something), but why >> do you and some others in this thread want users to actually edit >> a feature? >> That's going to wreck havoc with steps that won't match anymore, >> breaking features, and therefore making the client angry. >> >> WDYT? >> bartz > > What else would they want to do though that would add much value? > > My thinking now is that I would perhaps have the customers working > on a different branch of the code, which was still built in CI but > failed with a 'softer' noise, to indicate that there was new work > to do. We'd expect the build for this branch would be 'broken' most > of the time. That's what I missed, I guess :). rake features --as-blissfully-ignorant-client anyone? > As developers, we could then pull in the commits from this branch > (almost like a todo list) and get to work on the new or changed > features. > > Is that making any sense? Yep! thanks, bartz From f.mischa at gmail.com Tue Dec 16 06:08:40 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Tue, 16 Dec 2008 03:08:40 -0800 Subject: [rspec-users] Cucumber fat client In-Reply-To: References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <49455552.9070509@asolutions.com> Message-ID: I can maybe offer something here. *begin rambling* My team of 4 (2 coders, 2 biz people) has recently switched to using Pivotal Tracker, and we've been doing the following: 1) Figure out what we can do that will add value 2) Draw out the ui / changes on a whiteboard 3) Write out features & copy them into pivotal (as stories) 4) Implement This solves the following problems: Coders have trouble communicating how long things will take to MBAs (clients). Putting them in pivotal allows us to be clear about how long things will take, and that adding things will add time. Reduces miscommunications between clients and coders, because it forces clients to be clear about what they want / gives coders ability to show why some things are not worth the time. What is still lacking: While we've been getting better at this, what's lacking is a client ability to understand how features can/should be written. I've been just allowing them to write them however they want, with a few pointers, as for a lot of steps it requires a bit too much understanding about how Rails works. For example, explaining to a long-term client the difference between "press" and "follow" is fine, but I can imagine feeling a bit silly trying to explain it to a new client whom I am making a proposal to. So, the solution to this may be to work together (on this list) to come up with better ways of writing features. (E.g. I've stopped using "And I should be at xyz" and "And there should be a xyz form" and a few other similar things except in cases where they're necessary, as clients would not themselves include these kind of steps for the most part) So, in terms of an interface: I like the idea of changes coming in via something like git, where I would be able to see the differences. However this is not particularly different from updaing a feature on Pivotal, Trac or Lighhouse. I think a more interesting idea for an interface would be something that helps clients write features, like, some sort of drag and drop thing where they could start as a certain type of user, then drag in whens, then type in thens, or something. Probably not specific enough to be usefull, but maybe this will spark an idea for someone else. In the distant future I can imagine some sort of speccing web app that would allow clients to build features by clicking and typing, and then rearrange / sort them plus visualize how they link together. So, for example, there might be: UserTypes - role:string Actions - what:string Results - what_happens:string As a client I would be able to create a bunch of these, then arrange them and then print them out for my coders. M On Tue, Dec 16, 2008 at 12:42 AM, Matt Wynne wrote: > > On 15 Dec 2008, at 12:53, Bart Zonneveld wrote: > > >> On 14-dec-2008, at 19:49, mike.gaffney wrote: >> >> Why not make a web client that manipulates git based projects in the >>> background? I've been messing around with Grit and doing things like this >>> lately for http://rdocul.us a site I run and it is very easy to do. If >>> everything is in a standard location you could just add a project via an >>> administrative page and it would be cloned in the background, then they >>> could: >>> >>> browse all specs (just a filesystem listing) >>> edit and save specs (git add, commit, push) >>> look at a history on a given spec (log) >>> look at the history of all changes to the specs (log on a path) >>> merge changes / conflicts >>> >> >> Correct me if I'm wrong (and I probably missed something), but why do you >> and some others in this thread want users to actually edit a feature? >> That's going to wreck havoc with steps that won't match anymore, breaking >> features, and therefore making the client angry. >> >> WDYT? >> bartz >> > > What else would they want to do though that would add much value? > > My thinking now is that I would perhaps have the customers working on a > different branch of the code, which was still built in CI but failed with a > 'softer' noise, to indicate that there was new work to do. We'd expect the > build for this branch would be 'broken' most of the time. > > As developers, we could then pull in the commits from this branch (almost > like a todo list) and get to work on the new or changed features. > > Is that making any sense? > > > Matt Wynne > http://blog.mattwynne.net > http://www.songkick.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.mischa at gmail.com Tue Dec 16 06:17:28 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Tue, 16 Dec 2008 03:17:28 -0800 Subject: [rspec-users] Cucumber fat client In-Reply-To: References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <49455552.9070509@asolutions.com> Message-ID: A few other things... In the interface that I was describing, it would solve several problems to have something like: Given I'm a client When I follow "new story" And I drag in "Given I am a Pet Owner" And I press "new action" And I select "When I follow" And I fill in "follows_what_link" with "Buy another dog" And I press "new result" And I select "Then i should see" And I fill in "see_what" with "Say hello to your new dog" And I press "Save feature" Then I should see "Your feature has been saved!" When I select "mischa -- developer" When I press "Send feature" Then I should see "feature sent to mischa" Obviously a bit hacky of a feature, but does everyone see what I'm getting at? M On Tue, Dec 16, 2008 at 3:08 AM, Mischa Fierer wrote: > I can maybe offer something here. *begin rambling* > > My team of 4 (2 coders, 2 biz people) has recently switched to using > Pivotal Tracker, and we've been doing the following: > > 1) Figure out what we can do that will add value > 2) Draw out the ui / changes on a whiteboard > 3) Write out features & copy them into pivotal (as stories) > 4) Implement > > This solves the following problems: > > Coders have trouble communicating how long things will take to MBAs > (clients). Putting them in pivotal allows us to be clear about how long > things will take, and that adding things will add time. > > Reduces miscommunications between clients and coders, because it forces > clients to be clear about what they want / gives coders ability to show why > some things are not worth the time. > > What is still lacking: > > While we've been getting better at this, what's lacking is a client ability > to understand how features can/should be written. > I've been just allowing them to write them however they want, with a few > pointers, as for a lot of steps it requires a bit too much understanding > about how Rails works. For example, explaining to a long-term client the > difference between "press" and "follow" is fine, but I can imagine feeling a > bit silly trying to explain it to a new client whom I am making a proposal > to. > > So, the solution to this may be to work together (on this list) to come up > with better ways of writing features. (E.g. I've stopped using "And I should > be at xyz" and "And there should be a xyz form" and a few other similar > things except in cases where they're necessary, as clients would not > themselves include these kind of steps for the most part) > > So, in terms of an interface: > > I like the idea of changes coming in via something like git, where I would > be able to see the differences. However this is not particularly different > from updaing a feature on Pivotal, Trac or Lighhouse. > > I think a more interesting idea for an interface would be something that > helps clients write features, like, some sort of drag and drop thing where > they could start as a certain type of user, then drag in whens, then type in > thens, or something. Probably not specific enough to be usefull, but maybe > this will spark an idea for someone else. > > In the distant future I can imagine some sort of speccing web app that > would allow clients to build features by clicking and typing, and then > rearrange / sort them plus visualize how they link together. > > So, for example, there might be: > > UserTypes - role:string > > Actions - what:string > > Results - what_happens:string > > As a client I would be able to create a bunch of these, then arrange them > and then print them out for my coders. > > M > > > > > On Tue, Dec 16, 2008 at 12:42 AM, Matt Wynne wrote: > >> >> On 15 Dec 2008, at 12:53, Bart Zonneveld wrote: >> >> >>> On 14-dec-2008, at 19:49, mike.gaffney wrote: >>> >>> Why not make a web client that manipulates git based projects in the >>>> background? I've been messing around with Grit and doing things like this >>>> lately for http://rdocul.us a site I run and it is very easy to do. If >>>> everything is in a standard location you could just add a project via an >>>> administrative page and it would be cloned in the background, then they >>>> could: >>>> >>>> browse all specs (just a filesystem listing) >>>> edit and save specs (git add, commit, push) >>>> look at a history on a given spec (log) >>>> look at the history of all changes to the specs (log on a path) >>>> merge changes / conflicts >>>> >>> >>> Correct me if I'm wrong (and I probably missed something), but why do you >>> and some others in this thread want users to actually edit a feature? >>> That's going to wreck havoc with steps that won't match anymore, breaking >>> features, and therefore making the client angry. >>> >>> WDYT? >>> bartz >>> >> >> What else would they want to do though that would add much value? >> >> My thinking now is that I would perhaps have the customers working on a >> different branch of the code, which was still built in CI but failed with a >> 'softer' noise, to indicate that there was new work to do. We'd expect the >> build for this branch would be 'broken' most of the time. >> >> As developers, we could then pull in the commits from this branch (almost >> like a todo list) and get to work on the new or changed features. >> >> Is that making any sense? >> >> >> Matt Wynne >> http://blog.mattwynne.net >> http://www.songkick.com >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.mischa at gmail.com Tue Dec 16 06:23:57 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Tue, 16 Dec 2008 03:23:57 -0800 Subject: [rspec-users] Cucumber fat client In-Reply-To: References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <49455552.9070509@asolutions.com> Message-ID: Also, if people are into this sort of thing, I would be up for helping build it. On Tue, Dec 16, 2008 at 3:17 AM, Mischa Fierer wrote: > A few other things... > > In the interface that I was describing, it would solve several problems to > have something like: > > Given I'm a client > When I follow "new story" > And I drag in "Given I am a Pet Owner" > And I press "new action" > And I select "When I follow" > And I fill in "follows_what_link" with "Buy another dog" > And I press "new result" > And I select "Then i should see" > And I fill in "see_what" with "Say hello to your new dog" > And I press "Save feature" > Then I should see "Your feature has been saved!" > When I select "mischa -- developer" > When I press "Send feature" > Then I should see "feature sent to mischa" > > Obviously a bit hacky of a feature, but does everyone see what I'm getting > at? > > M > > > > On Tue, Dec 16, 2008 at 3:08 AM, Mischa Fierer wrote: > >> I can maybe offer something here. *begin rambling* >> >> My team of 4 (2 coders, 2 biz people) has recently switched to using >> Pivotal Tracker, and we've been doing the following: >> >> 1) Figure out what we can do that will add value >> 2) Draw out the ui / changes on a whiteboard >> 3) Write out features & copy them into pivotal (as stories) >> 4) Implement >> >> This solves the following problems: >> >> Coders have trouble communicating how long things will take to MBAs >> (clients). Putting them in pivotal allows us to be clear about how long >> things will take, and that adding things will add time. >> >> Reduces miscommunications between clients and coders, because it forces >> clients to be clear about what they want / gives coders ability to show why >> some things are not worth the time. >> >> What is still lacking: >> >> While we've been getting better at this, what's lacking is a client >> ability to understand how features can/should be written. >> I've been just allowing them to write them however they want, with a few >> pointers, as for a lot of steps it requires a bit too much understanding >> about how Rails works. For example, explaining to a long-term client the >> difference between "press" and "follow" is fine, but I can imagine feeling a >> bit silly trying to explain it to a new client whom I am making a proposal >> to. >> >> So, the solution to this may be to work together (on this list) to come up >> with better ways of writing features. (E.g. I've stopped using "And I should >> be at xyz" and "And there should be a xyz form" and a few other similar >> things except in cases where they're necessary, as clients would not >> themselves include these kind of steps for the most part) >> >> So, in terms of an interface: >> >> I like the idea of changes coming in via something like git, where I would >> be able to see the differences. However this is not particularly different >> from updaing a feature on Pivotal, Trac or Lighhouse. >> >> I think a more interesting idea for an interface would be something that >> helps clients write features, like, some sort of drag and drop thing where >> they could start as a certain type of user, then drag in whens, then type in >> thens, or something. Probably not specific enough to be usefull, but maybe >> this will spark an idea for someone else. >> >> In the distant future I can imagine some sort of speccing web app that >> would allow clients to build features by clicking and typing, and then >> rearrange / sort them plus visualize how they link together. >> >> So, for example, there might be: >> >> UserTypes - role:string >> >> Actions - what:string >> >> Results - what_happens:string >> >> As a client I would be able to create a bunch of these, then arrange them >> and then print them out for my coders. >> >> M >> >> >> >> >> On Tue, Dec 16, 2008 at 12:42 AM, Matt Wynne wrote: >> >>> >>> On 15 Dec 2008, at 12:53, Bart Zonneveld wrote: >>> >>> >>>> On 14-dec-2008, at 19:49, mike.gaffney wrote: >>>> >>>> Why not make a web client that manipulates git based projects in the >>>>> background? I've been messing around with Grit and doing things like this >>>>> lately for http://rdocul.us a site I run and it is very easy to do. If >>>>> everything is in a standard location you could just add a project via an >>>>> administrative page and it would be cloned in the background, then they >>>>> could: >>>>> >>>>> browse all specs (just a filesystem listing) >>>>> edit and save specs (git add, commit, push) >>>>> look at a history on a given spec (log) >>>>> look at the history of all changes to the specs (log on a path) >>>>> merge changes / conflicts >>>>> >>>> >>>> Correct me if I'm wrong (and I probably missed something), but why do >>>> you and some others in this thread want users to actually edit a feature? >>>> That's going to wreck havoc with steps that won't match anymore, >>>> breaking features, and therefore making the client angry. >>>> >>>> WDYT? >>>> bartz >>>> >>> >>> What else would they want to do though that would add much value? >>> >>> My thinking now is that I would perhaps have the customers working on a >>> different branch of the code, which was still built in CI but failed with a >>> 'softer' noise, to indicate that there was new work to do. We'd expect the >>> build for this branch would be 'broken' most of the time. >>> >>> As developers, we could then pull in the commits from this branch (almost >>> like a todo list) and get to work on the new or changed features. >>> >>> Is that making any sense? >>> >>> >>> Matt Wynne >>> http://blog.mattwynne.net >>> http://www.songkick.com >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aidy.lewis at googlemail.com Tue Dec 16 06:50:51 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Tue, 16 Dec 2008 11:50:51 +0000 Subject: [rspec-users] [Cucumber] factor out non-user steps Message-ID: <7ac2300c0812160350y2d69e04bn2b1185228a341a5e@mail.gmail.com> Hi, I have a step that has been defined by the user Given /a logged in user/ {} Now in that step I have my own step (not defined by the business) of Given "all projects have been deleted" The second step needs to be included in the first Given /a logged in user/ do Given("all projects have been deleted") end I am thinking that "all projects have been deleted" should be hidden in the report. Is there a way to prevent the sub step from being reported or should I factor that step off to a standard method in the features/support folder? Aidy From mike.gaffney at asolutions.com Tue Dec 16 10:10:07 2008 From: mike.gaffney at asolutions.com (mike.gaffney) Date: Tue, 16 Dec 2008 09:10:07 -0600 Subject: [rspec-users] Cucumber fat client In-Reply-To: <65E538FB-6CDA-4D17-9A42-017C878300DE@gmail.com> References: <8d961d900812090143g65739920j995bd69d9ce5cca4@mail.gmail.com> <49455552.9070509@asolutions.com> <65E538FB-6CDA-4D17-9A42-017C878300DE@gmail.com> Message-ID: <4947C4CF.3020301@asolutions.com> >>> Correct me if I'm wrong (and I probably missed something), but why do >>> you and some others in this thread want users to actually edit a >>> feature? >>> That's going to wreck havoc with steps that won't match anymore, >>> breaking features, and therefore making the client angry. >>> >>> WDYT? >>> bartz > My thinking now is that I would perhaps have the customers working on > a different branch of the code, which was still built in CI but failed > with a 'softer' noise, to indicate that there was new work to do. We'd > expect the build for this branch would be 'broken' most of the time. I was thinking the same thing with my original comment about letting people edit the features. I didn't think it fully through though. In our distributed environment we typically have people discussing stories / specs what have you over vnc or over the phone or over email and they change until they are 'accepted'. I was thinking that allowing this type of interaction in this tool before the specs are actually 'accepted'. eg keep them pending until 'accepted'/greenlit. Having developers pull them in would be another way as well. Perhaps 'accepting' could be done with pull requests. The accepting / pulling paradigm would depend on how you wanted to handle half done specs and not yet implemented features. Please bear with my terminology as I'm 1/2 way in the test::unit world. -Mike From josephwilk at joesniff.co.uk Tue Dec 16 10:40:22 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Tue, 16 Dec 2008 15:40:22 +0000 Subject: [rspec-users] [Cucumber] factor out non-user steps In-Reply-To: <7ac2300c0812160350y2d69e04bn2b1185228a341a5e@mail.gmail.com> References: <7ac2300c0812160350y2d69e04bn2b1185228a341a5e@mail.gmail.com> Message-ID: <4947CBE6.3030809@joesniff.co.uk> aidy lewis wrote: > Hi, > > I have a step that has been defined by the user > > Given /a logged in user/ {} > > Now in that step I have my own step (not defined by the business) of > > Given "all projects have been deleted" > This sounds like something that might be better suited to a Before / After. Before do Projects.delete_all end > The second step needs to be included in the first > > Given /a logged in user/ do > Given("all projects have been deleted") > end > > I am thinking that "all projects have been deleted" should be hidden > in the report. > > Is there a way to prevent the sub step from being reported or should I > factor that step > off to a standard method in the features/support folder? > Which type of report are you using? In my experience the pretty and html formatter when rending output do not display sub-steps. Could you perhaps give an example of a report you are having problems with? There is currently no support for excluding steps from documentation. Its an interesting idea but the example application of hiding steps from the user feels wrong to me. I think that if you need to hide it from the user then it does not really belong in the steps domain. What do people think? -- Joseph Wilk http://blog.josephwilk.net > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From jonathan at parkerhill.com Tue Dec 16 11:36:54 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Tue, 16 Dec 2008 11:36:54 -0500 Subject: [rspec-users] [Cucumber] factor out non-user steps In-Reply-To: <7ac2300c0812160350y2d69e04bn2b1185228a341a5e@mail.gmail.com> References: <7ac2300c0812160350y2d69e04bn2b1185228a341a5e@mail.gmail.com> Message-ID: <98115818-F0D0-4F79-B104-87CA9E4B2E97@parkerhill.com> On Dec 16, 2008, at 6:50 AM, aidy lewis wrote: > Hi, > > I have a step that has been defined by the user > > Given /a logged in user/ {} > > Now in that step I have my own step (not defined by the business) of > > Given "all projects have been deleted" > > The second step needs to be included in the first > > Given /a logged in user/ do > Given("all projects have been deleted") > end > > I am thinking that "all projects have been deleted" should be hidden > in the report. > > Is there a way to prevent the sub step from being reported or should I > factor that step > off to a standard method in the features/support folder? > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users or I would start with a step like Given a site with no projects From lists at ruby-forum.com Tue Dec 16 14:34:28 2008 From: lists at ruby-forum.com (James Byrne) Date: Tue, 16 Dec 2008 20:34:28 +0100 Subject: [rspec-users] step definitons to check login Message-ID: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> I am working with the authlogic gem and trying to create a simple login test from cucumber features. The feature statement is: Given the user is not logged in The step definition for this is confounding me. In the application_controller the authlogic tutorial recommends the following: private def require_user unless current_user store_location flash[:notice] = "You must sign in to access this page" redirect_to new_user_session_url return false end end def require_no_user if current_user store_location flash[:notice] = "You must be logged out to access this page" redirect_to account_url return false end As these are private methods they are not directly accessible from the step definitions and I am at a loss as to how to proceed. I could augment the application controller with a public user_authenticated method: def user_authenticated return true if current_user false end But it seems wrong to alter the application code for no other purpose than to ease testing. Is there another approach that I should be using? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Dec 16 14:54:53 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 16 Dec 2008 13:54:53 -0600 Subject: [rspec-users] step definitons to check login In-Reply-To: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> Message-ID: <57c63afe0812161154y14831390vc084776f235f73e1@mail.gmail.com> On Tue, Dec 16, 2008 at 1:34 PM, James Byrne wrote: > I am working with the authlogic gem and trying to create a simple login > test from cucumber features. The feature statement is: > > Given the user is not logged in > > The step definition for this is confounding me. In the > application_controller the authlogic tutorial recommends the following: > > private > def require_user > unless current_user > store_location > flash[:notice] = "You must sign in to access this page" > redirect_to new_user_session_url > return false > end > end > > def require_no_user > if current_user > store_location > flash[:notice] = "You must be logged out to access this page" > redirect_to account_url > return false > end > > As these are private methods they are not directly accessible from the > step definitions and I am at a loss as to how to proceed. I could > augment the application controller with a public user_authenticated > method: > > def user_authenticated > return true if current_user > false > end > > But it seems wrong to alter the application code for no other purpose > than to ease testing. Is there another approach that I should be using? For things like session state, general consensus seems to be to go through the app, not directly after its internals. So to log in I'd do something like this: Given /a user logged in as "(.*)"/ do |role| user = create_user(role, 'supersecret') #helper method visit login_path fill_in :username, :with => user.username fill_in :password, :with => 'supersecret' click_button "Login" end For an anonymous user, I usually just have an empty step: Given /an anonymous user/ do; end This assumes that you have to explicitly log in to be logged in, but that seems like a safe assumption to me. As for your point about changing code to make it testable, while I can appreciate the desire to avoid modifying code for tests, if that's what it takes to test it, I do it. In this case I wouldn't bother, but as a general principle tests are part of the code base, just important (if not more so) than the application code. FWIW, David From lenny at aps.org Tue Dec 16 15:01:32 2008 From: lenny at aps.org (Lenny Marks) Date: Tue, 16 Dec 2008 15:01:32 -0500 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: References: Message-ID: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> On Dec 9, 2008, at 10:40 PM, Avdi Grimm wrote: > I contributed an article on BDD and RSpec to the Ruby Advent Calendar > 2008, going over some of the rules I've collected for interpreting > what your specs say about your design. It can be found here: > http://advent2008.hackruby.com/past/2008/12/10/ > listening_to_your_specs/ > > -- > Avdi > > I'm curious where others stand on the topic of object level specs with describe blocks named after methods. I posted the comment below with my 2 cents. -lenny I agree with most of the points in this article, but not so much the part about: Contexts named after methods A describe block should encapsulate a particular scenario: an object or set of objects in a specific configuration. If objects are nouns, and methods are verbs, then contexts should describe nouns, not verbs. I think this is more or less what Aslak was saying but I wanted to get more specific. IMO, using rspec to spec behavior at the object/ unit level, it often makes perfect sense to describe the behavior of the verbs(methods). I think the following contrived example would be fine. It clearly shows me the what this method does and what the scenarios it handles are. describe Account, "#debit" #maybe 'debiting' is better, but #debit is actually more descriptive of the API which is the level I'm at here. describe "with sufficient funds" it "should reduce balance by debited amount" it "should ..." describe "with insufficient funds" it "should raise an InsufficentFundsError" it "should ... Actually in the above example I probably would have started with the following and only grouped into nested contexts when I started repeating myself(e.g. repetition of 'when balance is sufficient') describe Account, "#debit" it "should reduce balance by debited amount when balance is sufficient" it "should raise an InsufficentFundsError when insufficient" .. Examples named after methods There is rarely a one-to-one relationship between desired behaviors and methods on an object. When you name an example after the method it tests, it?s a clue that you have started to think in ?implementation brain? rather than ?behavior brain?. You?re thinking ?I know we are going to need a method ?#foo? which does such-and-so, so I?ll just start spec-ing it now??. Step back, and think about the behavior you are really interested in. You may find it changes how you write examples. Or, you may find that you didn?t need that method at all. I don't agree much with the above either. I think this the difference between speccing behavior at the application level vs. object level. I don't feel its a smell to get down to the object level when necessary. One of the benefits of BDD at the object/code level(as opposed to feature level) is helping to flesh out the API(what classes, what methods, what inputs/outputs) that implements a feature. New classes and methods spring into existence as I realize that there are details(a new responsibility) that I eventually want to drill into but would only be distracting or messy at the current level. Using object level examples to focus in on something in isolation is a valuable technique. Again, its all about focussing at the right level of granularity. For ex. part of an 'update profile' feature might involve showing a user an error message if he/she submits invalid data. Now I wouldn't start off thinking, I'm going to need a User class with a validate method, but going from the outside in might eventually drive me to it so that I can drill into all the details of what constitutes valid data directly/in isolation, without being mixed in with a bunch of other stuff or extra setup. From dchelimsky at gmail.com Tue Dec 16 15:35:30 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 16 Dec 2008 14:35:30 -0600 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> References: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> Message-ID: <57c63afe0812161235p39502a1ck9d60e264eee79aea@mail.gmail.com> On Tue, Dec 16, 2008 at 2:01 PM, Lenny Marks wrote: > > On Dec 9, 2008, at 10:40 PM, Avdi Grimm wrote: > >> I contributed an article on BDD and RSpec to the Ruby Advent Calendar >> 2008, going over some of the rules I've collected for interpreting >> what your specs say about your design. It can be found here: >> http://advent2008.hackruby.com/past/2008/12/10/listening_to_your_specs/ >> >> -- >> Avdi >> >> > > I'm curious where others stand on the topic of object level specs with > describe blocks named after methods. I posted the comment below with my 2 > cents. I posted on the blog, but essentially I don't think you guys are at odds. Avdi is talking about examples named for methods: it "#method_name" do not example groups (which I think are fine, and I think Avdi does as well): describe SomeObject do describe "#method_name" do context "some state" do it "does something" do Here there is a group named #method_name, but there are potentially multiple examples of how that object responds to that message in different states. Cheers, David > > -lenny > > I agree with most of the points in this article, but not so much the part > about: > > > Contexts named after methods > > A describe block should encapsulate a particular scenario: an object or set > of objects in a specific configuration. If objects are nouns, and methods > are verbs, then contexts should describe nouns, not verbs. > > > I think this is more or less what Aslak was saying but I wanted to get more > specific. IMO, using rspec to spec behavior at the object/unit level, it > often makes perfect sense to describe the behavior of the verbs(methods). I > think the following contrived example would be fine. It clearly shows me the > what this method does and what the scenarios it handles are. > > describe Account, "#debit" #maybe 'debiting' is better, but #debit is > actually more descriptive of the API which is the level I'm at here. > describe "with sufficient funds" > it "should reduce balance by debited amount" > it "should ..." > describe "with insufficient funds" > it "should raise an InsufficentFundsError" > it "should ... > > Actually in the above example I probably would have started with the > following and only grouped into nested contexts when I started repeating > myself(e.g. repetition of 'when balance is sufficient') > > describe Account, "#debit" > it "should reduce balance by debited amount when balance is sufficient" > it "should raise an InsufficentFundsError when insufficient" > .. > > > Examples named after methods > > There is rarely a one-to-one relationship between desired behaviors and > methods on an object. When you name an example after the method it tests, > it's a clue that you have started to think in "implementation brain" rather > than "behavior brain". You're thinking "I know we are going to need a method > "#foo" which does such-and-so, so I'll just start spec-ing it now?". Step > back, and think about the behavior you are really interested in. You may > find it changes how you write examples. Or, you may find that you didn't > need that method at all. > > > I don't agree much with the above either. I think this the difference > between speccing behavior at the application level vs. object level. I don't > feel its a smell to get down to the object level when necessary. One of the > benefits of BDD at the object/code level(as opposed to feature level) is > helping to flesh out the API(what classes, what methods, what > inputs/outputs) that implements a feature. New classes and methods spring > into existence as I realize that there are details(a new responsibility) > that I eventually want to drill into but would only be distracting or messy > at the current level. Using object level examples to focus in on something > in isolation is a valuable technique. Again, its all about focussing at the > right level of granularity. > > For ex. part of an 'update profile' feature might involve showing a user an > error message if he/she submits invalid data. Now I wouldn't start off > thinking, I'm going to need a User class with a validate method, but going > from the outside in might eventually drive me to it so that I can drill into > all the details of what constitutes valid data directly/in isolation, > without being mixed in with a bunch of other stuff or extra > setup._______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Tue Dec 16 15:47:41 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 16 Dec 2008 12:47:41 -0800 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> (Lenny Marks's message of "Tue\, 16 Dec 2008 15\:01\:32 -0500") References: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> Message-ID: Lenny Marks writes: > On Dec 9, 2008, at 10:40 PM, Avdi Grimm wrote: > >> I contributed an article on BDD and RSpec to the Ruby Advent Calendar >> 2008, going over some of the rules I've collected for interpreting >> what your specs say about your design. It can be found here: >> http://advent2008.hackruby.com/past/2008/12/10/ >> listening_to_your_specs/ >> >> -- >> Avdi >> >> > > I'm curious where others stand on the topic of object level specs > with describe blocks named after methods. I posted the comment below > with my 2 cents. > > -lenny > > I agree with most of the points in this article, but not so much the > part about: > > > Contexts named after methods > > A describe block should encapsulate a particular scenario: an object > or set of objects in a specific configuration. If objects are nouns, > and methods are verbs, then contexts should describe nouns, not verbs. > > > I think this is more or less what Aslak was saying but I wanted to > get more specific. IMO, using rspec to spec behavior at the object/ > unit level, it often makes perfect sense to describe the behavior of > the verbs(methods). I think the following contrived example would be > fine. It clearly shows me the what this method does and what the > scenarios it handles are. > > describe Account, "#debit" #maybe 'debiting' is better, but #debit is > actually more descriptive of the API which is the level I'm at here. > describe "with sufficient funds" > it "should reduce balance by debited amount" > it "should ..." > describe "with insufficient funds" > it "should raise an InsufficentFundsError" > it "should ... > > Actually in the above example I probably would have started with the > following and only grouped into nested contexts when I started > repeating myself(e.g. repetition of 'when balance is sufficient') > > describe Account, "#debit" > it "should reduce balance by debited amount when balance is sufficient" > it "should raise an InsufficentFundsError when insufficient" > .. Yes. This style of specification has a lot of documentation value. You look at the RDoc for a method that looks like what you want, and then you can look at the spec to get concrete examples of how it's used. A friend of mine has toyed with the idea of putting the specs directly in the RDoc, or generating RDoc from the specs. Seems promising. > > Examples named after methods > > There is rarely a one-to-one relationship between desired behaviors > and methods on an object. When you name an example after the method > it tests, it?s a clue that you have started to think in > ?implementation brain? rather than ?behavior brain?. You?re thinking > ?I know we are going to need a method ?#foo? which does such-and-so, > so I?ll just start spec-ing it now??. Step back, and think about the > behavior you are really interested in. You may find it changes how > you write examples. Or, you may find that you didn?t need that method > at all. > And when you do know that you need the method? Like if you had driven it from working outside-in. I don't like a lot of the stuff that Avdi writes. He made some pretty good points in this article though, but I would hope that nobody holds it up as a canonical description of BDD (I don't think there really is/should be one, but if there were, it'd have to be Dan's stuff imo). Pat From dchelimsky at gmail.com Tue Dec 16 15:49:49 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 16 Dec 2008 14:49:49 -0600 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: References: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> Message-ID: <57c63afe0812161249t586ee1bdn6ef8d68bc0fe1fbc@mail.gmail.com> On Tue, Dec 16, 2008 at 2:47 PM, Pat Maddox wrote: > Lenny Marks writes: > >> On Dec 9, 2008, at 10:40 PM, Avdi Grimm wrote: >> >>> I contributed an article on BDD and RSpec to the Ruby Advent Calendar >>> 2008, going over some of the rules I've collected for interpreting >>> what your specs say about your design. It can be found here: >>> http://advent2008.hackruby.com/past/2008/12/10/ >>> listening_to_your_specs/ >>> >>> -- >>> Avdi >>> >>> >> >> I'm curious where others stand on the topic of object level specs >> with describe blocks named after methods. I posted the comment below >> with my 2 cents. >> >> -lenny >> >> I agree with most of the points in this article, but not so much the >> part about: >> >> >> Contexts named after methods >> >> A describe block should encapsulate a particular scenario: an object >> or set of objects in a specific configuration. If objects are nouns, >> and methods are verbs, then contexts should describe nouns, not verbs. >> >> >> I think this is more or less what Aslak was saying but I wanted to >> get more specific. IMO, using rspec to spec behavior at the object/ >> unit level, it often makes perfect sense to describe the behavior of >> the verbs(methods). I think the following contrived example would be >> fine. It clearly shows me the what this method does and what the >> scenarios it handles are. >> >> describe Account, "#debit" #maybe 'debiting' is better, but #debit is >> actually more descriptive of the API which is the level I'm at here. >> describe "with sufficient funds" >> it "should reduce balance by debited amount" >> it "should ..." >> describe "with insufficient funds" >> it "should raise an InsufficentFundsError" >> it "should ... >> >> Actually in the above example I probably would have started with the >> following and only grouped into nested contexts when I started >> repeating myself(e.g. repetition of 'when balance is sufficient') >> >> describe Account, "#debit" >> it "should reduce balance by debited amount when balance is sufficient" >> it "should raise an InsufficentFundsError when insufficient" >> .. > > Yes. This style of specification has a lot of documentation value. You > look at the RDoc for a method that looks like what you want, and then > you can look at the spec to get concrete examples of how it's used. > > A friend of mine has toyed with the idea of putting the specs directly > in the RDoc, or generating RDoc from the specs. Seems promising. I want to hear more about this. It's something that I've been toying with in my head, not so much in code. > > >> >> Examples named after methods >> >> There is rarely a one-to-one relationship between desired behaviors >> and methods on an object. When you name an example after the method >> it tests, it's a clue that you have started to think in >> "implementation brain" rather than "behavior brain". You're thinking >> "I know we are going to need a method "#foo" which does such-and-so, >> so I'll just start spec-ing it now?". Step back, and think about the >> behavior you are really interested in. You may find it changes how >> you write examples. Or, you may find that you didn't need that method >> at all. >> > > And when you do know that you need the method? Like if you had driven > it from working outside-in. > > I don't like a lot of the stuff that Avdi writes. He made some pretty > good points in this article though, but I would hope that nobody holds > it up as a canonical description of BDD (I don't think there really > is/should be one, but if there were, it'd have to be Dan's stuff imo). > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Tue Dec 16 15:51:06 2008 From: ben at benmabey.com (Ben Mabey) Date: Tue, 16 Dec 2008 13:51:06 -0700 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: <57c63afe0812161235p39502a1ck9d60e264eee79aea@mail.gmail.com> References: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> <57c63afe0812161235p39502a1ck9d60e264eee79aea@mail.gmail.com> Message-ID: <494814BA.7040407@benmabey.com> David Chelimsky wrote: > On Tue, Dec 16, 2008 at 2:01 PM, Lenny Marks wrote: > >> On Dec 9, 2008, at 10:40 PM, Avdi Grimm wrote: >> >> >>> I contributed an article on BDD and RSpec to the Ruby Advent Calendar >>> 2008, going over some of the rules I've collected for interpreting >>> what your specs say about your design. It can be found here: >>> http://advent2008.hackruby.com/past/2008/12/10/listening_to_your_specs/ >>> >>> -- >>> Avdi >>> >>> >>> >> I'm curious where others stand on the topic of object level specs with >> describe blocks named after methods. I posted the comment below with my 2 >> cents. >> > > I posted on the blog, but essentially I don't think you guys are at > odds. Avdi is talking about examples named for methods: > > it "#method_name" do > > not example groups (which I think are fine, and I think Avdi does as well): > > describe SomeObject do > describe "#method_name" do > context "some state" do > it "does something" do > > Here there is a group named #method_name, but there are potentially > multiple examples of how that object responds to that message in > different states. > Actually, Avdi did argue against both cases... (Method names in example groups and examples.) > Cheers, > David > > >> -lenny >> >> I agree with most of the points in this article, but not so much the part >> about: >> >> >> Contexts named after methods >> >> A describe block should encapsulate a particular scenario: an object or set >> of objects in a specific configuration. If objects are nouns, and methods >> are verbs, then contexts should describe nouns, not verbs. >> >> >> I think this is more or less what Aslak was saying but I wanted to get more >> specific. IMO, using rspec to spec behavior at the object/unit level, it >> often makes perfect sense to describe the behavior of the verbs(methods). I >> think the following contrived example would be fine. It clearly shows me the >> what this method does and what the scenarios it handles are. >> >> describe Account, "#debit" #maybe 'debiting' is better, but #debit is >> actually more descriptive of the API which is the level I'm at here. >> describe "with sufficient funds" >> it "should reduce balance by debited amount" >> it "should ..." >> describe "with insufficient funds" >> it "should raise an InsufficentFundsError" >> it "should ... >> >> Actually in the above example I probably would have started with the >> following and only grouped into nested contexts when I started repeating >> myself(e.g. repetition of 'when balance is sufficient') >> >> describe Account, "#debit" >> it "should reduce balance by debited amount when balance is sufficient" >> it "should raise an InsufficentFundsError when insufficient" >> .. >> >> >> Examples named after methods >> >> There is rarely a one-to-one relationship between desired behaviors and >> methods on an object. When you name an example after the method it tests, >> it's a clue that you have started to think in "implementation brain" rather >> than "behavior brain". You're thinking "I know we are going to need a method >> "#foo" which does such-and-so, so I'll just start spec-ing it now?". Step >> back, and think about the behavior you are really interested in. You may >> find it changes how you write examples. Or, you may find that you didn't >> need that method at all. >> >> >> I don't agree much with the above either. I think this the difference >> between speccing behavior at the application level vs. object level. I don't >> feel its a smell to get down to the object level when necessary. One of the >> benefits of BDD at the object/code level(as opposed to feature level) is >> helping to flesh out the API(what classes, what methods, what >> inputs/outputs) that implements a feature. New classes and methods spring >> into existence as I realize that there are details(a new responsibility) >> that I eventually want to drill into but would only be distracting or messy >> at the current level. Using object level examples to focus in on something >> in isolation is a valuable technique. Again, its all about focussing at the >> right level of granularity. >> >> For ex. part of an 'update profile' feature might involve showing a user an >> error message if he/she submits invalid data. Now I wouldn't start off >> thinking, I'm going to need a User class with a validate method, but going >> from the outside in might eventually drive me to it so that I can drill into >> all the details of what constitutes valid data directly/in isolation, >> without being mixed in with a bunch of other stuff or extra >> setup._______________________________________________ >> 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 Dec 16 15:51:23 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 16 Dec 2008 12:51:23 -0800 Subject: [rspec-users] [Cucumber] factor out non-user steps In-Reply-To: <98115818-F0D0-4F79-B104-87CA9E4B2E97@parkerhill.com> (Jonathan Linowes's message of "Tue\, 16 Dec 2008 11\:36\:54 -0500") References: <7ac2300c0812160350y2d69e04bn2b1185228a341a5e@mail.gmail.com> <98115818-F0D0-4F79-B104-87CA9E4B2E97@parkerhill.com> Message-ID: Jonathan Linowes writes: > On Dec 16, 2008, at 6:50 AM, aidy lewis wrote: > >> Hi, >> >> I have a step that has been defined by the user >> >> Given /a logged in user/ {} >> >> Now in that step I have my own step (not defined by the business) of >> >> Given "all projects have been deleted" >> >> The second step needs to be included in the first >> >> Given /a logged in user/ do >> Given("all projects have been deleted") >> end >> >> I am thinking that "all projects have been deleted" should be hidden >> in the report. >> >> Is there a way to prevent the sub step from being reported or should I >> factor that step >> off to a standard method in the features/support folder? >> >> Aidy >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > or I would start with a step like > > Given a site with no projects > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users And that step would be blank, because your database should already be empty, or it's a precondition checking step like Project.count.should == 0 Pat From dchelimsky at gmail.com Tue Dec 16 15:56:45 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 16 Dec 2008 14:56:45 -0600 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: <494814BA.7040407@benmabey.com> References: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> <57c63afe0812161235p39502a1ck9d60e264eee79aea@mail.gmail.com> <494814BA.7040407@benmabey.com> Message-ID: <57c63afe0812161256o5bf29415nb32ccacac15909ee@mail.gmail.com> On Tue, Dec 16, 2008 at 2:51 PM, Ben Mabey wrote: > David Chelimsky wrote: >> >> On Tue, Dec 16, 2008 at 2:01 PM, Lenny Marks wrote: >> >>> >>> On Dec 9, 2008, at 10:40 PM, Avdi Grimm wrote: >>> >>> >>>> >>>> I contributed an article on BDD and RSpec to the Ruby Advent Calendar >>>> 2008, going over some of the rules I've collected for interpreting >>>> what your specs say about your design. It can be found here: >>>> http://advent2008.hackruby.com/past/2008/12/10/listening_to_your_specs/ >>>> >>>> -- >>>> Avdi >>>> >>>> >>>> >>> >>> I'm curious where others stand on the topic of object level specs with >>> describe blocks named after methods. I posted the comment below with my >>> 2 >>> cents. >>> >> >> I posted on the blog, but essentially I don't think you guys are at >> odds. Avdi is talking about examples named for methods: >> >> it "#method_name" do >> >> not example groups (which I think are fine, and I think Avdi does as >> well): >> >> describe SomeObject do >> describe "#method_name" do >> context "some state" do >> it "does something" do >> >> Here there is a group named #method_name, but there are potentially >> multiple examples of how that object responds to that message in >> different states. >> > > Actually, Avdi did argue against both cases... (Method names in example > groups and examples.) Oh - in that case, I disagree :) At least w/ including them in example group docstrings. I think it's just fine and can lead to very readable doco output: Stack #pop returns the top element removes the top element #peek returns the top element does not remove the top element etc. This is also a nice way to see things from a higher level. If the "does not remove the top element" example was missing, it'd be obvious that it was, and might lead you to add that example. >> >> Cheers, >> David >> >> >>> >>> -lenny >>> >>> I agree with most of the points in this article, but not so much the part >>> about: >>> >>> >>> Contexts named after methods >>> >>> A describe block should encapsulate a particular scenario: an object or >>> set >>> of objects in a specific configuration. If objects are nouns, and methods >>> are verbs, then contexts should describe nouns, not verbs. >>> >>> >>> I think this is more or less what Aslak was saying but I wanted to get >>> more >>> specific. IMO, using rspec to spec behavior at the object/unit level, it >>> often makes perfect sense to describe the behavior of the verbs(methods). >>> I >>> think the following contrived example would be fine. It clearly shows me >>> the >>> what this method does and what the scenarios it handles are. >>> >>> describe Account, "#debit" #maybe 'debiting' is better, but #debit is >>> actually more descriptive of the API which is the level I'm at here. >>> describe "with sufficient funds" >>> it "should reduce balance by debited amount" >>> it "should ..." >>> describe "with insufficient funds" >>> it "should raise an InsufficentFundsError" >>> it "should ... >>> >>> Actually in the above example I probably would have started with the >>> following and only grouped into nested contexts when I started repeating >>> myself(e.g. repetition of 'when balance is sufficient') >>> >>> describe Account, "#debit" >>> it "should reduce balance by debited amount when balance is sufficient" >>> it "should raise an InsufficentFundsError when insufficient" >>> .. >>> >>> >>> Examples named after methods >>> >>> There is rarely a one-to-one relationship between desired behaviors and >>> methods on an object. When you name an example after the method it tests, >>> it's a clue that you have started to think in "implementation brain" >>> rather >>> than "behavior brain". You're thinking "I know we are going to need a >>> method >>> "#foo" which does such-and-so, so I'll just start spec-ing it now?". Step >>> back, and think about the behavior you are really interested in. You may >>> find it changes how you write examples. Or, you may find that you didn't >>> need that method at all. >>> >>> >>> I don't agree much with the above either. I think this the difference >>> between speccing behavior at the application level vs. object level. I >>> don't >>> feel its a smell to get down to the object level when necessary. One of >>> the >>> benefits of BDD at the object/code level(as opposed to feature level) is >>> helping to flesh out the API(what classes, what methods, what >>> inputs/outputs) that implements a feature. New classes and methods spring >>> into existence as I realize that there are details(a new responsibility) >>> that I eventually want to drill into but would only be distracting or >>> messy >>> at the current level. Using object level examples to focus in on >>> something >>> in isolation is a valuable technique. Again, its all about focussing at >>> the >>> right level of granularity. >>> >>> For ex. part of an 'update profile' feature might involve showing a user >>> an >>> error message if he/she submits invalid data. Now I wouldn't start off >>> thinking, I'm going to need a User class with a validate method, but >>> going >>> from the outside in might eventually drive me to it so that I can drill >>> into >>> all the details of what constitutes valid data directly/in isolation, >>> without being mixed in with a bunch of other stuff or extra >>> setup._______________________________________________ >>> 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 ben at benmabey.com Tue Dec 16 15:58:35 2008 From: ben at benmabey.com (Ben Mabey) Date: Tue, 16 Dec 2008 13:58:35 -0700 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> References: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> Message-ID: <4948167B.7030407@benmabey.com> Lenny Marks wrote: > > On Dec 9, 2008, at 10:40 PM, Avdi Grimm wrote: > >> I contributed an article on BDD and RSpec to the Ruby Advent Calendar >> 2008, going over some of the rules I've collected for interpreting >> what your specs say about your design. It can be found here: >> http://advent2008.hackruby.com/past/2008/12/10/listening_to_your_specs/ >> >> -- >> Avdi >> >> > > I'm curious where others stand on the topic of object level specs with > describe blocks named after methods. I posted the comment below with > my 2 cents. > > -lenny > > I agree with most of the points in this article, but not so much the > part about: > > > Contexts named after methods > > A describe block should encapsulate a particular scenario: an object > or set of objects in a specific configuration. If objects are nouns, > and methods are verbs, then contexts should describe nouns, not verbs. > > > I think this is more or less what Aslak was saying but I wanted to get > more specific. IMO, using rspec to spec behavior at the object/unit > level, it often makes perfect sense to describe the behavior of the > verbs(methods). I think the following contrived example would be fine. > It clearly shows me the what this method does and what the scenarios > it handles are. > > describe Account, "#debit" #maybe 'debiting' is better, but #debit is > actually more descriptive of the API which is the level I'm at here. > describe "with sufficient funds" > it "should reduce balance by debited amount" > it "should ..." > describe "with insufficient funds" > it "should raise an InsufficentFundsError" > it "should ... > > Actually in the above example I probably would have started with the > following and only grouped into nested contexts when I started > repeating myself(e.g. repetition of 'when balance is sufficient') > > describe Account, "#debit" > it "should reduce balance by debited amount when balance is sufficient" > it "should raise an InsufficentFundsError when insufficient" > .. > > > Examples named after methods > > There is rarely a one-to-one relationship between desired behaviors > and methods on an object. When you name an example after the method it > tests, it?s a clue that you have started to think in ?implementation > brain? rather than ?behavior brain?. You?re thinking ?I know we are > going to need a method ?#foo? which does such-and-so, so I?ll just > start spec-ing it now??. Step back, and think about the behavior you > are really interested in. You may find it changes how you write > examples. Or, you may find that you didn?t need that method at all. > > > I don't agree much with the above either. I think this the difference > between speccing behavior at the application level vs. object level. I > don't feel its a smell to get down to the object level when necessary. > One of the benefits of BDD at the object/code level(as opposed to > feature level) is helping to flesh out the API(what classes, what > methods, what inputs/outputs) that implements a feature. New classes > and methods spring into existence as I realize that there are > details(a new responsibility) that I eventually want to drill into but > would only be distracting or messy at the current level. Using object > level examples to focus in on something in isolation is a valuable > technique. Again, its all about focussing at the right level of > granularity. > > For ex. part of an 'update profile' feature might involve showing a > user an error message if he/she submits invalid data. Now I wouldn't > start off thinking, I'm going to need a User class with a validate > method, but going from the outside in might eventually drive me to it > so that I can drill into all the details of what constitutes valid > data directly/in isolation, without being mixed in with a bunch of > other stuff or extra > setup._______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Hey Lenny, I agree with a lot of what Avdi said in the article. One big exception was the the "Contexts named after methods" section. (However, I do agree with the examples named after methods.) My argument for having contexts named after methods is simple: documentation. It helps me quickly scan example groups to find specific examples about how to use the public methods (the API.) Maybe we should be using rdoc more but the team I work with has adopted this convention and have found that it helps us understand how to use objects written by other team members. This convention does not work well with all examples however, so we use it on a case-by-case basis. Another reason why I think I like using method names in contexts is because of how I like to develop. Going from the outside-in I usually use mocks to discover the interfaces I wish I had. Once I finish writing the collaborators I then start on the object's implementation. I start by documenting (writing code examples of) the cases how the collaborators are already using that method and expecting the object to behave from using the object in that way... So, I actually find using method names in example groups a very natural thing to do that just comes from going outside-in. At least in my experience. :) Again, I don't stick to this way for organizing all of my examples but I think it has its place and adds value. -Ben From avdi at avdi.org Tue Dec 16 17:17:33 2008 From: avdi at avdi.org (Avdi Grimm) Date: Tue, 16 Dec 2008 17:17:33 -0500 Subject: [rspec-users] Warnings Message-ID: So I was running my specs with -w the other day, and noticed a lot of warnings being produced. Some of these appear to be coming from RSpec internals, which is an issue in its own right but not the subject of this email. What I'm asking about right now is this. Given an example of the form: @foo.should == 42 Running the spec with ruby -w produces a warning to the effect that I'm "making a comparison in a void context". Now, this is a perfectly reasonable warning anywhere but in an RSpec spec. My question is: is anyone running RSpec with -w turned on, and if so, how are you avoiding warnings of this nature? -- Avdi Home: http://avdi.org Developer Blog: http://avdi.org/devblog/ Twitter: http://twitter.com/avdi Journal: http://avdi.livejournal.com From scott at railsnewbie.com Tue Dec 16 17:46:05 2008 From: scott at railsnewbie.com (Scott Taylor) Date: Tue, 16 Dec 2008 17:46:05 -0500 Subject: [rspec-users] Warnings In-Reply-To: References: Message-ID: <79003D36-8AFF-4220-AC71-F8BECEB2D5BD@railsnewbie.com> On Dec 16, 2008, at 5:17 PM, Avdi Grimm wrote: > So I was running my specs with -w the other day, and noticed a lot of > warnings being produced. Some of these appear to be coming from RSpec > internals, which is an issue in its own right but not the subject of > this email. What I'm asking about right now is this. Given an > example of the form: > > @foo.should == 42 > > Running the spec with ruby -w produces a warning to the effect that > I'm "making a comparison in a void context". Now, this is a perfectly > reasonable warning anywhere but in an RSpec spec. My question is: is > anyone running RSpec with -w turned on, and if so, how are you > avoiding warnings of this nature? I haven't noticed any. Post a bug report on lighthouse, with full backtrace and error message, ruby (& rails version), rspec version, and OS. Scott From aslak.hellesoy at gmail.com Tue Dec 16 18:32:36 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 17 Dec 2008 00:32:36 +0100 Subject: [rspec-users] Warnings In-Reply-To: <79003D36-8AFF-4220-AC71-F8BECEB2D5BD@railsnewbie.com> References: <79003D36-8AFF-4220-AC71-F8BECEB2D5BD@railsnewbie.com> Message-ID: <8d961d900812161532u2af2329as238ac61c09156169@mail.gmail.com> On Tue, Dec 16, 2008 at 11:46 PM, Scott Taylor wrote: > > On Dec 16, 2008, at 5:17 PM, Avdi Grimm wrote: > > So I was running my specs with -w the other day, and noticed a lot of >> warnings being produced. Some of these appear to be coming from RSpec >> internals, which is an issue in its own right but not the subject of >> this email. What I'm asking about right now is this. Given an >> example of the form: >> >> @foo.should == 42 >> >> Running the spec with ruby -w produces a warning to the effect that >> I'm "making a comparison in a void context". Now, this is a perfectly >> reasonable warning anywhere but in an RSpec spec. My question is: is >> anyone running RSpec with -w turned on, and if so, how are you >> avoiding warnings of this nature? >> > Ruby gives a warning because the result of the == isn't stored anywhere. If you do x = @foo.should == 42 The waring is gone. There isn't much we can do about it - it's how Ruby decides to warn. Aslak > > I haven't noticed any. > > Post a bug report on lighthouse, with full backtrace and error message, > ruby (& rails version), rspec version, and OS. > > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Tue Dec 16 18:47:27 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Tue, 16 Dec 2008 23:47:27 +0000 Subject: [rspec-users] step definitons to check login In-Reply-To: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> Message-ID: <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> Doing this for Restful-Authentication I add the following in features/support/env.rb # Make visible for testing ApplicationController.send(:public, :logged_in?, :current_user, :authorized?) Hopefully something similar will work with Authlogic Andrew 2008/12/16 James Byrne > I am working with the authlogic gem and trying to create a simple login > test from cucumber features. The feature statement is: > > Given the user is not logged in > > The step definition for this is confounding me. In the > application_controller the authlogic tutorial recommends the following: > > private > def require_user > unless current_user > store_location > flash[:notice] = "You must sign in to access this page" > redirect_to new_user_session_url > return false > end > end > > def require_no_user > if current_user > store_location > flash[:notice] = "You must be logged out to access this page" > redirect_to account_url > return false > end > > As these are private methods they are not directly accessible from the > step definitions and I am at a loss as to how to proceed. I could > augment the application controller with a public user_authenticated > method: > > def user_authenticated > return true if current_user > false > end > > But it seems wrong to alter the application code for no other purpose > than to ease testing. Is there another approach that I should be using? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Tue Dec 16 18:52:11 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 16 Dec 2008 18:52:11 -0500 Subject: [rspec-users] step definitons to check login In-Reply-To: <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> Message-ID: <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> On Tue, Dec 16, 2008 at 6:47 PM, Andrew Premdas wrote: > Doing this for Restful-Authentication I add the following in > features/support/env.rb > > # Make visible for testing > ApplicationController.send(:public, :logged_in?, :current_user, > :authorized?) Why do you need these available for cucumber scenarios? > > Hopefully something similar will work with Authlogic > > Andrew > > 2008/12/16 James Byrne >> >> I am working with the authlogic gem and trying to create a simple login >> test from cucumber features. The feature statement is: >> >> Given the user is not logged in >> >> The step definition for this is confounding me. In the >> application_controller the authlogic tutorial recommends the following: >> >> private >> def require_user >> unless current_user >> store_location >> flash[:notice] = "You must sign in to access this page" >> redirect_to new_user_session_url >> return false >> end >> end >> >> def require_no_user >> if current_user >> store_location >> flash[:notice] = "You must be logged out to access this page" >> redirect_to account_url >> return false >> end >> >> As these are private methods they are not directly accessible from the >> step definitions and I am at a loss as to how to proceed. I could >> augment the application controller with a public user_authenticated >> method: >> >> def user_authenticated >> return true if current_user >> false >> end >> >> But it seems wrong to alter the application code for no other purpose >> than to ease testing. Is there another approach that I should be using? >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> 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 > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From apremdas at gmail.com Tue Dec 16 19:48:53 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Wed, 17 Dec 2008 00:48:53 +0000 Subject: [rspec-users] step definitons to check login In-Reply-To: <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> Message-ID: <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> So I can confirm that I'm logged in, that the user is who I say he is, etc. e.g Then /^I should be logged in$/ do controller.logged_in?.should be_true end makes sense? 2008/12/16 Zach Dennis > On Tue, Dec 16, 2008 at 6:47 PM, Andrew Premdas > wrote: > > Doing this for Restful-Authentication I add the following in > > features/support/env.rb > > > > # Make visible for testing > > ApplicationController.send(:public, :logged_in?, :current_user, > > :authorized?) > > Why do you need these available for cucumber scenarios? > > > > > > Hopefully something similar will work with Authlogic > > > > Andrew > > > > 2008/12/16 James Byrne > >> > >> I am working with the authlogic gem and trying to create a simple login > >> test from cucumber features. The feature statement is: > >> > >> Given the user is not logged in > >> > >> The step definition for this is confounding me. In the > >> application_controller the authlogic tutorial recommends the following: > >> > >> private > >> def require_user > >> unless current_user > >> store_location > >> flash[:notice] = "You must sign in to access this page" > >> redirect_to new_user_session_url > >> return false > >> end > >> end > >> > >> def require_no_user > >> if current_user > >> store_location > >> flash[:notice] = "You must be logged out to access this page" > >> redirect_to account_url > >> return false > >> end > >> > >> As these are private methods they are not directly accessible from the > >> step definitions and I am at a loss as to how to proceed. I could > >> augment the application controller with a public user_authenticated > >> method: > >> > >> def user_authenticated > >> return true if current_user > >> false > >> end > >> > >> But it seems wrong to alter the application code for no other purpose > >> than to ease testing. Is there another approach that I should be using? > >> -- > >> Posted via http://www.ruby-forum.com/. > >> _______________________________________________ > >> 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 > > > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Tue Dec 16 20:30:42 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 16 Dec 2008 20:30:42 -0500 Subject: [rspec-users] step definitons to check login In-Reply-To: <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> Message-ID: <85d99afe0812161730wf9556d0u12eab1de4fdba02e@mail.gmail.com> On Tue, Dec 16, 2008 at 7:48 PM, Andrew Premdas wrote: > So I can confirm that I'm logged in, that the user is who I say he is, etc. > > e.g > > Then /^I should be logged in$/ do > controller.logged_in?.should be_true > end > > makes sense? I know why you're doing it, but I just want to know *why* you're doing it? Can you not tell through the application itself that someone is logged in, logged out, and verify their identity without having to expose the internals? > > 2008/12/16 Zach Dennis >> >> On Tue, Dec 16, 2008 at 6:47 PM, Andrew Premdas >> wrote: >> > Doing this for Restful-Authentication I add the following in >> > features/support/env.rb >> > >> > # Make visible for testing >> > ApplicationController.send(:public, :logged_in?, :current_user, >> > :authorized?) >> >> Why do you need these available for cucumber scenarios? >> >> >> > >> > Hopefully something similar will work with Authlogic >> > >> > Andrew >> > >> > 2008/12/16 James Byrne >> >> >> >> I am working with the authlogic gem and trying to create a simple login >> >> test from cucumber features. The feature statement is: >> >> >> >> Given the user is not logged in >> >> >> >> The step definition for this is confounding me. In the >> >> application_controller the authlogic tutorial recommends the following: >> >> >> >> private >> >> def require_user >> >> unless current_user >> >> store_location >> >> flash[:notice] = "You must sign in to access this page" >> >> redirect_to new_user_session_url >> >> return false >> >> end >> >> end >> >> >> >> def require_no_user >> >> if current_user >> >> store_location >> >> flash[:notice] = "You must be logged out to access this page" >> >> redirect_to account_url >> >> return false >> >> end >> >> >> >> As these are private methods they are not directly accessible from the >> >> step definitions and I am at a loss as to how to proceed. I could >> >> augment the application controller with a public user_authenticated >> >> method: >> >> >> >> def user_authenticated >> >> return true if current_user >> >> false >> >> end >> >> >> >> But it seems wrong to alter the application code for no other purpose >> >> than to ease testing. Is there another approach that I should be >> >> using? >> >> -- >> >> Posted via http://www.ruby-forum.com/. >> >> _______________________________________________ >> >> 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 >> > >> >> >> >> -- >> Zach Dennis >> http://www.continuousthinking.com >> http://www.mutuallyhuman.com >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From aslak.hellesoy at gmail.com Tue Dec 16 20:36:17 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 17 Dec 2008 02:36:17 +0100 Subject: [rspec-users] step definitons to check login In-Reply-To: <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> Message-ID: <8d961d900812161736m585a342cnf2433152637e5a56@mail.gmail.com> On Wed, Dec 17, 2008 at 1:48 AM, Andrew Premdas wrote: > So I can confirm that I'm logged in, that the user is who I say he is, etc. > > e.g > > Then /^I should be logged in$/ do > controller.logged_in?.should be_true Or: controller.should be_logged_in Aslak > > end > > makes sense? > > 2008/12/16 Zach Dennis > > On Tue, Dec 16, 2008 at 6:47 PM, Andrew Premdas >> wrote: >> > Doing this for Restful-Authentication I add the following in >> > features/support/env.rb >> > >> > # Make visible for testing >> > ApplicationController.send(:public, :logged_in?, :current_user, >> > :authorized?) >> >> Why do you need these available for cucumber scenarios? >> >> >> > >> > Hopefully something similar will work with Authlogic >> > >> > Andrew >> > >> > 2008/12/16 James Byrne >> >> >> >> I am working with the authlogic gem and trying to create a simple login >> >> test from cucumber features. The feature statement is: >> >> >> >> Given the user is not logged in >> >> >> >> The step definition for this is confounding me. In the >> >> application_controller the authlogic tutorial recommends the following: >> >> >> >> private >> >> def require_user >> >> unless current_user >> >> store_location >> >> flash[:notice] = "You must sign in to access this page" >> >> redirect_to new_user_session_url >> >> return false >> >> end >> >> end >> >> >> >> def require_no_user >> >> if current_user >> >> store_location >> >> flash[:notice] = "You must be logged out to access this page" >> >> redirect_to account_url >> >> return false >> >> end >> >> >> >> As these are private methods they are not directly accessible from the >> >> step definitions and I am at a loss as to how to proceed. I could >> >> augment the application controller with a public user_authenticated >> >> method: >> >> >> >> def user_authenticated >> >> return true if current_user >> >> false >> >> end >> >> >> >> But it seems wrong to alter the application code for no other purpose >> >> than to ease testing. Is there another approach that I should be >> using? >> >> -- >> >> Posted via http://www.ruby-forum.com/. >> >> _______________________________________________ >> >> 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 >> > >> >> >> >> -- >> Zach Dennis >> http://www.continuousthinking.com >> http://www.mutuallyhuman.com >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Tue Dec 16 20:40:58 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Tue, 16 Dec 2008 20:40:58 -0500 Subject: [rspec-users] step definitons to check login In-Reply-To: <85d99afe0812161730wf9556d0u12eab1de4fdba02e@mail.gmail.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <85d99afe0812161730wf9556d0u12eab1de4fdba02e@mail.gmail.com> Message-ID: <85d99afe0812161740s22f3a1cbx656b521566d4c140@mail.gmail.com> On Tue, Dec 16, 2008 at 8:30 PM, Zach Dennis wrote: > On Tue, Dec 16, 2008 at 7:48 PM, Andrew Premdas wrote: >> So I can confirm that I'm logged in, that the user is who I say he is, etc. >> >> e.g >> >> Then /^I should be logged in$/ do >> controller.logged_in?.should be_true >> end >> >> makes sense? > > I know why you're doing it, but I just want to know *why* you're doing > it? Can you not tell through the application itself that someone is > logged in, logged out, and verify their identity without having to > expose the internals? I'm not trying to be pedantic or facetious. I'm really trying to explore the use case, > > >> >> 2008/12/16 Zach Dennis >>> >>> On Tue, Dec 16, 2008 at 6:47 PM, Andrew Premdas >>> wrote: >>> > Doing this for Restful-Authentication I add the following in >>> > features/support/env.rb >>> > >>> > # Make visible for testing >>> > ApplicationController.send(:public, :logged_in?, :current_user, >>> > :authorized?) >>> >>> Why do you need these available for cucumber scenarios? >>> >>> >>> > >>> > Hopefully something similar will work with Authlogic >>> > >>> > Andrew >>> > >>> > 2008/12/16 James Byrne >>> >> >>> >> I am working with the authlogic gem and trying to create a simple login >>> >> test from cucumber features. The feature statement is: >>> >> >>> >> Given the user is not logged in >>> >> >>> >> The step definition for this is confounding me. In the >>> >> application_controller the authlogic tutorial recommends the following: >>> >> >>> >> private >>> >> def require_user >>> >> unless current_user >>> >> store_location >>> >> flash[:notice] = "You must sign in to access this page" >>> >> redirect_to new_user_session_url >>> >> return false >>> >> end >>> >> end >>> >> >>> >> def require_no_user >>> >> if current_user >>> >> store_location >>> >> flash[:notice] = "You must be logged out to access this page" >>> >> redirect_to account_url >>> >> return false >>> >> end >>> >> >>> >> As these are private methods they are not directly accessible from the >>> >> step definitions and I am at a loss as to how to proceed. I could >>> >> augment the application controller with a public user_authenticated >>> >> method: >>> >> >>> >> def user_authenticated >>> >> return true if current_user >>> >> false >>> >> end >>> >> >>> >> But it seems wrong to alter the application code for no other purpose >>> >> than to ease testing. Is there another approach that I should be >>> >> using? >>> >> -- >>> >> Posted via http://www.ruby-forum.com/. >>> >> _______________________________________________ >>> >> 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 >>> > >>> >>> >>> >>> -- >>> Zach Dennis >>> http://www.continuousthinking.com >>> http://www.mutuallyhuman.com >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From f.mischa at gmail.com Wed Dec 17 04:39:18 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Wed, 17 Dec 2008 01:39:18 -0800 Subject: [rspec-users] Rails 2.3 Message-ID: Wanted to point out to anyone having problems that rspec-rails 1.1.11.1 works with rails 2.3, while rspec 1.1.11 does not appear to. Also, to get rspec 1.1.11.1 to build I had to remove UPDATE from the manifest. M -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Dec 17 07:01:56 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 17 Dec 2008 06:01:56 -0600 Subject: [rspec-users] Rails 2.3 In-Reply-To: References: Message-ID: <57c63afe0812170401j245a6674rc418b7843407fb1d@mail.gmail.com> On Wed, Dec 17, 2008 at 3:39 AM, Mischa Fierer wrote: > Wanted to point out to anyone having problems that rspec-rails 1.1.11.1 > works with rails 2.3, while rspec 1.1.11 does not appear to. $ gem q -rn rails ... rails (2.2.2) ... Doesn't look like rails-2.3 is released. Do you mean edge rails? Also - just so we're all clear, any gem w/ a 4th part (like 1.1.11.1) is an interim, unofficial release that I make available at github as a convenience (http://github.com/dchelimsky/rspec/wikis/releases-and-gems). They get prefixed w/ my github username, so: $ gem q -rn dchelimsky-rspec dchelimsky-rspec (1.1.11.1) dchelimsky-rspec-rails (1.1.11.1) I just pushed updated gemspecs, so there should be a pair of 1.1.11.2 gems up there soon (usually takes 15 to 30 minutes before they show up) that won't require you futzing with the manifest. Cheers, David > > Also, to get rspec 1.1.11.1 to build I had to remove UPDATE from the > manifest. > > M > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed Dec 17 07:21:39 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 17 Dec 2008 13:21:39 +0100 Subject: [rspec-users] Wanna make the Cucumber Logo? In-Reply-To: <8d961d900812090212o43cc402cnd07c252d144c7724@mail.gmail.com> References: <8d961d900812090212o43cc402cnd07c252d144c7724@mail.gmail.com> Message-ID: <8d961d900812170421p365aa480hed61673e62cbbc21@mail.gmail.com> On Tue, Dec 9, 2008 at 11:12 AM, aslak hellesoy wrote: > Check this out: > http://github.com/aslakhellesoy/cucumber/wikis/logo-contest > There is still time to enter the logo contest! So far I've received 3 great contributions. On Friday - exactly 48 hours from now I will set up a poll over the logos that have been registered thus far. The poll will be on the same page (using http://js-kit.com/polls/) and it will be open for 5 days (120 hours). May the best logo win! Aslak > > Aslak > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivorpaul at gmail.com Wed Dec 17 08:25:41 2008 From: ivorpaul at gmail.com (Ivor Paul) Date: Wed, 17 Dec 2008 15:25:41 +0200 Subject: [rspec-users] Broken rake tasks In-Reply-To: <88fd8ddc0812040054q432b832cudc842753b084bb6e@mail.gmail.com> References: <88fd8ddc0812040054q432b832cudc842753b084bb6e@mail.gmail.com> Message-ID: HI Andrew I am getting the same problem. I only get it when I install rspec-rails alongside rspec as gems. Did you get a resolution to this problem? Ivor On Thu, Dec 4, 2008 at 10:54 AM, Andrew Premdas wrote: > I've got a couple of rake tasks that seem to have broken with rspec 1.1.11. > http://pastie.org/330719 > > The trace I'm getting is > > /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in > `files_to_load': File or directory not found: tc:load (RuntimeError) > from > /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `each' > from > /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > `files_to_load' > from > /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > `run_examples' > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in `run' > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in > `register_at_exit_hook' > from /usr/bin/rake:19 > > Now I'm not even sure why spec/runner is running these tasks. > > Any ideas? > > All best > > Andrew > > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed Dec 17 09:44:48 2008 From: lists at ruby-forum.com (James Byrne) Date: Wed, 17 Dec 2008 15:44:48 +0100 Subject: [rspec-users] step definitons to check login In-Reply-To: <85d99afe0812161740s22f3a1cbx656b521566d4c140@mail.gmail.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <85d99afe0812161730wf9556d0u12eab1de4fdba02e@mail.gmail.com> <85d99afe0812161740s22f3a1cbx656b521566d4c140@mail.gmail.com> Message-ID: Zach Dennis wrote: > On Tue, Dec 16, 2008 at 8:30 PM, Zach Dennis > wrote: >> >> I know why you're doing it, but I just want to know *why* you're doing >> it? Can you not tell through the application itself that someone is >> logged in, logged out, and verify their identity without having to >> expose the internals? > In my case I am exploring the whole nature of BDD. Since experience, much of it bad, is the best teacher I am trying to cram as much of it as possible into the front end; before it gets expensive. Testing whether or not the application can detect and distinguish between authenticated and non-authenticate requests where it matters is important in my opinion. The situation being that some parts are accessible anonymously and some are not. It might be considered desirable to limit access to things like the log in form only to non-authenticated requests. It such a feature is required then the means to test for it must be provided as well. Regards, -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Dec 17 09:45:42 2008 From: lists at ruby-forum.com (James Byrne) Date: Wed, 17 Dec 2008 15:45:42 +0100 Subject: [rspec-users] step definitons to check login In-Reply-To: <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> Message-ID: <6422b880674431d4986181d803c5b78f@ruby-forum.com> Andrew Premdas wrote: > Doing this for Restful-Authentication I add the following in > features/support/env.rb > > # Make visible for testing > ApplicationController.send(:public, :logged_in?, :current_user, > :authorized?) > Forgive my ignorance but would you do me the favour of explaining exactly what this does? I can guess but I would rather have a clear understanding of how this construct works so that I can generalize its application. Regards, -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Dec 17 09:56:07 2008 From: lists at ruby-forum.com (James Byrne) Date: Wed, 17 Dec 2008 15:56:07 +0100 Subject: [rspec-users] step definitons to check login In-Reply-To: <6422b880674431d4986181d803c5b78f@ruby-forum.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <6422b880674431d4986181d803c5b78f@ruby-forum.com> Message-ID: Re: authlogin Can someone familiar with this gem explain where and how the user_sessions are maintained? I have pawed through the code but it has left me rather more confused than not. The best inkling I can arrive at is that the authlogic persistence token is stored in the session data and that the UserSession model serially searches sessions for that token string in whatever store medium that the Rails application is using. However, I cannot seem to identify exactly where and how this is done in the code. Advice would be welcome. -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Wed Dec 17 10:07:28 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 17 Dec 2008 07:07:28 -0800 Subject: [rspec-users] step definitons to check login In-Reply-To: (James Byrne's message of "Wed\, 17 Dec 2008 15\:44\:48 +0100") References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <85d99afe0812161730wf9556d0u12eab1de4fdba02e@mail.gmail.com> <85d99afe0812161740s22f3a1cbx656b521566d4c140@mail.gmail.com> Message-ID: James Byrne writes: > Zach Dennis wrote: >> On Tue, Dec 16, 2008 at 8:30 PM, Zach Dennis >> wrote: >>> >>> I know why you're doing it, but I just want to know *why* you're doing >>> it? Can you not tell through the application itself that someone is >>> logged in, logged out, and verify their identity without having to >>> expose the internals? >> > > In my case I am exploring the whole nature of BDD. Since experience, > much of it bad, is the best teacher I am trying to cram as much of it as > possible into the front end; before it gets expensive. > > Testing whether or not the application can detect and distinguish > between authenticated and non-authenticate requests where it matters is > important in my opinion. The situation being that some parts are > accessible anonymously and some are not. It might be considered > desirable to limit access to things like the log in form only to > non-authenticated requests. It such a feature is required then the > means to test for it must be provided as well. > > > Regards, I think Zach's point was that you can tell that someone is logged in if you see a "edit your profile" link somewhere, and they're not logged in if you see a "log in" link on the page. Yes, of course it's useful to know whether someone is authenticated or not...but you can test that through properties of your own app, rather than digging under the hood and calling the auth system directly. Pat From godfoca at gmail.com Wed Dec 17 10:17:19 2008 From: godfoca at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Sanguinetti?=) Date: Wed, 17 Dec 2008 13:17:19 -0200 Subject: [rspec-users] step definitons to check login In-Reply-To: <6422b880674431d4986181d803c5b78f@ruby-forum.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <6422b880674431d4986181d803c5b78f@ruby-forum.com> Message-ID: Module#public (a private method) works in one of two ways: 1) it receives a list of symbols with method names, those methods are decorated as public. 2) it receives no arguments, in which case all methods defined from that point forward (until another visibility declaration is encountered in the class definition or the class closed) are public. Same with Module#protected and Module#private. So what he's doing is turning logged_in?, current_user and authorized into public methods. Of course, a 30 second trip in google land would have led you to the ruby documentation, where you'd have found a good explanation with examples. Or, running `ri public` would've steered you in the right direction. -foca /me wishes people used ri more. On Wed, Dec 17, 2008 at 12:45 PM, James Byrne wrote: > > Andrew Premdas wrote: >> Doing this for Restful-Authentication I add the following in >> features/support/env.rb >> >> # Make visible for testing >> ApplicationController.send(:public, :logged_in?, :current_user, >> :authorized?) >> > > Forgive my ignorance but would you do me the favour of explaining > exactly what this does? I can guess but I would rather have a clear > understanding of how this construct works so that I can generalize its > application. > > Regards, > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Wed Dec 17 10:23:57 2008 From: lists at ruby-forum.com (James Byrne) Date: Wed, 17 Dec 2008 16:23:57 +0100 Subject: [rspec-users] step definitons to check login In-Reply-To: References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <85d99afe0812161730wf9556d0u12eab1de4fdba02e@mail.gmail.com> <85d99afe0812161740s22f3a1cbx656b521566d4c140@mail.gmail.com> Message-ID: Pat Maddox wrote: > James Byrne writes: > > I think Zach's point was that you can tell that someone is logged in if > you see a "edit your profile" link somewhere, and they're not logged in > if you see a "log in" link on the page. Yes, of course it's useful to > know whether someone is authenticated or not...but you can test that > through properties of your own app, rather than digging under the hood > and calling the auth system directly. > That is what I gathered from the "visits login_path" statement in David's example. Still, I am interested in finding out what other ways are possible to test for session authentication status and how implement them, if only to assure myself that they are not the way I want to do this. I have yet to unload a lot of baggage retained from previous experience. I am also trying to gain a comfort level with the authlogic gem. That desire is in part driving this quest. -- Posted via http://www.ruby-forum.com/. From ingo at ingoweiss.com Wed Dec 17 10:26:52 2008 From: ingo at ingoweiss.com (Ingo Weiss) Date: Wed, 17 Dec 2008 16:26:52 +0100 Subject: [rspec-users] Best practices for developing a rails plugin (extending ActiveRecord) with rspec? In-Reply-To: <6422b880674431d4986181d803c5b78f@ruby-forum.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <6422b880674431d4986181d803c5b78f@ruby-forum.com> Message-ID: <3DEB5406-7518-4EEB-9524-F4AEC6CA6E5F@ingoweiss.com> Hi all, I am developing a rails plugin/gem with rspec. The plugin extends ActiveRecord, so the specs basically needs a complete environment with database access to run. What is a good way to set this up in a way that can be bundled with the plugin, maybe in the form of a stripped- down rails and a sqlite db? Ingo From lists at ruby-forum.com Wed Dec 17 10:33:47 2008 From: lists at ruby-forum.com (James Byrne) Date: Wed, 17 Dec 2008 16:33:47 +0100 Subject: [rspec-users] step definitons to check login In-Reply-To: References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <6422b880674431d4986181d803c5b78f@ruby-forum.com> Message-ID: <286c58c236b75fbbaedd2e878b5e229c@ruby-forum.com> Nicol?s Sanguinetti wrote: > > Of course, a 30 second trip in google land would have led you to the > ruby documentation, where you'd have found a good explanation with > examples. Or, running `ri public` would've steered you in the right > direction. > > -foca > > /me wishes people used ri more. I have open on my desktop at this moment the rdocs for: Module Authlogic::ORMAdapters::ActiveRecordAdapter::ActsAsAuthentic::LoggedIn Class ActionController::Base I regret if my question upset you but it seemed to me a reasonable request at the time. Google is a wonderful tool. I use it a very great deal. But, it does require a certain facility with the topic to formulate effective searches. On this topic I fear that my capabilities are somewhat deficient. Your explanation was very helpful and informative. Thank you very much. -- Posted via http://www.ruby-forum.com/. From scott at railsnewbie.com Wed Dec 17 11:22:05 2008 From: scott at railsnewbie.com (Scott Taylor) Date: Wed, 17 Dec 2008 11:22:05 -0500 Subject: [rspec-users] Best practices for developing a rails plugin (extending ActiveRecord) with rspec? In-Reply-To: <3DEB5406-7518-4EEB-9524-F4AEC6CA6E5F@ingoweiss.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <6422b880674431d4986181d803c5b78f@ruby-forum.com> <3DEB5406-7518-4EEB-9524-F4AEC6CA6E5F@ingoweiss.com> Message-ID: <7C255779-63D8-4495-8B80-C485B77DC0CF@railsnewbie.com> On Dec 17, 2008, at 10:26 AM, Ingo Weiss wrote: > Hi all, > > I am developing a rails plugin/gem with rspec. The plugin extends > ActiveRecord, so the specs basically needs a complete environment > with database access to run. What is a good way to set this up in a > way that can be bundled with the plugin, maybe in the form of a > stripped-down rails and a sqlite db? Here's what I've used for FixtureReplacement in the past (which linoj generously contributed): https://gist.github.com/3525b4cb43f0710a0ac0 Scott From dchelimsky at gmail.com Wed Dec 17 11:56:48 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 17 Dec 2008 10:56:48 -0600 Subject: [rspec-users] step definitons to check login In-Reply-To: References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <85d99afe0812161730wf9556d0u12eab1de4fdba02e@mail.gmail.com> <85d99afe0812161740s22f3a1cbx656b521566d4c140@mail.gmail.com> Message-ID: <57c63afe0812170856k59fd0467lf4bf60e44b65406b@mail.gmail.com> On Wed, Dec 17, 2008 at 9:23 AM, James Byrne wrote: > Pat Maddox wrote: >> James Byrne writes: > >> >> I think Zach's point was that you can tell that someone is logged in if >> you see a "edit your profile" link somewhere, and they're not logged in >> if you see a "log in" link on the page. Yes, of course it's useful to >> know whether someone is authenticated or not...but you can test that >> through properties of your own app, rather than digging under the hood >> and calling the auth system directly. >> > > That is what I gathered from the "visits login_path" statement in > David's example. Still, I am interested in finding out what other ways > are possible to test for session authentication status and how implement > them, if only to assure myself that they are not the way I want to do > this. I have yet to unload a lot of baggage retained from previous > experience. You're a bit restricted in cucumber out of the box, because for rails, cucumber wraps ActionController::Integration::Session, which goes through routing. You don't have controller objects readily available. You have two options if you want to get at internals here (which should really be your last resort): 1. write a new World for cucumber that wraps ActionController::TestCase instead of ActionController::Integration::Session. You'd have to figure out a way to have that World loaded for some scenarios and the other loaded for others. 2. use rspec-rails for more granular inspection. In an rspec controller spec, you have access to the controller object. HTH, David > > I am also trying to gain a comfort level with the authlogic gem. That > desire is in part driving this quest. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pergesu at gmail.com Wed Dec 17 13:03:10 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 17 Dec 2008 10:03:10 -0800 Subject: [rspec-users] Best practices for developing a rails plugin (extending ActiveRecord) with rspec? In-Reply-To: <3DEB5406-7518-4EEB-9524-F4AEC6CA6E5F@ingoweiss.com> (Ingo Weiss's message of "Wed\, 17 Dec 2008 16\:26\:52 +0100") References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <6422b880674431d4986181d803c5b78f@ruby-forum.com> <3DEB5406-7518-4EEB-9524-F4AEC6CA6E5F@ingoweiss.com> Message-ID: Ingo Weiss writes: > Hi all, > > I am developing a rails plugin/gem with rspec. The plugin extends > ActiveRecord, so the specs basically needs a complete environment with > database access to run. What is a good way to set this up in a way > that can be bundled with the plugin, maybe in the form of a stripped- > down rails and a sqlite db? > > Ingo > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Hey Ingo, http://github.com/pat-maddox/rspec-plugin-generator/tree/master is a generator that allows you to easily generate plugins that use rspec, and will also set up a database if you pass it the --with-database option. Should be pretty self-explanatory if you generate one and look at the code. http://github.com/pat-maddox/acts_as_value_object/tree/master is a gem that I'm working on, extends activerecord as you need to do. Should be helpful. Pat From solaris at sundevil.de Wed Dec 17 13:19:52 2008 From: solaris at sundevil.de (Hendrik Volkmer) Date: Wed, 17 Dec 2008 19:19:52 +0100 Subject: [rspec-users] Best practices for developing a rails plugin (extending ActiveRecord) with rspec? In-Reply-To: <3DEB5406-7518-4EEB-9524-F4AEC6CA6E5F@ingoweiss.com> References: <00b68e0fc4aec651cc066eae14d3cf16@ruby-forum.com> <88fd8ddc0812161547q21ce6a6k8cb226e1624f1f1@mail.gmail.com> <85d99afe0812161552i7b62cfefk694ed78df2de8f43@mail.gmail.com> <88fd8ddc0812161648s55eb11d1od328e6777ac3d5bd@mail.gmail.com> <6422b880674431d4986181d803c5b78f@ruby-forum.com> <3DEB5406-7518-4EEB-9524-F4AEC6CA6E5F@ingoweiss.com> Message-ID: Hi Ingo, we use our own dry_plugin_test_helper [1] for almost all our plugin tests and it works fine. It provides a stripped down Rails environment inside the gem so that you don't need it in your plugin just to test your plugin code. We mainly use it with Test::Unit but I don't see why rspec wouldn't work. Cheers, Hendrik [1] http://github.com/imedo/dry_plugin_test_helper/tree/master -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at gmail.com Wed Dec 17 13:37:42 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Wed, 17 Dec 2008 16:37:42 -0200 Subject: [rspec-users] fixtures and associations Message-ID: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> Hello... I want ask for a help in error that don't understand. I have properties model and tenants model. Tenant belongs to Property and Property has many Tenants... I try this test association but allways get "not valid" error for association. Anyone can help? I post all my classes below: My Tenant class: class Tenant < ActiveRecord::Base belongs_to :property validates_associated :property validates_presence_of :property ... My tenant_spec.rb describe Tenant do fixtures :properties def create_tenant(options = {}) record = Tenant.create({ :property => properties(:two), :renters => "value for renters", :guarantor => "value for guarantor", :contact_name => "value for contact_name", :contact_phone => "value for contact_phone", :contact_email => "teste at hosttest.com", :end_date => Date.today, :beginning_date => Date.today, :initial_value => "9.99" }.merge(options)) end before(:each) do @tenant = create_tenant end it "should create a new instance given valid attributes" do @tenant.errors.should be_blank end ... My property_spec.rb class Property < ActiveRecord::Base has_many :tenants ... My properties.yml: two: user: aaron owner: tania address: Rua de teste address_number: 250 neighborhood: Bairro ABC country_state: MG country: Brasil city: Belo Horizonte cep: 30566500 area: 150m constructed_area: 120m category: galp?o usage: comercial owner_code: AS341ADV garage: 2 description: Casa com 3 quartos observation: condominium_value: 0 iptu_value: 90.50 Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Dec 17 14:18:03 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 17 Dec 2008 13:18:03 -0600 Subject: [rspec-users] fixtures and associations In-Reply-To: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> Message-ID: <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> On Wed, Dec 17, 2008 at 12:37 PM, Daniel Lopes wrote: > Hello... I want ask for a help in error that don't understand. > I have properties model and tenants model. Tenant belongs to Property and > Property has many Tenants... I try this test association but allways get > "not valid" error for association. Anyone can help? I post all my classes > below: > My Tenant class: > class Tenant < ActiveRecord::Base > belongs_to :property > > validates_associated :property > validates_presence_of :property > ... > My tenant_spec.rb > describe Tenant do > fixtures :properties > def create_tenant(options = {}) > record = Tenant.create({ > :property => properties(:two), > :renters => "value for renters", > :guarantor => "value for guarantor", > :contact_name => "value for contact_name", > :contact_phone => "value for contact_phone", > :contact_email => "teste at hosttest.com", > :end_date => Date.today, > :beginning_date => Date.today, > :initial_value => "9.99" > }.merge(options)) > end > > before(:each) do > @tenant = create_tenant > end > > it "should create a new instance given valid attributes" do > @tenant.errors.should be_blank > end > ... > My property_spec.rb > class Property < ActiveRecord::Base > has_many :tenants > ... > My properties.yml: > two: > user: aaron > owner: tania > address: Rua de teste > address_number: 250 > neighborhood: Bairro ABC > country_state: MG > country: Brasil > city: Belo Horizonte > cep: 30566500 > area: 150m > constructed_area: 120m > category: galp?o > usage: comercial > owner_code: AS341ADV > garage: 2 > description: Casa com 3 quartos > observation: > condominium_value: 0 > iptu_value: 90.50 Hi Daniel, Are both tenant_spec and property_spec failing? What are the failure messages you're getting? > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 From danielvlopes at gmail.com Wed Dec 17 14:40:08 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Wed, 17 Dec 2008 17:40:08 -0200 Subject: [rspec-users] fixtures and associations In-Reply-To: <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> Message-ID: <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> Hello David, the error is only in tenant_spec ... in property_spec all my examples passed. The error is in "@tenant.errors.should be_empty" line and the message is expected empty? to return true, got false If I use puts to print my @tenant object before the assertion I get those values: #["is not valid"]}, @base=#, created_at: nil, updated_at: nil, contact_email: "teste at hosttest.com">> Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Wed, Dec 17, 2008 at 5:18 PM, David Chelimsky wrote: > On Wed, Dec 17, 2008 at 12:37 PM, Daniel Lopes > wrote: > > Hello... I want ask for a help in error that don't understand. > > I have properties model and tenants model. Tenant belongs to Property and > > Property has many Tenants... I try this test association but allways get > > "not valid" error for association. Anyone can help? I post all my classes > > below: > > My Tenant class: > > class Tenant < ActiveRecord::Base > > belongs_to :property > > > > validates_associated :property > > validates_presence_of :property > > ... > > My tenant_spec.rb > > describe Tenant do > > fixtures :properties > > def create_tenant(options = {}) > > record = Tenant.create({ > > :property => properties(:two), > > :renters => "value for renters", > > :guarantor => "value for guarantor", > > :contact_name => "value for contact_name", > > :contact_phone => "value for contact_phone", > > :contact_email => "teste at hosttest.com", > > :end_date => Date.today, > > :beginning_date => Date.today, > > :initial_value => "9.99" > > }.merge(options)) > > end > > > > before(:each) do > > @tenant = create_tenant > > end > > > > it "should create a new instance given valid attributes" do > > @tenant.errors.should be_blank > > end > > ... > > My property_spec.rb > > class Property < ActiveRecord::Base > > has_many :tenants > > ... > > My properties.yml: > > two: > > user: aaron > > owner: tania > > address: Rua de teste > > address_number: 250 > > neighborhood: Bairro ABC > > country_state: MG > > country: Brasil > > city: Belo Horizonte > > cep: 30566500 > > area: 150m > > constructed_area: 120m > > category: galp?o > > usage: comercial > > owner_code: AS341ADV > > garage: 2 > > description: Casa com 3 quartos > > observation: > > condominium_value: 0 > > iptu_value: 90.50 > > Hi Daniel, > > Are both tenant_spec and property_spec failing? What are the failure > messages you're getting? > > > > > Atenciosamente, > > > > Daniel Lopes ? Area Cria??es > > Design, Websites e Sistemas Web > > > > Visite: http://www.areacriacoes.com.br/projects > > http://blog.areacriacoes.com.br/ > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > > * > > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Wed Dec 17 15:02:58 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 17 Dec 2008 12:02:58 -0800 Subject: [rspec-users] fixtures and associations In-Reply-To: <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> (Daniel Lopes's message of "Wed\, 17 Dec 2008 17\:40\:08 -0200") References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> Message-ID: Hi Daniel, What happens when you do properties(:two).valid? p properties(:two).errors It looks like that fixture is not valid. Pat "Daniel Lopes" writes: > Hello David, the error is only in tenant_spec ... in property_spec all my examples passed. The error is in "@tenant.errors.should be_empty" > line and the message is expected empty? to return true, got false > > If I use puts to print my @tenant object before the assertion I get those values: > > # @errors={"property"=>["is not valid"]}, > @base=# property_id: 996332877, > renters: "value for renters", > guarantor: "value for guarantor", > contact_name: "value for contact_name", > contact_phone: "value for contact_phone", > end_date: "2008-12-17", > beginning_date: "2008-12-17", > initial_value: #, > created_at: nil, > updated_at: nil, > contact_email: "teste at hosttest.com">> > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > On Wed, Dec 17, 2008 at 5:18 PM, David Chelimsky wrote: > > On Wed, Dec 17, 2008 at 12:37 PM, Daniel Lopes wrote: > > Hello... I want ask for a help in error that don't understand. > > I have properties model and tenants model. Tenant belongs to Property and > > Property has many Tenants... I try this test association but allways get > > "not valid" error for association. Anyone can help? I post all my classes > > below: > > My Tenant class: > > class Tenant < ActiveRecord::Base > > belongs_to :property > > > > validates_associated :property > > validates_presence_of :property > > ... > > My tenant_spec.rb > > describe Tenant do > > fixtures :properties > > def create_tenant(options = {}) > > record = Tenant.create({ > > :property => properties(:two), > > :renters => "value for renters", > > :guarantor => "value for guarantor", > > :contact_name => "value for contact_name", > > :contact_phone => "value for contact_phone", > > :contact_email => "teste at hosttest.com", > > :end_date => Date.today, > > :beginning_date => Date.today, > > :initial_value => "9.99" > > }.merge(options)) > > end > > > > before(:each) do > > @tenant = create_tenant > > end > > > > it "should create a new instance given valid attributes" do > > @tenant.errors.should be_blank > > end > > ... > > My property_spec.rb > > class Property < ActiveRecord::Base > > has_many :tenants > > ... > > My properties.yml: > > two: > > user: aaron > > owner: tania > > address: Rua de teste > > address_number: 250 > > neighborhood: Bairro ABC > > country_state: MG > > country: Brasil > > city: Belo Horizonte > > cep: 30566500 > > area: 150m > > constructed_area: 120m > > category: galp?o > > usage: comercial > > owner_code: AS341ADV > > garage: 2 > > description: Casa com 3 quartos > > observation: > > condominium_value: 0 > > iptu_value: 90.50 > > Hi Daniel, > > Are both tenant_spec and property_spec failing? What are the failure > messages you're getting? > > > > > Atenciosamente, > > > > Daniel Lopes ? Area Cria??es > > Design, Websites e Sistemas Web > > > > Visite: http://www.areacriacoes.com.br/projects > > http://blog.areacriacoes.com.br/ > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > > * > > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > _______________________________________________ > 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 danielvlopes at gmail.com Wed Dec 17 15:26:44 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Wed, 17 Dec 2008 18:26:44 -0200 Subject: [rspec-users] fixtures and associations In-Reply-To: References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> Message-ID: <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> I get cannot be null error user in active record object... like below: properties(:two).valid? return false, but I don't understand why... because my properties.yml file is like below: two: user: aaron owner: tania address: Rua de teste address_number: 250 neighborhood: Bairro ABC ... and my users.yml is: aaron: id: 2 login: aaron name: aaron lorem email: aaron at rspectest.com ... But my activerecord object return this: #["can't be blank"]}, @base=#, iptu_value: #, garage: 2, description: "Casa com 3 quartos", observation: nil, cep: "30566500", country_state: "MG", created_at: "2008-12-17 20:11:11", updated_at: "2008-12-17 20:11:11", zoning: "z10" >> But it is not blank. What i'm doing wrong on my fixtures files? I think I don't get the message yet in other model spec because this is the fist model that use properties.yml ( in properties_spec I only use fixtures for users ) Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Wed, Dec 17, 2008 at 6:02 PM, Pat Maddox wrote: > Hi Daniel, > > What happens when you do > > properties(:two).valid? > p properties(:two).errors > > It looks like that fixture is not valid. > > Pat > > "Daniel Lopes" writes: > > > Hello David, the error is only in tenant_spec ... in property_spec all my > examples passed. The error is in "@tenant.errors.should be_empty" > > line and the message is expected empty? to return true, got false > > > > If I use puts to print my @tenant object before the assertion I get those > values: > > > > # > @errors={"property"=>["is not valid"]}, > > @base=# > property_id: 996332877, > > renters: "value for renters", > > guarantor: "value for guarantor", > > contact_name: "value for contact_name", > > contact_phone: "value for contact_phone", > > end_date: "2008-12-17", > > beginning_date: "2008-12-17", > > initial_value: #, > > created_at: nil, > > updated_at: nil, > > contact_email: "teste at hosttest.com">> > > > > Atenciosamente, > > > > Daniel Lopes ? Area Cria??es > > Design, Websites e Sistemas Web > > > > Visite: http://www.areacriacoes.com.br/projects > > http://blog.areacriacoes.com.br/ > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * > > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > > On Wed, Dec 17, 2008 at 5:18 PM, David Chelimsky > wrote: > > > > On Wed, Dec 17, 2008 at 12:37 PM, Daniel Lopes < > danielvlopes at gmail.com> wrote: > > > Hello... I want ask for a help in error that don't understand. > > > I have properties model and tenants model. Tenant belongs to > Property and > > > Property has many Tenants... I try this test association but > allways get > > > "not valid" error for association. Anyone can help? I post all my > classes > > > below: > > > My Tenant class: > > > class Tenant < ActiveRecord::Base > > > belongs_to :property > > > > > > validates_associated :property > > > validates_presence_of :property > > > ... > > > My tenant_spec.rb > > > describe Tenant do > > > fixtures :properties > > > def create_tenant(options = {}) > > > record = Tenant.create({ > > > :property => properties(:two), > > > :renters => "value for renters", > > > :guarantor => "value for guarantor", > > > :contact_name => "value for contact_name", > > > :contact_phone => "value for contact_phone", > > > :contact_email => "teste at hosttest.com", > > > :end_date => Date.today, > > > :beginning_date => Date.today, > > > :initial_value => "9.99" > > > }.merge(options)) > > > end > > > > > > before(:each) do > > > @tenant = create_tenant > > > end > > > > > > it "should create a new instance given valid attributes" do > > > @tenant.errors.should be_blank > > > end > > > ... > > > My property_spec.rb > > > class Property < ActiveRecord::Base > > > has_many :tenants > > > ... > > > My properties.yml: > > > two: > > > user: aaron > > > owner: tania > > > address: Rua de teste > > > address_number: 250 > > > neighborhood: Bairro ABC > > > country_state: MG > > > country: Brasil > > > city: Belo Horizonte > > > cep: 30566500 > > > area: 150m > > > constructed_area: 120m > > > category: galp?o > > > usage: comercial > > > owner_code: AS341ADV > > > garage: 2 > > > description: Casa com 3 quartos > > > observation: > > > condominium_value: 0 > > > iptu_value: 90.50 > > > > Hi Daniel, > > > > Are both tenant_spec and property_spec failing? What are the failure > > messages you're getting? > > > > > > > > Atenciosamente, > > > > > > Daniel Lopes ? Area Cria??es > > > Design, Websites e Sistemas Web > > > > > > Visite: http://www.areacriacoes.com.br/projects > > > http://blog.areacriacoes.com.br/ > > > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * * > > > * > > > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From walketim at gmail.com Wed Dec 17 15:34:59 2008 From: walketim at gmail.com (Tim Walker) Date: Wed, 17 Dec 2008 13:34:59 -0700 Subject: [rspec-users] [Cucumber] a few clarifications please... Message-ID: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> Hi Guys, Things are working great with Cucumber and am getting better at expressing requirements as behaviors. Kudos! I seek a couple of points of clarification, or confirmation, if someone has a minute or two... FWIW - I've read the wiki and the given-when-then page and just seek confirmation: There is no dependency implied in the keywords "given", "then" and "when" (as well as "and" and "but), correct? These are simply naming conventions that denote the well known "Build/Operate/Check" pattern but have no real physical relationship, they're just tags that denote the steps. A "pending" step is any step that has a matching step but nothing is implemented. A "successful" step is any step that is matched, has some code and doesn't assert anything resolving to false. A "gray" out step means that no steps were found that matched the feature. You need to be careful that features do not match steps in the step file or cucumber will execute the first step it finds that matches (really don't know how this works, will a test sequence ever go 'backwards'?) Going back and changing the stuff in the .feature file is risky as it's very easy to create a mismatch and the step won't be found. Thanks very much, Tim From pergesu at gmail.com Wed Dec 17 16:07:42 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 17 Dec 2008 13:07:42 -0800 Subject: [rspec-users] fixtures and associations In-Reply-To: <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> (Daniel Lopes's message of "Wed\, 17 Dec 2008 18\:26\:44 -0200") References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> Message-ID: You are loading the users fixtures. You need to change your fixtures line to read fixtures :properties, :users (and any other models' fixtures you want to use) I highly recommend ditching fixtures all together. You avoid funky shit like this, and you won't have coupling between tests that occurs with fixtures, and you'll be able to create more clear specs because you do all the setup in the spec itself. If you're interested, look into something like fixtures_replacement, factory girl, object daddy, etc. Personally, I use a little 15-line homebrew framework. Pat "Daniel Lopes" writes: > I get cannot be null error user in active record object... like below: > > properties(:two).valid? return false, but I don't understand why... because my properties.yml file is like below: > > two: > user: aaron > owner: tania > address: Rua de teste > address_number: 250 > neighborhood: Bairro ABC > ... > > and my users.yml is: > > aaron: > id: 2 > login: aaron > name: aaron lorem > email: aaron at rspectest.com > ... > > But my activerecord object return this: > > #["can't be blank"]}, > @base=# user_id: 317248456, > owner_id: 465176508, > address: "Rua de teste", > address_number: "250", > neighborhood: "Bairro ABC", > country: "Brasil", > city: "Belo Horizonte", > area: "150m", > constructed_area: "120m", > category: "galp?o", > usage: "comercial", > owner_code: "AS341ADV", > condominium_value: #, > iptu_value: #, > garage: 2, > description: "Casa com 3 quartos", > observation: nil, > cep: "30566500", > country_state: "MG", > created_at: "2008-12-17 20:11:11", > updated_at: "2008-12-17 20:11:11", > zoning: "z10" >> > > But it is not blank. What i'm doing wrong on my fixtures files? I think I don't get the message yet in other model spec because this is the > fist model that use properties.yml ( in properties_spec I only use fixtures for users ) > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > On Wed, Dec 17, 2008 at 6:02 PM, Pat Maddox wrote: > > Hi Daniel, > > What happens when you do > > properties(:two).valid? > p properties(:two).errors > > It looks like that fixture is not valid. > > Pat > > "Daniel Lopes" writes: > > > Hello David, the error is only in tenant_spec ... in property_spec all my examples passed. The error is in "@tenant.errors.should > be_empty" > > line and the message is expected empty? to return true, got false > > > > If I use puts to print my @tenant object before the assertion I get those values: > > > > # > @errors={"property"=>["is not valid"]}, > > @base=# > property_id: 996332877, > > renters: "value for renters", > > guarantor: "value for guarantor", > > contact_name: "value for contact_name", > > contact_phone: "value for contact_phone", > > end_date: "2008-12-17", > > beginning_date: "2008-12-17", > > initial_value: #, > > created_at: nil, > > updated_at: nil, > > contact_email: "teste at hosttest.com">> > > > > Atenciosamente, > > > > Daniel Lopes ? Area Cria??es > > Design, Websites e Sistemas Web > > > > Visite: http://www.areacriacoes.com.br/projects > > http://blog.areacriacoes.com.br/ > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > > On Wed, Dec 17, 2008 at 5:18 PM, David Chelimsky wrote: > > > > On Wed, Dec 17, 2008 at 12:37 PM, Daniel Lopes wrote: > > > Hello... I want ask for a help in error that don't understand. > > > I have properties model and tenants model. Tenant belongs to Property and > > > Property has many Tenants... I try this test association but allways get > > > "not valid" error for association. Anyone can help? I post all my classes > > > below: > > > My Tenant class: > > > class Tenant < ActiveRecord::Base > > > belongs_to :property > > > > > > validates_associated :property > > > validates_presence_of :property > > > ... > > > My tenant_spec.rb > > > describe Tenant do > > > fixtures :properties > > > def create_tenant(options = {}) > > > record = Tenant.create({ > > > :property => properties(:two), > > > :renters => "value for renters", > > > :guarantor => "value for guarantor", > > > :contact_name => "value for contact_name", > > > :contact_phone => "value for contact_phone", > > > :contact_email => "teste at hosttest.com", > > > :end_date => Date.today, > > > :beginning_date => Date.today, > > > :initial_value => "9.99" > > > }.merge(options)) > > > end > > > > > > before(:each) do > > > @tenant = create_tenant > > > end > > > > > > it "should create a new instance given valid attributes" do > > > @tenant.errors.should be_blank > > > end > > > ... > > > My property_spec.rb > > > class Property < ActiveRecord::Base > > > has_many :tenants > > > ... > > > My properties.yml: > > > two: > > > user: aaron > > > owner: tania > > > address: Rua de teste > > > address_number: 250 > > > neighborhood: Bairro ABC > > > country_state: MG > > > country: Brasil > > > city: Belo Horizonte > > > cep: 30566500 > > > area: 150m > > > constructed_area: 120m > > > category: galp?o > > > usage: comercial > > > owner_code: AS341ADV > > > garage: 2 > > > description: Casa com 3 quartos > > > observation: > > > condominium_value: 0 > > > iptu_value: 90.50 > > > > Hi Daniel, > > > > Are both tenant_spec and property_spec failing? What are the failure > > messages you're getting? > > > > > > > > Atenciosamente, > > > > > > Daniel Lopes ? Area Cria??es > > > Design, Websites e Sistemas Web > > > > > > Visite: http://www.areacriacoes.com.br/projects > > > http://blog.areacriacoes.com.br/ > > > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > > > * > > > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > _______________________________________________ > > 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From walketim at gmail.com Wed Dec 17 16:14:11 2008 From: walketim at gmail.com (Tim Walker) Date: Wed, 17 Dec 2008 14:14:11 -0700 Subject: [rspec-users] [cucumber] before/after scenarios Message-ID: <1ebf5a4d0812171314n4faf2f49x55d6086483a45fc1@mail.gmail.com> Hi Guys, Sorry for the double-whine but I've seen references to these listeners but not a lot of luck finding any details. So...that's it: Setup/Teardown Before/After scenarios...what's the scoop? Thanks, Tim (Also, the logo's are looking awesome!) From dchelimsky at gmail.com Wed Dec 17 16:22:40 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 17 Dec 2008 15:22:40 -0600 Subject: [rspec-users] [Cucumber] a few clarifications please... In-Reply-To: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> References: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> Message-ID: <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker wrote: > Hi Guys, > > Things are working great with Cucumber and am getting better at > expressing requirements as behaviors. Kudos! > > I seek a couple of points of clarification, or confirmation, if > someone has a minute or two... > > FWIW - I've read the wiki and the given-when-then page and just seek > confirmation: > > There is no dependency implied in the keywords "given", "then" and > "when" (as well as "and" and "but), correct? These are simply naming > conventions that denote the well known "Build/Operate/Check" pattern > but have no real physical relationship, they're just tags that denote > the steps. Correct. > A "pending" step is any step that has a matching step but nothing is > implemented. Correct. > A "successful" step is any step that is matched, has some code and > doesn't assert anything resolving to false. Or raise an error. > A "gray" out step means that no steps were found that matched the feature. Blue? Means that a step was found, but a previous step was either pending or failed. > You need to be careful that features do not match steps in the step > file or cucumber will execute the first step it finds that matches > (really don't know how this works, will a test sequence ever go > 'backwards'?) Cucumber tells you when it finds two steps definitions that could match the step in the feature. > Going back and changing the stuff in the .feature file is risky as > it's very easy to create a mismatch and the step won't be found. Not sure why that is risky, unless you mean that there are non-developers making these changes. If so, then they should probably be made collaboratively. > > Thanks very much, > > Tim > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From josephwilk at joesniff.co.uk Wed Dec 17 16:23:05 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Wed, 17 Dec 2008 21:23:05 +0000 Subject: [rspec-users] [cucumber] before/after scenarios In-Reply-To: <1ebf5a4d0812171314n4faf2f49x55d6086483a45fc1@mail.gmail.com> References: <1ebf5a4d0812171314n4faf2f49x55d6086483a45fc1@mail.gmail.com> Message-ID: <49496DB9.4020609@joesniff.co.uk> Tim Walker wrote: > Hi Guys, > > Sorry for the double-whine but I've seen references to these listeners > but not a lot of luck finding any details. > > So...that's it: Setup/Teardown Before/After scenarios...what's the scoop? > http://github.com/aslakhellesoy/cucumber/wikis/hooks Does the information here answer your questions or do you think its missing some details? HTH -- Joseph Wilk http://blog.josephwilk.net > Thanks, > > Tim > (Also, the logo's are looking awesome!) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > From dchelimsky at gmail.com Wed Dec 17 16:23:09 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 17 Dec 2008 15:23:09 -0600 Subject: [rspec-users] [cucumber] before/after scenarios In-Reply-To: <1ebf5a4d0812171314n4faf2f49x55d6086483a45fc1@mail.gmail.com> References: <1ebf5a4d0812171314n4faf2f49x55d6086483a45fc1@mail.gmail.com> Message-ID: <57c63afe0812171323w743cd680y47a0cec54dc9d041@mail.gmail.com> On Wed, Dec 17, 2008 at 3:14 PM, Tim Walker wrote: > Hi Guys, > > Sorry for the double-whine but I've seen references to these listeners > but not a lot of luck finding any details. > > So...that's it: Setup/Teardown Before/After scenarios...what's the scoop? That's it. > > Thanks, > > Tim > (Also, the logo's are looking awesome!) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Wed Dec 17 16:25:56 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 17 Dec 2008 14:25:56 -0700 Subject: [rspec-users] [cucumber] before/after scenarios In-Reply-To: <1ebf5a4d0812171314n4faf2f49x55d6086483a45fc1@mail.gmail.com> References: <1ebf5a4d0812171314n4faf2f49x55d6086483a45fc1@mail.gmail.com> Message-ID: <49496E64.7050104@benmabey.com> Tim Walker wrote: > Hi Guys, > > Sorry for the double-whine but I've seen references to these listeners > but not a lot of luck finding any details. > > So...that's it: Setup/Teardown Before/After scenarios...what's the scoop? > > Thanks, > > Tim > (Also, the logo's are looking awesome!) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Hey Tim, The 'Hooks' and "RSpec Stories Migration' pages on the wiki has some information on this. Have you looked at those pages? If you have and are still confused, could you be more specific on what you are needing to do? -Ben From walketim at gmail.com Wed Dec 17 16:37:07 2008 From: walketim at gmail.com (Tim Walker) Date: Wed, 17 Dec 2008 14:37:07 -0700 Subject: [rspec-users] [Cucumber] a few clarifications please... In-Reply-To: <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> References: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> Message-ID: <1ebf5a4d0812171337y392a1279le2875cb8bdc1d372@mail.gmail.com> Thank you David. This helps a lot. Question, if there are matching steps...will cucumber find the first matching step during execution? I noticed a test executing at higher line numbers and then picking up a step with a lower line number. Thanks again, Tim On Wed, Dec 17, 2008 at 2:22 PM, David Chelimsky wrote: > On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker wrote: >> Hi Guys, >> >> Things are working great with Cucumber and am getting better at >> expressing requirements as behaviors. Kudos! >> >> I seek a couple of points of clarification, or confirmation, if >> someone has a minute or two... >> >> FWIW - I've read the wiki and the given-when-then page and just seek >> confirmation: >> >> There is no dependency implied in the keywords "given", "then" and >> "when" (as well as "and" and "but), correct? These are simply naming >> conventions that denote the well known "Build/Operate/Check" pattern >> but have no real physical relationship, they're just tags that denote >> the steps. > > Correct. > >> A "pending" step is any step that has a matching step but nothing is >> implemented. > > Correct. > >> A "successful" step is any step that is matched, has some code and >> doesn't assert anything resolving to false. > > Or raise an error. > >> A "gray" out step means that no steps were found that matched the feature. > > Blue? Means that a step was found, but a previous step was either > pending or failed. > >> You need to be careful that features do not match steps in the step >> file or cucumber will execute the first step it finds that matches >> (really don't know how this works, will a test sequence ever go >> 'backwards'?) > > Cucumber tells you when it finds two steps definitions that could > match the step in the feature. > >> Going back and changing the stuff in the .feature file is risky as >> it's very easy to create a mismatch and the step won't be found. > > Not sure why that is risky, unless you mean that there are > non-developers making these changes. If so, then they should probably > be made collaboratively. > >> >> Thanks very much, >> >> Tim >> _______________________________________________ >> 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 josephwilk at joesniff.co.uk Wed Dec 17 16:39:17 2008 From: josephwilk at joesniff.co.uk (Joseph Wilk) Date: Wed, 17 Dec 2008 21:39:17 +0000 Subject: [rspec-users] [Cucumber] a few clarifications please... In-Reply-To: <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> References: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> Message-ID: <49497185.7060107@joesniff.co.uk> David Chelimsky wrote: > On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker wrote: > >> Hi Guys, >> >> Things are working great with Cucumber and am getting better at >> expressing requirements as behaviors. Kudos! >> >> I seek a couple of points of clarification, or confirmation, if >> someone has a minute or two... >> >> FWIW - I've read the wiki and the given-when-then page and just seek >> confirmation: >> >> There is no dependency implied in the keywords "given", "then" and >> "when" (as well as "and" and "but), correct? These are simply naming >> conventions that denote the well known "Build/Operate/Check" pattern >> but have no real physical relationship, they're just tags that denote >> the steps. >> > > Correct. > > >> A "pending" step is any step that has a matching step but nothing is >> implemented. >> > > Correct. > In the latest version in Github (0.1.13) you can also force steps which have an implementation to the pending state using the 'pending' method which works in the same way as Rspec's pending. When "I want to be lazy" do pending "Implement me!" end -- Joseph Wilk http://blog.josephwilk.net > >> A "successful" step is any step that is matched, has some code and >> doesn't assert anything resolving to false. >> > > Or raise an error. > > >> A "gray" out step means that no steps were found that matched the feature. >> > > Blue? Means that a step was found, but a previous step was either > pending or failed. > > >> You need to be careful that features do not match steps in the step >> file or cucumber will execute the first step it finds that matches >> (really don't know how this works, will a test sequence ever go >> 'backwards'?) >> > > Cucumber tells you when it finds two steps definitions that could > match the step in the feature. > > >> Going back and changing the stuff in the .feature file is risky as >> it's very easy to create a mismatch and the step won't be found. >> > > Not sure why that is risky, unless you mean that there are > non-developers making these changes. If so, then they should probably > be made collaboratively. > > >> Thanks very much, >> >> Tim >> _______________________________________________ >> 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 Wed Dec 17 16:53:10 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 17 Dec 2008 15:53:10 -0600 Subject: [rspec-users] [Cucumber] a few clarifications please... In-Reply-To: <1ebf5a4d0812171337y392a1279le2875cb8bdc1d372@mail.gmail.com> References: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> <1ebf5a4d0812171337y392a1279le2875cb8bdc1d372@mail.gmail.com> Message-ID: <57c63afe0812171353w65d1a8a6u69e1a89fd9e31f3c@mail.gmail.com> On Wed, Dec 17, 2008 at 3:37 PM, Tim Walker wrote: > Thank you David. This helps a lot. Question, if there are matching > steps...will cucumber find the first matching step during execution? I > noticed a test executing at higher line numbers and then picking up a > step with a lower line number. Again, cucumber looks at all of the steps and throws an error if more than one will match your step. So order should not be an issue. > > Thanks again, > > Tim > > On Wed, Dec 17, 2008 at 2:22 PM, David Chelimsky wrote: >> On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker wrote: >>> Hi Guys, >>> >>> Things are working great with Cucumber and am getting better at >>> expressing requirements as behaviors. Kudos! >>> >>> I seek a couple of points of clarification, or confirmation, if >>> someone has a minute or two... >>> >>> FWIW - I've read the wiki and the given-when-then page and just seek >>> confirmation: >>> >>> There is no dependency implied in the keywords "given", "then" and >>> "when" (as well as "and" and "but), correct? These are simply naming >>> conventions that denote the well known "Build/Operate/Check" pattern >>> but have no real physical relationship, they're just tags that denote >>> the steps. >> >> Correct. >> >>> A "pending" step is any step that has a matching step but nothing is >>> implemented. >> >> Correct. >> >>> A "successful" step is any step that is matched, has some code and >>> doesn't assert anything resolving to false. >> >> Or raise an error. >> >>> A "gray" out step means that no steps were found that matched the feature. >> >> Blue? Means that a step was found, but a previous step was either >> pending or failed. >> >>> You need to be careful that features do not match steps in the step >>> file or cucumber will execute the first step it finds that matches >>> (really don't know how this works, will a test sequence ever go >>> 'backwards'?) >> >> Cucumber tells you when it finds two steps definitions that could >> match the step in the feature. >> >>> Going back and changing the stuff in the .feature file is risky as >>> it's very easy to create a mismatch and the step won't be found. >> >> Not sure why that is risky, unless you mean that there are >> non-developers making these changes. If so, then they should probably >> be made collaboratively. >> >>> >>> Thanks very much, >>> >>> Tim >>> _______________________________________________ >>> 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 walketim at gmail.com Wed Dec 17 16:58:07 2008 From: walketim at gmail.com (Tim Walker) Date: Wed, 17 Dec 2008 14:58:07 -0700 Subject: [rspec-users] [Cucumber] Autotest and multiple scenarios Message-ID: <1ebf5a4d0812171358j3ce1e30bhac808ea2395afbd9@mail.gmail.com> Hi Guys, Using AUTOFEATURE=true autospec and have a feature with multiple scenarios. When we save the feature or steps file AUTOTEST seems to only run the last scenario. Is this a known issue or are we doing something boneheaded, or both!? Thanks, Tim From danielvlopes at gmail.com Wed Dec 17 17:13:43 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Wed, 17 Dec 2008 20:13:43 -0200 Subject: [rspec-users] fixtures and associations In-Reply-To: References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> Message-ID: <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> Hello Pat, even I load all my fixtures it still not reading anything from users.yml ... I will look at factory_girl but before I need understand what happening. I try this: require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Tenant do fixtures :properties, :users , :owners def create_tenant(options = {}) record = Tenant.create({ :property => properties(:two), :renters => "value for renters", :guarantor => "value for guarantor", :contact_name => "value for contact_name", :contact_phone => "value for contact_phone", :contact_email => "teste at hosttest.com", :end_date => Date.today, :beginning_date => Date.today, :initial_value => "9.99" }.merge(options)) end before(:each) do @tenant = create_tenant end it "should create a new instance given valid attributes" do p properties(:two).errors properties(:two).should be_valid # @tenant.errors.should be_empty end end Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Wed, Dec 17, 2008 at 7:07 PM, Pat Maddox wrote: > You are loading the users fixtures. You need to change your fixtures > line to read > > fixtures :properties, :users > > (and any other models' fixtures you want to use) > > I highly recommend ditching fixtures all together. You avoid funky shit > like this, and you won't have coupling between tests that occurs with > fixtures, and you'll be able to create more clear specs because you do > all the setup in the spec itself. If you're interested, look into > something like fixtures_replacement, factory girl, object daddy, etc. > Personally, I use a little 15-line homebrew framework. > > Pat > > > "Daniel Lopes" writes: > > > I get cannot be null error user in active record object... like below: > > > > properties(:two).valid? return false, but I don't understand why... > because my properties.yml file is like below: > > > > two: > > user: aaron > > owner: tania > > address: Rua de teste > > address_number: 250 > > neighborhood: Bairro ABC > > ... > > > > and my users.yml is: > > > > aaron: > > id: 2 > > login: aaron > > name: aaron lorem > > email: aaron at rspectest.com > > ... > > > > But my activerecord object return this: > > > > #["can't be blank"]}, > > @base=# > user_id: 317248456, > > owner_id: 465176508, > > address: "Rua de teste", > > address_number: "250", > > neighborhood: "Bairro ABC", > > country: "Brasil", > > city: "Belo Horizonte", > > area: "150m", > > constructed_area: "120m", > > category: "galp?o", > > usage: "comercial", > > owner_code: "AS341ADV", > > condominium_value: #, > > iptu_value: #, > > garage: 2, > > description: "Casa com 3 quartos", > > observation: nil, > > cep: "30566500", > > country_state: "MG", > > created_at: "2008-12-17 20:11:11", > > updated_at: "2008-12-17 20:11:11", > > zoning: "z10" >> > > > > But it is not blank. What i'm doing wrong on my fixtures files? I think I > don't get the message yet in other model spec because this is the > > fist model that use properties.yml ( in properties_spec I only use > fixtures for users ) > > > > Atenciosamente, > > > > Daniel Lopes ? Area Cria??es > > Design, Websites e Sistemas Web > > > > Visite: http://www.areacriacoes.com.br/projects > > http://blog.areacriacoes.com.br/ > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * > > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > > On Wed, Dec 17, 2008 at 6:02 PM, Pat Maddox wrote: > > > > Hi Daniel, > > > > What happens when you do > > > > properties(:two).valid? > > p properties(:two).errors > > > > It looks like that fixture is not valid. > > > > Pat > > > > "Daniel Lopes" writes: > > > > > Hello David, the error is only in tenant_spec ... in property_spec > all my examples passed. The error is in "@tenant.errors.should > > be_empty" > > > line and the message is expected empty? to return true, got false > > > > > > If I use puts to print my @tenant object before the assertion I get > those values: > > > > > > # > > @errors={"property"=>["is not valid"]}, > > > @base=# > > property_id: 996332877, > > > renters: "value for renters", > > > guarantor: "value for guarantor", > > > contact_name: "value for contact_name", > > > contact_phone: "value for contact_phone", > > > end_date: "2008-12-17", > > > beginning_date: "2008-12-17", > > > initial_value: #, > > > created_at: nil, > > > updated_at: nil, > > > contact_email: "teste at hosttest.com">> > > > > > > Atenciosamente, > > > > > > Daniel Lopes ? Area Cria??es > > > Design, Websites e Sistemas Web > > > > > > Visite: http://www.areacriacoes.com.br/projects > > > http://blog.areacriacoes.com.br/ > > > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * * * > > > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > > > > On Wed, Dec 17, 2008 at 5:18 PM, David Chelimsky < > dchelimsky at gmail.com> wrote: > > > > > > On Wed, Dec 17, 2008 at 12:37 PM, Daniel Lopes < > danielvlopes at gmail.com> wrote: > > > > Hello... I want ask for a help in error that don't > understand. > > > > I have properties model and tenants model. Tenant belongs to > Property and > > > > Property has many Tenants... I try this test association but > allways get > > > > "not valid" error for association. Anyone can help? I post > all my classes > > > > below: > > > > My Tenant class: > > > > class Tenant < ActiveRecord::Base > > > > belongs_to :property > > > > > > > > validates_associated :property > > > > validates_presence_of :property > > > > ... > > > > My tenant_spec.rb > > > > describe Tenant do > > > > fixtures :properties > > > > def create_tenant(options = {}) > > > > record = Tenant.create({ > > > > :property => properties(:two), > > > > :renters => "value for renters", > > > > :guarantor => "value for guarantor", > > > > :contact_name => "value for contact_name", > > > > :contact_phone => "value for contact_phone", > > > > :contact_email => "teste at hosttest.com", > > > > :end_date => Date.today, > > > > :beginning_date => Date.today, > > > > :initial_value => "9.99" > > > > }.merge(options)) > > > > end > > > > > > > > before(:each) do > > > > @tenant = create_tenant > > > > end > > > > > > > > it "should create a new instance given valid attributes" do > > > > @tenant.errors.should be_blank > > > > end > > > > ... > > > > My property_spec.rb > > > > class Property < ActiveRecord::Base > > > > has_many :tenants > > > > ... > > > > My properties.yml: > > > > two: > > > > user: aaron > > > > owner: tania > > > > address: Rua de teste > > > > address_number: 250 > > > > neighborhood: Bairro ABC > > > > country_state: MG > > > > country: Brasil > > > > city: Belo Horizonte > > > > cep: 30566500 > > > > area: 150m > > > > constructed_area: 120m > > > > category: galp?o > > > > usage: comercial > > > > owner_code: AS341ADV > > > > garage: 2 > > > > description: Casa com 3 quartos > > > > observation: > > > > condominium_value: 0 > > > > iptu_value: 90.50 > > > > > > Hi Daniel, > > > > > > Are both tenant_spec and property_spec failing? What are the > failure > > > messages you're getting? > > > > > > > > > > > Atenciosamente, > > > > > > > > Daniel Lopes ? Area Cria??es > > > > Design, Websites e Sistemas Web > > > > > > > > Visite: http://www.areacriacoes.com.br/projects > > > > http://blog.areacriacoes.com.br/ > > > > > > > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * * * * * > > > > * > > > > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > _______________________________________________ > > > 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 > > > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From walketim at gmail.com Wed Dec 17 17:50:31 2008 From: walketim at gmail.com (Tim Walker) Date: Wed, 17 Dec 2008 15:50:31 -0700 Subject: [rspec-users] [Cucumber] a few clarifications please... In-Reply-To: <49497185.7060107@joesniff.co.uk> References: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> <49497185.7060107@joesniff.co.uk> Message-ID: <1ebf5a4d0812171450x339f2726n5b892f7ba5b9b3f9@mail.gmail.com> Great information guys, making some progress on this end. It is much appreciated. Discovered that step definitions can not be duplicated even across step files. Is this correct? Thanks again. Sincerely, Tim On Wed, Dec 17, 2008 at 2:39 PM, Joseph Wilk wrote: > David Chelimsky wrote: >> >> On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker wrote: >> >>> >>> Hi Guys, >>> >>> Things are working great with Cucumber and am getting better at >>> expressing requirements as behaviors. Kudos! >>> >>> I seek a couple of points of clarification, or confirmation, if >>> someone has a minute or two... >>> >>> FWIW - I've read the wiki and the given-when-then page and just seek >>> confirmation: >>> >>> There is no dependency implied in the keywords "given", "then" and >>> "when" (as well as "and" and "but), correct? These are simply naming >>> conventions that denote the well known "Build/Operate/Check" pattern >>> but have no real physical relationship, they're just tags that denote >>> the steps. >>> >> >> Correct. >> >> >>> >>> A "pending" step is any step that has a matching step but nothing is >>> implemented. >>> >> >> Correct. >> > > In the latest version in Github (0.1.13) you can also force steps which have > an implementation to the pending state using the 'pending' method which > works in the same way as Rspec's pending. > > When "I want to be lazy" do > pending "Implement me!" > end > > -- > Joseph Wilk > http://blog.josephwilk.net > >> >>> >>> A "successful" step is any step that is matched, has some code and >>> doesn't assert anything resolving to false. >>> >> >> Or raise an error. >> >> >>> >>> A "gray" out step means that no steps were found that matched the >>> feature. >>> >> >> Blue? Means that a step was found, but a previous step was either >> pending or failed. >> >> >>> >>> You need to be careful that features do not match steps in the step >>> file or cucumber will execute the first step it finds that matches >>> (really don't know how this works, will a test sequence ever go >>> 'backwards'?) >>> >> >> Cucumber tells you when it finds two steps definitions that could >> match the step in the feature. >> >> >>> >>> Going back and changing the stuff in the .feature file is risky as >>> it's very easy to create a mismatch and the step won't be found. >>> >> >> Not sure why that is risky, unless you mean that there are >> non-developers making these changes. If so, then they should probably >> be made collaboratively. >> >> >>> >>> Thanks very much, >>> >>> Tim >>> _______________________________________________ >>> 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 aslak.hellesoy at gmail.com Wed Dec 17 17:51:37 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 17 Dec 2008 23:51:37 +0100 Subject: [rspec-users] [Cucumber] a few clarifications please... In-Reply-To: <57c63afe0812171353w65d1a8a6u69e1a89fd9e31f3c@mail.gmail.com> References: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> <1ebf5a4d0812171337y392a1279le2875cb8bdc1d372@mail.gmail.com> <57c63afe0812171353w65d1a8a6u69e1a89fd9e31f3c@mail.gmail.com> Message-ID: <8d961d900812171451x6ea578fdv6e120fd3b34bbb23@mail.gmail.com> On Wed, Dec 17, 2008 at 10:53 PM, David Chelimsky wrote: > On Wed, Dec 17, 2008 at 3:37 PM, Tim Walker wrote: > > Thank you David. This helps a lot. Question, if there are matching > > steps...will cucumber find the first matching step during execution? I > > noticed a test executing at higher line numbers and then picking up a > > step with a lower line number. > > Again, cucumber looks at all of the steps and throws an error if more > than one will match your step. So order should not be an issue. > > > > > Thanks again, > > > > Tim > > > > On Wed, Dec 17, 2008 at 2:22 PM, David Chelimsky > wrote: > >> On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker wrote: > >>> Hi Guys, > >>> > >>> Things are working great with Cucumber and am getting better at > >>> expressing requirements as behaviors. Kudos! > >>> > >>> I seek a couple of points of clarification, or confirmation, if > >>> someone has a minute or two... > >>> > >>> FWIW - I've read the wiki and the given-when-then page and just seek > >>> confirmation: > >>> > >>> There is no dependency implied in the keywords "given", "then" and > >>> "when" (as well as "and" and "but), correct? These are simply naming > >>> conventions that denote the well known "Build/Operate/Check" pattern > >>> but have no real physical relationship, they're just tags that denote > >>> the steps. > >> > >> Correct. > >> > >>> A "pending" step is any step that has a matching step but nothing is > >>> implemented. > >> > >> Correct. > >> > A "pending" step (plain text) is any step that *does not* have a matching step definition (regexp+proc). -Or (as of 0.1.13) a matching step definition that raises Pending (for example by calling #pending). > > >>> A "successful" step is any step that is matched, has some code and > >>> doesn't assert anything resolving to false. > >> > >> Or raise an error. > >> > >>> A "gray" out step means that no steps were found that matched the > feature. > >> > >> Blue? Means that a step was found, but a previous step was either > >> pending or failed. > >> > >>> You need to be careful that features do not match steps in the step > >>> file or cucumber will execute the first step it finds that matches > >>> (really don't know how this works, will a test sequence ever go > >>> 'backwards'?) > >> > >> Cucumber tells you when it finds two steps definitions that could > >> match the step in the feature. > >> > >>> Going back and changing the stuff in the .feature file is risky as > >>> it's very easy to create a mismatch and the step won't be found. > >> > >> Not sure why that is risky, unless you mean that there are > >> non-developers making these changes. If so, then they should probably > >> be made collaboratively. > >> > Every time something is changed, you run Cucumber immediately, and then you'll know if you broke something. Aslak > > >>> > >>> Thanks very much, > >>> > >>> Tim > >>> _______________________________________________ > >>> 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From walketim at gmail.com Wed Dec 17 17:52:25 2008 From: walketim at gmail.com (Tim Walker) Date: Wed, 17 Dec 2008 15:52:25 -0700 Subject: [rspec-users] [cucumber] before/after scenarios In-Reply-To: <49496DB9.4020609@joesniff.co.uk> References: <1ebf5a4d0812171314n4faf2f49x55d6086483a45fc1@mail.gmail.com> <49496DB9.4020609@joesniff.co.uk> Message-ID: <1ebf5a4d0812171452t2416ef31y7027b1a85ec9eb2b@mail.gmail.com> Joseph, This is very, very helpful and gets me to a place where I can try it. If anything, I just didn't think to look in "hooks" for the concept of setup/teardown. Really looking forward to the book! Many sincere thanks, I hope i can return the favor some day. Tim On Wed, Dec 17, 2008 at 2:23 PM, Joseph Wilk wrote: > Tim Walker wrote: >> >> Hi Guys, >> >> Sorry for the double-whine but I've seen references to these listeners >> but not a lot of luck finding any details. >> >> So...that's it: Setup/Teardown Before/After scenarios...what's the scoop? >> > > http://github.com/aslakhellesoy/cucumber/wikis/hooks > > Does the information here answer your questions or do you think its missing > some details? > > HTH > -- > Joseph Wilk > http://blog.josephwilk.net > >> Thanks, >> >> Tim >> (Also, the logo's are looking awesome!) >> _______________________________________________ >> 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 f.mischa at gmail.com Wed Dec 17 18:18:48 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Wed, 17 Dec 2008 15:18:48 -0800 Subject: [rspec-users] Rails 2.3 In-Reply-To: <57c63afe0812170401j245a6674rc418b7843407fb1d@mail.gmail.com> References: <57c63afe0812170401j245a6674rc418b7843407fb1d@mail.gmail.com> Message-ID: Thank you for clarifying. Yes, I mean edge rails. Best, M On Wed, Dec 17, 2008 at 4:01 AM, David Chelimsky wrote: > On Wed, Dec 17, 2008 at 3:39 AM, Mischa Fierer wrote: > > Wanted to point out to anyone having problems that rspec-rails 1.1.11.1 > > works with rails 2.3, while rspec 1.1.11 does not appear to. > > $ gem q -rn rails > ... > rails (2.2.2) > ... > > Doesn't look like rails-2.3 is released. Do you mean edge rails? > > Also - just so we're all clear, any gem w/ a 4th part (like 1.1.11.1) > is an interim, unofficial release that I make available at github as a > convenience (http://github.com/dchelimsky/rspec/wikis/releases-and-gems). > They get prefixed w/ my github username, so: > > $ gem q -rn dchelimsky-rspec > dchelimsky-rspec (1.1.11.1) > dchelimsky-rspec-rails (1.1.11.1) > > I just pushed updated gemspecs, so there should be a pair of 1.1.11.2 > gems up there soon (usually takes 15 to 30 minutes before they show > up) that won't require you futzing with the manifest. > > Cheers, > David > > > > > Also, to get rspec 1.1.11.1 to build I had to remove UPDATE from the > > manifest. > > > > M > > > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Wed Dec 17 18:19:07 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 17 Dec 2008 23:19:07 +0000 Subject: [rspec-users] fixtures and associations In-Reply-To: References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> Message-ID: On 17 Dec 2008, at 21:07, Pat Maddox wrote: > I highly recommend ditching fixtures all together. You avoid funky > shit > like this, and you won't have coupling between tests that occurs with > fixtures, and you'll be able to create more clear specs because you do > all the setup in the spec itself. If you're interested, look into > something like fixtures_replacement, factory girl, object daddy, etc. +1 You'll never look back. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From ben at benmabey.com Wed Dec 17 18:44:48 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 17 Dec 2008 16:44:48 -0700 Subject: [rspec-users] [Cucumber] a few clarifications please... In-Reply-To: <1ebf5a4d0812171450x339f2726n5b892f7ba5b9b3f9@mail.gmail.com> References: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> <49497185.7060107@joesniff.co.uk> <1ebf5a4d0812171450x339f2726n5b892f7ba5b9b3f9@mail.gmail.com> Message-ID: <49498EF0.3070607@benmabey.com> Tim Walker wrote: > Great information guys, making some progress on this end. It is much > appreciated. > > Discovered that step definitions can not be duplicated even across > step files. Is this correct? > > Correct. They can't be duplicated in any given process, no mater what file(s) the definitions come from. -Ben > Thanks again. > > Sincerely, > > Tim > > On Wed, Dec 17, 2008 at 2:39 PM, Joseph Wilk wrote: > >> David Chelimsky wrote: >> >>> On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker wrote: >>> >>> >>>> Hi Guys, >>>> >>>> Things are working great with Cucumber and am getting better at >>>> expressing requirements as behaviors. Kudos! >>>> >>>> I seek a couple of points of clarification, or confirmation, if >>>> someone has a minute or two... >>>> >>>> FWIW - I've read the wiki and the given-when-then page and just seek >>>> confirmation: >>>> >>>> There is no dependency implied in the keywords "given", "then" and >>>> "when" (as well as "and" and "but), correct? These are simply naming >>>> conventions that denote the well known "Build/Operate/Check" pattern >>>> but have no real physical relationship, they're just tags that denote >>>> the steps. >>>> >>>> >>> Correct. >>> >>> >>> >>>> A "pending" step is any step that has a matching step but nothing is >>>> implemented. >>>> >>>> >>> Correct. >>> >>> >> In the latest version in Github (0.1.13) you can also force steps which have >> an implementation to the pending state using the 'pending' method which >> works in the same way as Rspec's pending. >> >> When "I want to be lazy" do >> pending "Implement me!" >> end >> >> -- >> Joseph Wilk >> http://blog.josephwilk.net >> >> >>>> A "successful" step is any step that is matched, has some code and >>>> doesn't assert anything resolving to false. >>>> >>>> >>> Or raise an error. >>> >>> >>> >>>> A "gray" out step means that no steps were found that matched the >>>> feature. >>>> >>>> >>> Blue? Means that a step was found, but a previous step was either >>> pending or failed. >>> >>> >>> >>>> You need to be careful that features do not match steps in the step >>>> file or cucumber will execute the first step it finds that matches >>>> (really don't know how this works, will a test sequence ever go >>>> 'backwards'?) >>>> >>>> >>> Cucumber tells you when it finds two steps definitions that could >>> match the step in the feature. >>> >>> >>> >>>> Going back and changing the stuff in the .feature file is risky as >>>> it's very easy to create a mismatch and the step won't be found. >>>> >>>> >>> Not sure why that is risky, unless you mean that there are >>> non-developers making these changes. If so, then they should probably >>> be made collaboratively. >>> >>> >>> >>>> Thanks very much, >>>> >>>> Tim >>>> _______________________________________________ >>>> 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 >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Wed Dec 17 19:07:56 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 18 Dec 2008 01:07:56 +0100 Subject: [rspec-users] [Cucumber] a few clarifications please... In-Reply-To: <1ebf5a4d0812171450x339f2726n5b892f7ba5b9b3f9@mail.gmail.com> References: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> <49497185.7060107@joesniff.co.uk> <1ebf5a4d0812171450x339f2726n5b892f7ba5b9b3f9@mail.gmail.com> Message-ID: <8d961d900812171607m75d878b1g9a6dac4ee7865175@mail.gmail.com> On Wed, Dec 17, 2008 at 11:50 PM, Tim Walker wrote: > Great information guys, making some progress on this end. It is much > appreciated. > > Discovered that step definitions can not be duplicated even across > step files. Is this correct? > Regexen can not be the same (even if the blocks are different). I just refactored the wiki a little and added a new page about this: http://github.com/aslakhellesoy/cucumber/wikis/step-definitions Aslak > Thanks again. > > Sincerely, > > Tim > > On Wed, Dec 17, 2008 at 2:39 PM, Joseph Wilk > wrote: > > David Chelimsky wrote: > >> > >> On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker wrote: > >> > >>> > >>> Hi Guys, > >>> > >>> Things are working great with Cucumber and am getting better at > >>> expressing requirements as behaviors. Kudos! > >>> > >>> I seek a couple of points of clarification, or confirmation, if > >>> someone has a minute or two... > >>> > >>> FWIW - I've read the wiki and the given-when-then page and just seek > >>> confirmation: > >>> > >>> There is no dependency implied in the keywords "given", "then" and > >>> "when" (as well as "and" and "but), correct? These are simply naming > >>> conventions that denote the well known "Build/Operate/Check" pattern > >>> but have no real physical relationship, they're just tags that denote > >>> the steps. > >>> > >> > >> Correct. > >> > >> > >>> > >>> A "pending" step is any step that has a matching step but nothing is > >>> implemented. > >>> > >> > >> Correct. > >> > > > > In the latest version in Github (0.1.13) you can also force steps which > have > > an implementation to the pending state using the 'pending' method which > > works in the same way as Rspec's pending. > > > > When "I want to be lazy" do > > pending "Implement me!" > > end > > > > -- > > Joseph Wilk > > http://blog.josephwilk.net > > > >> > >>> > >>> A "successful" step is any step that is matched, has some code and > >>> doesn't assert anything resolving to false. > >>> > >> > >> Or raise an error. > >> > >> > >>> > >>> A "gray" out step means that no steps were found that matched the > >>> feature. > >>> > >> > >> Blue? Means that a step was found, but a previous step was either > >> pending or failed. > >> > >> > >>> > >>> You need to be careful that features do not match steps in the step > >>> file or cucumber will execute the first step it finds that matches > >>> (really don't know how this works, will a test sequence ever go > >>> 'backwards'?) > >>> > >> > >> Cucumber tells you when it finds two steps definitions that could > >> match the step in the feature. > >> > >> > >>> > >>> Going back and changing the stuff in the .feature file is risky as > >>> it's very easy to create a mismatch and the step won't be found. > >>> > >> > >> Not sure why that is risky, unless you mean that there are > >> non-developers making these changes. If so, then they should probably > >> be made collaboratively. > >> > >> > >>> > >>> Thanks very much, > >>> > >>> Tim > >>> _______________________________________________ > >>> 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Wed Dec 17 19:14:56 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 17 Dec 2008 16:14:56 -0800 Subject: [rspec-users] fixtures and associations In-Reply-To: <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> Message-ID: <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes wrote: > Hello Pat, even I load all my fixtures it still not reading anything from > users.yml ... > I will look at factory_girl but before I need understand what happening. > I try this: > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > describe Tenant do > fixtures :properties, :users , :owners > def create_tenant(options = {}) > record = Tenant.create({ > :property => properties(:two), > :renters => "value for renters", > :guarantor => "value for guarantor", > :contact_name => "value for contact_name", > :contact_phone => "value for contact_phone", > :contact_email => "teste at hosttest.com", > :end_date => Date.today, > :beginning_date => Date.today, > :initial_value => "9.99" > }.merge(options)) > end > > before(:each) do > @tenant = create_tenant > end > > it "should create a new instance given valid attributes" do > p properties(:two).errors > properties(:two).should be_valid > # @tenant.errors.should be_empty > end > end What error are you getting now? Please post whatever error you're experiencing...when we change this code, I expect a different error, and would not know what it is. If it's the same, that's strange. Also, I noticed you have p properties(:two).errors properties(:two).should be_valid That's not going to show you anything, because errors don't get added until you call #valid? So change that to properties(:two).valid? p properties(:two).errors Pat From danielvlopes at gmail.com Wed Dec 17 19:38:04 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Wed, 17 Dec 2008 22:38:04 -0200 Subject: [rspec-users] fixtures and associations In-Reply-To: <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> Message-ID: <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> Hello Pat, the error still the same. at errors={"user"=>["can't be blank"]} But if we look on @base we have user: @base=# And my code is: describe Tenant do fixtures :properties, :users ,:owners def create_tenant(options = {}) record = Tenant.create({ :property => properties(:two), :renters => "value for renters", :guarantor => "value for guarantor", :contact_name => "value for contact_name", :contact_phone => "value for contact_phone", :contact_email => "teste at hosttest.com", :end_date => Date.today, :beginning_date => Date.today, :initial_value => "9.99" }.merge(options)) end before(:each) do @tenant = create_tenant end it "should create a new instance given valid attributes" do properties(:two).valid? p properties(:two).errors # @tenant.errors.should be_empty end And my fixtures still the same... I don't know what's happening, when I try run on console or in browser everything ok... I think is something strange with fixtures. Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Wed, Dec 17, 2008 at 10:14 PM, Pat Maddox wrote: > On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes > wrote: > > Hello Pat, even I load all my fixtures it still not reading anything from > > users.yml ... > > I will look at factory_girl but before I need understand what happening. > > I try this: > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe Tenant do > > fixtures :properties, :users , :owners > > def create_tenant(options = {}) > > record = Tenant.create({ > > :property => properties(:two), > > :renters => "value for renters", > > :guarantor => "value for guarantor", > > :contact_name => "value for contact_name", > > :contact_phone => "value for contact_phone", > > :contact_email => "teste at hosttest.com", > > :end_date => Date.today, > > :beginning_date => Date.today, > > :initial_value => "9.99" > > }.merge(options)) > > end > > > > before(:each) do > > @tenant = create_tenant > > end > > > > it "should create a new instance given valid attributes" do > > p properties(:two).errors > > properties(:two).should be_valid > > # @tenant.errors.should be_empty > > end > > end > > What error are you getting now? Please post whatever error you're > experiencing...when we change this code, I expect a different error, > and would not know what it is. If it's the same, that's strange. > > Also, I noticed you have > p properties(:two).errors > properties(:two).should be_valid > > That's not going to show you anything, because errors don't get added > until you call #valid? So change that to > > properties(:two).valid? > p properties(:two).errors > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Wed Dec 17 19:45:14 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 18 Dec 2008 01:45:14 +0100 Subject: [rspec-users] fixtures and associations In-Reply-To: <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> Message-ID: <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> On Thu, Dec 18, 2008 at 1:38 AM, Daniel Lopes wrote: > Hello Pat, the error still the same. at errors={"user"=>["can't be blank"]} > > But if we look on @base we have user: > @base=# ... > > > And my code is: > describe Tenant do > fixtures :properties, :users ,:owners > > def create_tenant(options = {}) > record = Tenant.create({ > Just a small tip. Always, always use create! in specs. You want an error to be raised in case creation is unsuccessful, and create doesn't do that - it just returns false. Aslak > :property => properties(:two), > :renters => "value for renters", > :guarantor => "value for guarantor", > :contact_name => "value for contact_name", > :contact_phone => "value for contact_phone", > :contact_email => "teste at hosttest.com", > :end_date => Date.today, > :beginning_date => Date.today, > :initial_value => "9.99" > }.merge(options)) > end > > before(:each) do > @tenant = create_tenant > end > > it "should create a new instance given valid attributes" do > properties(:two).valid? > p properties(:two).errors > # @tenant.errors.should be_empty > end > > And my fixtures still the same... I don't know what's happening, when I try > run on console or in browser everything ok... I think is something strange > with fixtures. > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > On Wed, Dec 17, 2008 at 10:14 PM, Pat Maddox wrote: > >> On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes >> wrote: >> > Hello Pat, even I load all my fixtures it still not reading anything >> from >> > users.yml ... >> > I will look at factory_girl but before I need understand what happening. >> > I try this: >> > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >> > describe Tenant do >> > fixtures :properties, :users , :owners >> > def create_tenant(options = {}) >> > record = Tenant.create({ >> > :property => properties(:two), >> > :renters => "value for renters", >> > :guarantor => "value for guarantor", >> > :contact_name => "value for contact_name", >> > :contact_phone => "value for contact_phone", >> > :contact_email => "teste at hosttest.com", >> > :end_date => Date.today, >> > :beginning_date => Date.today, >> > :initial_value => "9.99" >> > }.merge(options)) >> > end >> > >> > before(:each) do >> > @tenant = create_tenant >> > end >> > >> > it "should create a new instance given valid attributes" do >> > p properties(:two).errors >> > properties(:two).should be_valid >> > # @tenant.errors.should be_empty >> > end >> > end >> >> What error are you getting now? Please post whatever error you're >> experiencing...when we change this code, I expect a different error, >> and would not know what it is. If it's the same, that's strange. >> >> Also, I noticed you have >> p properties(:two).errors >> properties(:two).should be_valid >> >> That's not going to show you anything, because errors don't get added >> until you call #valid? So change that to >> >> properties(:two).valid? >> p properties(:two).errors >> >> Pat >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at gmail.com Wed Dec 17 20:02:31 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Wed, 17 Dec 2008 23:02:31 -0200 Subject: [rspec-users] fixtures and associations In-Reply-To: <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <57c63afe0812171118x259020cake66e0abd609c34c3@mail.gmail.com> <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> Message-ID: <992995550812171702h65f8cb92td0484767aabb973b@mail.gmail.com> I know... I just don't use create!, in this special case, because it will be more complicate to know what field have the error . I'm still scratching my head, my @tenant instance var on spec has values for user_id and owner_id and don't understand why my validates_associated :property raise an error. And if I mock model on model spec will not be a good thing. Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Wed, Dec 17, 2008 at 10:45 PM, aslak hellesoy wrote: > > > On Thu, Dec 18, 2008 at 1:38 AM, Daniel Lopes wrote: > >> Hello Pat, the error still the same. at errors={"user"=>["can't be blank"]} >> >> But if we look on @base we have user: >> @base=#> ... > >> >> And my code is: >> describe Tenant do >> fixtures :properties, :users ,:owners >> >> def create_tenant(options = {}) >> record = Tenant.create({ >> > > Just a small tip. Always, always use create! in specs. You want an error to > be raised in case creation is unsuccessful, and create doesn't do that - it > just returns false. > > Aslak > > >> :property => properties(:two), >> :renters => "value for renters", >> :guarantor => "value for guarantor", >> :contact_name => "value for contact_name", >> :contact_phone => "value for contact_phone", >> :contact_email => "teste at hosttest.com", >> :end_date => Date.today, >> :beginning_date => Date.today, >> :initial_value => "9.99" >> }.merge(options)) >> end >> >> before(:each) do >> @tenant = create_tenant >> end >> >> it "should create a new instance given valid attributes" do >> properties(:two).valid? >> p properties(:two).errors >> # @tenant.errors.should be_empty >> end >> >> And my fixtures still the same... I don't know what's happening, when I >> try run on console or in browser everything ok... I think is something >> strange with fixtures. >> >> Atenciosamente, >> >> Daniel Lopes ? Area Cria??es >> Design, Websites e Sistemas Web >> >> Visite: http://www.areacriacoes.com.br/projects >> http://blog.areacriacoes.com.br/ >> >> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * * >> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >> >> >> On Wed, Dec 17, 2008 at 10:14 PM, Pat Maddox wrote: >> >>> On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes >>> wrote: >>> > Hello Pat, even I load all my fixtures it still not reading anything >>> from >>> > users.yml ... >>> > I will look at factory_girl but before I need understand what >>> happening. >>> > I try this: >>> > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >>> > describe Tenant do >>> > fixtures :properties, :users , :owners >>> > def create_tenant(options = {}) >>> > record = Tenant.create({ >>> > :property => properties(:two), >>> > :renters => "value for renters", >>> > :guarantor => "value for guarantor", >>> > :contact_name => "value for contact_name", >>> > :contact_phone => "value for contact_phone", >>> > :contact_email => "teste at hosttest.com", >>> > :end_date => Date.today, >>> > :beginning_date => Date.today, >>> > :initial_value => "9.99" >>> > }.merge(options)) >>> > end >>> > >>> > before(:each) do >>> > @tenant = create_tenant >>> > end >>> > >>> > it "should create a new instance given valid attributes" do >>> > p properties(:two).errors >>> > properties(:two).should be_valid >>> > # @tenant.errors.should be_empty >>> > end >>> > end >>> >>> What error are you getting now? Please post whatever error you're >>> experiencing...when we change this code, I expect a different error, >>> and would not know what it is. If it's the same, that's strange. >>> >>> Also, I noticed you have >>> p properties(:two).errors >>> properties(:two).should be_valid >>> >>> That's not going to show you anything, because errors don't get added >>> until you call #valid? So change that to >>> >>> properties(:two).valid? >>> p properties(:two).errors >>> >>> Pat >>> _______________________________________________ >>> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevemolitor at gmail.com Wed Dec 17 20:30:44 2008 From: stevemolitor at gmail.com (Steve Molitor) Date: Wed, 17 Dec 2008 19:30:44 -0600 Subject: [rspec-users] [Cucumber] a few clarifications please... In-Reply-To: <8d961d900812171607m75d878b1g9a6dac4ee7865175@mail.gmail.com> References: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> <49497185.7060107@joesniff.co.uk> <1ebf5a4d0812171450x339f2726n5b892f7ba5b9b3f9@mail.gmail.com> <8d961d900812171607m75d878b1g9a6dac4ee7865175@mail.gmail.com> Message-ID: <3e21ad60812171730l17f65879ie809c6049455663b@mail.gmail.com> What about two steps with the same regex but are of different types -- i.e. a Given and a Then with the same regexp? Steve On Wed, Dec 17, 2008 at 6:07 PM, aslak hellesoy wrote: > > > On Wed, Dec 17, 2008 at 11:50 PM, Tim Walker wrote: > >> Great information guys, making some progress on this end. It is much >> appreciated. >> >> Discovered that step definitions can not be duplicated even across >> step files. Is this correct? >> > > Regexen can not be the same (even if the blocks are different). I just > refactored the wiki a little and added a new page about this: > http://github.com/aslakhellesoy/cucumber/wikis/step-definitions > > Aslak > > >> Thanks again. >> >> Sincerely, >> >> Tim >> >> On Wed, Dec 17, 2008 at 2:39 PM, Joseph Wilk >> wrote: >> > David Chelimsky wrote: >> >> >> >> On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker >> wrote: >> >> >> >>> >> >>> Hi Guys, >> >>> >> >>> Things are working great with Cucumber and am getting better at >> >>> expressing requirements as behaviors. Kudos! >> >>> >> >>> I seek a couple of points of clarification, or confirmation, if >> >>> someone has a minute or two... >> >>> >> >>> FWIW - I've read the wiki and the given-when-then page and just seek >> >>> confirmation: >> >>> >> >>> There is no dependency implied in the keywords "given", "then" and >> >>> "when" (as well as "and" and "but), correct? These are simply naming >> >>> conventions that denote the well known "Build/Operate/Check" pattern >> >>> but have no real physical relationship, they're just tags that denote >> >>> the steps. >> >>> >> >> >> >> Correct. >> >> >> >> >> >>> >> >>> A "pending" step is any step that has a matching step but nothing is >> >>> implemented. >> >>> >> >> >> >> Correct. >> >> >> > >> > In the latest version in Github (0.1.13) you can also force steps which >> have >> > an implementation to the pending state using the 'pending' method which >> > works in the same way as Rspec's pending. >> > >> > When "I want to be lazy" do >> > pending "Implement me!" >> > end >> > >> > -- >> > Joseph Wilk >> > http://blog.josephwilk.net >> > >> >> >> >>> >> >>> A "successful" step is any step that is matched, has some code and >> >>> doesn't assert anything resolving to false. >> >>> >> >> >> >> Or raise an error. >> >> >> >> >> >>> >> >>> A "gray" out step means that no steps were found that matched the >> >>> feature. >> >>> >> >> >> >> Blue? Means that a step was found, but a previous step was either >> >> pending or failed. >> >> >> >> >> >>> >> >>> You need to be careful that features do not match steps in the step >> >>> file or cucumber will execute the first step it finds that matches >> >>> (really don't know how this works, will a test sequence ever go >> >>> 'backwards'?) >> >>> >> >> >> >> Cucumber tells you when it finds two steps definitions that could >> >> match the step in the feature. >> >> >> >> >> >>> >> >>> Going back and changing the stuff in the .feature file is risky as >> >>> it's very easy to create a mismatch and the step won't be found. >> >>> >> >> >> >> Not sure why that is risky, unless you mean that there are >> >> non-developers making these changes. If so, then they should probably >> >> be made collaboratively. >> >> >> >> >> >>> >> >>> Thanks very much, >> >>> >> >>> Tim >> >>> _______________________________________________ >> >>> 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 >> > >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Wed Dec 17 21:10:48 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 18 Dec 2008 03:10:48 +0100 Subject: [rspec-users] fixtures and associations In-Reply-To: <992995550812171702h65f8cb92td0484767aabb973b@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <992995550812171140w2f2ff926sa650cffd544736d1@mail.gmail.com> <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> <992995550812171702h65f8cb92td0484767aabb973b@mail.gmail.com> Message-ID: <8d961d900812171810p479c0edbiabc7c2e2f5d3da15@mail.gmail.com> On Thu, Dec 18, 2008 at 2:02 AM, Daniel Lopes wrote: > I know... I just don't use create!, in this special case, because it will > be more complicate to know what field have the error . > No it won't. The error message tells you what field has the error, and if creation is unsuccessful you *need* to know about it. Otherwise you'll get tons of false positives. I can't think of a single case where it makes sense to use create inside a spec. Aslak > I'm still scratching my head, my @tenant instance var on spec has values > for user_id and owner_id and don't understand why my validates_associated > :property raise an error. > > And if I mock model on model spec will not be a good thing. > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > On Wed, Dec 17, 2008 at 10:45 PM, aslak hellesoy > wrote: > >> >> >> On Thu, Dec 18, 2008 at 1:38 AM, Daniel Lopes wrote: >> >>> Hello Pat, the error still the same. at errors={"user"=>["can't be blank"]} >>> >>> But if we look on @base we have user: >>> @base=#>> ... > >>> >>> And my code is: >>> describe Tenant do >>> fixtures :properties, :users ,:owners >>> >>> def create_tenant(options = {}) >>> record = Tenant.create({ >>> >> >> Just a small tip. Always, always use create! in specs. You want an error >> to be raised in case creation is unsuccessful, and create doesn't do that - >> it just returns false. >> >> Aslak >> >> >>> :property => properties(:two), >>> :renters => "value for renters", >>> :guarantor => "value for guarantor", >>> :contact_name => "value for contact_name", >>> :contact_phone => "value for contact_phone", >>> :contact_email => "teste at hosttest.com", >>> :end_date => Date.today, >>> :beginning_date => Date.today, >>> :initial_value => "9.99" >>> }.merge(options)) >>> end >>> >>> before(:each) do >>> @tenant = create_tenant >>> end >>> >>> it "should create a new instance given valid attributes" do >>> properties(:two).valid? >>> p properties(:two).errors >>> # @tenant.errors.should be_empty >>> end >>> >>> And my fixtures still the same... I don't know what's happening, when I >>> try run on console or in browser everything ok... I think is something >>> strange with fixtures. >>> >>> Atenciosamente, >>> >>> Daniel Lopes ? Area Cria??es >>> Design, Websites e Sistemas Web >>> >>> Visite: http://www.areacriacoes.com.br/projects >>> http://blog.areacriacoes.com.br/ >>> >>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>> * * >>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>> >>> >>> On Wed, Dec 17, 2008 at 10:14 PM, Pat Maddox wrote: >>> >>>> On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes >>>> wrote: >>>> > Hello Pat, even I load all my fixtures it still not reading anything >>>> from >>>> > users.yml ... >>>> > I will look at factory_girl but before I need understand what >>>> happening. >>>> > I try this: >>>> > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >>>> > describe Tenant do >>>> > fixtures :properties, :users , :owners >>>> > def create_tenant(options = {}) >>>> > record = Tenant.create({ >>>> > :property => properties(:two), >>>> > :renters => "value for renters", >>>> > :guarantor => "value for guarantor", >>>> > :contact_name => "value for contact_name", >>>> > :contact_phone => "value for contact_phone", >>>> > :contact_email => "teste at hosttest.com", >>>> > :end_date => Date.today, >>>> > :beginning_date => Date.today, >>>> > :initial_value => "9.99" >>>> > }.merge(options)) >>>> > end >>>> > >>>> > before(:each) do >>>> > @tenant = create_tenant >>>> > end >>>> > >>>> > it "should create a new instance given valid attributes" do >>>> > p properties(:two).errors >>>> > properties(:two).should be_valid >>>> > # @tenant.errors.should be_empty >>>> > end >>>> > end >>>> >>>> What error are you getting now? Please post whatever error you're >>>> experiencing...when we change this code, I expect a different error, >>>> and would not know what it is. If it's the same, that's strange. >>>> >>>> Also, I noticed you have >>>> p properties(:two).errors >>>> properties(:two).should be_valid >>>> >>>> That's not going to show you anything, because errors don't get added >>>> until you call #valid? So change that to >>>> >>>> properties(:two).valid? >>>> p properties(:two).errors >>>> >>>> Pat >>>> _______________________________________________ >>>> 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 >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at gmail.com Wed Dec 17 21:36:46 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Thu, 18 Dec 2008 00:36:46 -0200 Subject: [rspec-users] fixtures and associations In-Reply-To: <8d961d900812171810p479c0edbiabc7c2e2f5d3da15@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> <992995550812171702h65f8cb92td0484767aabb973b@mail.gmail.com> <8d961d900812171810p479c0edbiabc7c2e2f5d3da15@mail.gmail.com> Message-ID: <992995550812171836p63ce38aesb1b011c5b5eae779@mail.gmail.com> I think I was misunderstood. I am not saying to use create rather than create! ... In this case, I just use it because will help me with puts for debug my own error in spec. In this case a really don't know what is going on, if I use create! I can't store the value in a var and then try to look what is the message of the failed attribute with puts. I using puts to print the error object to debug who is the wrong attribute. If I use create! I will have this message: Validation failed: Property is not valid => and cant use puts to know the content of @errors If I use create and print the result of fixture I will get: ["n?o pode ser vazio"]}, @base=#wrote: > > > On Thu, Dec 18, 2008 at 2:02 AM, Daniel Lopes wrote: > >> I know... I just don't use create!, in this special case, because it will >> be more complicate to know what field have the error . >> > > No it won't. The error message tells you what field has the error, and if > creation is unsuccessful you *need* to know about it. Otherwise you'll get > tons of false positives. I can't think of a single case where it makes sense > to use create inside a spec. > > Aslak > > >> I'm still scratching my head, my @tenant instance var on spec has values >> for user_id and owner_id and don't understand why my validates_associated >> :property raise an error. >> >> And if I mock model on model spec will not be a good thing. >> >> Atenciosamente, >> >> Daniel Lopes ? Area Cria??es >> Design, Websites e Sistemas Web >> >> Visite: http://www.areacriacoes.com.br/projects >> http://blog.areacriacoes.com.br/ >> >> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * * >> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >> >> >> On Wed, Dec 17, 2008 at 10:45 PM, aslak hellesoy < >> aslak.hellesoy at gmail.com> wrote: >> >>> >>> >>> On Thu, Dec 18, 2008 at 1:38 AM, Daniel Lopes wrote: >>> >>>> Hello Pat, the error still the same. at errors={"user"=>["can't be >>>> blank"]} >>>> >>>> But if we look on @base we have user: >>>> @base=#>>> ... > >>>> >>>> And my code is: >>>> describe Tenant do >>>> fixtures :properties, :users ,:owners >>>> >>>> def create_tenant(options = {}) >>>> record = Tenant.create({ >>>> >>> >>> Just a small tip. Always, always use create! in specs. You want an error >>> to be raised in case creation is unsuccessful, and create doesn't do that - >>> it just returns false. >>> >>> Aslak >>> >>> >>>> :property => properties(:two), >>>> :renters => "value for renters", >>>> :guarantor => "value for guarantor", >>>> :contact_name => "value for contact_name", >>>> :contact_phone => "value for contact_phone", >>>> :contact_email => "teste at hosttest.com", >>>> :end_date => Date.today, >>>> :beginning_date => Date.today, >>>> :initial_value => "9.99" >>>> }.merge(options)) >>>> end >>>> >>>> before(:each) do >>>> @tenant = create_tenant >>>> end >>>> >>>> it "should create a new instance given valid attributes" do >>>> properties(:two).valid? >>>> p properties(:two).errors >>>> # @tenant.errors.should be_empty >>>> end >>>> >>>> And my fixtures still the same... I don't know what's happening, when I >>>> try run on console or in browser everything ok... I think is something >>>> strange with fixtures. >>>> >>>> Atenciosamente, >>>> >>>> Daniel Lopes ? Area Cria??es >>>> Design, Websites e Sistemas Web >>>> >>>> Visite: http://www.areacriacoes.com.br/projects >>>> http://blog.areacriacoes.com.br/ >>>> >>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>> * * * >>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>> >>>> >>>> On Wed, Dec 17, 2008 at 10:14 PM, Pat Maddox wrote: >>>> >>>>> On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes >>>>> wrote: >>>>> > Hello Pat, even I load all my fixtures it still not reading anything >>>>> from >>>>> > users.yml ... >>>>> > I will look at factory_girl but before I need understand what >>>>> happening. >>>>> > I try this: >>>>> > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >>>>> > describe Tenant do >>>>> > fixtures :properties, :users , :owners >>>>> > def create_tenant(options = {}) >>>>> > record = Tenant.create({ >>>>> > :property => properties(:two), >>>>> > :renters => "value for renters", >>>>> > :guarantor => "value for guarantor", >>>>> > :contact_name => "value for contact_name", >>>>> > :contact_phone => "value for contact_phone", >>>>> > :contact_email => "teste at hosttest.com", >>>>> > :end_date => Date.today, >>>>> > :beginning_date => Date.today, >>>>> > :initial_value => "9.99" >>>>> > }.merge(options)) >>>>> > end >>>>> > >>>>> > before(:each) do >>>>> > @tenant = create_tenant >>>>> > end >>>>> > >>>>> > it "should create a new instance given valid attributes" do >>>>> > p properties(:two).errors >>>>> > properties(:two).should be_valid >>>>> > # @tenant.errors.should be_empty >>>>> > end >>>>> > end >>>>> >>>>> What error are you getting now? Please post whatever error you're >>>>> experiencing...when we change this code, I expect a different error, >>>>> and would not know what it is. If it's the same, that's strange. >>>>> >>>>> Also, I noticed you have >>>>> p properties(:two).errors >>>>> properties(:two).should be_valid >>>>> >>>>> That's not going to show you anything, because errors don't get added >>>>> until you call #valid? So change that to >>>>> >>>>> properties(:two).valid? >>>>> p properties(:two).errors >>>>> >>>>> Pat >>>>> _______________________________________________ >>>>> 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 >>> >> >> >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Wed Dec 17 21:44:13 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 17 Dec 2008 21:44:13 -0500 Subject: [rspec-users] [Cucumber] a few clarifications please... In-Reply-To: <3e21ad60812171730l17f65879ie809c6049455663b@mail.gmail.com> References: <1ebf5a4d0812171234l41007412j306fc5423412b0cd@mail.gmail.com> <57c63afe0812171322u1a8ddb6dye05ed65e6dc31cb1@mail.gmail.com> <49497185.7060107@joesniff.co.uk> <1ebf5a4d0812171450x339f2726n5b892f7ba5b9b3f9@mail.gmail.com> <8d961d900812171607m75d878b1g9a6dac4ee7865175@mail.gmail.com> <3e21ad60812171730l17f65879ie809c6049455663b@mail.gmail.com> Message-ID: <85d99afe0812171844t61eb2f48h52460a796915db02@mail.gmail.com> On Wed, Dec 17, 2008 at 8:30 PM, Steve Molitor wrote: > What about two steps with the same regex but are of different types -- i.e. > a Given and a Then with the same regexp? They do the exact same thing. Given|When|Then is just a nicety for you as the developer. Cucumber could care less. This is the code from Cucumber: def Given(key, &proc) step_mother.register_step_proc(key, &proc) end def When(key, &proc) step_mother.register_step_proc(key, &proc) end def Then(key, &proc) step_mother.register_step_proc(key, &proc) end > Steve > > On Wed, Dec 17, 2008 at 6:07 PM, aslak hellesoy > wrote: >> >> >> On Wed, Dec 17, 2008 at 11:50 PM, Tim Walker wrote: >>> >>> Great information guys, making some progress on this end. It is much >>> appreciated. >>> >>> Discovered that step definitions can not be duplicated even across >>> step files. Is this correct? >> >> Regexen can not be the same (even if the blocks are different). I just >> refactored the wiki a little and added a new page about this: >> http://github.com/aslakhellesoy/cucumber/wikis/step-definitions >> >> Aslak >> >>> >>> Thanks again. >>> >>> Sincerely, >>> >>> Tim >>> >>> On Wed, Dec 17, 2008 at 2:39 PM, Joseph Wilk >>> wrote: >>> > David Chelimsky wrote: >>> >> >>> >> On Wed, Dec 17, 2008 at 2:34 PM, Tim Walker >>> >> wrote: >>> >> >>> >>> >>> >>> Hi Guys, >>> >>> >>> >>> Things are working great with Cucumber and am getting better at >>> >>> expressing requirements as behaviors. Kudos! >>> >>> >>> >>> I seek a couple of points of clarification, or confirmation, if >>> >>> someone has a minute or two... >>> >>> >>> >>> FWIW - I've read the wiki and the given-when-then page and just seek >>> >>> confirmation: >>> >>> >>> >>> There is no dependency implied in the keywords "given", "then" and >>> >>> "when" (as well as "and" and "but), correct? These are simply naming >>> >>> conventions that denote the well known "Build/Operate/Check" pattern >>> >>> but have no real physical relationship, they're just tags that denote >>> >>> the steps. >>> >>> >>> >> >>> >> Correct. >>> >> >>> >> >>> >>> >>> >>> A "pending" step is any step that has a matching step but nothing is >>> >>> implemented. >>> >>> >>> >> >>> >> Correct. >>> >> >>> > >>> > In the latest version in Github (0.1.13) you can also force steps which >>> > have >>> > an implementation to the pending state using the 'pending' method which >>> > works in the same way as Rspec's pending. >>> > >>> > When "I want to be lazy" do >>> > pending "Implement me!" >>> > end >>> > >>> > -- >>> > Joseph Wilk >>> > http://blog.josephwilk.net >>> > >>> >> >>> >>> >>> >>> A "successful" step is any step that is matched, has some code and >>> >>> doesn't assert anything resolving to false. >>> >>> >>> >> >>> >> Or raise an error. >>> >> >>> >> >>> >>> >>> >>> A "gray" out step means that no steps were found that matched the >>> >>> feature. >>> >>> >>> >> >>> >> Blue? Means that a step was found, but a previous step was either >>> >> pending or failed. >>> >> >>> >> >>> >>> >>> >>> You need to be careful that features do not match steps in the step >>> >>> file or cucumber will execute the first step it finds that matches >>> >>> (really don't know how this works, will a test sequence ever go >>> >>> 'backwards'?) >>> >>> >>> >> >>> >> Cucumber tells you when it finds two steps definitions that could >>> >> match the step in the feature. >>> >> >>> >> >>> >>> >>> >>> Going back and changing the stuff in the .feature file is risky as >>> >>> it's very easy to create a mismatch and the step won't be found. >>> >>> >>> >> >>> >> Not sure why that is risky, unless you mean that there are >>> >> non-developers making these changes. If so, then they should probably >>> >> be made collaboratively. >>> >> >>> >> >>> >>> >>> >>> Thanks very much, >>> >>> >>> >>> Tim >>> >>> _______________________________________________ >>> >>> 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 >>> > >>> _______________________________________________ >>> 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 > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From f.mischa at gmail.com Wed Dec 17 21:46:26 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Wed, 17 Dec 2008 18:46:26 -0800 Subject: [rspec-users] Testing email w/ cucumber Message-ID: Dear all, Wanted to let people know that Ben Mabey has an excellent little plugin here: http://github.com/bmabey/email-spec/tree/master For testing e-mail. Aaron Gibralter made some additions as well here: http://github.com/agibralter/email-spec/tree/master I made some further changes here: http://github.com/mischa/email-spec/tree/master With my current version, you can do stories like below. Obviously you wouldn't use all of those steps, but I wanted to show what is possible. Scenario: A new person signs up Given I am at "/" And a clear email queue When I fill in "Email" with "quentin at example.com" And I fill in "Password" with "monkey" And I fill in "Password confirmation" with "monkey" And I press "Sign up" Then "quentin at example.com" should receive 1 email And "quentin at example.com" should have 1 email And "foo at bar.com" should not receive an email When I open the email Then I should see "confirm" in the email And I should see "Account confirmation" in the subject When I follow "confirm" in the email Then I should see "Confirm your new account" Best, M -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Wed Dec 17 23:37:26 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 17 Dec 2008 21:37:26 -0700 Subject: [rspec-users] Testing email w/ cucumber In-Reply-To: References: Message-ID: <4949D386.7000901@benmabey.com> Mischa Fierer wrote: > Dear all, > > Wanted to let people know that Ben Mabey has an excellent little > plugin here: http://github.com/bmabey/email-spec/tree/master Thanks! > > For testing e-mail. > > Aaron Gibralter made some additions as well here: > http://github.com/agibralter/email-spec/tree/master > > I made some further changes here: > http://github.com/mischa/email-spec/tree/master Wow, github rocks! I just threw that up there so for Aaron to see since it was slightly too big for a pastie/gist.. And now their are two forks of it! I'll pull from both of you guys now, thanks for sharing. -Ben > > With my current version, you can do stories like below. Obviously you > wouldn't use all of those steps, but I wanted to show what is possible. > > Scenario: A new person signs up > Given I am at "/" > And a clear email queue > When I fill in "Email" with "quentin at example.com > " > And I fill in "Password" with "monkey" > And I fill in "Password confirmation" with "monkey" > And I press "Sign up" > Then "quentin at example.com " should > receive 1 email > And "quentin at example.com " should > have 1 email > And "foo at bar.com " should not receive an email > When I open the email > Then I should see "confirm" in the email > And I should see "Account confirmation" in the subject > When I follow "confirm" in the email > Then I should see "Confirm your new account" > > > Best, > > M > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From aslak.hellesoy at gmail.com Thu Dec 18 00:04:17 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 18 Dec 2008 06:04:17 +0100 Subject: [rspec-users] Testing email w/ cucumber In-Reply-To: <4949D386.7000901@benmabey.com> References: <4949D386.7000901@benmabey.com> Message-ID: <8d961d900812172104n58450a5dw8072b1f4e347d456@mail.gmail.com> On Thu, Dec 18, 2008 at 5:37 AM, Ben Mabey wrote: > Mischa Fierer wrote: > >> Dear all, >> >> Wanted to let people know that Ben Mabey has an excellent little plugin >> here: http://github.com/bmabey/email-spec/tree/master >> > Thanks! > >> >> For testing e-mail. >> >> Aaron Gibralter made some additions as well here: >> http://github.com/agibralter/email-spec/tree/master >> >> I made some further changes here: >> http://github.com/mischa/email-spec/tree/master >> > > Wow, github rocks! I just threw that up there so for Aaron to see since it > was slightly too big for a pastie/gist.. And now their are two forks of it! > I'll pull from both of you guys now, thanks for sharing. > I stuck it on the Cucumber tools page: http://github.com/aslakhellesoy/cucumber/wikis/related-tools Thanks! Aslak > > -Ben > >> >> With my current version, you can do stories like below. Obviously you >> wouldn't use all of those steps, but I wanted to show what is possible. >> >> Scenario: A new person signs up >> Given I am at "/" >> And a clear email queue >> When I fill in "Email" with "quentin at example.com > quentin at example.com>" >> And I fill in "Password" with "monkey" >> And I fill in "Password confirmation" with "monkey" >> And I press "Sign up" >> Then "quentin at example.com " should >> receive 1 email >> And "quentin at example.com " should have 1 >> email >> And "foo at bar.com " should not receive an email >> When I open the email >> Then I should see "confirm" in the email >> And I should see "Account confirmation" in the subject >> When I follow "confirm" in the email >> Then I should see "Confirm your new account" >> >> >> Best, >> >> M >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at gmail.com Thu Dec 18 10:24:22 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Thu, 18 Dec 2008 13:24:22 -0200 Subject: [rspec-users] fixtures and associations In-Reply-To: <992995550812171836p63ce38aesb1b011c5b5eae779@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <992995550812171226ud2938te2c42f2039c2cf85@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> <992995550812171702h65f8cb92td0484767aabb973b@mail.gmail.com> <8d961d900812171810p479c0edbiabc7c2e2f5d3da15@mail.gmail.com> <992995550812171836p63ce38aesb1b011c5b5eae779@mail.gmail.com> Message-ID: <992995550812180724m723abfb7reeba13371812ee92@mail.gmail.com> I really don't know what's going on with those hell fixtures, and start thinking I will never find... I will try migrate all my fixtures to factory-girl, the only problem are my six hundred examples and no time to change all. Somebody have any link about rspec + factory-girl ? or maybe link to any project on github that use factory-girl and rspec ? Thanks for all help. Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Thu, Dec 18, 2008 at 12:36 AM, Daniel Lopes wrote: > I think I was misunderstood. I am not saying to use create rather than > create! ... In this case, I just use it because will help me with puts for > debug my own error in spec. > In this case a really don't know what is going on, if I use create! I can't > store the value in a var and then try to look what is the message of the > failed attribute with puts. > I using puts to print the error object to debug who is the wrong attribute. > If I use create! I will have this message: > Validation failed: Property is not valid => and cant use puts to know the > content of @errors > > If I use create and print the result of fixture I will get: > > ["n?o pode ser vazio"]}, > @base=# > And find the problem, it is just for debugging and help me to find where is > the problem, after fix this I will change to create! again. > > -- > > Anyone can figure why even property_id and owner_id are defined still raise > "can't be blank" ? > > Thanks a lot for all help. > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > On Thu, Dec 18, 2008 at 12:10 AM, aslak hellesoy > wrote: > >> >> >> On Thu, Dec 18, 2008 at 2:02 AM, Daniel Lopes wrote: >> >>> I know... I just don't use create!, in this special case, because it will >>> be more complicate to know what field have the error . >>> >> >> No it won't. The error message tells you what field has the error, and if >> creation is unsuccessful you *need* to know about it. Otherwise you'll get >> tons of false positives. I can't think of a single case where it makes sense >> to use create inside a spec. >> >> Aslak >> >> >>> I'm still scratching my head, my @tenant instance var on spec has values >>> for user_id and owner_id and don't understand why my validates_associated >>> :property raise an error. >>> >>> And if I mock model on model spec will not be a good thing. >>> >>> Atenciosamente, >>> >>> Daniel Lopes ? Area Cria??es >>> Design, Websites e Sistemas Web >>> >>> Visite: http://www.areacriacoes.com.br/projects >>> http://blog.areacriacoes.com.br/ >>> >>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>> * * >>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>> >>> >>> On Wed, Dec 17, 2008 at 10:45 PM, aslak hellesoy < >>> aslak.hellesoy at gmail.com> wrote: >>> >>>> >>>> >>>> On Thu, Dec 18, 2008 at 1:38 AM, Daniel Lopes wrote: >>>> >>>>> Hello Pat, the error still the same. at errors={"user"=>["can't be >>>>> blank"]} >>>>> >>>>> But if we look on @base we have user: >>>>> @base=#>>>> 465176508, ... > >>>>> >>>>> And my code is: >>>>> describe Tenant do >>>>> fixtures :properties, :users ,:owners >>>>> >>>>> def create_tenant(options = {}) >>>>> record = Tenant.create({ >>>>> >>>> >>>> Just a small tip. Always, always use create! in specs. You want an error >>>> to be raised in case creation is unsuccessful, and create doesn't do that - >>>> it just returns false. >>>> >>>> Aslak >>>> >>>> >>>>> :property => properties(:two), >>>>> :renters => "value for renters", >>>>> :guarantor => "value for guarantor", >>>>> :contact_name => "value for contact_name", >>>>> :contact_phone => "value for contact_phone", >>>>> :contact_email => "teste at hosttest.com", >>>>> :end_date => Date.today, >>>>> :beginning_date => Date.today, >>>>> :initial_value => "9.99" >>>>> }.merge(options)) >>>>> end >>>>> >>>>> before(:each) do >>>>> @tenant = create_tenant >>>>> end >>>>> >>>>> it "should create a new instance given valid attributes" do >>>>> properties(:two).valid? >>>>> p properties(:two).errors >>>>> # @tenant.errors.should be_empty >>>>> end >>>>> >>>>> And my fixtures still the same... I don't know what's happening, when I >>>>> try run on console or in browser everything ok... I think is something >>>>> strange with fixtures. >>>>> >>>>> Atenciosamente, >>>>> >>>>> Daniel Lopes ? Area Cria??es >>>>> Design, Websites e Sistemas Web >>>>> >>>>> Visite: http://www.areacriacoes.com.br/projects >>>>> http://blog.areacriacoes.com.br/ >>>>> >>>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>>> * * * >>>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>>> >>>>> >>>>> On Wed, Dec 17, 2008 at 10:14 PM, Pat Maddox wrote: >>>>> >>>>>> On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes >>>>>> wrote: >>>>>> > Hello Pat, even I load all my fixtures it still not reading anything >>>>>> from >>>>>> > users.yml ... >>>>>> > I will look at factory_girl but before I need understand what >>>>>> happening. >>>>>> > I try this: >>>>>> > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') >>>>>> > describe Tenant do >>>>>> > fixtures :properties, :users , :owners >>>>>> > def create_tenant(options = {}) >>>>>> > record = Tenant.create({ >>>>>> > :property => properties(:two), >>>>>> > :renters => "value for renters", >>>>>> > :guarantor => "value for guarantor", >>>>>> > :contact_name => "value for contact_name", >>>>>> > :contact_phone => "value for contact_phone", >>>>>> > :contact_email => "teste at hosttest.com", >>>>>> > :end_date => Date.today, >>>>>> > :beginning_date => Date.today, >>>>>> > :initial_value => "9.99" >>>>>> > }.merge(options)) >>>>>> > end >>>>>> > >>>>>> > before(:each) do >>>>>> > @tenant = create_tenant >>>>>> > end >>>>>> > >>>>>> > it "should create a new instance given valid attributes" do >>>>>> > p properties(:two).errors >>>>>> > properties(:two).should be_valid >>>>>> > # @tenant.errors.should be_empty >>>>>> > end >>>>>> > end >>>>>> >>>>>> What error are you getting now? Please post whatever error you're >>>>>> experiencing...when we change this code, I expect a different error, >>>>>> and would not know what it is. If it's the same, that's strange. >>>>>> >>>>>> Also, I noticed you have >>>>>> p properties(:two).errors >>>>>> properties(:two).should be_valid >>>>>> >>>>>> That's not going to show you anything, because errors don't get added >>>>>> until you call #valid? So change that to >>>>>> >>>>>> properties(:two).valid? >>>>>> p properties(:two).errors >>>>>> >>>>>> Pat >>>>>> _______________________________________________ >>>>>> 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 >>>> >>> >>> >>> _______________________________________________ >>> 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 >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at gmail.com Thu Dec 18 10:51:36 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Thu, 18 Dec 2008 13:51:36 -0200 Subject: [rspec-users] fixtures and associations In-Reply-To: <992995550812180724m723abfb7reeba13371812ee92@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> <992995550812171702h65f8cb92td0484767aabb973b@mail.gmail.com> <8d961d900812171810p479c0edbiabc7c2e2f5d3da15@mail.gmail.com> <992995550812171836p63ce38aesb1b011c5b5eae779@mail.gmail.com> <992995550812180724m723abfb7reeba13371812ee92@mail.gmail.com> Message-ID: <992995550812180751x7540ce84oe52c8739ee373a6a@mail.gmail.com> So, I think the problem is my fixture became crazy with id's and not assign the right id for the right object in association when I try use Rails 2 sintax for fixtures ( omitting the ids and using the name of the fixture in the association instead of id ) ... when I change everything to fixed id in my yml files everything works. Crazy. I'm still want to migrate to factory-girl, if anybody has material or links on github about projects using rspec and factory-girl will help alot. Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Thu, Dec 18, 2008 at 1:24 PM, Daniel Lopes wrote: > I really don't know what's going on with those hell fixtures, and start > thinking I will never find... I will try migrate all my fixtures to > factory-girl, the only problem are my six hundred examples and no time to > change all. Somebody have any link about rspec + factory-girl ? or maybe > link to any project on github that use factory-girl and rspec ? > Thanks for all help. > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > On Thu, Dec 18, 2008 at 12:36 AM, Daniel Lopes wrote: > >> I think I was misunderstood. I am not saying to use create rather than >> create! ... In this case, I just use it because will help me with puts for >> debug my own error in spec. >> In this case a really don't know what is going on, if I use create! I >> can't store the value in a var and then try to look what is the message of >> the failed attribute with puts. >> I using puts to print the error object to debug who is the wrong >> attribute. >> If I use create! I will have this message: >> Validation failed: Property is not valid => and cant use puts to know the >> content of @errors >> >> If I use create and print the result of fixture I will get: >> >> ["n?o pode ser vazio"]}, >> @base=#> >> And find the problem, it is just for debugging and help me to find where >> is the problem, after fix this I will change to create! again. >> >> -- >> >> Anyone can figure why even property_id and owner_id are defined still >> raise "can't be blank" ? >> >> Thanks a lot for all help. >> >> Atenciosamente, >> >> Daniel Lopes ? Area Cria??es >> Design, Websites e Sistemas Web >> >> Visite: http://www.areacriacoes.com.br/projects >> http://blog.areacriacoes.com.br/ >> >> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * * >> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >> >> >> On Thu, Dec 18, 2008 at 12:10 AM, aslak hellesoy < >> aslak.hellesoy at gmail.com> wrote: >> >>> >>> >>> On Thu, Dec 18, 2008 at 2:02 AM, Daniel Lopes wrote: >>> >>>> I know... I just don't use create!, in this special case, because it >>>> will be more complicate to know what field have the error . >>>> >>> >>> No it won't. The error message tells you what field has the error, and if >>> creation is unsuccessful you *need* to know about it. Otherwise you'll get >>> tons of false positives. I can't think of a single case where it makes sense >>> to use create inside a spec. >>> >>> Aslak >>> >>> >>>> I'm still scratching my head, my @tenant instance var on spec has values >>>> for user_id and owner_id and don't understand why my validates_associated >>>> :property raise an error. >>>> >>>> And if I mock model on model spec will not be a good thing. >>>> >>>> Atenciosamente, >>>> >>>> Daniel Lopes ? Area Cria??es >>>> Design, Websites e Sistemas Web >>>> >>>> Visite: http://www.areacriacoes.com.br/projects >>>> http://blog.areacriacoes.com.br/ >>>> >>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>> * * * >>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>> >>>> >>>> On Wed, Dec 17, 2008 at 10:45 PM, aslak hellesoy < >>>> aslak.hellesoy at gmail.com> wrote: >>>> >>>>> >>>>> >>>>> On Thu, Dec 18, 2008 at 1:38 AM, Daniel Lopes wrote: >>>>> >>>>>> Hello Pat, the error still the same. at errors={"user"=>["can't be >>>>>> blank"]} >>>>>> >>>>>> But if we look on @base we have user: >>>>>> @base=#>>>>> 465176508, ... > >>>>>> >>>>>> And my code is: >>>>>> describe Tenant do >>>>>> fixtures :properties, :users ,:owners >>>>>> >>>>>> def create_tenant(options = {}) >>>>>> record = Tenant.create({ >>>>>> >>>>> >>>>> Just a small tip. Always, always use create! in specs. You want an >>>>> error to be raised in case creation is unsuccessful, and create doesn't do >>>>> that - it just returns false. >>>>> >>>>> Aslak >>>>> >>>>> >>>>>> :property => properties(:two), >>>>>> :renters => "value for renters", >>>>>> :guarantor => "value for guarantor", >>>>>> :contact_name => "value for contact_name", >>>>>> :contact_phone => "value for contact_phone", >>>>>> :contact_email => "teste at hosttest.com", >>>>>> :end_date => Date.today, >>>>>> :beginning_date => Date.today, >>>>>> :initial_value => "9.99" >>>>>> }.merge(options)) >>>>>> end >>>>>> >>>>>> before(:each) do >>>>>> @tenant = create_tenant >>>>>> end >>>>>> >>>>>> it "should create a new instance given valid attributes" do >>>>>> properties(:two).valid? >>>>>> p properties(:two).errors >>>>>> # @tenant.errors.should be_empty >>>>>> end >>>>>> >>>>>> And my fixtures still the same... I don't know what's happening, when >>>>>> I try run on console or in browser everything ok... I think is something >>>>>> strange with fixtures. >>>>>> >>>>>> Atenciosamente, >>>>>> >>>>>> Daniel Lopes ? Area Cria??es >>>>>> Design, Websites e Sistemas Web >>>>>> >>>>>> Visite: http://www.areacriacoes.com.br/projects >>>>>> http://blog.areacriacoes.com.br/ >>>>>> >>>>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>>>> * * * * >>>>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>>>> >>>>>> >>>>>> On Wed, Dec 17, 2008 at 10:14 PM, Pat Maddox wrote: >>>>>> >>>>>>> On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes < >>>>>>> danielvlopes at gmail.com> wrote: >>>>>>> > Hello Pat, even I load all my fixtures it still not reading >>>>>>> anything from >>>>>>> > users.yml ... >>>>>>> > I will look at factory_girl but before I need understand what >>>>>>> happening. >>>>>>> > I try this: >>>>>>> > require File.expand_path(File.dirname(__FILE__) + >>>>>>> '/../spec_helper') >>>>>>> > describe Tenant do >>>>>>> > fixtures :properties, :users , :owners >>>>>>> > def create_tenant(options = {}) >>>>>>> > record = Tenant.create({ >>>>>>> > :property => properties(:two), >>>>>>> > :renters => "value for renters", >>>>>>> > :guarantor => "value for guarantor", >>>>>>> > :contact_name => "value for contact_name", >>>>>>> > :contact_phone => "value for contact_phone", >>>>>>> > :contact_email => "teste at hosttest.com", >>>>>>> > :end_date => Date.today, >>>>>>> > :beginning_date => Date.today, >>>>>>> > :initial_value => "9.99" >>>>>>> > }.merge(options)) >>>>>>> > end >>>>>>> > >>>>>>> > before(:each) do >>>>>>> > @tenant = create_tenant >>>>>>> > end >>>>>>> > >>>>>>> > it "should create a new instance given valid attributes" do >>>>>>> > p properties(:two).errors >>>>>>> > properties(:two).should be_valid >>>>>>> > # @tenant.errors.should be_empty >>>>>>> > end >>>>>>> > end >>>>>>> >>>>>>> What error are you getting now? Please post whatever error you're >>>>>>> experiencing...when we change this code, I expect a different error, >>>>>>> and would not know what it is. If it's the same, that's strange. >>>>>>> >>>>>>> Also, I noticed you have >>>>>>> p properties(:two).errors >>>>>>> properties(:two).should be_valid >>>>>>> >>>>>>> That's not going to show you anything, because errors don't get added >>>>>>> until you call #valid? So change that to >>>>>>> >>>>>>> properties(:two).valid? >>>>>>> p properties(:two).errors >>>>>>> >>>>>>> Pat >>>>>>> _______________________________________________ >>>>>>> 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 >>>>> >>>> >>>> >>>> _______________________________________________ >>>> 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 >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.mischa at gmail.com Thu Dec 18 11:16:57 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Thu, 18 Dec 2008 08:16:57 -0800 Subject: [rspec-users] fixtures and associations In-Reply-To: <992995550812180724m723abfb7reeba13371812ee92@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> <992995550812171702h65f8cb92td0484767aabb973b@mail.gmail.com> <8d961d900812171810p479c0edbiabc7c2e2f5d3da15@mail.gmail.com> <992995550812171836p63ce38aesb1b011c5b5eae779@mail.gmail.com> <992995550812180724m723abfb7reeba13371812ee92@mail.gmail.com> Message-ID: http://toolmantim.com/article/2008/10/27/fixtureless_datas_with_machinist_and_sham http://www.slideshare.net/toolmantim/cucumbers-presentation http://github.com/tpope/pickler/tree/master On Thu, Dec 18, 2008 at 7:24 AM, Daniel Lopes wrote: > I really don't know what's going on with those hell fixtures, and start > thinking I will never find... I will try migrate all my fixtures to > factory-girl, the only problem are my six hundred examples and no time to > change all. Somebody have any link about rspec + factory-girl ? or maybe > link to any project on github that use factory-girl and rspec ? > Thanks for all help. > > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > On Thu, Dec 18, 2008 at 12:36 AM, Daniel Lopes wrote: > >> I think I was misunderstood. I am not saying to use create rather than >> create! ... In this case, I just use it because will help me with puts for >> debug my own error in spec. >> In this case a really don't know what is going on, if I use create! I >> can't store the value in a var and then try to look what is the message of >> the failed attribute with puts. >> I using puts to print the error object to debug who is the wrong >> attribute. >> If I use create! I will have this message: >> Validation failed: Property is not valid => and cant use puts to know the >> content of @errors >> >> If I use create and print the result of fixture I will get: >> >> ["n?o pode ser vazio"]}, >> @base=#> >> And find the problem, it is just for debugging and help me to find where >> is the problem, after fix this I will change to create! again. >> >> -- >> >> Anyone can figure why even property_id and owner_id are defined still >> raise "can't be blank" ? >> >> Thanks a lot for all help. >> >> Atenciosamente, >> >> Daniel Lopes ? Area Cria??es >> Design, Websites e Sistemas Web >> >> Visite: http://www.areacriacoes.com.br/projects >> http://blog.areacriacoes.com.br/ >> >> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * * >> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >> >> >> On Thu, Dec 18, 2008 at 12:10 AM, aslak hellesoy < >> aslak.hellesoy at gmail.com> wrote: >> >>> >>> >>> On Thu, Dec 18, 2008 at 2:02 AM, Daniel Lopes wrote: >>> >>>> I know... I just don't use create!, in this special case, because it >>>> will be more complicate to know what field have the error . >>>> >>> >>> No it won't. The error message tells you what field has the error, and if >>> creation is unsuccessful you *need* to know about it. Otherwise you'll get >>> tons of false positives. I can't think of a single case where it makes sense >>> to use create inside a spec. >>> >>> Aslak >>> >>> >>>> I'm still scratching my head, my @tenant instance var on spec has values >>>> for user_id and owner_id and don't understand why my validates_associated >>>> :property raise an error. >>>> >>>> And if I mock model on model spec will not be a good thing. >>>> >>>> Atenciosamente, >>>> >>>> Daniel Lopes ? Area Cria??es >>>> Design, Websites e Sistemas Web >>>> >>>> Visite: http://www.areacriacoes.com.br/projects >>>> http://blog.areacriacoes.com.br/ >>>> >>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>> * * * >>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>> >>>> >>>> On Wed, Dec 17, 2008 at 10:45 PM, aslak hellesoy < >>>> aslak.hellesoy at gmail.com> wrote: >>>> >>>>> >>>>> >>>>> On Thu, Dec 18, 2008 at 1:38 AM, Daniel Lopes wrote: >>>>> >>>>>> Hello Pat, the error still the same. at errors={"user"=>["can't be >>>>>> blank"]} >>>>>> >>>>>> But if we look on @base we have user: >>>>>> @base=#>>>>> 465176508, ... > >>>>>> >>>>>> And my code is: >>>>>> describe Tenant do >>>>>> fixtures :properties, :users ,:owners >>>>>> >>>>>> def create_tenant(options = {}) >>>>>> record = Tenant.create({ >>>>>> >>>>> >>>>> Just a small tip. Always, always use create! in specs. You want an >>>>> error to be raised in case creation is unsuccessful, and create doesn't do >>>>> that - it just returns false. >>>>> >>>>> Aslak >>>>> >>>>> >>>>>> :property => properties(:two), >>>>>> :renters => "value for renters", >>>>>> :guarantor => "value for guarantor", >>>>>> :contact_name => "value for contact_name", >>>>>> :contact_phone => "value for contact_phone", >>>>>> :contact_email => "teste at hosttest.com", >>>>>> :end_date => Date.today, >>>>>> :beginning_date => Date.today, >>>>>> :initial_value => "9.99" >>>>>> }.merge(options)) >>>>>> end >>>>>> >>>>>> before(:each) do >>>>>> @tenant = create_tenant >>>>>> end >>>>>> >>>>>> it "should create a new instance given valid attributes" do >>>>>> properties(:two).valid? >>>>>> p properties(:two).errors >>>>>> # @tenant.errors.should be_empty >>>>>> end >>>>>> >>>>>> And my fixtures still the same... I don't know what's happening, when >>>>>> I try run on console or in browser everything ok... I think is something >>>>>> strange with fixtures. >>>>>> >>>>>> Atenciosamente, >>>>>> >>>>>> Daniel Lopes ? Area Cria??es >>>>>> Design, Websites e Sistemas Web >>>>>> >>>>>> Visite: http://www.areacriacoes.com.br/projects >>>>>> http://blog.areacriacoes.com.br/ >>>>>> >>>>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>>>> * * * * >>>>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>>>> >>>>>> >>>>>> On Wed, Dec 17, 2008 at 10:14 PM, Pat Maddox wrote: >>>>>> >>>>>>> On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes < >>>>>>> danielvlopes at gmail.com> wrote: >>>>>>> > Hello Pat, even I load all my fixtures it still not reading >>>>>>> anything from >>>>>>> > users.yml ... >>>>>>> > I will look at factory_girl but before I need understand what >>>>>>> happening. >>>>>>> > I try this: >>>>>>> > require File.expand_path(File.dirname(__FILE__) + >>>>>>> '/../spec_helper') >>>>>>> > describe Tenant do >>>>>>> > fixtures :properties, :users , :owners >>>>>>> > def create_tenant(options = {}) >>>>>>> > record = Tenant.create({ >>>>>>> > :property => properties(:two), >>>>>>> > :renters => "value for renters", >>>>>>> > :guarantor => "value for guarantor", >>>>>>> > :contact_name => "value for contact_name", >>>>>>> > :contact_phone => "value for contact_phone", >>>>>>> > :contact_email => "teste at hosttest.com", >>>>>>> > :end_date => Date.today, >>>>>>> > :beginning_date => Date.today, >>>>>>> > :initial_value => "9.99" >>>>>>> > }.merge(options)) >>>>>>> > end >>>>>>> > >>>>>>> > before(:each) do >>>>>>> > @tenant = create_tenant >>>>>>> > end >>>>>>> > >>>>>>> > it "should create a new instance given valid attributes" do >>>>>>> > p properties(:two).errors >>>>>>> > properties(:two).should be_valid >>>>>>> > # @tenant.errors.should be_empty >>>>>>> > end >>>>>>> > end >>>>>>> >>>>>>> What error are you getting now? Please post whatever error you're >>>>>>> experiencing...when we change this code, I expect a different error, >>>>>>> and would not know what it is. If it's the same, that's strange. >>>>>>> >>>>>>> Also, I noticed you have >>>>>>> p properties(:two).errors >>>>>>> properties(:two).should be_valid >>>>>>> >>>>>>> That's not going to show you anything, because errors don't get added >>>>>>> until you call #valid? So change that to >>>>>>> >>>>>>> properties(:two).valid? >>>>>>> p properties(:two).errors >>>>>>> >>>>>>> Pat >>>>>>> _______________________________________________ >>>>>>> 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 >>>>> >>>> >>>> >>>> _______________________________________________ >>>> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From f.mischa at gmail.com Thu Dec 18 11:18:04 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Thu, 18 Dec 2008 08:18:04 -0800 Subject: [rspec-users] fixtures and associations In-Reply-To: References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> <992995550812171702h65f8cb92td0484767aabb973b@mail.gmail.com> <8d961d900812171810p479c0edbiabc7c2e2f5d3da15@mail.gmail.com> <992995550812171836p63ce38aesb1b011c5b5eae779@mail.gmail.com> <992995550812180724m723abfb7reeba13371812ee92@mail.gmail.com> Message-ID: oops that last one was supposed to be http://github.com/ianwhite/pickle/tree/master similar names On Thu, Dec 18, 2008 at 8:16 AM, Mischa Fierer wrote: > > http://toolmantim.com/article/2008/10/27/fixtureless_datas_with_machinist_and_sham > > http://www.slideshare.net/toolmantim/cucumbers-presentation > > http://github.com/tpope/pickler/tree/master > > > > On Thu, Dec 18, 2008 at 7:24 AM, Daniel Lopes wrote: > >> I really don't know what's going on with those hell fixtures, and start >> thinking I will never find... I will try migrate all my fixtures to >> factory-girl, the only problem are my six hundred examples and no time to >> change all. Somebody have any link about rspec + factory-girl ? or maybe >> link to any project on github that use factory-girl and rspec ? >> Thanks for all help. >> >> Atenciosamente, >> >> Daniel Lopes ? Area Cria??es >> Design, Websites e Sistemas Web >> >> Visite: http://www.areacriacoes.com.br/projects >> http://blog.areacriacoes.com.br/ >> >> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * * >> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >> >> >> On Thu, Dec 18, 2008 at 12:36 AM, Daniel Lopes wrote: >> >>> I think I was misunderstood. I am not saying to use create rather than >>> create! ... In this case, I just use it because will help me with puts for >>> debug my own error in spec. >>> In this case a really don't know what is going on, if I use create! I >>> can't store the value in a var and then try to look what is the message of >>> the failed attribute with puts. >>> I using puts to print the error object to debug who is the wrong >>> attribute. >>> If I use create! I will have this message: >>> Validation failed: Property is not valid => and cant use puts to know the >>> content of @errors >>> >>> If I use create and print the result of fixture I will get: >>> >>> ["n?o pode ser vazio"]}, >>> @base=#>> >>> And find the problem, it is just for debugging and help me to find where >>> is the problem, after fix this I will change to create! again. >>> >>> -- >>> >>> Anyone can figure why even property_id and owner_id are defined still >>> raise "can't be blank" ? >>> >>> Thanks a lot for all help. >>> >>> Atenciosamente, >>> >>> Daniel Lopes ? Area Cria??es >>> Design, Websites e Sistemas Web >>> >>> Visite: http://www.areacriacoes.com.br/projects >>> http://blog.areacriacoes.com.br/ >>> >>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>> * * >>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>> >>> >>> On Thu, Dec 18, 2008 at 12:10 AM, aslak hellesoy < >>> aslak.hellesoy at gmail.com> wrote: >>> >>>> >>>> >>>> On Thu, Dec 18, 2008 at 2:02 AM, Daniel Lopes wrote: >>>> >>>>> I know... I just don't use create!, in this special case, because it >>>>> will be more complicate to know what field have the error . >>>>> >>>> >>>> No it won't. The error message tells you what field has the error, and >>>> if creation is unsuccessful you *need* to know about it. Otherwise you'll >>>> get tons of false positives. I can't think of a single case where it makes >>>> sense to use create inside a spec. >>>> >>>> Aslak >>>> >>>> >>>>> I'm still scratching my head, my @tenant instance var on spec has >>>>> values for user_id and owner_id and don't understand why >>>>> my validates_associated :property raise an error. >>>>> >>>>> And if I mock model on model spec will not be a good thing. >>>>> >>>>> Atenciosamente, >>>>> >>>>> Daniel Lopes ? Area Cria??es >>>>> Design, Websites e Sistemas Web >>>>> >>>>> Visite: http://www.areacriacoes.com.br/projects >>>>> http://blog.areacriacoes.com.br/ >>>>> >>>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>>> * * * >>>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>>> >>>>> >>>>> On Wed, Dec 17, 2008 at 10:45 PM, aslak hellesoy < >>>>> aslak.hellesoy at gmail.com> wrote: >>>>> >>>>>> >>>>>> >>>>>> On Thu, Dec 18, 2008 at 1:38 AM, Daniel Lopes >>>>> > wrote: >>>>>> >>>>>>> Hello Pat, the error still the same. at errors={"user"=>["can't be >>>>>>> blank"]} >>>>>>> >>>>>>> But if we look on @base we have user: >>>>>>> @base=#>>>>>> 465176508, ... > >>>>>>> >>>>>>> And my code is: >>>>>>> describe Tenant do >>>>>>> fixtures :properties, :users ,:owners >>>>>>> >>>>>>> def create_tenant(options = {}) >>>>>>> record = Tenant.create({ >>>>>>> >>>>>> >>>>>> Just a small tip. Always, always use create! in specs. You want an >>>>>> error to be raised in case creation is unsuccessful, and create doesn't do >>>>>> that - it just returns false. >>>>>> >>>>>> Aslak >>>>>> >>>>>> >>>>>>> :property => properties(:two), >>>>>>> :renters => "value for renters", >>>>>>> :guarantor => "value for guarantor", >>>>>>> :contact_name => "value for contact_name", >>>>>>> :contact_phone => "value for contact_phone", >>>>>>> :contact_email => "teste at hosttest.com", >>>>>>> :end_date => Date.today, >>>>>>> :beginning_date => Date.today, >>>>>>> :initial_value => "9.99" >>>>>>> }.merge(options)) >>>>>>> end >>>>>>> >>>>>>> before(:each) do >>>>>>> @tenant = create_tenant >>>>>>> end >>>>>>> >>>>>>> it "should create a new instance given valid attributes" do >>>>>>> properties(:two).valid? >>>>>>> p properties(:two).errors >>>>>>> # @tenant.errors.should be_empty >>>>>>> end >>>>>>> >>>>>>> And my fixtures still the same... I don't know what's happening, when >>>>>>> I try run on console or in browser everything ok... I think is something >>>>>>> strange with fixtures. >>>>>>> >>>>>>> Atenciosamente, >>>>>>> >>>>>>> Daniel Lopes ? Area Cria??es >>>>>>> Design, Websites e Sistemas Web >>>>>>> >>>>>>> Visite: http://www.areacriacoes.com.br/projects >>>>>>> http://blog.areacriacoes.com.br/ >>>>>>> >>>>>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>>>>> * * * * >>>>>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>>>>> >>>>>>> >>>>>>> On Wed, Dec 17, 2008 at 10:14 PM, Pat Maddox wrote: >>>>>>> >>>>>>>> On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes < >>>>>>>> danielvlopes at gmail.com> wrote: >>>>>>>> > Hello Pat, even I load all my fixtures it still not reading >>>>>>>> anything from >>>>>>>> > users.yml ... >>>>>>>> > I will look at factory_girl but before I need understand what >>>>>>>> happening. >>>>>>>> > I try this: >>>>>>>> > require File.expand_path(File.dirname(__FILE__) + >>>>>>>> '/../spec_helper') >>>>>>>> > describe Tenant do >>>>>>>> > fixtures :properties, :users , :owners >>>>>>>> > def create_tenant(options = {}) >>>>>>>> > record = Tenant.create({ >>>>>>>> > :property => properties(:two), >>>>>>>> > :renters => "value for renters", >>>>>>>> > :guarantor => "value for guarantor", >>>>>>>> > :contact_name => "value for contact_name", >>>>>>>> > :contact_phone => "value for contact_phone", >>>>>>>> > :contact_email => "teste at hosttest.com", >>>>>>>> > :end_date => Date.today, >>>>>>>> > :beginning_date => Date.today, >>>>>>>> > :initial_value => "9.99" >>>>>>>> > }.merge(options)) >>>>>>>> > end >>>>>>>> > >>>>>>>> > before(:each) do >>>>>>>> > @tenant = create_tenant >>>>>>>> > end >>>>>>>> > >>>>>>>> > it "should create a new instance given valid attributes" do >>>>>>>> > p properties(:two).errors >>>>>>>> > properties(:two).should be_valid >>>>>>>> > # @tenant.errors.should be_empty >>>>>>>> > end >>>>>>>> > end >>>>>>>> >>>>>>>> What error are you getting now? Please post whatever error you're >>>>>>>> experiencing...when we change this code, I expect a different error, >>>>>>>> and would not know what it is. If it's the same, that's strange. >>>>>>>> >>>>>>>> Also, I noticed you have >>>>>>>> p properties(:two).errors >>>>>>>> properties(:two).should be_valid >>>>>>>> >>>>>>>> That's not going to show you anything, because errors don't get >>>>>>>> added >>>>>>>> until you call #valid? So change that to >>>>>>>> >>>>>>>> properties(:two).valid? >>>>>>>> p properties(:two).errors >>>>>>>> >>>>>>>> Pat >>>>>>>> _______________________________________________ >>>>>>>> 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 >>>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> 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 >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mwilden.com Thu Dec 18 11:18:35 2008 From: mark at mwilden.com (Mark Wilden) Date: Thu, 18 Dec 2008 08:18:35 -0800 Subject: [rspec-users] fixtures and associations In-Reply-To: <992995550812180724m723abfb7reeba13371812ee92@mail.gmail.com> References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <992995550812171413u34d98e97mc3ae3b45b200d5b8@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> <992995550812171702h65f8cb92td0484767aabb973b@mail.gmail.com> <8d961d900812171810p479c0edbiabc7c2e2f5d3da15@mail.gmail.com> <992995550812171836p63ce38aesb1b011c5b5eae779@mail.gmail.com> <992995550812180724m723abfb7reeba13371812ee92@mail.gmail.com> Message-ID: <3c30da400812180818i34610e7em5bd1a92e9ddb4b77@mail.gmail.com> On Thu, Dec 18, 2008 at 7:24 AM, Daniel Lopes wrote: > I really don't know what's going on with those hell fixtures, and start > thinking I will never find... I will try migrate all my fixtures to > factory-girl, the only problem are my six hundred examples and no time to > change all. You don't have to change all your fixtures to factories right now, of course, and, indeed, you should not. Just change the ones that are giving you problems for now; and later, maybe, change each on as you work on it. /// -------------- next part -------------- An HTML attachment was scrubbed... URL: From danielvlopes at gmail.com Thu Dec 18 12:36:41 2008 From: danielvlopes at gmail.com (Daniel Lopes) Date: Thu, 18 Dec 2008 15:36:41 -0200 Subject: [rspec-users] fixtures and associations In-Reply-To: References: <992995550812171037p4e973f13re0d3659a8656b2a5@mail.gmail.com> <810a540e0812171614n3292229cic7360faccb9cf063@mail.gmail.com> <992995550812171638w66e801dj686ee8fb9aa73a7c@mail.gmail.com> <8d961d900812171645v7b16a394s4b49deee3ba63b4a@mail.gmail.com> <992995550812171702h65f8cb92td0484767aabb973b@mail.gmail.com> <8d961d900812171810p479c0edbiabc7c2e2f5d3da15@mail.gmail.com> <992995550812171836p63ce38aesb1b011c5b5eae779@mail.gmail.com> <992995550812180724m723abfb7reeba13371812ee92@mail.gmail.com> Message-ID: <992995550812180936v316f0ceq71b7f7517bd8196c@mail.gmail.com> Thanks everybody... Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Thu, Dec 18, 2008 at 2:18 PM, Mischa Fierer wrote: > oops > that last one was supposed to be > > http://github.com/ianwhite/pickle/tree/master > > similar names > > On Thu, Dec 18, 2008 at 8:16 AM, Mischa Fierer wrote: > >> >> http://toolmantim.com/article/2008/10/27/fixtureless_datas_with_machinist_and_sham >> >> http://www.slideshare.net/toolmantim/cucumbers-presentation >> >> http://github.com/tpope/pickler/tree/master >> >> >> >> On Thu, Dec 18, 2008 at 7:24 AM, Daniel Lopes wrote: >> >>> I really don't know what's going on with those hell fixtures, and start >>> thinking I will never find... I will try migrate all my fixtures to >>> factory-girl, the only problem are my six hundred examples and no time to >>> change all. Somebody have any link about rspec + factory-girl ? or maybe >>> link to any project on github that use factory-girl and rspec ? >>> Thanks for all help. >>> >>> Atenciosamente, >>> >>> Daniel Lopes ? Area Cria??es >>> Design, Websites e Sistemas Web >>> >>> Visite: http://www.areacriacoes.com.br/projects >>> http://blog.areacriacoes.com.br/ >>> >>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>> * * >>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>> >>> >>> On Thu, Dec 18, 2008 at 12:36 AM, Daniel Lopes wrote: >>> >>>> I think I was misunderstood. I am not saying to use create rather than >>>> create! ... In this case, I just use it because will help me with puts for >>>> debug my own error in spec. >>>> In this case a really don't know what is going on, if I use create! I >>>> can't store the value in a var and then try to look what is the message of >>>> the failed attribute with puts. >>>> I using puts to print the error object to debug who is the wrong >>>> attribute. >>>> If I use create! I will have this message: >>>> Validation failed: Property is not valid => and cant use puts to know >>>> the content of @errors >>>> >>>> If I use create and print the result of fixture I will get: >>>> >>>> ["n?o pode ser >>>> vazio"]}, @base=#>>> >>>> And find the problem, it is just for debugging and help me to find where >>>> is the problem, after fix this I will change to create! again. >>>> >>>> -- >>>> >>>> Anyone can figure why even property_id and owner_id are defined still >>>> raise "can't be blank" ? >>>> >>>> Thanks a lot for all help. >>>> >>>> Atenciosamente, >>>> >>>> Daniel Lopes ? Area Cria??es >>>> Design, Websites e Sistemas Web >>>> >>>> Visite: http://www.areacriacoes.com.br/projects >>>> http://blog.areacriacoes.com.br/ >>>> >>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>> * * * >>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>> >>>> >>>> On Thu, Dec 18, 2008 at 12:10 AM, aslak hellesoy < >>>> aslak.hellesoy at gmail.com> wrote: >>>> >>>>> >>>>> >>>>> On Thu, Dec 18, 2008 at 2:02 AM, Daniel Lopes wrote: >>>>> >>>>>> I know... I just don't use create!, in this special case, because it >>>>>> will be more complicate to know what field have the error . >>>>>> >>>>> >>>>> No it won't. The error message tells you what field has the error, and >>>>> if creation is unsuccessful you *need* to know about it. Otherwise you'll >>>>> get tons of false positives. I can't think of a single case where it makes >>>>> sense to use create inside a spec. >>>>> >>>>> Aslak >>>>> >>>>> >>>>>> I'm still scratching my head, my @tenant instance var on spec has >>>>>> values for user_id and owner_id and don't understand why >>>>>> my validates_associated :property raise an error. >>>>>> >>>>>> And if I mock model on model spec will not be a good thing. >>>>>> >>>>>> Atenciosamente, >>>>>> >>>>>> Daniel Lopes ? Area Cria??es >>>>>> Design, Websites e Sistemas Web >>>>>> >>>>>> Visite: http://www.areacriacoes.com.br/projects >>>>>> http://blog.areacriacoes.com.br/ >>>>>> >>>>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>>>> * * * * >>>>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>>>> >>>>>> >>>>>> On Wed, Dec 17, 2008 at 10:45 PM, aslak hellesoy < >>>>>> aslak.hellesoy at gmail.com> wrote: >>>>>> >>>>>>> >>>>>>> >>>>>>> On Thu, Dec 18, 2008 at 1:38 AM, Daniel Lopes < >>>>>>> danielvlopes at gmail.com> wrote: >>>>>>> >>>>>>>> Hello Pat, the error still the same. at errors={"user"=>["can't be >>>>>>>> blank"]} >>>>>>>> >>>>>>>> But if we look on @base we have user: >>>>>>>> @base=#>>>>>>> 465176508, ... > >>>>>>>> >>>>>>>> And my code is: >>>>>>>> describe Tenant do >>>>>>>> fixtures :properties, :users ,:owners >>>>>>>> >>>>>>>> def create_tenant(options = {}) >>>>>>>> record = Tenant.create({ >>>>>>>> >>>>>>> >>>>>>> Just a small tip. Always, always use create! in specs. You want an >>>>>>> error to be raised in case creation is unsuccessful, and create doesn't do >>>>>>> that - it just returns false. >>>>>>> >>>>>>> Aslak >>>>>>> >>>>>>> >>>>>>>> :property => properties(:two), >>>>>>>> :renters => "value for renters", >>>>>>>> :guarantor => "value for guarantor", >>>>>>>> :contact_name => "value for contact_name", >>>>>>>> :contact_phone => "value for contact_phone", >>>>>>>> :contact_email => "teste at hosttest.com", >>>>>>>> :end_date => Date.today, >>>>>>>> :beginning_date => Date.today, >>>>>>>> :initial_value => "9.99" >>>>>>>> }.merge(options)) >>>>>>>> end >>>>>>>> >>>>>>>> before(:each) do >>>>>>>> @tenant = create_tenant >>>>>>>> end >>>>>>>> >>>>>>>> it "should create a new instance given valid attributes" do >>>>>>>> properties(:two).valid? >>>>>>>> p properties(:two).errors >>>>>>>> # @tenant.errors.should be_empty >>>>>>>> end >>>>>>>> >>>>>>>> And my fixtures still the same... I don't know what's happening, >>>>>>>> when I try run on console or in browser everything ok... I think is >>>>>>>> something strange with fixtures. >>>>>>>> >>>>>>>> Atenciosamente, >>>>>>>> >>>>>>>> Daniel Lopes ? Area Cria??es >>>>>>>> Design, Websites e Sistemas Web >>>>>>>> >>>>>>>> Visite: http://www.areacriacoes.com.br/projects >>>>>>>> http://blog.areacriacoes.com.br/ >>>>>>>> >>>>>>>> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >>>>>>>> * * * * * >>>>>>>> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >>>>>>>> >>>>>>>> >>>>>>>> On Wed, Dec 17, 2008 at 10:14 PM, Pat Maddox wrote: >>>>>>>> >>>>>>>>> On Wed, Dec 17, 2008 at 2:13 PM, Daniel Lopes < >>>>>>>>> danielvlopes at gmail.com> wrote: >>>>>>>>> > Hello Pat, even I load all my fixtures it still not reading >>>>>>>>> anything from >>>>>>>>> > users.yml ... >>>>>>>>> > I will look at factory_girl but before I need understand what >>>>>>>>> happening. >>>>>>>>> > I try this: >>>>>>>>> > require File.expand_path(File.dirname(__FILE__) + >>>>>>>>> '/../spec_helper') >>>>>>>>> > describe Tenant do >>>>>>>>> > fixtures :properties, :users , :owners >>>>>>>>> > def create_tenant(options = {}) >>>>>>>>> > record = Tenant.create({ >>>>>>>>> > :property => properties(:two), >>>>>>>>> > :renters => "value for renters", >>>>>>>>> > :guarantor => "value for guarantor", >>>>>>>>> > :contact_name => "value for contact_name", >>>>>>>>> > :contact_phone => "value for contact_phone", >>>>>>>>> > :contact_email => "teste at hosttest.com", >>>>>>>>> > :end_date => Date.today, >>>>>>>>> > :beginning_date => Date.today, >>>>>>>>> > :initial_value => "9.99" >>>>>>>>> > }.merge(options)) >>>>>>>>> > end >>>>>>>>> > >>>>>>>>> > before(:each) do >>>>>>>>> > @tenant = create_tenant >>>>>>>>> > end >>>>>>>>> > >>>>>>>>> > it "should create a new instance given valid attributes" do >>>>>>>>> > p properties(:two).errors >>>>>>>>> > properties(:two).should be_valid >>>>>>>>> > # @tenant.errors.should be_empty >>>>>>>>> > end >>>>>>>>> > end >>>>>>>>> >>>>>>>>> What error are you getting now? Please post whatever error you're >>>>>>>>> experiencing...when we change this code, I expect a different >>>>>>>>> error, >>>>>>>>> and would not know what it is. If it's the same, that's strange. >>>>>>>>> >>>>>>>>> Also, I noticed you have >>>>>>>>> p properties(:two).errors >>>>>>>>> properties(:two).should be_valid >>>>>>>>> >>>>>>>>> That's not going to show you anything, because errors don't get >>>>>>>>> added >>>>>>>>> until you call #valid? So change that to >>>>>>>>> >>>>>>>>> properties(:two).valid? >>>>>>>>> p properties(:two).errors >>>>>>>>> >>>>>>>>> Pat >>>>>>>>> _______________________________________________ >>>>>>>>> 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 >>>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> 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 >>> >> >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Thu Dec 18 20:08:09 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 19 Dec 2008 01:08:09 +0000 Subject: [rspec-users] Broken rake tasks In-Reply-To: References: <88fd8ddc0812040054q432b832cudc842753b084bb6e@mail.gmail.com> Message-ID: <88fd8ddc0812181708q6ee23aa0j9a3ea2bd610fd022@mail.gmail.com> No I don't think so. I'll post something when I next try and get the tasks to work 2008/12/17 Ivor Paul > HI Andrew > > I am getting the same problem. I only get it when I install > rspec-rails alongside rspec as gems. > > Did you get a resolution to this problem? > > Ivor > > On Thu, Dec 4, 2008 at 10:54 AM, Andrew Premdas > wrote: > > I've got a couple of rake tasks that seem to have broken with rspec > 1.1.11. > > http://pastie.org/330719 > > > > The trace I'm getting is > > > > > /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in > > `files_to_load': File or directory not found: tc:load (RuntimeError) > > from > > > /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > > `each' > > from > > > /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in > > `files_to_load' > > from > > /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in > > `run_examples' > > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in `run' > > from > /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in > > `register_at_exit_hook' > > from /usr/bin/rake:19 > > > > Now I'm not even sure why spec/runner is running these tasks. > > > > Any ideas? > > > > All best > > > > Andrew > > > > > > > > > > > > > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.a.jaros at gmail.com Thu Dec 18 20:18:28 2008 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Thu, 18 Dec 2008 20:18:28 -0500 Subject: [rspec-users] [Cucumber] Autotest and multiple scenarios In-Reply-To: <1ebf5a4d0812171358j3ce1e30bhac808ea2395afbd9@mail.gmail.com> References: <1ebf5a4d0812171358j3ce1e30bhac808ea2395afbd9@mail.gmail.com> Message-ID: <937d9d810812181718p7cf30d2co7d884ec4ed8a748d@mail.gmail.com> On Wed, Dec 17, 2008 at 4:58 PM, Tim Walker wrote: > Using AUTOFEATURE=true autospec and have a feature with multiple > scenarios. When we save the feature or steps file AUTOTEST seems to > only run the last scenario. Is this a known issue or are we doing > something boneheaded, or both!? Neither, I think. :) I assume that scenario isn't passing. It will only run scenarios which don't pass until they've all passed. Then it will run them all from the top to make sure they still all pass. The idea is to run the ones you're working on and not bother with the rest, since running an entire feature suite on every save would take far too long. Then, when you're done, autotest/autospec runs the whole suite to check for regressions. Peter From apremdas at gmail.com Fri Dec 19 01:09:31 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 19 Dec 2008 06:09:31 +0000 Subject: [rspec-users] Using semantics in steps Message-ID: <88fd8ddc0812182209x687751d4y4920910f9808bc35@mail.gmail.com> Hi All, Wanted to put this idea forward, see what you think of it. I'm using Aslaks lorry feature to illustrate this. See http://github.com/aslakhellesoy/cucumber_rails/tree/master/features/step_definitions/lorry_steps.rb . In particular within("table > tr:nth-child(#{pos.to_i+1})") do click_link "Destroy" and Then /^I should see the following lorries:$/ do |lorries| lorries.raw[1..-1].each_with_index do |row, i| row.each_with_index do |cell, j| response.should have_selector("table > tr:nth-child(#{i+2}) > td:nth-child(#{j+1})") { |td| td.inner_text.should == cell } end end Now imagine this is a real project, and your designer comes along and decides that lorries really should be shown in a horizontal scrolling zoomable javascript widgity thing. Now out go the tables and the scenario breaks. However if we use something like within("#lorries > .lorry:nth-child # not tested this syntax, hope the meaning is clear then we have 1) Defined semantic tags that the designer should not touch 2) Not relied on any html elements that a designer might change 3) Created a step that works with the meaning of the UI not its presentation So what do you think? Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivorpaul at gmail.com Fri Dec 19 08:06:50 2008 From: ivorpaul at gmail.com (Ivor Paul) Date: Fri, 19 Dec 2008 15:06:50 +0200 Subject: [rspec-users] Broken rake tasks In-Reply-To: <88fd8ddc0812181708q6ee23aa0j9a3ea2bd610fd022@mail.gmail.com> References: <88fd8ddc0812040054q432b832cudc842753b084bb6e@mail.gmail.com> <88fd8ddc0812181708q6ee23aa0j9a3ea2bd610fd022@mail.gmail.com> Message-ID: The latest rspec-rails and rspec worked for me. Are you using the remarkable gem? On Fri, Dec 19, 2008 at 3:08 AM, Andrew Premdas wrote: > No I don't think so. I'll post something when I next try and get the tasks > to work > > 2008/12/17 Ivor Paul > > HI Andrew >> >> I am getting the same problem. I only get it when I install >> rspec-rails alongside rspec as gems. >> >> Did you get a resolution to this problem? >> >> Ivor >> >> On Thu, Dec 4, 2008 at 10:54 AM, Andrew Premdas >> wrote: >> > I've got a couple of rake tasks that seem to have broken with rspec >> 1.1.11. >> > http://pastie.org/330719 >> > >> > The trace I'm getting is >> > >> > >> /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:229:in >> > `files_to_load': File or directory not found: tc:load (RuntimeError) >> > from >> > >> /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in >> > `each' >> > from >> > >> /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:221:in >> > `files_to_load' >> > from >> > >> /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner/options.rb:98:in >> > `run_examples' >> > from /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec.rb:21:in >> `run' >> > from >> /Library/Ruby/Gems/1.8/gems/rspec-1.1.11/lib/spec/runner.rb:191:in >> > `register_at_exit_hook' >> > from /usr/bin/rake:19 >> > >> > Now I'm not even sure why spec/runner is running these tasks. >> > >> > Any ideas? >> > >> > All best >> > >> > Andrew >> > >> > >> > >> > >> > >> > >> > _______________________________________________ >> > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.a.jaros at gmail.com Fri Dec 19 09:53:56 2008 From: peter.a.jaros at gmail.com (Peter Jaros) Date: Fri, 19 Dec 2008 09:53:56 -0500 Subject: [rspec-users] Using semantics in steps In-Reply-To: <88fd8ddc0812182209x687751d4y4920910f9808bc35@mail.gmail.com> References: <88fd8ddc0812182209x687751d4y4920910f9808bc35@mail.gmail.com> Message-ID: <937d9d810812190653u1e0b0560ja6bbf757382c1f36@mail.gmail.com> On Fri, Dec 19, 2008 at 1:09 AM, Andrew Premdas wrote: > then we have > > 1) Defined semantic tags that the designer should not touch > 2) Not relied on any html elements that a designer might change > 3) Created a step that works with the meaning of the UI not its presentation > > So what do you think? 100% agree. The more semantic your test code is, the less likely it is to break, and the more likely it ought to when it does. If there's no longer a #lorries element on the page, the step will fail, but that's a lot like saying that if the lorries aren't on the page the step will fail. And that's a good thing. Peter From lists at ruby-forum.com Fri Dec 19 10:50:06 2008 From: lists at ruby-forum.com (James Byrne) Date: Fri, 19 Dec 2008 16:50:06 +0100 Subject: [rspec-users] OT: Implementation Question Message-ID: <97040d7a24eb6e5166c83758d4410130@ruby-forum.com> I have asked about this issue on several different mailing lists and have had no response. If anyone here can offer some advice then I would be much obliged. I have a feature that essentially says: Given I have a user "myuser" When I fill in "User Name" with "MyUser" And I press "Login" Then I should find a user "myuser" And I should be logged in The steps definitions for this are all quite conventional and at the moment "Then I should find the user "myuser"" is failing, as expected. My question is: What is best practice with respect to normalizing form input data? My feeling is that this sort of thing belongs in the model but I cannot see a way to get this to work. In short, how to implement this feature? I have extended String with a method called hll_keycase which preforms the desired normalization. The setter for Users.username is overridden in the model and the stored values in the database are all properly normalized. But, it seems to me at the moment that the only place to normalize form input data for the SELECT required to determine if the username exists or not is either in the form or in the controller. Is that the case? This has to be a recurring issue for data input forms and yet I can find very few resources on the web that address this issue at all, and those are often terse to the point of unintelligible. Not exactly a test issue but I really could use some guidance with this as whatever technique I finally adopt will pervade the entire project. -- Posted via http://www.ruby-forum.com/. From zach.dennis at gmail.com Fri Dec 19 11:18:34 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 19 Dec 2008 11:18:34 -0500 Subject: [rspec-users] Using semantics in steps In-Reply-To: <88fd8ddc0812182209x687751d4y4920910f9808bc35@mail.gmail.com> References: <88fd8ddc0812182209x687751d4y4920910f9808bc35@mail.gmail.com> Message-ID: <85d99afe0812190818r290bd4e0x70f0793a06666d34@mail.gmail.com> On Fri, Dec 19, 2008 at 1:09 AM, Andrew Premdas wrote: > Hi All, > > Wanted to put this idea forward, see what you think of it. I'm using Aslaks > lorry feature to illustrate this. See > http://github.com/aslakhellesoy/cucumber_rails/tree/master/features/step_definitions/lorry_steps.rb. > > In particular > > within("table > tr:nth-child(#{pos.to_i+1})") do > click_link "Destroy" > and > > Then /^I should see the following lorries:$/ do |lorries| > lorries.raw[1..-1].each_with_index do |row, i| > row.each_with_index do |cell, j| > response.should have_selector("table > tr:nth-child(#{i+2}) > > td:nth-child(#{j+1})") { |td| > td.inner_text.should == cell > } > end > end > Now imagine this is a real project, and your designer comes along and > decides that lorries really should be shown in a horizontal scrolling > zoomable javascript widgity thing. Now out go the tables and the scenario > breaks. > > However if we use something like > > within("#lorries > .lorry:nth-child # not tested this syntax, > hope the meaning is clear > > then we have > > 1) Defined semantic tags that the designer should not touch > 2) Not relied on any html elements that a designer might change > 3) Created a step that works with the meaning of the UI not its presentation > > So what do you think? > I agree with your sentiments. It's how I access (and encourage others to access) the views (both in step definitions and in view specs). -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From lists at ruby-forum.com Fri Dec 19 11:36:25 2008 From: lists at ruby-forum.com (Juanma Cervera) Date: Fri, 19 Dec 2008 17:36:25 +0100 Subject: [rspec-users] [rspec-devel] The RSpec Book In-Reply-To: <5c493e530811071209n367514c1u6a84466281f7e438@mail.gmail.com> References: <57c63afe0811070703w7a8320eoa5c259d7d8263c4b@mail.gmail.com> <71166b3b0811070723i77d77742pd0f25591767025fa@mail.gmail.com> <5c493e530811071209n367514c1u6a84466281f7e438@mail.gmail.com> Message-ID: I've gota a question. Is the beta for the book coming soon before Christmas or do I better think in something different from Santa Claus? Oh. Please!! Juanma -- Posted via http://www.ruby-forum.com/. From pergesu at gmail.com Fri Dec 19 11:39:23 2008 From: pergesu at gmail.com (Pat Maddox) Date: Fri, 19 Dec 2008 08:39:23 -0800 Subject: [rspec-users] OT: Implementation Question In-Reply-To: <97040d7a24eb6e5166c83758d4410130@ruby-forum.com> References: <97040d7a24eb6e5166c83758d4410130@ruby-forum.com> Message-ID: <810a540e0812190839m3e5cbbfbmf6f760376a4fbd0e@mail.gmail.com> On Fri, Dec 19, 2008 at 7:50 AM, James Byrne wrote: > I have asked about this issue on several different mailing lists and > have had no response. If anyone here can offer some advice then I would > be much obliged. > > I have a feature that essentially says: > > Given I have a user "myuser" > When I fill in "User Name" with "MyUser" > And I press "Login" > Then I should find a user "myuser" > And I should be logged in > > The steps definitions for this are all quite conventional and at the > moment "Then I should find the user "myuser"" is failing, as expected. > > My question is: What is best practice with respect to normalizing form > input data? My feeling is that this sort of thing belongs in the model > but I cannot see a way to get this to work. In short, how to implement > this feature? > > I have extended String with a method called hll_keycase which preforms > the desired normalization. The setter for Users.username is overridden > in the model and the stored values in the database are all properly > normalized. But, it seems to me at the moment that the only place to > normalize form input data for the SELECT required to determine if the > username exists or not is either in the form or in the controller. Is > that the case? > > This has to be a recurring issue for data input forms and yet I can find > very few resources on the web that address this issue at all, and those > are often terse to the point of unintelligible. > > Not exactly a test issue but I really could use some guidance with this > as whatever technique I finally adopt will pervade the entire project. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > There are a couple things you can do. First, if you're using webrat and you've labeled fields exactly as you have them in that feature, you can offload the work to webrat: When /^I fill in "(.*)" with "(.*)$/" do |field, value| fills_in field, :with => value end Or you can do some kind of transformation: prop_map = {"User name" => :username} When /^I fill in "(.*)" with "(.*)$/" do |prop_name, value| fills_in prop_map[prop_name], :with => value end or if you're accessing the model directly @user.send(prop_map[prop_name] + '=', value) Looking back at the full email now though I think you're asking about how to just convert MyUser to myuser? class User < ActiveRecord::Base def username=(new_username) self[:username] = new_username.downcase end end or non-AR class User attr_reader :username def username=(new_username) @username = new_username.downcase end end Is that what you're looking for? Pat From apremdas at gmail.com Fri Dec 19 11:56:03 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 19 Dec 2008 16:56:03 +0000 Subject: [rspec-users] OT: Implementation Question In-Reply-To: <97040d7a24eb6e5166c83758d4410130@ruby-forum.com> References: <97040d7a24eb6e5166c83758d4410130@ruby-forum.com> Message-ID: <88fd8ddc0812190856g796fc1e2g4bfad0f01d850484@mail.gmail.com> You can use read_attribute and write_attribute in models to do this sort of thing - though I'm not really clear exactly what it is you're trying to do. I don't think normalising is quite the right term here. Anyhow I think you're saying that you have an attribute whose storage format is different from its presenation format. To deal with this you can override the attribute accessor in the model e.g. you present product_names in a capitlalized form even if they are stored lower case # Always titleize product names when showing def name read_attribute(:name).titleize end Another example, you're seriously old school and believe only capital letters should be in databases def name=(name) write_attribute(:name, name.upcase) end Another technique would be to create a virtual attribute, so you can have two representations of the same value. For example a price and a currency_price where both refer to the same attribute but one deals with an integer and the other deals with nicely formatted prices. HTH 2008/12/19 James Byrne > I have asked about this issue on several different mailing lists and > have had no response. If anyone here can offer some advice then I would > be much obliged. > > I have a feature that essentially says: > > Given I have a user "myuser" > When I fill in "User Name" with "MyUser" > And I press "Login" > Then I should find a user "myuser" > And I should be logged in > > The steps definitions for this are all quite conventional and at the > moment "Then I should find the user "myuser"" is failing, as expected. > > My question is: What is best practice with respect to normalizing form > input data? My feeling is that this sort of thing belongs in the model > but I cannot see a way to get this to work. In short, how to implement > this feature? > > I have extended String with a method called hll_keycase which preforms > the desired normalization. The setter for Users.username is overridden > in the model and the stored values in the database are all properly > normalized. But, it seems to me at the moment that the only place to > normalize form input data for the SELECT required to determine if the > username exists or not is either in the form or in the controller. Is > that the case? > > This has to be a recurring issue for data input forms and yet I can find > very few resources on the web that address this issue at all, and those > are often terse to the point of unintelligible. > > Not exactly a test issue but I really could use some guidance with this > as whatever technique I finally adopt will pervade the entire project. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lenny at aps.org Fri Dec 19 12:02:08 2008 From: lenny at aps.org (Lenny Marks) Date: Fri, 19 Dec 2008 12:02:08 -0500 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: <4948167B.7030407@benmabey.com> References: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> <4948167B.7030407@benmabey.com> Message-ID: <55F2E91D-C60C-4651-B7AB-3C008439A5D6@aps.org> On Dec 16, 2008, at 3:58 PM, Ben Mabey wrote: > Lenny Marks wrote: >> >> On Dec 9, 2008, at 10:40 PM, Avdi Grimm wrote: >> >>> I contributed an article on BDD and RSpec to the Ruby Advent >>> Calendar >>> 2008, going over some of the rules I've collected for interpreting >>> what your specs say about your design. It can be found here: >>> http://advent2008.hackruby.com/past/2008/12/10/ >>> listening_to_your_specs/ >>> >>> -- >>> Avdi >>> >>> >> >> I'm curious where others stand on the topic of object level specs >> with describe blocks named after methods. I posted the comment >> below with my 2 cents. >> >> -lenny >> >> I agree with most of the points in this article, but not so much >> the part about: >> >> >> Contexts named after methods >> >> A describe block should encapsulate a particular scenario: an >> object or set of objects in a specific configuration. If objects >> are nouns, and methods are verbs, then contexts should describe >> nouns, not verbs. >> >> >> I think this is more or less what Aslak was saying but I wanted to >> get more specific. IMO, using rspec to spec behavior at the object/ >> unit level, it often makes perfect sense to describe the behavior >> of the verbs(methods). I think the following contrived example >> would be fine. It clearly shows me the what this method does and >> what the scenarios it handles are. >> >> describe Account, "#debit" #maybe 'debiting' is better, but #debit >> is actually more descriptive of the API which is the level I'm at >> here. >> describe "with sufficient funds" >> it "should reduce balance by debited amount" >> it "should ..." >> describe "with insufficient funds" >> it "should raise an InsufficentFundsError" >> it "should ... >> >> Actually in the above example I probably would have started with >> the following and only grouped into nested contexts when I started >> repeating myself(e.g. repetition of 'when balance is sufficient') >> >> describe Account, "#debit" >> it "should reduce balance by debited amount when balance is >> sufficient" >> it "should raise an InsufficentFundsError when insufficient" >> .. >> >> >> Examples named after methods >> >> There is rarely a one-to-one relationship between desired >> behaviors and methods on an object. When you name an example after >> the method it tests, it?s a clue that you have started to think in >> ?implementation brain? rather than ?behavior brain?. You?re >> thinking ?I know we are going to need a method ?#foo? which does >> such-and-so, so I?ll just start spec-ing it now??. Step back, and >> think about the behavior you are really interested in. You may >> find it changes how you write examples. Or, you may find that you >> didn?t need that method at all. >> >> >> I don't agree much with the above either. I think this the >> difference between speccing behavior at the application level vs. >> object level. I don't feel its a smell to get down to the object >> level when necessary. One of the benefits of BDD at the object/ >> code level(as opposed to feature level) is helping to flesh out >> the API(what classes, what methods, what inputs/outputs) that >> implements a feature. New classes and methods spring into >> existence as I realize that there are details(a new >> responsibility) that I eventually want to drill into but would >> only be distracting or messy at the current level. Using object >> level examples to focus in on something in isolation is a valuable >> technique. Again, its all about focussing at the right level of >> granularity. >> >> For ex. part of an 'update profile' feature might involve showing >> a user an error message if he/she submits invalid data. Now I >> wouldn't start off thinking, I'm going to need a User class with a >> validate method, but going from the outside in might eventually >> drive me to it so that I can drill into all the details of what >> constitutes valid data directly/in isolation, without being mixed >> in with a bunch of other stuff or extra >> setup._______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > Hey Lenny, > I agree with a lot of what Avdi said in the article. One big > exception was the the "Contexts named after methods" section. > (However, I do agree with the examples named after methods.) > > My argument for having contexts named after methods is simple: > documentation. It helps me quickly scan example groups to find > specific examples about how to use the public methods (the API.) > Maybe we should be using rdoc more but the team I work with has > adopted this convention and have found that it helps us understand > how to use objects written by other team members. This convention > does not work well with all examples however, so we use it on a > case-by-case basis. > > Another reason why I think I like using method names in contexts is > because of how I like to develop. Going from the outside-in I > usually use mocks to discover the interfaces I wish I had. Once I > finish writing the collaborators I then start on the object's > implementation. I start by documenting (writing code examples of) > the cases how the collaborators are already using that method and > expecting the object to behave from using the object in that way... > So, I actually find using method names in example groups a very > natural thing to do that just comes from going outside-in. At > least in my experience. :) Again, I don't stick to this way for > organizing all of my examples but I think it has its place and adds > value. > > -Ben Actually, I got lost in the semantics a bit. I didn't realize his 'Examples named after methods' anti-example was specify "#flush_and_reset" not 'describe'. Anyway, I too was mainly having a problem with 'Contexts named after methods' being identified as a smell for much the same reasons as you site. Thanks to you and Dave for your responses. I've commented on the original article with back links to this thread. Hope I didn't overstep by saying "I think there is some consensus that 'Contexts named after methods' is not a smell and can even be a natural result of 'Outside In' coding". -lenny > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Fri Dec 19 12:01:59 2008 From: aslak.hellesoy at gmail.com (=?utf-8?Q?Aslak_Helles=C3=B8y?=) Date: Fri, 19 Dec 2008 18:01:59 +0100 Subject: [rspec-users] Using semantics in steps In-Reply-To: <85d99afe0812190818r290bd4e0x70f0793a06666d34@mail.gmail.com> References: <88fd8ddc0812182209x687751d4y4920910f9808bc35@mail.gmail.com> <85d99afe0812190818r290bd4e0x70f0793a06666d34@mail.gmail.com> Message-ID: > On Fri, Dec 19, 2008 at 1:09 AM, Andrew Premdas > wrote: >> Hi All, >> >> Wanted to put this idea forward, see what you think of it. I'm >> using Aslaks >> lorry feature to illustrate this. See >> http://github.com/aslakhellesoy/cucumber_rails/tree/master/features/step_definitions/lorry_steps.rb >> . >> >> In particular >> >> within("table > tr:nth-child(#{pos.to_i+1})") do >> click_link "Destroy" >> and >> >> Then /^I should see the following lorries:$/ do |lorries| >> lorries.raw[1..-1].each_with_index do |row, i| >> row.each_with_index do |cell, j| >> response.should have_selector("table > tr:nth-child(#{i+2}) > >> td:nth-child(#{j+1})") { |td| >> td.inner_text.should == cell >> } >> end >> end >> Now imagine this is a real project, and your designer comes along and >> decides that lorries really should be shown in a horizontal scrolling >> zoomable javascript widgity thing. Now out go the tables and the >> scenario >> breaks. >> >> However if we use something like >> >> within("#lorries > .lorry:nth-child # not tested this >> syntax, >> hope the meaning is clear >> >> then we have >> >> 1) Defined semantic tags that the designer should not touch >> 2) Not relied on any html elements that a designer might change >> 3) Created a step that works with the meaning of the UI not its >> presentation >> >> So what do you think? >> > Feel free to submit a patch. Aslak > I agree with your sentiments. It's how I access (and encourage others > to access) the views (both in step definitions and in view specs). > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Dec 19 12:25:20 2008 From: lists at ruby-forum.com (James Byrne) Date: Fri, 19 Dec 2008 18:25:20 +0100 Subject: [rspec-users] OT: Implementation Question In-Reply-To: <97040d7a24eb6e5166c83758d4410130@ruby-forum.com> References: <97040d7a24eb6e5166c83758d4410130@ruby-forum.com> Message-ID: Thanks for the responses. For some reason they showed up in the digest email and yet have still not made it to the RSpec forum at Ruby_forum.com. I have been trying variants of these suggestions, indeed my very first approach was: def username @username.hll_keycase end However, I am working with authlogic and the UserSession Class of that gem throws an error complaining about a missing username= method when I provide the username method. When I provide username= then it complains about a missing password= method. At the time that I asked my question here I was trying to determine if there was something fundamentally wrong with my approach. Evidently this is not the case so I have now contacted the author directly since these issues are definitely outside the scope of this mailing list. Many thanks for the advice. Regards, -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Dec 19 12:37:41 2008 From: lists at ruby-forum.com (James Byrne) Date: Fri, 19 Dec 2008 18:37:41 +0100 Subject: [rspec-users] OT: Implementation Question In-Reply-To: <88fd8ddc0812190856g796fc1e2g4bfad0f01d850484@mail.gmail.com> References: <97040d7a24eb6e5166c83758d4410130@ruby-forum.com> <88fd8ddc0812190856g796fc1e2g4bfad0f01d850484@mail.gmail.com> Message-ID: Andrew Premdas wrote: > You can use read_attribute and write_attribute in models to do this sort > of thing - though I'm not really clear exactly what it is you're trying > to do. > I don't think normalising is quite the right term here. Ahh. Well when I was working with sendmail email addresses the practice was called munging. But I believe that text normalization is defined as the practice of modifying any arbitrary text to a standard representation. In this case user logins are all stored as lowercase, whitespace trimmed, left-shifted, single spaced token delimited, phrases. So that MYUSER == MyUser == myuser. It avoids much unhappiness with users. -- Posted via http://www.ruby-forum.com/. From avdi at avdi.org Fri Dec 19 12:55:01 2008 From: avdi at avdi.org (Avdi Grimm) Date: Fri, 19 Dec 2008 12:55:01 -0500 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: <55F2E91D-C60C-4651-B7AB-3C008439A5D6@aps.org> References: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> <4948167B.7030407@benmabey.com> <55F2E91D-C60C-4651-B7AB-3C008439A5D6@aps.org> Message-ID: On Fri, Dec 19, 2008 at 12:02 PM, Lenny Marks wrote: > Thanks to you and Dave for your responses. I've commented on the original > article with back links to this thread. Hope I didn't overstep by saying "I > think there is some consensus that 'Contexts named after methods' is not a > smell and can even be a natural result of 'Outside In' coding". I'd like to remind folks of something I pointed out at the top of the article: the definition of a "code smell" is a pattern that *might* indicate something is amiss. It's not a surety. I agree that naming description blocks after methods is *less* of a smell than naming examples after methods. I've been known to name contexts after methods, especially when spec-ing a) Rails helper methods; and b) public library APIs. I don't feel guilty for this. Where a description block named for a method becomes a more probable indicator of a design issue is when it's coupled with a block that goes on and on for many examples. This often indicates that the method being described is doing too much, and wants to be either broken up or factored out into another class. I don't pretend to be a canonical source for RSpec best practices. Lakshan asked me for an article on RSpec practices and I listed some of the guidelines that have served me well. He said some nice things at the top of the article which I'm not sure were wholly warranted. Your mileage, as always, may vary. Anyway I'm happy to hear that some people got at least a little value out of the article, and I appreciate all the feedback. -- Avdi Home: http://avdi.org Developer Blog: http://avdi.org/devblog/ Twitter: http://twitter.com/avdi Journal: http://avdi.livejournal.com From danielvlopes at areacriacoes.com.br Fri Dec 19 12:56:46 2008 From: danielvlopes at areacriacoes.com.br (=?ISO-8859-1?Q?Daniel_Area_Cria=E7=F5es?=) Date: Fri, 19 Dec 2008 15:56:46 -0200 Subject: [rspec-users] [rspec-devel] The RSpec Book In-Reply-To: References: <57c63afe0811070703w7a8320eoa5c259d7d8263c4b@mail.gmail.com> <71166b3b0811070723i77d77742pd0f25591767025fa@mail.gmail.com> <5c493e530811071209n367514c1u6a84466281f7e438@mail.gmail.com> Message-ID: <992995550812190956l32dd6d2ei20fb83ec0692058f@mail.gmail.com> I am also super interested in this book Atenciosamente, Daniel Lopes ? Area Cria??es Design, Websites e Sistemas Web Visite: http://www.areacriacoes.com.br/projects http://blog.areacriacoes.com.br/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 On Fri, Dec 19, 2008 at 2:36 PM, Juanma Cervera wrote: > > I've gota a question. > > Is the beta for the book coming soon before Christmas or > do I better think in something different from Santa Claus? > > Oh. Please!! > > Juanma > > > > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Fri Dec 19 13:09:08 2008 From: ben at benmabey.com (Ben Mabey) Date: Fri, 19 Dec 2008 11:09:08 -0700 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: References: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> <4948167B.7030407@benmabey.com> <55F2E91D-C60C-4651-B7AB-3C008439A5D6@aps.org> Message-ID: <494BE344.5010203@benmabey.com> Avdi Grimm wrote: > On Fri, Dec 19, 2008 at 12:02 PM, Lenny Marks wrote: > >> Thanks to you and Dave for your responses. I've commented on the original >> article with back links to this thread. Hope I didn't overstep by saying "I >> think there is some consensus that 'Contexts named after methods' is not a >> smell and can even be a natural result of 'Outside In' coding". >> > > I'd like to remind folks of something I pointed out at the top of the > article: the definition of a "code smell" is a pattern that *might* > indicate something is amiss. It's not a surety. > Of course, I always treat code smells as indicators and not dictators. :) > I agree that naming description blocks after methods is *less* of a > smell than naming examples after methods. I've been known to name > contexts after methods, especially when spec-ing a) Rails helper > methods; and b) public library APIs. I don't feel guilty for this. > > Where a description block named for a method becomes a more probable > indicator of a design issue is when it's coupled with a block that > goes on and on for many examples. This often indicates that the > method being described is doing too much, and wants to be either > broken up or factored out into another class. > > I don't pretend to be a canonical source for RSpec best practices. > Lakshan asked me for an article on RSpec practices and I listed some > of the guidelines that have served me well. He said some nice things > at the top of the article which I'm not sure were wholly warranted. > Your mileage, as always, may vary. > > Anyway I'm happy to hear that some people got at least a little value > out of the article, and I appreciate all the feedback. > > I definitely got some value out of it! In fact I have already started adopting some of the patterns you shared, so thank you for writing it. My response to Lenny was in no means trying to discount the article but rather just stating my view on that particular code smell. I apologize if you felt like my reply was trying to discredit the article. -Ben From dchelimsky at gmail.com Fri Dec 19 13:13:50 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 19 Dec 2008 12:13:50 -0600 Subject: [rspec-users] Using semantics in steps In-Reply-To: References: <88fd8ddc0812182209x687751d4y4920910f9808bc35@mail.gmail.com> <85d99afe0812190818r290bd4e0x70f0793a06666d34@mail.gmail.com> Message-ID: <57c63afe0812191013v5267db30uc720eeba9aef5aef@mail.gmail.com> Is this a feature request or a style thing? On Fri, Dec 19, 2008 at 11:01 AM, Aslak Helles?y wrote: > >> On Fri, Dec 19, 2008 at 1:09 AM, Andrew Premdas >> wrote: >>> >>> Hi All, >>> >>> Wanted to put this idea forward, see what you think of it. I'm using >>> Aslaks >>> lorry feature to illustrate this. See >>> >>> http://github.com/aslakhellesoy/cucumber_rails/tree/master/features/step_definitions/lorry_steps.rb. >>> >>> In particular >>> >>> within("table > tr:nth-child(#{pos.to_i+1})") do >>> click_link "Destroy" >>> and >>> >>> Then /^I should see the following lorries:$/ do |lorries| >>> lorries.raw[1..-1].each_with_index do |row, i| >>> row.each_with_index do |cell, j| >>> response.should have_selector("table > tr:nth-child(#{i+2}) > >>> td:nth-child(#{j+1})") { |td| >>> td.inner_text.should == cell >>> } >>> end >>> end >>> Now imagine this is a real project, and your designer comes along and >>> decides that lorries really should be shown in a horizontal scrolling >>> zoomable javascript widgity thing. Now out go the tables and the scenario >>> breaks. >>> >>> However if we use something like >>> >>> within("#lorries > .lorry:nth-child # not tested this syntax, >>> hope the meaning is clear >>> >>> then we have >>> >>> 1) Defined semantic tags that the designer should not touch >>> 2) Not relied on any html elements that a designer might change >>> 3) Created a step that works with the meaning of the UI not its >>> presentation >>> >>> So what do you think? >>> >> > > Feel free to submit a patch. > > Aslak > >> I agree with your sentiments. It's how I access (and encourage others >> to access) the views (both in step definitions and in view specs). >> >> -- >> Zach Dennis >> http://www.continuousthinking.com >> http://www.mutuallyhuman.com >> _______________________________________________ >> 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 zach.dennis at gmail.com Fri Dec 19 13:32:19 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Fri, 19 Dec 2008 13:32:19 -0500 Subject: [rspec-users] Using semantics in steps In-Reply-To: <57c63afe0812191013v5267db30uc720eeba9aef5aef@mail.gmail.com> References: <88fd8ddc0812182209x687751d4y4920910f9808bc35@mail.gmail.com> <85d99afe0812190818r290bd4e0x70f0793a06666d34@mail.gmail.com> <57c63afe0812191013v5267db30uc720eeba9aef5aef@mail.gmail.com> Message-ID: <85d99afe0812191032m72ebaac6x414eccc9b2fa794b@mail.gmail.com> On Fri, Dec 19, 2008 at 1:13 PM, David Chelimsky wrote: > Is this a feature request or a style thing? I believe strictly style. Webrat supports within already, ie: within "#my-css-selector" do |scope| scope.should have_selector("child element") end > > On Fri, Dec 19, 2008 at 11:01 AM, Aslak Helles?y > wrote: >> >>> On Fri, Dec 19, 2008 at 1:09 AM, Andrew Premdas >>> wrote: >>>> >>>> Hi All, >>>> >>>> Wanted to put this idea forward, see what you think of it. I'm using >>>> Aslaks >>>> lorry feature to illustrate this. See >>>> >>>> http://github.com/aslakhellesoy/cucumber_rails/tree/master/features/step_definitions/lorry_steps.rb. >>>> >>>> In particular >>>> >>>> within("table > tr:nth-child(#{pos.to_i+1})") do >>>> click_link "Destroy" >>>> and >>>> >>>> Then /^I should see the following lorries:$/ do |lorries| >>>> lorries.raw[1..-1].each_with_index do |row, i| >>>> row.each_with_index do |cell, j| >>>> response.should have_selector("table > tr:nth-child(#{i+2}) > >>>> td:nth-child(#{j+1})") { |td| >>>> td.inner_text.should == cell >>>> } >>>> end >>>> end >>>> Now imagine this is a real project, and your designer comes along and >>>> decides that lorries really should be shown in a horizontal scrolling >>>> zoomable javascript widgity thing. Now out go the tables and the scenario >>>> breaks. >>>> >>>> However if we use something like >>>> >>>> within("#lorries > .lorry:nth-child # not tested this syntax, >>>> hope the meaning is clear >>>> >>>> then we have >>>> >>>> 1) Defined semantic tags that the designer should not touch >>>> 2) Not relied on any html elements that a designer might change >>>> 3) Created a step that works with the meaning of the UI not its >>>> presentation >>>> >>>> So what do you think? >>>> >>> >> >> Feel free to submit a patch. >> >> Aslak >> >>> I agree with your sentiments. It's how I access (and encourage others >>> to access) the views (both in step definitions and in view specs). >>> >>> -- >>> Zach Dennis >>> http://www.continuousthinking.com >>> http://www.mutuallyhuman.com >>> _______________________________________________ >>> 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 >> > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From apremdas at gmail.com Fri Dec 19 13:51:28 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 19 Dec 2008 18:51:28 +0000 Subject: [rspec-users] Using semantics in steps In-Reply-To: References: <88fd8ddc0812182209x687751d4y4920910f9808bc35@mail.gmail.com> <85d99afe0812190818r290bd4e0x70f0793a06666d34@mail.gmail.com> Message-ID: <88fd8ddc0812191051t499f7752gf7595e52dd2dbbfd@mail.gmail.com> Was just using your code as an example, not being critical of it. Sorry if it came out that way :). In its context it makes its point very clearly. Andrew 2008/12/19 Aslak Helles?y > > On Fri, Dec 19, 2008 at 1:09 AM, Andrew Premdas >> wrote: >> >>> Hi All, >>> >>> Wanted to put this idea forward, see what you think of it. I'm using >>> Aslaks >>> lorry feature to illustrate this. See >>> >>> http://github.com/aslakhellesoy/cucumber_rails/tree/master/features/step_definitions/lorry_steps.rb >>> . >>> >>> In particular >>> >>> within("table > tr:nth-child(#{pos.to_i+1})") do >>> click_link "Destroy" >>> and >>> >>> Then /^I should see the following lorries:$/ do |lorries| >>> lorries.raw[1..-1].each_with_index do |row, i| >>> row.each_with_index do |cell, j| >>> response.should have_selector("table > tr:nth-child(#{i+2}) > >>> td:nth-child(#{j+1})") { |td| >>> td.inner_text.should == cell >>> } >>> end >>> end >>> Now imagine this is a real project, and your designer comes along and >>> decides that lorries really should be shown in a horizontal scrolling >>> zoomable javascript widgity thing. Now out go the tables and the scenario >>> breaks. >>> >>> However if we use something like >>> >>> within("#lorries > .lorry:nth-child # not tested this syntax, >>> hope the meaning is clear >>> >>> then we have >>> >>> 1) Defined semantic tags that the designer should not touch >>> 2) Not relied on any html elements that a designer might change >>> 3) Created a step that works with the meaning of the UI not its >>> presentation >>> >>> So what do you think? >>> >>> >> > Feel free to submit a patch. > > Aslak > > > I agree with your sentiments. It's how I access (and encourage others >> to access) the views (both in step definitions and in view specs). >> >> -- >> Zach Dennis >> http://www.continuousthinking.com >> http://www.mutuallyhuman.com >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Dec 19 13:53:19 2008 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 19 Dec 2008 18:53:19 +0000 Subject: [rspec-users] Using semantics in steps In-Reply-To: <57c63afe0812191013v5267db30uc720eeba9aef5aef@mail.gmail.com> References: <88fd8ddc0812182209x687751d4y4920910f9808bc35@mail.gmail.com> <85d99afe0812190818r290bd4e0x70f0793a06666d34@mail.gmail.com> <57c63afe0812191013v5267db30uc720eeba9aef5aef@mail.gmail.com> Message-ID: <88fd8ddc0812191053g728ae225u14720d45fa88ed33@mail.gmail.com> A style thing, just exploring interactions between features and UI 2008/12/19 David Chelimsky > Is this a feature request or a style thing? > > On Fri, Dec 19, 2008 at 11:01 AM, Aslak Helles?y > wrote: > > > >> On Fri, Dec 19, 2008 at 1:09 AM, Andrew Premdas > >> wrote: > >>> > >>> Hi All, > >>> > >>> Wanted to put this idea forward, see what you think of it. I'm using > >>> Aslaks > >>> lorry feature to illustrate this. See > >>> > >>> > http://github.com/aslakhellesoy/cucumber_rails/tree/master/features/step_definitions/lorry_steps.rb > . > >>> > >>> In particular > >>> > >>> within("table > tr:nth-child(#{pos.to_i+1})") do > >>> click_link "Destroy" > >>> and > >>> > >>> Then /^I should see the following lorries:$/ do |lorries| > >>> lorries.raw[1..-1].each_with_index do |row, i| > >>> row.each_with_index do |cell, j| > >>> response.should have_selector("table > tr:nth-child(#{i+2}) > > >>> td:nth-child(#{j+1})") { |td| > >>> td.inner_text.should == cell > >>> } > >>> end > >>> end > >>> Now imagine this is a real project, and your designer comes along and > >>> decides that lorries really should be shown in a horizontal scrolling > >>> zoomable javascript widgity thing. Now out go the tables and the > scenario > >>> breaks. > >>> > >>> However if we use something like > >>> > >>> within("#lorries > .lorry:nth-child # not tested this > syntax, > >>> hope the meaning is clear > >>> > >>> then we have > >>> > >>> 1) Defined semantic tags that the designer should not touch > >>> 2) Not relied on any html elements that a designer might change > >>> 3) Created a step that works with the meaning of the UI not its > >>> presentation > >>> > >>> So what do you think? > >>> > >> > > > > Feel free to submit a patch. > > > > Aslak > > > >> I agree with your sentiments. It's how I access (and encourage others > >> to access) the views (both in step definitions and in view specs). > >> > >> -- > >> Zach Dennis > >> http://www.continuousthinking.com > >> http://www.mutuallyhuman.com > >> _______________________________________________ > >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lenny at aps.org Fri Dec 19 15:43:24 2008 From: lenny at aps.org (Lenny Marks) Date: Fri, 19 Dec 2008 15:43:24 -0500 Subject: [rspec-users] New article on "Listening to Your Specs" up on Ruby Advent 2008 In-Reply-To: References: <79CA47CC-AED4-47E8-BEDB-D681620FB13E@aps.org> <4948167B.7030407@benmabey.com> <55F2E91D-C60C-4651-B7AB-3C008439A5D6@aps.org> Message-ID: On Dec 19, 2008, at 12:55 PM, Avdi Grimm wrote: > On Fri, Dec 19, 2008 at 12:02 PM, Lenny Marks wrote: >> Thanks to you and Dave for your responses. I've commented on the >> original >> article with back links to this thread. Hope I didn't overstep by >> saying "I >> think there is some consensus that 'Contexts named after methods' >> is not a >> smell and can even be a natural result of 'Outside In' coding". > > I'd like to remind folks of something I pointed out at the top of the > article: the definition of a "code smell" is a pattern that *might* > indicate something is amiss. It's not a surety. > > I agree that naming description blocks after methods is *less* of a > smell than naming examples after methods. I've been known to name > contexts after methods, especially when spec-ing a) Rails helper > methods; and b) public library APIs. I don't feel guilty for this. > > Where a description block named for a method becomes a more probable > indicator of a design issue is when it's coupled with a block that > goes on and on for many examples. This often indicates that the > method being described is doing too much, and wants to be either > broken up or factored out into another class. > > I don't pretend to be a canonical source for RSpec best practices. > Lakshan asked me for an article on RSpec practices and I listed some > of the guidelines that have served me well. He said some nice things > at the top of the article which I'm not sure were wholly warranted. > Your mileage, as always, may vary. > > Anyway I'm happy to hear that some people got at least a little value > out of the article, and I appreciate all the feedback. > > -- > Avdi > Just to clarify...I thought most of your article was good stuff and I can appreciate how difficult it is to articulate this kind of stuff. I really just had a problem with that one smell as I understood it from your article since it contradicted advice I often give about coding outside in. I just wanted to get some reassurance that I wasn't steering my fellow employees in the wrong direction. FWIW, I agree with the way you state things above. Thanks for taking the time to share. -lenny From walketim at gmail.com Fri Dec 19 19:46:27 2008 From: walketim at gmail.com (Tim Walker) Date: Fri, 19 Dec 2008 17:46:27 -0700 Subject: [rspec-users] [rspec-devel] The RSpec Book In-Reply-To: <992995550812190956l32dd6d2ei20fb83ec0692058f@mail.gmail.com> References: <57c63afe0811070703w7a8320eoa5c259d7d8263c4b@mail.gmail.com> <71166b3b0811070723i77d77742pd0f25591767025fa@mail.gmail.com> <5c493e530811071209n367514c1u6a84466281f7e438@mail.gmail.com> <992995550812190956l32dd6d2ei20fb83ec0692058f@mail.gmail.com> Message-ID: <1ebf5a4d0812191646l3c3a8692oab4ed7fef336b799@mail.gmail.com> As am I! Really looking forward to it. Thanks guys for any head's up or link to the preview/beta! Tim On Fri, Dec 19, 2008 at 10:56 AM, Daniel Area Cria??es wrote: > I am also super interested in this book > Atenciosamente, > > Daniel Lopes ? Area Cria??es > Design, Websites e Sistemas Web > > Visite: http://www.areacriacoes.com.br/projects > http://blog.areacriacoes.com.br/ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 > > > On Fri, Dec 19, 2008 at 2:36 PM, Juanma Cervera > wrote: >> >> I've gota a question. >> >> Is the beta for the book coming soon before Christmas or >> do I better think in something different from Santa Claus? >> >> Oh. Please!! >> >> Juanma >> >> >> >> >> >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> 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 Dec 19 21:06:51 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 19 Dec 2008 20:06:51 -0600 Subject: [rspec-users] [rspec-devel] The RSpec Book In-Reply-To: <1ebf5a4d0812191646l3c3a8692oab4ed7fef336b799@mail.gmail.com> References: <57c63afe0811070703w7a8320eoa5c259d7d8263c4b@mail.gmail.com> <71166b3b0811070723i77d77742pd0f25591767025fa@mail.gmail.com> <5c493e530811071209n367514c1u6a84466281f7e438@mail.gmail.com> <992995550812190956l32dd6d2ei20fb83ec0692058f@mail.gmail.com> <1ebf5a4d0812191646l3c3a8692oab4ed7fef336b799@mail.gmail.com> Message-ID: <57c63afe0812191806n2d1f13d3ub2b275f48d0b9957@mail.gmail.com> Hi all - I'm sorry to report that we were not able to get the beta out this month as we had hoped. We're very close, and should have a beta for you in early January, but with holiday schedules as they are it's just not possible to tie up the necessary loose ends before the year's end. That said, I and the other authors are working hard to get things into shape so that we'll be able to tie things together as soon as everyone is back on line after the 1st of the year. Thanks for your enthusiasm (as expressed in this thread), and thanks for your patience. Cheers, David On Fri, Dec 19, 2008 at 6:46 PM, Tim Walker wrote: > As am I! Really looking forward to it. Thanks guys for any head's up > or link to the preview/beta! > > Tim > > On Fri, Dec 19, 2008 at 10:56 AM, Daniel Area Cria??es > wrote: >> I am also super interested in this book >> Atenciosamente, >> >> Daniel Lopes ? Area Cria??es >> Design, Websites e Sistemas Web >> >> Visite: http://www.areacriacoes.com.br/projects >> http://blog.areacriacoes.com.br/ >> >> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * >> 55 (31) 3077-4560 / 55 (31) 8808-8748 / 55 (31) 8737-7501 >> >> >> On Fri, Dec 19, 2008 at 2:36 PM, Juanma Cervera >> wrote: >>> >>> I've gota a question. >>> >>> Is the beta for the book coming soon before Christmas or >>> do I better think in something different from Santa Claus? >>> >>> Oh. Please!! >>> >>> Juanma >>> >>> >>> >>> >>> >>> >>> -- >>> Posted via http://www.ruby-forum.com/. >>> _______________________________________________ >>> 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 aslak.hellesoy at gmail.com Sat Dec 20 16:02:01 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 20 Dec 2008 22:02:01 +0100 Subject: [rspec-users] [ANN] Cucumber 0.1.13 Message-ID: <8d961d900812201302m39f99e0bra731a8cb52583761@mail.gmail.com> It's time for some new features again. Output is now much better since you can use diffing, tweak the output colours and get the full --backtrace if you want. Managing your support/* files became a little easier since they are now always loaded before the step definitions. Life became easier for Windows users in Norway (and other countries using unicode in the features). Plus several other bug fixes. One of the coolest new feature is Scenario Outline, implemented by Joseph Wilk with lots of great input from several others. It's not yet documented in the Wiki, but you can read about it here: http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/57 Full release notes on GitHub: http://github.com/aslakhellesoy/cucumber/tree/v0.1.13/History.txt Cheers, Aslak -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Sat Dec 20 18:41:04 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 21 Dec 2008 00:41:04 +0100 Subject: [rspec-users] Cucumber logo poll is open Message-ID: <8d961d900812201541y1334f5acpd927b1779c079a26@mail.gmail.com> Cast your ballots! http://cukes.info/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sat Dec 20 21:11:37 2008 From: lists at ruby-forum.com (Slava Mikerin) Date: Sun, 21 Dec 2008 03:11:37 +0100 Subject: [rspec-users] cucumber and selenium Message-ID: <4dee2c96a5a7a3d0eb2655d5519191c3@ruby-forum.com> hello, I am starting out with cucumber and selenium. Whenever I run a rake features on my features or on cucumber/examples/selenium/features too many browser windows start... for example if run cucumber examples/selenium/features 3 browser windows get launched. I commented out browser closing after tests to see exactly how many windows and for a simple google search feature I ended up with 3 windows. If I run it again I get 3 more.. After do #@browser.stop end I only need one window for running tests and one for the selenium dashboard. Is there a way to stop this to save time and resources? thank you. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat Dec 20 23:42:50 2008 From: lists at ruby-forum.com (Sarah Allen) Date: Sun, 21 Dec 2008 05:42:50 +0100 Subject: [rspec-users] newbie: errors getting started with cucumber Message-ID: <97a61caed5257bf71bca4c5afd95a224@ruby-forum.com> Just getting started with Ruby and Rails, I wanted to check out BDD and cucumber seemed like a good place to start. Let me know if this stuff is too new for a newbie and I'll wander off. I've installed the following: sudo gem install cucumber sudo gem install rspec rspec-rails webrat $ rake features (in /Library/WebServer/Documents/todolist) /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- webrat/rspec-rails (MissingSourceFile) Failed to load features/support/env.rb from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in `require' from ./features/support/env.rb:12 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/../lib/cucumber/cli.rb:230:in `require_files' from /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/../lib/cucumber/cli.rb:228:in `each' from /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/../lib/cucumber/cli.rb:228:in `require_files' from /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/../lib/cucumber/cli.rb:152:in `execute!' from /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/../lib/cucumber/cli.rb:13:in `execute' from /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/cucumber:6 rake aborted! I even tried installing webrat as a plugin which seemed to be a solution proposed in a previous post: script/plugin install git://github.com/brynary/webrat.git but in either case I see the same errors. I'm on Mac OS 10.5.6 if that matters. Thanks in advance, Sarah home: www.ultrasaurus.com code: www.ultrasaurus.com/code -- Posted via http://www.ruby-forum.com/. From f.mischa at gmail.com Sun Dec 21 00:09:21 2008 From: f.mischa at gmail.com (Mischa Fierer) Date: Sat, 20 Dec 2008 21:09:21 -0800 Subject: [rspec-users] newbie: errors getting started with cucumber In-Reply-To: <97a61caed5257bf71bca4c5afd95a224@ruby-forum.com> References: <97a61caed5257bf71bca4c5afd95a224@ruby-forum.com> Message-ID: Try pasting this into config/environments/test.rb #config/environments/test.rb #config.gem 'rspec-rails', :source => "http://gems.github.com", :lib => 'spec/rails' #config.gem 'cucumber', :version => '0.1.12', :source => " http://gems.github.com" config.gem 'webrat' , :source => "http://gems.github.com" #config.gem 'nokogiri' , :source => "http://gems.github.com" Example cucumber apps here: http://github.com/bmabey/email-spec/tree/master/spec/rails_root And here: http://github.com/qrush/cucumber_seeds/tree/master On Sat, Dec 20, 2008 at 8:42 PM, Sarah Allen wrote: > Just getting started with Ruby and Rails, I wanted to check out BDD and > cucumber seemed like a good place to start. Let me know if this stuff > is too new for a newbie and I'll wander off. > > I've installed the following: > sudo gem install cucumber > sudo gem install rspec rspec-rails webrat > > $ rake features > (in /Library/WebServer/Documents/todolist) > /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require': no such file to load -- webrat/rspec-rails > (MissingSourceFile) > Failed to load features/support/env.rb from > /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' > from > > /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in > `require' > from ./features/support/env.rb:12 > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' > from > > /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/../lib/cucumber/cli.rb:230:in > `require_files' > from > > /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/../lib/cucumber/cli.rb:228:in > `each' > from > > /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/../lib/cucumber/cli.rb:228:in > `require_files' > from > > /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/../lib/cucumber/cli.rb:152:in > `execute!' > from > > /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/../lib/cucumber/cli.rb:13:in > `execute' > from /Users/sarah/.gem/ruby/1.8/gems/cucumber-0.1.13/bin/cucumber:6 > rake aborted! > > I even tried installing webrat as a plugin which seemed to be a solution > proposed in a previous post: > script/plugin install git://github.com/brynary/webrat.git > > but in either case I see the same errors. > > I'm on Mac OS 10.5.6 if that matters. > > Thanks in advance, > > Sarah > home: www.ultrasaurus.com > code: www.ultrasaurus.com/code > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Dec 21 00:11:46 2008 From: lists at ruby-forum.com (Sarah Allen) Date: Sun, 21 Dec 2008 06:11:46 +0100 Subject: [rspec-users] newbie: errors getting started with cucumber In-Reply-To: <97a61caed5257bf71bca4c5afd95a224@ruby-forum.com> References: <97a61caed5257bf71bca4c5afd95a224@ruby-forum.com> Message-ID: <5eb02bfc6069be8bc219e20a37d2dc3b@ruby-forum.com> More poking around and I found this page: http://github.com/aslakhellesoy/cucumber/wikis/ruby-on-rails never mind. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Dec 22 04:01:45 2008 From: lists at ruby-forum.com (Sarah Allen) Date: Mon, 22 Dec 2008 10:01:45 +0100 Subject: [rspec-users] newbie cucumber tutorial Message-ID: I got started with cucumber and it sure is fun. I've written up my initial experience in tutorial format here for any newbies who want to follow in my tracks: http://www.ultrasaurus.com/code/2008/12/rails-2-day-3.html If anyone has any corrections, let me know. I was wondering whether when writing a real application, do you usually write your whole spec with lots of scenarios at once and then get them the execute one at a time? or do you write and code one scenario at a time? Thanks, Sarah p.s. what is the relationship between cucumber and RSpec? -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Mon Dec 22 04:37:41 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 22 Dec 2008 09:37:41 +0000 Subject: [rspec-users] newbie cucumber tutorial In-Reply-To: References: Message-ID: <70EB29EA-89B4-4E0E-821F-A1D21377AEAA@mattwynne.net> Great stuff. One thing I'd point out is the missing (and extremely important) step 3.5 in Rick Denatale's TDD steps: *Refactor to remove duplication*. Not that there's any refactoring necessary in your example, but it's always worth reminding people they should check for it. On 22 Dec 2008, at 09:01, Sarah Allen wrote: > I got started with cucumber and it sure is fun. I've written up my > initial experience in tutorial format here for any newbies who want to > follow in my tracks: > http://www.ultrasaurus.com/code/2008/12/rails-2-day-3.html > > If anyone has any corrections, let me know. I was wondering whether > when writing a real application, do you usually write your whole spec > with lots of scenarios at once and then get them the execute one at a > time? or do you write and code one scenario at a time? Mostly I pick off a simple scenario, write it into Cucumber, then dive into the code to make it work. Then when I'm back on the surface with the scenario passing, I think about the next simplest scenario, write that up into a feature, and I'm off again. Sometimes I keep a list (you can use # to comment lines in the .feature file) of scenarios I'm going to write up later, so I have a kind of 'todo list' but I don't usually flesh them out into executable scenarios with steps until I'm ready to work on them. > p.s. what is the relationship between cucumber and RSpec? Short version: RSpec is for unit testing, Cucumber is for acceptance testing. Matt Wynne http://blog.mattwynne.net http://www.songkick.com From aslak.hellesoy at gmail.com Mon Dec 22 06:05:30 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 22 Dec 2008 12:05:30 +0100 Subject: [rspec-users] newbie cucumber tutorial In-Reply-To: References: Message-ID: <8d961d900812220305x38c21bccsa557feceff5f1ecb@mail.gmail.com> On Mon, Dec 22, 2008 at 10:01 AM, Sarah Allen wrote: > I got started with cucumber and it sure is fun. I've written up my > initial experience in tutorial format here for any newbies who want to > follow in my tracks: > http://www.ultrasaurus.com/code/2008/12/rails-2-day-3.html > > If anyone has any corrections, let me know. I was wondering whether > when writing a real application, do you usually write your whole spec > with lots of scenarios at once and then get them the execute one at a > time? or do you write and code one scenario at a time? > Hi Sarah, Thanks for the great writeup. It is simple to follow and explains what's going on really well. I have a few comments: * I released 0.1.13 yesterday. In the Rails installation wiki page I recommend using my webrat gem. It lets you use response.should have_selector(...) (You're not using it in your tutorial, but just in case...) * "Write a Spec" should be "Write a feature" (specs is confusing here because that is what people use RSpec for. describe and it style). There are some other refs to "spec" which should be "feature". * Use bang! methods when creating records. Otherwise a failure to create will silently pass without you knowing. Example: task = Task.new(:description => desc) # Lose the semicolon task.save! Or simpler: Task.create!(:description => desc) Cheers, Aslak > > Thanks, > Sarah > > p.s. what is the relationship between cucumber and RSpec? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Mon Dec 22 08:01:05 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 22 Dec 2008 08:01:05 -0500 Subject: [rspec-users] Cucumber logo poll is open In-Reply-To: <8d961d900812201541y1334f5acpd927b1779c079a26@mail.gmail.com> References: <8d961d900812201541y1334f5acpd927b1779c079a26@mail.gmail.com> Message-ID: <85d99afe0812220501q2bd7e8eepda6b109ddf5b03a2@mail.gmail.com> Daniel Lopes / Dan Ryan, Can you combine the cucumber in Dan Ryan's B logo with Daniel's font / shadowing from his A & B ? Zach On Sat, Dec 20, 2008 at 6:41 PM, aslak hellesoy wrote: > Cast your ballots! > > http://cukes.info/ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From aslak.hellesoy at gmail.com Mon Dec 22 08:07:51 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 22 Dec 2008 14:07:51 +0100 Subject: [rspec-users] Cucumber logo poll is open In-Reply-To: <85d99afe0812220501q2bd7e8eepda6b109ddf5b03a2@mail.gmail.com> References: <8d961d900812201541y1334f5acpd927b1779c079a26@mail.gmail.com> <85d99afe0812220501q2bd7e8eepda6b109ddf5b03a2@mail.gmail.com> Message-ID: <8d961d900812220507i6bc2f44es5b2056d2c51ac2f4@mail.gmail.com> On Mon, Dec 22, 2008 at 2:01 PM, Zach Dennis wrote: > Daniel Lopes / Dan Ryan, > > Can you combine the cucumber in Dan Ryan's B logo with Daniel's font / > shadowing from his A & B ? > 170 people have voted already. Adding a new logo to the poll now would mess everything up. Logo submission is closed I'm afraid. Aslak > > Zach > > On Sat, Dec 20, 2008 at 6:41 PM, aslak hellesoy > wrote: > > Cast your ballots! > > > > http://cukes.info/ > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon Dec 22 11:59:51 2008 From: lists at ruby-forum.com (Sarah Allen) Date: Mon, 22 Dec 2008 17:59:51 +0100 Subject: [rspec-users] newbie cucumber tutorial In-Reply-To: <8d961d900812220305x38c21bccsa557feceff5f1ecb@mail.gmail.com> References: <8d961d900812220305x38c21bccsa557feceff5f1ecb@mail.gmail.com> Message-ID: <0123602a68a5ed556a9c5071b8b0b57f@ruby-forum.com> Aslak Helles?y wrote: > * I released 0.1.13 yesterday. In the Rails installation wiki page I > recommend using my webrat gem. It lets you use response.should > have_selector(...) (You're not using it in your tutorial, but just in > case...) Luckily I started with cucumber on Sunday just after your release, so I'm using that version. What does have_selector do? (Is there an API reference somewhere that I missed?) > * "Write a Spec" should be "Write a feature" (specs is confusing here > because that is what people use RSpec for. describe and it style). There > are > some other refs to "spec" which should be "feature". I changed it to "describe a feature," since to me "write a feature" means writing the code. When I started using cucumber, I thought it was part of RSpec. The cucumber .feature files still feel like a spec to me and since I've never used RSpec, I don't really appreciate the distinction. > * Use bang! methods when creating records. Otherwise a failure to create > will silently pass without you knowing. Example: > > task = Task.new(:description => desc) # Lose the semicolon > task.save! > > Or simpler: > Task.create!(:description => desc) Thanks for the tip. As you can see from my series of blog posts, I'm new to Ruby and Rails. I thought that ending a method with ! was a naming convention. Reading the humble ruby book it says "Another convention to follow is that if the method modifies its receiver in place (i.e. the method modifies the object that called it), then it should end in an exclamation point" and the Rails doc show examples of create without ! http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001969 but if I make the change you suggest the test passes. I've updated the tutorial and my code, but I'm confused. Fun stuff. Thanks for making this! Sarah -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Mon Dec 22 12:18:27 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 22 Dec 2008 18:18:27 +0100 Subject: [rspec-users] newbie cucumber tutorial In-Reply-To: <0123602a68a5ed556a9c5071b8b0b57f@ruby-forum.com> References: <8d961d900812220305x38c21bccsa557feceff5f1ecb@mail.gmail.com> <0123602a68a5ed556a9c5071b8b0b57f@ruby-forum.com> Message-ID: <8d961d900812220918l7829008dpd884f599749a0ab5@mail.gmail.com> On Mon, Dec 22, 2008 at 5:59 PM, Sarah Allen wrote: > Aslak Helles?y wrote: > > * I released 0.1.13 yesterday. In the Rails installation wiki page I > > recommend using my webrat gem. It lets you use response.should > > have_selector(...) (You're not using it in your tutorial, but just in > > case...) > > Luckily I started with cucumber on Sunday just after your release, so > I'm using that version. What does have_selector do? (Is there an API > reference somewhere that I missed?) > That's part of the WebRat API: http://gitrdoc.com/brynary/webrat/tree/master/ > > > * "Write a Spec" should be "Write a feature" (specs is confusing here > > because that is what people use RSpec for. describe and it style). There > > are > > some other refs to "spec" which should be "feature". > > I changed it to "describe a feature," since to me "write a feature" > means writing the code. "Cucumber Feature Description" is probably a better term. > When I started using cucumber, I thought it was > part of RSpec. It's not part of RSpec, but grew out of it. > The cucumber .feature files still feel like a spec to me > and since I've never used RSpec, I don't really appreciate the > distinction. > They are two different projects. RSpec is for lower levels (objects). A "test" in RSpec is called a spec. A "test" in Cucumber is called a Feature. > > > * Use bang! methods when creating records. Otherwise a failure to create > > will silently pass without you knowing. Example: > > > > task = Task.new(:description => desc) # Lose the semicolon > > task.save! > > > > Or simpler: > > Task.create!(:description => desc) > > Thanks for the tip. As you can see from my series of blog posts, I'm > new to Ruby and Rails. I thought that ending a method with ! was a > naming convention. Reading the humble ruby book it says "Another > convention to follow is that if the method modifies its receiver in > place (i.e. the method modifies the object that called it), then it > should end in an exclamation point" and the Rails doc show examples of > create without ! > http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001969 but if > I make the change you suggest the test passes. I've updated the > tutorial and my code, but I'm confused. > The #create! method is documented here: http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001902 Essentially, #create will never raise an error no matter what you pass it, and you actually want exceptions for bad input in your tests (step definitions). Therefore - use #create! (or #save!). In your app, use the non-bang methods. Cheers, Aslak > Fun stuff. Thanks for making this! > > Sarah > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon Dec 22 14:09:19 2008 From: lists at ruby-forum.com (Sarah Allen) Date: Mon, 22 Dec 2008 20:09:19 +0100 Subject: [rspec-users] newbie cucumber tutorial In-Reply-To: <8d961d900812220918l7829008dpd884f599749a0ab5@mail.gmail.com> References: <8d961d900812220305x38c21bccsa557feceff5f1ecb@mail.gmail.com> <0123602a68a5ed556a9c5071b8b0b57f@ruby-forum.com> <8d961d900812220918l7829008dpd884f599749a0ab5@mail.gmail.com> Message-ID: I realize this is off-topic for the RSpec forum and cucumber tutorial, but I'm hoping you'll enlighten me on this point which is, I guess, more of a Ruby language question... Aslak Helles?y wrote: >> As you can see from my series of blog posts, I'm >> new to Ruby and Rails. I thought that ending a method with ! was a >> naming convention. Reading the humble ruby book it says "Another >> convention to follow is that if the method modifies its receiver in >> place (i.e. the method modifies the object that called it), then it >> should end in an exclamation point" and the Rails doc show examples of >> create without ! >> http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001969 but if >> I make the change you suggest the test passes. I've updated the >> tutorial and my code, but I'm confused. >> > > The #create! method is documented here: > http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001902 > > Essentially, #create will never raise an error no matter what you pass > it, > and you actually want exceptions for bad input in your tests (step > definitions). > Therefore - use #create! (or #save!). In your app, use the non-bang > methods. My Task model is simply defined (by the generate scaffold script) as: class Task < ActiveRecord::Base end How is it that I can call Task.create! which is a method of ActiveRecord::Validations ? Thanks in advance, Sarah -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Mon Dec 22 14:20:10 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 22 Dec 2008 20:20:10 +0100 Subject: [rspec-users] newbie cucumber tutorial In-Reply-To: References: <8d961d900812220305x38c21bccsa557feceff5f1ecb@mail.gmail.com> <0123602a68a5ed556a9c5071b8b0b57f@ruby-forum.com> <8d961d900812220918l7829008dpd884f599749a0ab5@mail.gmail.com> Message-ID: <8d961d900812221120v3d335e89m7de3902981e523f7@mail.gmail.com> On Mon, Dec 22, 2008 at 8:09 PM, Sarah Allen wrote: > I realize this is off-topic for the RSpec forum and cucumber tutorial, > but I'm hoping you'll enlighten me on this point which is, I guess, more > of a Ruby language question... > > Aslak Helles?y wrote: > >> As you can see from my series of blog posts, I'm > >> new to Ruby and Rails. I thought that ending a method with ! was a > >> naming convention. Reading the humble ruby book it says "Another > >> convention to follow is that if the method modifies its receiver in > >> place (i.e. the method modifies the object that called it), then it > >> should end in an exclamation point" and the Rails doc show examples of > >> create without ! > >> http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001969 but > if > >> I make the change you suggest the test passes. I've updated the > >> tutorial and my code, but I'm confused. > >> > > > > The #create! method is documented here: > > > http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001902 > > > > Essentially, #create will never raise an error no matter what you pass > > it, > > and you actually want exceptions for bad input in your tests (step > > definitions). > > Therefore - use #create! (or #save!). In your app, use the non-bang > > methods. > > My Task model is simply defined (by the generate scaffold script) as: > class Task < ActiveRecord::Base > end > > How is it that I can call Task.create! which is a method of > ActiveRecord::Validations ? > Because ActiveRecord::Base includes the ActiveRecord::Validations module. It's not clear from the RDoc though... >From active_record.rb: ActiveRecord::Base.class_eval do extend ActiveRecord::QueryCache include ActiveRecord::Validations include ActiveRecord::Locking::Optimistic include ActiveRecord::Locking::Pessimistic ...lots more Aslak > Thanks in advance, > Sarah > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From caius at caius.name Mon Dec 22 14:29:07 2008 From: caius at caius.name (Caius Durling) Date: Mon, 22 Dec 2008 19:29:07 +0000 Subject: [rspec-users] newbie cucumber tutorial In-Reply-To: <8d961d900812220918l7829008dpd884f599749a0ab5@mail.gmail.com> References: <8d961d900812220305x38c21bccsa557feceff5f1ecb@mail.gmail.com> <0123602a68a5ed556a9c5071b8b0b57f@ruby-forum.com> <8d961d900812220918l7829008dpd884f599749a0ab5@mail.gmail.com> Message-ID: <20E44B0F-9A78-4FD9-BBCC-E8021483E8DC@caius.name> On 22 Dec 2008, at 17:18, aslak hellesoy wrote: > Essentially, #create will never raise an error no matter what you > pass it, and you actually want exceptions for bad input in your > tests (step definitions). > Therefore - use #create! (or #save!). In your app, use the non-bang > methods. Use the bang methods everywhere, but make sure to catch ActiveRecord::RecordInvalid and ActiveRecord::RecordNotFound either in rescue_from handlers or within the controller actions themselves. If you use rescue_from you need to turn on rails_error_handling in rspec's config though. C --- Caius Durling caius at caius.name +44 (0) 7960 268 100 http://caius.name/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part URL: From walketim at gmail.com Mon Dec 22 14:52:07 2008 From: walketim at gmail.com (Tim Walker) Date: Mon, 22 Dec 2008 12:52:07 -0700 Subject: [rspec-users] [cucumber] automation and historical Message-ID: <1ebf5a4d0812221152u22cd1468s510d6a5fcd3446ac@mail.gmail.com> Hi guys, Can someone point me to information regarding: 1) running cucumber as an automated task decoupled from CI. Assuming cron or similar. 2) parsing and storing results so they can be graphed, etc. Many thanks in advance, Tim From walketim at gmail.com Mon Dec 22 14:55:38 2008 From: walketim at gmail.com (Tim Walker) Date: Mon, 22 Dec 2008 12:55:38 -0700 Subject: [rspec-users] [cucumber] automation and historical In-Reply-To: <1ebf5a4d0812221152u22cd1468s510d6a5fcd3446ac@mail.gmail.com> References: <1ebf5a4d0812221152u22cd1468s510d6a5fcd3446ac@mail.gmail.com> Message-ID: <1ebf5a4d0812221155j7738cc0djad978d200a9f5fee@mail.gmail.com> Hate to "glom on"...I was curious about the exit status from cucumber... I did a rake features to a log file and this is the