Re: [rspec-users] be_none and be_any don't seem to work properly
On 21 Oct 2009, at 16:45, David Chelimsky wrote: On Oct 19, 2009, at 2:12 PM, iain wrote: I use be_all(&:some_predicate) to test if all the elements in the collection are valid, which works, but when I try to test the inverse, it fails. I'm not certain, but I _think_ that the problem is the way you're setting up the factories. I don't think be_all(&:some_predicate) actually works at all, except in the accidental sense that Enumerable#all indiscriminately returns true as long as all of the entries in the collection are truthy. At the moment it looks like dynamic predicate matchers like be_all completely ignore their block argument (&:some_predicate doesn't get rolled into *args) so you just get the default blockless behaviour of the underlying predicate. I've reported and patched this on Lighthouse: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/905 Cheers, -Tom ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] [BDD] View specs and cucumber -- duplication of effort?
2009/10/29 nruth > Hi Guys > > I'm going to put the cat amongst the pigeons here in the hope of some > clarity falling out of the sky on me. > My question is this: In a world with Cucumber what is the value of > view specs? > > In the community (railscamp, for example) there are a fair number of > people using Cucumber and skipping view specs, but still speccing > controllers, models, tricky view helpers and so on. > > Why? Because they don't find them helpful. Indeed they are seen as a > waste of time (money) not only duplicating Cucumber coverage, but also > introducing a high-maintenance example group which designers (who > don't run tests) will frequently break. > > These people aren't stupid. They're producing working apps. I don't > claim that their work cycle is perfect: this is about utility and > efficiency, or about being lazy or avoiding boredom, if you prefer. > > I've been working in a mixed environment, with an existing project > which uses rspec and cucumber (sans view specs) and my own green field > app for a different client. > I've been following the BDD approach prescribed by the RSpec book (or > so I think). This works, and has produced a lot of LOC. > > I've not worried, as it has given me plenty of practice with the > various arms of rspec, webrat, and other tools. > Now that I'm more comfortable with them things are starting to get > tiresome, especially duplication, and I'm worried I'm creating a > monolith. Too many specs => TLDR ? > > What should I try using view specs for? Why are they better than > cucumber for this? > > "Driving views through examples helps us think about what the view > needs in order for it to do its job. It encourages us to write the > code we wish we had to fulfil those needs." > > I'm not sure how this is any different to what I do in the outer > circle with Cucumber. If I write an explicit scenario like > http://gist.github.com/221004 then I already know what the view needs > to let me do. > > If I write something more broad-brush (which you will do, if quickly > sketching out features during a design meeting) like "When I add a > page link" I have to then define that step so it goes red (or, heaven > forbid, green). But to write that step definition I have to know how I > can interact with the page. This example actually comes from a broad- > brush step being expanded in the scenario itself rather than hiding it > away in a step definition, but that's a different subject. > > I'm specifying the page's behaviour in the scenario, or in the step > definition. Why duplicate this process with a view spec? > > I keep coming back to the introduction of chapter 23 in the RSpec book > but don't seem to be getting anywhere from it. > > For the time being I'm going to keep writing view specs, but try to > make them lighter and cut some of the dead wood by describing unusual > or interesting behaviour rather than all behaviour. > > I'd love to hear your thoughts. > > Regards > > Nick > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Currently I don't do view specs, but I'm beginning to see a use for them. This is all to do with a recent change change in my thinking about features. In addition to all the other things features do, I am now seeing them as a map to what the "business" wants from the application. This map works best if it is clear and simple (a bit like the London tube map). Putting lots of view details in the features (and I should see a wibble field etc. ...) pollutes this map with clutter that is not relevant to the "business" context. So view specs seem like a really good place to spec all this detail. Another benefit of this is that the view specs might end up as another map that is useful to designers and front end developers. I've been thinking about features, specs and even code as maps recently. It provides a really good explanation of why names and description are so important. Andrew ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] [BDD] View specs and cucumber -- duplication of effort?
On Wed, Nov 4, 2009 at 10:56 AM, Andrew Premdas wrote: > > Putting lots of > view details in the features (and I should see a wibble field etc. ...) > pollutes this map with clutter that is not relevant to the "business" > context. So view specs seem like a really good place to spec all this > detail. I think this is a really good point. However, I'd suggest that this could still be done in Cucumber. If you have a step like "Then I should see my wozbat's details" you could put your detail map in the step definition: Then /^I should see my wozbat's details$/ do Then "I should see my wozbat's wibble" Then "I should see my wozbat's wobble" Then "I should see my wozbat's wombat" end And so forth. Generalize or specialize as needed. I don't think this is conceptually better than doing it in a view spec. View specs probably are philosophically superior in most cases. The advantage is that in Cucumber this takes essentially no extra setup and is fairly concise to read, whereas mocking your model instances in a view spec is a pain and the specs themselves tend to be much more verbose. -- Have Fun, Steve Eley (sfe...@gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] [BDD] View specs and cucumber -- duplication of effort?
2009/11/4 Stephen Eley > On Wed, Nov 4, 2009 at 10:56 AM, Andrew Premdas > wrote: > > > > Putting lots of > > view details in the features (and I should see a wibble field etc. ...) > > pollutes this map with clutter that is not relevant to the "business" > > context. So view specs seem like a really good place to spec all this > > detail. > > I think this is a really good point. However, I'd suggest that this > could still be done in Cucumber. If you have a step like "Then I > should see my wozbat's details" you could put your detail map in the > step definition: > > Then /^I should see my wozbat's details$/ do > Then "I should see my wozbat's wibble" > Then "I should see my wozbat's wobble" > Then "I should see my wozbat's wombat" > end > > And so forth. Generalize or specialize as needed. > > I don't think this is conceptually better than doing it in a view > spec. View specs probably are philosophically superior in most cases. > The advantage is that in Cucumber this takes essentially no extra > setup and is fairly concise to read, whereas mocking your model > instances in a view spec is a pain and the specs themselves tend to be > much more verbose. > > > -- > Have Fun, > Steve Eley (sfe...@gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Yes you can use step definitions to do this, but I would avoid nesting the steps and actually make the direct calls e.g. response.should_have (#wozbat) Personally I now think nested steps are evil - but thats another story :) If the items are fields in forms I'd just assume their presence and fill them in in a step e.g. when /^I fill in foo form correctly$/ do fill_in foo.wibble, :with => "wibbling" However before I can do this I'm thinking that a view spec that says the form has a wibble field would be useful, concise and expressive. The feature drives what you do with the view, and the view spec specifies whats in the view. This matches the loop within loop workflow in the rspec book. Having said all this I haven't actually done this in practice yet, going to try it on my next view. By the way its nice to find a fellow soul who appreciates the wonderfully expressive power of the word 'wibble'! All best Andrew ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] unable to build gem
Is the following expected? C:\dev\ruby\downloads\rspec>rake gem (in C:/dev/ruby/downloads/rspec) in rdoc 2.4.3 rake aborted! Don't know how to build task 'lib/spec/matchers/extensions/ instance_exec.rb' (See full trace by running task with --trace) Thanks. -r ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] [BDD] View specs and cucumber -- duplication of effort?
On Wed, Nov 4, 2009 at 3:24 PM, Andrew Premdas wrote: > > Personally I now think nested steps are evil - but thats another story :) It sounds like an entertaining one. I'd love to hear why sometime. (Though whether the right place for it would be here or the Cucumber list, I couldn't say.) > Having said all this I haven't actually done this in practice yet, going to > try it on my next view. Please share what you find out. Particularly if you discover a way to do them that doesn't make them feel like more work. >8-> > By the way its nice to find a fellow soul who appreciates the wonderfully > expressive power of the word 'wibble'! Of course! They wobble, but they don't fall down. >8-> -- Have Fun, Steve Eley (sfe...@gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] question
Perhaps it would be useful to do some parsing of the messages... it "should raise an Exception if record is invalid" do end # expects that block to raise Thoughts? -r ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] odd error
with 1.8.6 + rspec 1.2.9 (sorry couldn't try trunk, see previous post) I get: C:\dev\ruby\old\arguments>spec spec\arguments_spec.rb ..F 0.00 0.00 0.00 ( 0.00) .F 0.00 0.00 0.00 ( 0.00) 0.015000 0.00 0.015000 ( 0.015625) . 1) 'Arguments should raise ArgumentError if passing recoginized keywords' FAILED expected: "`four, five` are not recognized argument keywords", got: "`five, four` are not recognized argument keywords" (using ==) ./spec\arguments_spec.rb:140: (succeeds with 1.9.x) Thanks. -r ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] better documentation?
I'm interested in helping the documentation for rspec, ex: http://rspec.info/ described similarly to how this person feels (that there's not too much "getting started" docu). http://creativedeletion.com/2007/05/27/the-new-rspec-format-testingspecing-in-ruby/ Is there anywhere to fork or what not for the website? Thanks. -r ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] better documentation?
On Nov 4, 2009, at 4:51 PM, rogerdpack wrote: I'm interested in helping the documentation for rspec, ex: http://rspec.info/ described similarly to how this person feels (that there's not too much "getting started" docu). http://creativedeletion.com/2007/05/27/the-new-rspec-format-testingspecing-in-ruby/ Is there anywhere to fork or what not for the website? Hey Roger, I really like what Aslak and the Cucumber community have done by making cukes.info more high level and building up more extensive documentation on the github wiki, so I'd rather put energy into beefing up the github wiki than improve rspec.info. What do you think? Cheers, David Thanks. -r ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] unable to build gem
On Wed, Nov 4, 2009 at 3:34 PM, rogerdpack wrote: > Is the following expected? > Absolutely not. I moved some things around and failed to update the manifest. This is fixed in git HEAD now, so please update and try again. Cheers, David > > > C:\dev\ruby\downloads\rspec>rake gem > (in C:/dev/ruby/downloads/rspec) > in rdoc 2.4.3 > rake aborted! > Don't know how to build task 'lib/spec/matchers/extensions/ > instance_exec.rb' > > (See full trace by running task with --trace) > > Thanks. > -r > ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] odd error
On Wed, Nov 4, 2009 at 3:37 PM, rogerdpack wrote: > with 1.8.6 + rspec 1.2.9 (sorry couldn't try trunk, see previous post) > > I get: > > > C:\dev\ruby\old\arguments>spec spec\arguments_spec.rb > ..F 0.00 0.00 0.00 ( 0.00) > .F 0.00 0.00 0.00 ( 0.00) > 0.015000 0.00 0.015000 ( 0.015625) > . > > 1) > 'Arguments should raise ArgumentError if passing recoginized keywords' > FAILED > expected: "`four, five` are not recognized argument keywords", > got: "`five, four` are not recognized argument keywords" (using > ==) > ./spec\arguments_spec.rb:140: > Please be sure to post the relevant code when you are asking for help on this list. I'll take a guess at what is going on, but it's hard to know if I'm barking up the right tree without seeing the code. If I understand the problem correctly, it's that the spec is expecting hash keys to be in a specific order. In Ruby 1.8, the order of hash keys are not guaranteed to be in any specific order, whereas in 1.9, AFAIK, they are. HTH, David > > (succeeds with 1.9.x) > > Thanks. > -r > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9
Hi, 'rake spec' failed to run on Ruby 1.9.1p243 and RSpec 1.2.9. I'm getting the following error message when I run the specs: /opt/local/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/spec/spec/runner/ option_parser_spec.rb:21:in `block (2 levels) in ': wrong number of arguments (0 for 1) (ArgumentError) After analyzing the error message, it appears that "use_fakefs" method on lines 21 and 522 of the option_parser_spec.rb should take an argument. -Conrad ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Some tiny but usefill fix
Dear David! I use rpec for the several years and almost in every prject I apply the following patch. Today I thought that maybe you will accept it so that others may have it's benefit. diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb index 4f8b9b7..895dcbd 100644 --- a/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb +++ b/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb @@ -52,7 +52,7 @@ module Spec def dump_summary(duration, example_count, failure_count, pending_count) return if dry_run? @output.puts - @output.puts "Finished in #{duration} seconds" + @output.puts "Finished in #{duration} seconds at #{Time.now.strftime('%Y.%m.%d %H:%M:%S')}" @output.puts summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}" Thank you in advance. -- With best regards, Dmitri Koulikoff mailto:d...@koulikoff.ru phone: +7-495-5052185 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] [RSpec] Testing "validates_uniquesness of"
Guys, Getting used to doing BDD, and in my current project I'm trying to spec out my model, and in particular the fact that my model must validate that one of its fields are unique; in this case, the customer's email address. Simple enough model, a customer, who only has two fields. :email_address and :state. I have a model spec that does the following: it "ensureness that the customer's email is unique" do customer.new :email_address => "j...@test.com" customer2.new :email_address => "Joe @Test.com" customer2.should_not be_valid end Once I run my spec, it fails, as their is no validator in the model yet. However, once I add the validator it still fails. class Customer < ActiveRecord::Base validates_precense_of :email_address, :message => "needs to be valid." end The thing is, the validator actually works if I fire up the server and try to do it myself. Anybody know why that spec doesn't do what I expect it to? I have a feeling its something to do with the variables I'm creating, but could anybody give me an example that would show me how to do this? Thanks, Joe ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9
On Tue, Nov 3, 2009 at 7:25 AM, Conrad Taylor wrote: > Hi, 'rake spec' failed to run on Ruby 1.9.1p243 and RSpec 1.2.9. Hi Conrad, If this was a problem in the gem, it is now fixed: $ rvm 1.9.1 $ which ruby /Users/david/.rvm/ruby-1.9.1-p243/bin/ruby $ rake spec ... 1522 examples, 0 failures, 2 pending Cheers, David > I'm > getting the following error message when I run the specs: > > /opt/local/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/spec/spec/runner/ > option_parser_spec.rb:21:in `block (2 levels) in ': > wrong number of arguments (0 for 1) (ArgumentError) > > After analyzing the error message, it appears that "use_fakefs" method > on lines 21 and 522 of the > > option_parser_spec.rb > > should take an argument. > > -Conrad > > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] [RSpec] Testing "validates_uniquesness of"
Em 02-11-2009 04:48, Joseph.DelCioppio escreveu: Guys, Getting used to doing BDD, and in my current project I'm trying to spec out my model, and in particular the fact that my model must validate that one of its fields are unique; in this case, the customer's email address. Simple enough model, a customer, who only has two fields. :email_address and :state. I have a model spec that does the following: it "ensureness that the customer's email is unique" do customer.new :email_address => "j...@test.com" It is simple. You should have used this instead: customer.*create* :email_address => "j...@test.com" When you call new, it doesn't instanciate in database and there is why the second try suceeds... Hope that helps, Rodrigo. __ Faça ligações para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] [BDD] View specs and cucumber -- duplication of effort?
On Wed, Nov 4, 2009 at 3:36 PM, Stephen Eley wrote: > On Wed, Nov 4, 2009 at 3:24 PM, Andrew Premdas wrote: > > > > Personally I now think nested steps are evil - but thats another story :) > > It sounds like an entertaining one. I'd love to hear why sometime. > (Though whether the right place for it would be here or the Cucumber > list, I couldn't say.) > I'll pipe in since it's here on this list at the moment: I won't go as far as to say that nested steps are evil, but I don't really like to use them myself because they do conflate two levels of abstraction. I'd sooner have two steps delegate to a helper than one step delegate to another. FWIW, David > > Having said all this I haven't actually done this in practice yet, going > to > > try it on my next view. > > Please share what you find out. Particularly if you discover a way to > do them that doesn't make them feel like more work. >8-> > > > > By the way its nice to find a fellow soul who appreciates the wonderfully > > expressive power of the word 'wibble'! > > Of course! They wobble, but they don't fall down. >8-> > > > -- > Have Fun, > Steve Eley (sfe...@gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users