From dchelimsky at gmail.com Fri Aug 4 19:52:32 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 4 Aug 2006 18:52:32 -0500 Subject: [Rspec-users] a commitment to underscores Message-ID: <57c63afe0608041652n10744519pc102b65eedb65cc@mail.gmail.com> rspec'ers We've been living in a world for a couple of months in which rspec supports both dots and underscores. Supporting both is gumming up the works at this point and I'd like to commit to one or the other. Assuming that all would prefer underscores, I've changed all of the tests to use only underscores, fixing a few new problems as they appeared. Unless there is a surprising and overwhelming desire to revert to dots, I'd like to commit to supporting only underscores (not dots). Doing so will allow us to clean up quite a bit of code. Any concerns? Objections? Thanks, David From dchelimsky at gmail.com Sat Aug 5 17:07:14 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 5 Aug 2006 16:07:14 -0500 Subject: [Rspec-users] underscore commitment committed Message-ID: <57c63afe0608051407m25ff711dm6b15846567108bb@mail.gmail.com> rspec'ers I've committed numerous changes relating to dots, underscores, and mocks. This code will break your specs that use dots (with a couple of exceptions noted below), so you'll have to change the dots to underscores if you've been using them. Feel free to check out the trunk, run it against your existing specs and report back any problems other than those related to dots and underscores (I'm expecting none, but you never know). Note that there are still a couple of places where dots seem more correct. For example: mock.should_receive(:message).once.and_return(value) that makes more sense (IMO) than: mock.should_receive(:message).once_and_return(value) because "once_and_return" doesn't really make sense as a message to me. Assuming there are no major issues, we'll do a release mid-week. Thanks, David From dchelimsky at gmail.com Wed Aug 9 16:08:49 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 9 Aug 2006 15:08:49 -0500 Subject: [Rspec-users] [ANN] RSpec 0.6.0 Message-ID: <57c63afe0608091308l91e2440x46126d1333c8fdd9@mail.gmail.com> This release represents a formal commitment to underscores (dots are no longer supported), which allowed us to reduce the code base by nearly 10%. http://rubyforge.org/frs/shownotes.php?release_id=6377 http://rspec.rubyforge.org/ To be clear, if you have dots in your examples, they may break. The only exception to the rule is after "once" or "twice" when setting mock expectations: http://rspec.rubyforge.org/documentation/mocks.html Additionally, there are several other improvements to the mock API, as well as some bug fixes. Enjoy! David From aschur1 at telus.net Sat Aug 12 17:18:21 2006 From: aschur1 at telus.net (Alvin Schur) Date: Sat, 12 Aug 2006 15:18:21 -0600 Subject: [Rspec-users] Strategy pattern: comparing Context/Specify to Given/When/Then Message-ID: <200608121518.21929.aschur1@telus.net> Comments and suggestions for improving the specifications are welcome. Thanks, Alvin One example comparing context/specify (CS) with given/when/then (GWT) with a strategy pattern follows: Consider a pipeline transporting oil supplied by multiple partners. The amounts transported on behalf of each partner are recorded as transactions in a general ledger. There are multiple approaches to allocating the pipeline operational costs to each partner: - fixed amount - equal split - fixed percentage - gross override with subsidiary cost allocation - proportional cost allocation - tiered cost allocation The fixed amount, equal split, and fixed percentage methods were easy to specify since all logic is contained within one class. The CS and GWT provide similar descriptions. The remaining cost allocation methods make use of relationships between classes. Then the GWT terminology seems easier to use than the CS terminology. Using CS and GWT certainly helped me to understand the inter-relationships between classes. For example: given "A cost allocation with a gross override amount of $5000 to cost allocation 1 and the remainder to cost allocation 2" when "the allocated amount is $5000" then "the amount is allocated by cost allocation 1" when "the allocated amount is $5001" then "$5000 is allocated by cost allocation 1" then "$1 is allocated by cost allocation 2" *** Compared to *** context "A cost allocation with a gross override amount of $5000 to cost allocation 1 and the remainder based on cost allocation 2" specify "should allocate an amount of $5000 based on cost allocation 1 when allocating $5000" specify "should allocate an amount of $5000 based on cost allocation 1 when allocating $5001" specify "should allocate an amount of $1 based on cost allocation 2 when allocating $5001" *** OR *** context "A cost allocation with a gross override amount of $5000 to cost allocation 1 and the remainder based on cost allocation 2 and allocating $5000" specify "should allocate an amount of $5000 based on cost allocation 1" context "A cost allocation with a gross override amount of $5000 to cost allocation 1 and the remainder based on cost allocation 2 and allocating $5001" specify "should allocate an amount of $5000 based on cost allocation 1" specify "should allocate an amount of $1 based on cost allocation 2" From aslak.hellesoy at gmail.com Sat Aug 12 18:56:55 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 12 Aug 2006 17:56:55 -0500 Subject: [Rspec-users] Strategy pattern: comparing Context/Specify to Given/When/Then In-Reply-To: <200608121518.21929.aschur1@telus.net> References: <200608121518.21929.aschur1@telus.net> Message-ID: <8d961d900608121556s10823c89xc0e22d3b5cae7a26@mail.gmail.com> On 8/12/06, Alvin Schur wrote: > Comments and suggestions for improving the specifications are welcome. > Hi Alvin, I don't know your domain, but I have some general comments on your use of the GWT format. Your GWT examples look somewhat more focused on state than behaviour. (This might be due to my lack of domain knowledge - please let me know if I'm wrong). I'll try to explain... GWT is not only a format for defining acceptance criteria by example. It is also a format that is intended to describe behaviour. So what is behaviour? If you look it up in a dictionary (http://webster.com/dictionary/behavior) you'll find something along the lines of "what something does when it's poked in a certain way". In order to describe the behaviour of something we have to give an example of what it does in response to some stimulus. Here is an example of how to describe a behaviour of a window when a rock is thrown at it - using GWT: Given a 5mm thick window When I throw a 1kg rock at it from 3 meters away Then it will break Or more generally: Given a subject in a known state When the subject is exposed to a certain *stimulus* Then the subject will *respond* in a certain way The role of the When is to describe the stimulus - some sort of event. A common mistake is to overlook this and just use the When to describe additional state. Example: Given I have a 5mm thick window When the window is 1 square meter in area Then it will be 0.005 cube meters in volume GWT when used this way does *not* describe behaviour. It's describing state. BDD is all about describing how things behave, and the GWT should be used accordingly. --- With this in mind, could your behaviour examples in the GWT format be written differently? If that's difficult, can you think of some stimulus or event that your system can be exposed to - and describe that? Cheers, Aslak > Thanks, > Alvin > > > One example comparing context/specify (CS) with given/when/then (GWT) > with a strategy pattern follows: > > Consider a pipeline transporting oil supplied by multiple partners. > The amounts transported on behalf of each partner are recorded as > transactions in a general ledger. > > There are multiple approaches to allocating the pipeline operational > costs to each partner: > - fixed amount > - equal split > - fixed percentage > - gross override with subsidiary cost allocation > - proportional cost allocation > - tiered cost allocation > > The fixed amount, equal split, and fixed percentage methods were easy > to specify since all logic is contained within one class. The CS and > GWT provide similar descriptions. > > The remaining cost allocation methods make use of relationships > between classes. Then the GWT terminology seems easier to use than > the CS terminology. > > Using CS and GWT certainly helped me to understand the > inter-relationships between classes. > > For example: > > given "A cost allocation with a gross override amount of $5000 to cost > allocation 1 and the remainder to cost allocation 2" > when "the allocated amount is $5000" > then "the amount is allocated by cost allocation 1" > > when "the allocated amount is $5001" > then "$5000 is allocated by cost allocation 1" > then "$1 is allocated by cost allocation 2" > > > *** Compared to *** > > > context "A cost allocation with a gross override amount of $5000 to cost > allocation 1 and the remainder based on cost allocation 2" > specify "should allocate an amount of $5000 based on cost allocation 1 when > allocating $5000" > specify "should allocate an amount of $5000 based on cost allocation 1 when > allocating $5001" > specify "should allocate an amount of $1 based on cost allocation 2 when > allocating $5001" > > *** OR *** > > context "A cost allocation with a gross override amount of $5000 to cost > allocation 1 and the remainder based on cost allocation 2 and allocating > $5000" > specify "should allocate an amount of $5000 based on cost allocation 1" > > context "A cost allocation with a gross override amount of $5000 to cost > allocation 1 and the remainder based on cost allocation 2 and allocating > $5001" > specify "should allocate an amount of $5000 based on cost allocation 1" > specify "should allocate an amount of $1 based on cost allocation 2" > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben.askins at gmail.com Wed Aug 16 04:09:03 2006 From: ben.askins at gmail.com (Ben Askins) Date: Wed, 16 Aug 2006 18:09:03 +1000 Subject: [Rspec-users] Testing has_many, :through relationships Message-ID: Hi All, This is my first post on this list. I'm a developer working on the Central Coast of NSW, Australia and came across RSpec via Lachie who demoed RSpec on Rails at a Sydney rails user group meeting a couple of months ago. I'm loving the expressiveness of RSpec and can't really see myself going back to Test::Unit. I've come across one oddity though. I have 3 models, two in a typical many to many relationship, with the other providing the join: class Book < ActiveRecord::Base has_many :readings has_many :readers, :through => :readings end class Reader < ActiveRecord::Base has_many :readings has_many :books, :through => :readings end class Reading < ActiveRecord::Base belongs_to :book belongs_to :reader end My spec is simply: context "Ben" do fixtures :readers, :books, :readings specify "should have read HHGTTG" do ben = readers(:Ben) ben.books.should_include books(:HHGTTG) end end And the spec fails with: TypeError in 'Ben should have read HHGTTG' wrong argument type Book (expected Module) A quick test in the console reveals that: ben.books.include? Book.find(:first) returns true, which I'm assuming is the logical expression that the spec resolves to. Is this a problem with my spec or a problem with Rspec on Rails? I've only been using it for the last couple of hours so I expect I'm the problem. cheers, Ben -- http://teamaskins.net From aslak.hellesoy at gmail.com Tue Aug 22 18:57:57 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Wed, 23 Aug 2006 00:57:57 +0200 Subject: [Rspec-users] ANN: RSpec 0.6.1 Message-ID: <8d961d900608221557y4d7e35feu2ad3e420c2c64464@mail.gmail.com> Hi all Go grab the latest release of RSpec (gem install rspec). It has 9 bug fixes and some extra features, most notably a working rails_spec_runner, which allows you to run your Rails specs *fast*. Release notes: http://rubyforge.org/frs/shownotes.php?release_id=6590 Cheers, The RSpec team From hughes.james at gmail.com Thu Aug 24 18:12:14 2006 From: hughes.james at gmail.com (James Hughes) Date: Thu, 24 Aug 2006 15:12:14 -0700 Subject: [Rspec-users] "rake spec" doesn't work after upgrade to 0.6.1 Message-ID: <765a2c230608241512o360ece79la75842490294f749@mail.gmail.com> Hi: spec works though. Stack trace: rake spec (in /home/jhughes/work/media-catalog/trunk) /usr/bin/ruby1.8 -Ilib /usr/lib/ruby/gems/1.8/gems/rspec-0.6.1/bin/spec "spec/models/category_spec.rb" "spec/models/item_spec.rb" /usr/lib/ruby/gems/1.8/gems/rspec-0.6.1/lib/spec.rb:1:in `require': no such file to load -- spec/version (LoadError) from /usr/lib/ruby/gems/1.8/gems/rspec-0.6.1/lib/spec.rb:1 from /usr/lib/ruby/gems/1.8/gems/rspec-0.6.1/bin/spec:2 /usr/bin/ruby1.8 -Ilib /usr/lib/ruby/gems/1.8/gems/rspec-0.6.1/bin/spec "spec/controllers/media_controller_spec.rb" "spec/controllers/media_listing_worker_spec.rb" "spec/controllers/items_controller_spec.rb" /usr/lib/ruby/gems/1.8/gems/rspec-0.6.1/lib/spec.rb:1:in `require': no such file to load -- spec/version (LoadError) from /usr/lib/ruby/gems/1.8/gems/rspec-0.6.1/lib/spec.rb:1 from /usr/lib/ruby/gems/1.8/gems/rspec-0.6.1/bin/spec:2 rake aborted! RSpec failures Thoughts? jh -- James Hughes Web application developer Vancouver, BC "Developing a coherent political analysis is in many respects contingent upon an ability to connect one context to another, a process not dissimilar to playing the kid's game of dot-to-dot." - Ward Churchill, from '"A Government of Laws"?' From dchelimsky at gmail.com Sat Aug 26 14:57:43 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 26 Aug 2006 13:57:43 -0500 Subject: [Rspec-users] back from vacation Message-ID: <57c63afe0608261157rf986ccbhdd3aae5aa01c4caf@mail.gmail.com> Hi all. Sorry for the silence over the last couple of weeks but I just got back from vacation. As you may imagine I have a ton to catch up on, but I'll be chiming in on some of the threads over the next few days. Cheers, David From aslak.hellesoy at gmail.com Sat Aug 26 16:06:14 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 26 Aug 2006 22:06:14 +0200 Subject: [Rspec-users] back from vacation In-Reply-To: <57c63afe0608261157rf986ccbhdd3aae5aa01c4caf@mail.gmail.com> References: <57c63afe0608261157rf986ccbhdd3aae5aa01c4caf@mail.gmail.com> Message-ID: <8d961d900608261306o11540229vdd9d06fea5b71c8f@mail.gmail.com> On 8/26/06, David Chelimsky wrote: > Hi all. Sorry for the silence over the last couple of weeks but I just > got back from vacation. As you may imagine I have a ton to catch up > on, but I'll be chiming in on some of the threads over the next few > days. > Welcome back David. Could you please take a look at http://rubyurl.com/4HT Cheers, Aslak > Cheers, > David > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Sat Aug 26 16:23:57 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sat, 26 Aug 2006 22:23:57 +0200 Subject: [Rspec-users] ANN: RSpec 0.6.2 Message-ID: <8d961d900608261323t60004cf8qcc2d715584b54590@mail.gmail.com> I just released RSpec 0.6.2 Hopefully this fixes the couple of glitches that went into 0.6.1 - the RSpec rake task was heavily refactored in 0.6.1 and didn't work properly when packaged as a gem. This should be fixed now. Holler if things are still broken. Cheers, Aslak From aslak.hellesoy at gmail.com Sun Aug 27 06:19:51 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Sun, 27 Aug 2006 12:19:51 +0200 Subject: [Rspec-users] ANN: RSpec 0.6.2 In-Reply-To: <8d961d900608261323t60004cf8qcc2d715584b54590@mail.gmail.com> References: <8d961d900608261323t60004cf8qcc2d715584b54590@mail.gmail.com> Message-ID: <8d961d900608270319k71a0ecf7g19cba84e46236170@mail.gmail.com> It seems that 13 hours after the last release the 0.6.2 gem is still not rsync'ed across rubyforge's cluster of gem servers: $ sudo gem install rspec Attempting local installation of 'rspec' Local gem file not found: rspec*.gem Attempting remote installation of 'rspec' Updating Gem source index for: http://gems.rubyforge.org ERROR: While executing gem ... (OpenURI::HTTPError) 404 Not Found Hopefully the replication will complete soon so this can work. If not, you can download the gem to your filesystem and do a gem install path/to/rspec-0.6.2.gem Aslak On 8/26/06, aslak hellesoy wrote: > I just released RSpec 0.6.2 > > Hopefully this fixes the couple of glitches that went into 0.6.1 - the > RSpec rake task was heavily refactored in 0.6.1 and didn't work > properly when packaged as a gem. This should be fixed now. Holler if > things are still broken. > > Cheers, > Aslak > From dchelimsky at gmail.com Mon Aug 28 01:49:07 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Aug 2006 00:49:07 -0500 Subject: [Rspec-users] single specs Message-ID: <57c63afe0608272249u1e0ff3d3nae8b17673d05209a@mail.gmail.com> The spec command has an option to run a single spec. I'm realizing that I never, ever use this. Does anyone else? If not, I'd like to get rid of it! It's one of those things that "seemed like a good idea at the time", but resulted in a bunch of hack-ish code. From aslak.hellesoy at gmail.com Mon Aug 28 03:33:49 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 28 Aug 2006 09:33:49 +0200 Subject: [Rspec-users] single specs In-Reply-To: <57c63afe0608272249u1e0ff3d3nae8b17673d05209a@mail.gmail.com> References: <57c63afe0608272249u1e0ff3d3nae8b17673d05209a@mail.gmail.com> Message-ID: <8d961d900608280033u16499374h5a86f9b2bf8dbee8@mail.gmail.com> On 8/28/06, David Chelimsky wrote: > The spec command has an option to run a single spec. I'm realizing > that I never, ever use this. Does anyone else? If not, I'd like to get > rid of it! It's one of those things that "seemed like a good idea at > the time", but resulted in a bunch of hack-ish code. I use this feature a lot. It's especially useful when you have a bunch of slow specs. Even as one of the writers of Ashcroft (http://docs.codehaus.org/display/ASH/Home) slow specs are sometimes unavoidable. Now for example, I'm writing a library that interfaces with a local scm, which is inherently slow. Example of the way I use it is: 1) spec # run all specs - they pass. The suite takes 15 seconds (sloooow) 2) Do a refactoring 3) spec # 10 of the specs fail 4) spec -s 'One of the failing specs' # Takes 1 second instead of 15. The nice thing about this is that the argument to -s can be copied and pasted from the error messages. So please don't remove this feature. Aslak > _______________________________________________ > Rspec-users mailing list > Rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Aug 28 08:30:26 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Aug 2006 07:30:26 -0500 Subject: [Rspec-users] slightly different view Message-ID: <57c63afe0608280530v283004d9nd1a5a326324c9565@mail.gmail.com> All, One of the things I learned when I started to do TDD was that you should write enough tests to give you the courage to move forward. For some, that results in more tests than others. In approaching BDD, my initial thinking was to write examples for all of the possible behaviours in every context. I've had a change of thinking on this. Please check out my blog on it and let me know your thoughts (here or there). http://butunclebob.com/ArticleS.DavidChelimsky.SpecOrganization Thanks, David From dchelimsky at gmail.com Mon Aug 28 08:32:18 2006 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 28 Aug 2006 07:32:18 -0500 Subject: [Rspec-users] slightly different view In-Reply-To: <57c63afe0608280530v283004d9nd1a5a326324c9565@mail.gmail.com> References: <57c63afe0608280530v283004d9nd1a5a326324c9565@mail.gmail.com> Message-ID: <57c63afe0608280532v50c004cei343b6062eb6fd90e@mail.gmail.com> On 8/28/06, David Chelimsky wrote: > All, > > One of the things I learned when I started to do TDD was that you > should write enough tests to give you the courage to move forward. For > some, that results in more tests than others. > > In approaching BDD, my initial thinking was to write examples for all > of the possible behaviours in every context. I've had a change of > thinking on this. Please check out my blog on it and let me know your > thoughts (here or there). > > http://butunclebob.com/ArticleS.DavidChelimsky.SpecOrganization > > Thanks, > David PS - if you check out the trunk, examples/stack_spec.rb now reflects this thinking. From demmer12 at fastmail.us Mon Aug 28 14:22:35 2006 From: demmer12 at fastmail.us (Craig Demyanovich) Date: Mon, 28 Aug 2006 14:22:35 -0400 Subject: [Rspec-users] single specs In-Reply-To: <57c63afe0608272249u1e0ff3d3nae8b17673d05209a@mail.gmail.com> References: <57c63afe0608272249u1e0ff3d3nae8b17673d05209a@mail.gmail.com> Message-ID: <518604E4-437C-4BF4-A52E-5EDEC66F0F5B@fastmail.us> On Aug 28, 2006, at 1:49 AM, David Chelimsky wrote: > The spec command has an option to run a single spec. I'm realizing > that I never, ever use this. Does anyone else? If not, I'd like to get > rid of it! It's one of those things that "seemed like a good idea at > the time", but resulted in a bunch of hack-ish code. I sometimes like being able to do this in xUnit frameworks when writing something new or digging in to something that isn't working. I don't yet have this use case while using rspec, though, since I'm not actively using it on anything yet. At this point, then, I don't care either way, but I wanted to throw this idea out there. Regards, Craig From aslak.hellesoy at gmail.com Thu Aug 31 06:00:11 2006 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 31 Aug 2006 12:00:11 +0200 Subject: [Rspec-users] RSpec style in Scriptaculous' unittest.js Message-ID: <8d961d900608310300x4af50af6pfceec46fb29b034b@mail.gmail.com> Doing Javascript? Looks like Scriptaculous' *excellent* unittest.js has got some BDD love: http://ajaxian.com/archives/scriptaculous-behaviour-driven-development-testing Aslak