Re: [rspec-users] Not running correct specs under autotest:
On 4 Jun 2008, at 15:14, Matt Mower wrote: On Wed, Jun 4, 2008 at 3:06 PM, David Chelimsky [EMAIL PROTECTED] wrote: Rails 2.1 supports plugins from git. Yep 2.1 and I used script/plugin to install from git this time. That's new again to me since I've been using piston for quite a while (or submodules with a git based project). The new, git compatible, script/plugin update takes care of the details? AFAIK it doesn't -- script/plugin install from a git URL is no better than manually unpacking the tgz into vendor/plugins, i.e. completely useless. I've pretty much resigned myself to just blowing away each plugin directory when I want to update it, and either tracking my local changes manually (i.e. maintaining a diff that I laboriously reapply after updating) or monkeypatching plugins in lib/ rather than modifying them directly. (script/plugin update relies on svn:externals.) Rails dependency management is getting worse. Maybe piston 2.0, with git support, will make it better again? Cheers, -Tom ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] any_instance
HI Scott. On Thu, Jun 5, 2008 at 3:05 AM, Scott Taylor [EMAIL PROTECTED] wrote: There's a general idea with rspec (and one which probably isn't present in other testing frameworks) that says that testing *should* influence your design. I'm sure this is one of the reasons that David considers it an anti-pattern - as it does not influence your design in any way. In fact, I developed the the stub_any_instance patch because I needed to test legacy code (legacy because it wasn't designed well), and it was the only way to get to the object. I guess that's how I see this. My code, that I am writing specs for, depends upon a lower-level library that does not expose the details of it's implementation to it's clients. The use of any_instance allows me to test my code simply. Without it I seem to be forced to build complex arrangements of mocks to, essentially, emulate the behaviour of the underlying library. This feels like busy work. Whilst it would be possible to re-write the underlying library I do not feel that's a worthwhile investment of my time right now. Especially not when I have a spec suite that already works but for the lack of any_instance. I'm all for encouraging good practice and wrapping any_instance in the shame of your peers. But I'm also all for being pragmatic. Does your patch work? I wasn't clear whether David was saying that it doesn't. Regards, Matt. -- Matt Mower :: http://matt.blogs.it/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Using and_yield to pass multiple or no iterations
Hi, imagine there's a class called Egg which has the following method (which calls another method): CODE def do_thing has_iterated = false self.each_row do |row| has_iterated = true unless has_iterated end has_iterated end /CODE Stupid code, I know. I have two questions with it. The first is, would it be possible to set it up to test the case when each_row operates on an empty Array? Sort of like this: SPEC it should return false if it does not iterate over anything do @egg.stub!( each_row ).and_yield( nil ) # I know this doesn't work @egg.do_thing.should be_false end it should return true if it does iterate over something do @egg.stub!( each_row ).and_yield( :value ) @egg.do_thing.should be_true end /SPEC Secondly, is this the best (correct) way to pass multiple values to iterate over? SPEC it should be doing something else, too @egg.stub!( :each_row ). and_yield( :first_value ). and_yield( :second_value ). and_yield( :third_value ) @egg.do_thing.should be_true end /SPEC As you can see, my understanding of and_yield() is *very* imperfect, so any all pointers are very gratefully received. Cheers, Doug. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] any_instance
On Jun 4, 2008, at 9:05 PM, Scott Taylor wrote: There's a general idea with rspec (and one which probably isn't present in other testing frameworks) that says that testing *should* influence your design. This isn't really a framework issue - it's about TDD. Remember that BDD started off as another way of framing TDD - it's roots are still in TDD. As you've read before, TDD is a design practice, not a testing practice. There is a testing benefit we get out of it, but the great benefit of writing tests first is that you start off thinking from a client's perspective. This and the fact that you're adding small bits at a time, doing the simplest thing that could possibly work, generally leads to more highly decoupled nuggets of code than back- filling tests. I'm sure this is one of the reasons that David considers it an anti- pattern - as it does not influence your design in any way. In fact, I developed the the stub_any_instance patch because I needed to test legacy code (legacy because it wasn't designed well), and it was the only way to get to the object. I'm sure David would have specific examples, and I'd be curious to see them. any_instance is a global concept. Any time you're doing something global in an executable example you're making it harder for yourself to understand failures later. I guess that it's a bit more harmless with stubs, so, as I said, I'm still open to adding a patch. I'm just not going to make it myself as it's low priority for me. Cheers, David ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] any_instance
On Jun 5, 2008, at 5:07 AM, Matt Mower wrote: Does your patch work? I wasn't clear whether David was saying that it doesn't. The patch works but is incomplete and duplicates a bunch of code. You should probably be able to use it as/is for what you need. Cheers, David ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] additional logging
Hi, I am using the 'spec/story' module with Fire(Watir). Is there additional logging? I don't want to do this: code Then the resultant links are displayed with the search text in each description do browser.links.each do |lnk| if lnk.id =~ /programmeLink/ lnk.click sleep 0.5 puts pass unless ui.does_the_html_include?(@text)== 0 #regex browser.back end end /code Or am I structuring this wrong? Is it one Then per verification point? Problem with that is I have a dynamic number of verification points. Regards Aidy -- Aidy www.agiletester.co.uk ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] xhr :post giving wrong number of arguments on rails 2.1?
Use xml_http_request in your stories rather than xhr. I believe the xhr method is aliased to the wrong method... I haven't looked to see if this is a Rails issue or a rspec-rails issue, Zach On Thu, Jun 5, 2008 at 1:33 AM, Mikel Lindsaar [EMAIL PROTECTED] wrote: Getting a strange error. In a story I have the following step: When I submit a search name do xhr :post, '/searches', {:search = {:given_name = bob, :family_name = smith}} end I am getting: ArgumentError: wrong number of arguments (4 for 3) stories/searching_story_spec.rb:45 in I submit a search name But I only have 3 arguments in the above list, a symbol, a string and a hash. No exception comes up in the test.log I am on Rspec trunk from a couple of days ago and Rails 2.1. Any ideas? Mikel ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users -- Zach Dennis http://www.continuousthinking.com ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Using and_yield to pass multiple or no iterations
On Thu, Jun 5, 2008 at 5:46 AM, Doug Livesey [EMAIL PROTECTED] wrote: I have two questions with it. The first is, would it be possible to set it up to test the case when each_row operates on an empty Array? If there were no rows, each_row wouldn't yield at all, so you should just be able to do @o.stub! :each_row (with no and_yield). Note that Ruby is happy to let you associate a block with any method call, whether it's expected or not. -hume. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] RSpec Story - SystemStackError: stack level too deep
I have a story that executes the following (as an example to show the bug I'm experiencing): -- Given I have a fake post saved do @postCount = Post.find(:all).length @post = Post.new @post.employee_id = 123 @post.name = Name of the Post @post.description = Description of the Post @post.save end Given I have visited some page do get(/posts/) end When I get some other page do get('/posts/'[EMAIL PROTECTED]) end Then my variable should still be set do Post.find(:all).length.should == 1 + @postCount end -- It fails with SystemStackError: stack level too deep on the When I get some other page bit. If I remove the [EMAIL PROTECTED] bit, OR if I switch the order execution of the Given statements, the story works. What's going on? Is this a bug, or am I just missing something? Additionally, I've tried updating to RSpec Edge by running script/plugin install git://github.com/dchelimsky/rspec, but I keep receiving Plugin not found: [git://github.com/dchelimsky/rspec]. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] xhr :post giving wrong number of arguments on rails 2.1?
On Fri, Jun 6, 2008 at 1:39 AM, Zach Dennis [EMAIL PROTECTED] wrote: Use xml_http_request in your stories rather than xhr. I believe the xhr method is aliased to the wrong method... I haven't looked to see if this is a Rails issue or a rspec-rails issue, Thanks, that worked. Mikel ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users