|
Since this is more or less the Ruby thread, I'll ask this here - I'm using RSpec but I'm pretty new to it. I'm writing a web crawler and I want to set up a test to ensure that any page is only downloaded once. I have my Crawler class send an update message to my Observer class every time it downloads a page with the response and URI objects as arguments. My test looks like this: code:
code:
Lamont Cranston fucked around with this message at 23:31 on Jan 24, 2010 |
# ? Jan 24, 2010 23:29 |
|
|
# ? Apr 19, 2024 03:03 |
|
Lamont Cranston posted:This passes even though I know that page5.html is downloaded twice. If I change .once to .twice, it also passes. If I change to 3 times, I get this: It's hard to tell without looking at the code in your app, but I think you're passing every page url in an array each time you talk to the observer. Each time you hit a new page, the array grows and so does the list of pages passed to the observer. Because of the way RSpec does "with", as long as the page is in that array it will pass.
|
# ? Jan 25, 2010 16:24 |
|
Operation Atlas posted:It's hard to tell without looking at the code in your app, but I think you're passing every page url in an array each time you talk to the observer. Each time you hit a new page, the array grows and so does the list of pages passed to the observer. Because of the way RSpec does "with", as long as the page is in that array it will pass. It just passes the URI object, no array. I managed to get it to (correctly) fail when I change to: code:
|
# ? Jan 25, 2010 20:56 |
|
Lamont Cranston posted:It just passes the URI object, no array. I managed to get it to (correctly) fail when I change to: Well, dude, I don't know what to tell you, but it is definitely passing an array.
|
# ? Jan 26, 2010 16:54 |
|
Operation Atlas posted:Well, dude, I don't know what to tell you, but it is definitely passing an array. Or, I guess, the uri object's #to_s could print like an array. But that's unlikely and you're probably right.
|
# ? Jan 26, 2010 18:32 |
|
http://github.com/tylercunnion/crawler/blob/master/lib/crawler/webcrawler.rb It's not passing an array, have a look for yourselves. At any rate, I think the problem I'm having has to do with what they discuss in this ticket: https://rspec.lighthouseapp.com/projects/5645/tickets/618-exactlyntimes-incorrectly-failing-for-n-actual I stub the update method onto my observer object, because for the Observable module, observer classes must respond to update. Then, I put an expectation on top of that - and when it's finished, it removes the expectation and reverts back to the stub method - which is why it doesn't catch that the method is being called more than what I specify, but it will catch it when I put the expectation to a high number I know it won't reach. Anyway, thanks for your help. I guess I'll just have to continue to work around or else figure out something clever.
|
# ? Jan 27, 2010 04:46 |
|
Lamont Cranston posted:http://github.com/tylercunnion/crawler/blob/master/lib/crawler/webcrawler.rb Ok, so try using at_most(1).times. Also, try calling delete_observers before add_observer. There might be some weird poo poo going on with multiple observers getting attached. Operation Atlas fucked around with this message at 08:50 on Jan 27, 2010 |
# ? Jan 27, 2010 08:27 |
|
I'm about to convert a rails app to support mobile devices--no specific type. Other than busting out mobile_fu, optimizing layouts, js, and css... anyone have any recommendations or gotchas that they experienced doing the same thing?
|
# ? Feb 1, 2010 17:21 |
|
Until you can replicate every option and every feature from the normal interface into the mobile interface, always give the mobile user an option to use the normal website. I can't recall how many times I've encountered not being able to do what I want on a mobile site, and then I wouldn't be able to switch to the normal site to do what I want. Easiest way to lose mobile visitors.
|
# ? Feb 2, 2010 08:55 |
|
I stupidly upgraded my Ruby install on OS X Snow Leopard to 1.9.1 while following a new Rails book tutorial. To my credit, I followed the directions word-for-word, thinking what a good idea it would be to have the latest version of Rails AND the latest stable version of Ruby, too. Now WEBrick crashes like a champ (EDIT: mongrel fails to build, too!) - obviously Rails isn't ready for Ruby 1.9.1. Is there an easy way to downgrade my Ruby back to 1.8.7? EDIT 3: Fixed my code and WEBrick is still crashing. My Ruby is in: /usr/local/bin/ruby Also, if you are gracious enough to help me, please assume that I'm a complete idiot. EDIT 4: Holy poo poo. After an hour of wrestling with installing and uninstalling Ruby, Gems and Rails, my ultimate solution was to TRASH my Ruby binary, my Rails binaries (rake, heroku et al.) AND my entire Gem folder (my 1.8 AND my 1.9 gems) - every single Gem. I reinstalled Ruby 1.8.7, reinstalled RubyGems and all my gems including Rails. It works. Lesson learned. Don't do what I did. plasticbugs fucked around with this message at 09:44 on Feb 3, 2010 |
# ? Feb 3, 2010 06:39 |
|
Rails 3.0 is not out, but the release notes have been written. They outline most of the changes we will see in 3.0, how they work, and why they were changed. http://guides.rails.info/3_0_release_notes.html
|
# ? Feb 3, 2010 13:17 |
|
plasticbugs posted:I stupidly upgraded my Ruby install on OS X Snow Leopard to 1.9.1 while following a new Rails book tutorial. To my credit, I followed the directions word-for-word, thinking what a good idea it would be to have the latest version of Rails AND the latest stable version of Ruby, too. Use rvm. I've come to love it like a gay go-to bottom that's always willing. It works even without a system Ruby.
|
# ? Feb 3, 2010 15:42 |
|
NotShadowStar posted:Use rvm. I've come to love it like a gay go-to bottom that's always willing. It works even without a system Ruby. This is the best review of a gem ever.
|
# ? Feb 3, 2010 16:02 |
|
NotShadowStar posted:Use rvm. I've come to love it like a gay go-to bottom that's always willing. It works even without a system Ruby. Halfway through my process I found rvm, but I was well past the point of no return. I didn't realize the amount of things that were about to break as I "sudo rm'd" Rails binaries one-by-one from /usr/local. I will begin using rvm to avoid this nonsense with future updates.
|
# ? Feb 3, 2010 19:19 |
|
NotShadowStar posted:Use rvm. I've come to love it like a gay go-to bottom that's always willing. It works even without a system Ruby. RVM really is totally fantastic. I recommend it to EVERYBODY. If you aren't using it you should start using it right now.
|
# ? Feb 3, 2010 20:08 |
|
Seriously rvm is so erection worthy I hope other languages copy it. Especially Perl, loving CPAN is a goddamn nightmare. I even have a legacy Ruby CGI app I have floating around still that I got working with rvm easily. I put #/path/to/user/.rvm/bin/passenger_ruby and it runs the same rvm setup routine that Passenger uses to setup the correct Ruby and Gem versions and that's it. Come here you little mustached leather stud, lets go another round.
|
# ? Feb 3, 2010 20:25 |
|
I'm really curious how you found out about rvm.
|
# ? Feb 3, 2010 20:42 |
|
wolffenstein posted:I'm really curious how you found out about rvm. Well NSS found out about it on the last page I found out about it since I'm an RSS/podcast whore.
|
# ? Feb 3, 2010 20:59 |
|
Does RVM provide anything other than one "bucket" per Ruby version/implementation? I.e. how exactly does it compare to Rip or (Rip's inspiration) Python's virtualenv? It sounds like that it makes it easy to switch the default Ruby interpreter/loadpath/gempath between e.g. 1.8.6/1.8.7/JRuby/etc...but what if you wanted to have a couple different projects all using e.g. 1.8.6 but each with different sets of gems/libs? (Which is the use case for Rip/virtualenv -- each project can have a "clean" set of packages instead of clobbering each other's dependencies or dealing with multiple versions of the same gem.) It still sounds like a rockin' way to achieve the base/obvious use case, though.
|
# ? Feb 3, 2010 21:11 |
|
Pardot posted:Well NSS found out about it on the last page
|
# ? Feb 3, 2010 21:21 |
|
wolffenstein posted:I'm really curious how you found out about rvm. I think I found about it from the rails envy podcast. Now I answer all gem related questions on stackoverflow with RVM propaganda in the hope that it gets more traction.
|
# ? Feb 3, 2010 22:09 |
|
bitprophet posted:Does RVM provide anything other than one "bucket" per Ruby version/implementation? I.e. how exactly does it compare to Rip or (Rip's inspiration) Python's virtualenv? You read the goddamn documentation. Then lube up because you're in for a fun time, and you're the dominant man entirely in control while the freshly shaven studmuffin is rear end up ready to take your orders.
|
# ? Feb 4, 2010 00:09 |
|
jonnii posted:I think I found about it from the rails envy podcast. Now I answer all gem related questions on stackoverflow with RVM propaganda in the hope that it gets more traction. I found out about it from the internet. But seriously I found out about it from http://delicious.com/popular/ruby -- I have it set up in RSS menu.
|
# ? Feb 4, 2010 00:27 |
|
NotShadowStar posted:You read the goddamn documentation. A Ruby project with documentation? (It actually looks quite thorough, for a change. Nice. I guess I'll...read it! And then decide if I want to manhandle it.) EDIT: According to the gemsets page it does indeed have mechanisms for multiple "environments" per interpreter. Cool beans. Will definitely have to look into it, I've been pining for a virtualenv-a-like, and tried out Rip previously which was too unstable. bitprophet fucked around with this message at 02:44 on Feb 4, 2010 |
# ? Feb 4, 2010 01:03 |
|
I'm sorry, this isn't a rails question. It's a ruby question, but I don't have the guts to start a general ruby thread. I can if there's a want/need for it, though. I've got an array of Edge objects. Edge is defined as such, basically: code:
I want to get a Vector with the smallest x and y coordinates across all the Edges' points. To be clear, the x component can come from a different Edge than the y component. I'm doing this like this currently: code:
|
# ? Feb 4, 2010 07:49 |
|
my setup:code:
code:
code:
|
# ? Feb 4, 2010 08:30 |
|
Thank you so much! I feel like an idiot not thinking of that. This is a huge help.
|
# ? Feb 4, 2010 09:05 |
|
Not a huge Rails user, but I have been following Rails 3 with some interest -- Katz seems like a heck of a guy, and they're clearly drawing some inspiration from e.g. Django, which can only lead to good things. So I'm glad to see that not only were those pre-release release notes published, but the Rails 3 beta is out now
|
# ? Feb 5, 2010 16:01 |
|
Anyone have any recommendations for graphing packages? I'm looking for something that can dynamically generate graphs using database data.
|
# ? Feb 6, 2010 00:18 |
|
I went down that route and decided that they all suck rear end. Most of them depend on RMagick which is loving terrible. What I ended up doing is generating json data (easy with standard records doing to_json) and using flot to display it and give the user more control over the graph. Only problem is since IE is loving terrible and doesn't support canvas flot uses a VRML JS wrapper, and IE's JS performance is such poo poo it can take unreasonably long. About 8-10 seconds on a modern system with 384 points of data, whereas Firefox >3.5 and any Webkit is instant.
|
# ? Feb 6, 2010 01:33 |
|
NotShadowStar posted:I went down that route and decided that they all suck rear end. Most of them depend on RMagick which is loving terrible. I've had to do some rails graphing again and I've had the same experience, gently caress Scruffy/Gruff etc. We've started using flot (and failing that I probably would have gone back to google charts again), but again we don't need to support IE for this app since it's internal.
|
# ? Feb 6, 2010 02:56 |
|
Splinter posted:Anyone have any recommendations for graphing packages? I'm looking for something that can dynamically generate graphs using database data. I've been using Highcharts and it works quite well. Sure, it's Javascript, but it beats the hell out of using RMagick.
|
# ? Feb 6, 2010 04:39 |
|
Just chiming in. We use flot as well. I've come to the conclusion that if they're looking at my charts in IE6 then gently caress them. They're getting what they deserved.
|
# ? Feb 8, 2010 04:48 |
|
Ghotli posted:Just chiming in. We use flot as well. I've come to the conclusion that if they're looking at my charts in IE6 then gently caress them. They're getting what they deserved. Amen, http://emotify.com/acy149/
|
# ? Feb 8, 2010 10:43 |
|
Thanks for the recommendations. I'll be giving flot a try. Does anyone have experience using any flot related gems? Are they any good? I saw there was one called flotilla, but it doesn't look like its been added to gemcutter yet.
|
# ? Feb 9, 2010 08:45 |
|
There really is no need for some sort of gem since all the stuff in Rails makes it straightforward. All you require from Rails is your data in JSON, which is easy. The rest is all building a UI around Flot and that's all view work.
|
# ? Feb 9, 2010 17:05 |
|
This isn't Rails-specific, but hey, whatev. I've been fixing up Net::LDAP because it needs a LOT of love. I've managed to get the file structure sane so it loads according to general Ruby principles and works fine in Rails 3, and with the help of some Swiss guy got it to at least function in 1.9. It does what I need to, but it needs quite a bit more love to make it modern and so I feel comfortable releasing it, the original developers seemed to have dropped off the planet. Something that needs to happen is comprehensive communication tests. Right now the test coverage just makes sure that encodes and decodes data properly. What I want to do is add tests for different LDAP servers, but that's impossible as-is without actually having different types of LDAP servers (AD, OpenDirectory etcetra) which is impossible to replicate. As an idea, would it be a bad idea making a mock object that mocks the relevant IO and SSL objects as needed, capture the data from a real LDAP server, then use the mock object to contain that data? Such as code:
|
# ? Feb 15, 2010 20:30 |
|
I think that as an addition to the encoding checks, that makes a lot of sense. Just include a readme explaining what you did and that a failure in one of those tests shouldn't imply that it absolutely for sure won't work.
|
# ? Feb 16, 2010 03:01 |
|
Anyone else going to the LA Ruby conference this weekend? http://www.larubyconf.com/
|
# ? Feb 18, 2010 06:34 |
|
|
# ? Apr 19, 2024 03:03 |
|
I asked recently about getting RoR setup on windows for some development. Well since Instant Rails is boat loads behind, and one can assume version 3 wont be ported to it anytime soon, Im thinking of setting up a VM with Linux to do my work. So any suggestions on what to use? A friend told me to try Ubuntu, this a good idea? Also any good guides for setting up RoR after that's all setup?
|
# ? Feb 25, 2010 22:10 |