Re: [rspec-users] ApplicationHelper
That shouldn't be needed. In my spec's it works fine. does: describe ApplicationHelper do it doesn't find what it's looking for do helper.distribute(1,2,3,[4,5,6]).should eql([1,2,3]) end end work? I know that there was some talk of introducing an explicit helper object on the list. JD On Mar 20, 2008, at 11:30 AM, Corey Haines wrote: You could just write specs for ApplicationHelper::distribute -Corey On Wed, Mar 19, 2008 at 3:55 PM, nzook [EMAIL PROTECTED] wrote: When working with views, I use instance methods of ApplicationHelper: # app/helpers/application_helper.rb: module ApplicationHelper def distribute(total, min, cutof, list) [1,2,3] end end # app/views/planner/_mta_colors.rhtml: td % ... dist = distribute(total_v_px, 4, 0, colors.collect{|color| color[1]}) ... % So to test the distribute method in ApplicationHelper, I have to extend my spec models: describe ApplicationHelper do extend(ApplicationHelper) it doesn't find what it's looking for do distribute(1,2,3,[4,5,6]).should eql([1,2,3]) end end This could use some documentation. -- View this message in context: http://www.nabble.com/ApplicationHelper-tp16149622p16149622.html Sent from the rspec-users mailing list archive at Nabble.com. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines ___ 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] Why not MockEverthing or why use fixtures for all tests?
(a half-arsed test is worse than no test at all, right?). The case that crystalised that opinion for me was a spec for a destroy action. In spec::rails scaffold (and in many examples I see online) this action is tested by asserting that the instance receives a destroy message. I personally think thats inadequate. It makes assumptions about implementation and doesnt guard against unwanted side effects. I should be able to delete a record any way I please (delete, destroy, connection().execute(...)) and the test should pass. However, each of those have different behaviour, and that is what I am spec'ing when I do model.should_receive(:destroy) James Deville This is BDD after all. We should be testing the behaviour of the action, not the implementation, and the desired behaviour is that the corresponding record *and only that record* are deleted ... no one cares how its achieved. The only correct way to test this IMHO is to assert that TheModel.find(:all) before the action is equal to TheModel.find(:all) after the action less the record in question. For this I see fixtures as the way to go. Just my opinion. Commence flaming. ___ 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] Problem with mocking a simple has_many relationship
On Mar 18, 2008, at 4:26 PM, Nikos Dimitrakopoulos wrote: Hi there all. Sorry if the question sounds silly but i'm rather new at the 'mocking' stuff... So here is my problem (code helps more than talking): the model: class Item ActiveRecord::Base ... has_many :images, :dependent = :destroy ... protected def validate errors.add(:images, cannot be empty) if self.images.count end end the spec: describe Item do before(:each) do @item = Item.new end ... it should have at least one image do @item.should have(1).error_on(:images) @item.images.should_receive(:count).at_least(:once).and_return(1) @item.should have(0).errors_on(:images) end end I would try: it should have an error with no images do @item.should have(1).error_on(:images) end it should be okay with one image do @item.stub!(:images).and_return(mock(images,:count = 1)) @item.should have(0).errors_on(:images) end JD Obviously i'm doing something wrong cause this doesn't work: 1) 'Item should have at least one image' FAILED expected 0 errors on :images, got 1 ./spec/models/item_spec.rb:60: script/spec:4: Finished in 0.341594 seconds 10 examples, 1 failure, 5 pending (ignore the rest) Any help would be more than welcome :) -- Posted via http://www.ruby-forum.com/. ___ 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] Problem with mocking a simple has_many relationship
Doh! I can't believe that I missed that. You can also use if self.images.size.zero? Just a little more readable. James Deville On Mar 18, 2008, at 4:38 PM, Rafael Mueller wrote: Hi Nikos, On Tue, Mar 18, 2008 at 8:26 PM, Nikos Dimitrakopoulos [EMAIL PROTECTED] wrote: the model: class Item ActiveRecord::Base has_many :images, :dependent = :destroy protected def validate errors.add(:images, cannot be empty) if self.images.count end end self.images.count is always true, the Fixnum 0 (returned when theres no images) is true try on irb: foo = bar if [].size I guess the correct way is errors.add(:images, cannot be empty) if self.images.size 1 Regards, -- Rafael Mueller http://queroseragil.wordpress.com ___ 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] Stories (well, integration tests) which aren't plain text
Google for some of the stuff about story runner. It was originally not plain text, that's just a convenience. There are some earlier tutorials on David's blog about just doing stories. JD On Mar 13, 2008, at 9:11 AM, Rob Holland wrote: Hi, Having just played with getting my first plain text story working, I like how it all fits together. It worked out nicely. However, I don't feel our project needs to have stories as plain text, in fact it's a slight hindrance for us. Is there any sensible mechanism for doing integration testing using rspec without plain text stories? Thanks, Rob ___ 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] running a specific describe block
Does Support attached image or support attached image work? JD On Mar 12, 2008, at 10:41 AM, David Chelimsky wrote: On Wed, Mar 12, 2008 at 5:22 PM, Jay Donnell [EMAIL PROTECTED] wrote: This doesn't work for me on 1.1.3 I have something like this: describe Support do describe attached image do it should validate presence of attachment do # test stuff ... end it should validate that attachment is an image do # test stuff ... end it should cleanly save attachment do # test stuff ... end end end Here's what I'm doing and the results # It doesn't test when I use the text from the describe block jays-imac:ov2 jay$ ruby spec/models/support_spec.rb -e attached image Finished in 0.015778 seconds 0 examples, 0 failures # it works fine with the test from an example jays-imac:ov2 jay$ ruby spec/models/support_spec.rb -e should validate presence of attachment . Finished in 0.379727 seconds 1 example, 0 failures Seems like a nested-example-group bug. Would you kindly submit this as a report to http://rspec.lighthouseapp.com? Cheers, David - Original Message From: James Deville [EMAIL PROTECTED] To: rspec-users rspec-users@rubyforge.org Sent: Tuesday, March 11, 2008 9:26:13 PM Subject: Re: [rspec-users] running a specific describe block the -e option should run a describe block if the string passed matches a describe block On Feb 29, 2008, at 10:57 AM, Jay Donnell wrote: I use a lot of nested describe blocks and am wondering if there is a way to run a specific describe block similar to the -e option for running specific examples. Jay Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users James Deville http://devillecompanies.org [EMAIL PROTECTED] rspec r3172 rspec_on_rails r3172 rails r8331 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs ___ 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 mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] rspec groups?
Using the -e option from the command line, you can also specify a string which is to be run, this is a way to run only one describe block, or one it block. The rake task method suggested by Edvard is the other option On Mar 10, 2008, at 5:42 AM, Edvard Majakari wrote: The idea is that you can specify that certain tests exist in groups, and can be run as a set. You can define groups and groups of groups, and so you can run a set of functional tests or all the tests dealing with a specific feature without running through the entire thing. It's kinda like an rspec pattern, but more flexible. Might not be of help, but my problem was a tad similar when I used test/spec (rspecish test/unit wrapper). I had five types of test tasks in my Rakefile: test:units, test:functionals, test:integration, test:libs and test:helpers. The integration and lib tests took the most of the time, so I created custom tasks test:all_but_integration (quite self-explanatory, no?) and test:webserver, which ran everything else except test:libs. The way I did it was that test:all_but_integration just depended on the tasks test:units, tests:functionals etc. So, if you want grouping inside features in a single test suite, this won't help, but for me, being able to control which (whole) files were run with Rake was sufficient for me. The whole suite took something like 15 minutes, but we had thousands of tests and when we started, we didn't use that much mock objects. That said, I have never needed nor wished the ability to combine test suites using test/spec or rspec. Being able to choose which contexts/describes or individual specs will be run has been more than sufficient to me, but of course, YNMDFTOM. -- One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair. -- Terry Pratchett, Mr. Bunnsy Has An Adventure ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users James Deville http://devillecompanies.org [EMAIL PROTECTED] rspec r3172 rspec_on_rails r3172 rails r8331 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] running a specific describe block
the -e option should run a describe block if the string passed matches a describe block On Feb 29, 2008, at 10:57 AM, Jay Donnell wrote: I use a lot of nested describe blocks and am wondering if there is a way to run a specific describe block similar to the -e option for running specific examples. Jay Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users James Deville http://devillecompanies.org [EMAIL PROTECTED] rspec r3172 rspec_on_rails r3172 rails r8331 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] render_to_string in a controller test?
On Feb 19, 2008, at 3:42 AM, David Chelimsky wrote: On Feb 18, 2008 8:10 PM, EAW [EMAIL PROTECTED] wrote: Hi all, I know that in general, view and controller tests should be isolated, such that controller specs don't test views etc. However, I think I've run into a situation that might be an exception. My controller uses render_to_string to produce a chunk of HTML that it passes to a model to be processed. The controller then redirects the user to a different page. The results of the render_to_string are not seen by the user. Since the controller is calling render_to_string, I've been trying to test that it is rendered correctly in my controller spec. Because a controller spec normally doesn't render views, render_to_string just returns the path of the view, rather than the rendered output. This prevents me from testing the output of render_to_string in the controller spec. I can work around the issue by using integrate_views, and I guess that's fine, but shouldn't render_to_string really work in controllers? The whole point of isolation is to isolate the code in the controller from the code in the view. The two primary reasons for this are that it allows you to write controller code before the view exists and it keeps failures in views isolated to the view specs (why should a controller spec fail because of a typo in a view?). The fact that the result of rendering is being passed to a model instead of a (theoretical) browser should not make a difference, should it? I am of two minds on this. On one, I can see testing that the controller assigns a template to a variable, and then test that the view is as expected in a view spec. On the other hand, if I am doing a render to string, then from a testing perspective, I'm assigning a variable. Whether that variable goes to the browser or a model shouldn't matter, we should enable testing of it as a variable. I can see your argument for wanting to be able to treat this example differently, and you can, as you pointed out, accomplish that with integrate_views. Perhaps there should be a way to allow render_to_string to render a without making all views render. WDYT? James Deville http://devillecompanies.org [EMAIL PROTECTED] rspec r3172 rspec_on_rails r3172 rails r8331 FWIW, David Thanks for your input, e. -- [EMAIL PROTECTED] If the answer isn't violence, neither is your silence! -- Pop Will Eat Itself, Ich Bin Ein Auslander ___ 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 mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] RSpec and the Basecamp API
basecamp = mock(basecamp api,;projects = whatever you expect to get from the projects call) Basecamp.stub!(:new).and_return(basecamp) So for the projects one, you could return an array, or a bunch of mocks, or a string. Just make it match how the Basecamp API is behaving. On Jan 31, 2008, at 6:31 AM, desaperados wrote: I realise that this is kind of a basic question but I'm new to rspec and still trying to work out how to do things. I'm working on a rails project that requires basecamp integration via the api, which is fairly trivial to use via the basecamp.rb wrapper: Connection: basecamp = Basecamp.new(APP_CONFIG['api_host'], APP_CONFIG['api_username'], APP_CONFIG['api_pwd']) And to retrieve a list of Projects: puts Projects: #{basecamp.projects} I know how to make this work in the model, I'm just having trouble working out how to create a usable mock for this in rspec. I can't work out to mock 'basecamp.projects' with an object which can then be used in the tests. Sorry if this is a stupid question but I'm just a bit stuck with it. -- View this message in context: http://www.nabble.com/RSpec-and-the-Basecamp-API-tp15205668p15205668.html Sent from the rspec-users mailing list archive at Nabble.com. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users James Deville http://devillecompanies.org [EMAIL PROTECTED] rspec r3172 rspec_on_rails r3172 rails r8331 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] reby-debug and rspec
The other options is to do require 'ruby-debug' in your development.rb and test.rb environment files, and just do debugger where you want the breakpoint in your test On Jan 30, 2008, at 4:15 PM, Rick DeNatale wrote: On 1/30/08, Jay Donnell [EMAIL PROTECTED] wrote: How do I use the ruby debugger with a specific test (not the whole spec file)? I want to do something like this. $ rdebug spec/models/user_spec.rb -s should error if not new_record Almost there: $rdebug spec/models/user_spec -- s should error if not new_record The -- separates the rdebug options from the options for the program being debugged. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users James Deville http://devillecompanies.org [EMAIL PROTECTED] rspec r3172 rspec_on_rails r3172 rails r8331 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Textmate RSpec Bundle 'it' snippet
Along these lines, I also think that a empty spec should be failing or at least pending. On Jan 27, 2008, at 6:50 AM, Matt Darby wrote: Ah, I was unaware of this. Thanks for the pointer. On Jan 27, 2008, at 2:42 AM, Francois Wurmus wrote: Hi Matt, one way of doing this is to leave the block out and just write: it should bla bla No 'do', no 'end'. The example will be pending this way. François ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users James Deville http://devillecompanies.org [EMAIL PROTECTED] rspec r3172 rspec_on_rails r3172 rails r8331 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story runner macros
It sounds like what you really want is the plain text stories. David has a few good articles, and there have been some good ones on this list. JD On Jan 20, 2008, at 9:09 PM, Rick DeNatale wrote: I've gotten quite a bit out of Pat Maddox's screencast http://evang.eli.st/blog/2007/10/8/story-runner-top-to-bottom-screencast One thing I'm not sure of is the feature where he writes things like: When I POST to, /articles, :post = {:title = Title, :body = Body) do | path, params| post_via_redirect path, params end This bothers me because it seems an abrupt level jump. Most of the stories are written at a level where the goal donor can understand them, For example, I'm pretty sure that the above when clause started life as somethign more like When I add an article I actually changed Pat's example a bit to use article instead of post to keep the domain and implementation nouns different. I'd say that the add an article form is easily understood by a client, but the POST to , ... form is not. When I try the parameterized form, I notice that the story runner only reports the story as When I post to So the output is even less useful for talking to the client. Now I really like the idea of the parameterized stories, but the step away from client-speak makes me shy away from them. Is there a way to get the power without loosing the intelligibility? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ ___ 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] Shoulda
Speaking for myself, since I support the same philosophy, I wouldn't test the association. I don't care that it has_many posts. I might care that I can add multiple posts, or that I can find posts by criteria, so I would test that. JD On Jan 10, 2008, at 4:04 PM, Jonathan Leighton wrote: On Thu, 2008-01-10 at 17:59 -0600, David Chelimsky wrote: Another issue is BDD philosophy. BDD is about behaviour. should have_many(:posts) is not behaviour. It is structure. I understand that there are people who view this differently, and I would not want to get in the way of anyone using that approach, but RSpec should not be sporting conveniences, even very pragmatic ones, that fundamentally go against the grain of BDD. Out of interest, how would/do you test associations David? What if should have_many(:posts) tested the behaviour of the association rather than whether it's defined? -- Jonathan Leighton http://jonathanleighton.com/ ___ 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] Shoulda
On Jan 10, 2008, at 4:11 PM, Nathan Sutton wrote: Well then, hop to! ;) Nathan Sutton [EMAIL PROTECTED] rspec 1.1 rspec_on_rails 1.1 rails 2.0.2 On Jan 10, 2008, at 6:10 PM, David Chelimsky wrote: On Jan 10, 2008 6:07 PM, Nathan Sutton [EMAIL PROTECTED] wrote: Hey now! Really though, have you ever been digging through old mailing lists and wondered which version they were using when they had that issue? Or when someone posts and issue, you need to ask them what versions of everything they're using? It can be a pain and it usually wastes time/energy, so this is a simple solution. :) I wasn't criticizing. It cracks me up in the sort of that's so obvious, I should do it myself' sort of way. Nathan Sutton [EMAIL PROTECTED] rspec 1.1 rspec_on_rails 1.1 rails 2.0.2 On Jan 10, 2008, at 6:04 PM, David Chelimsky wrote: On Jan 10, 2008 6:02 PM, Nathan Sutton [EMAIL PROTECTED] wrote: Nathan Sutton [EMAIL PROTECTED] rspec 1.1 rspec_on_rails 1.1 rails 2.0.2 I love that your sig has your rspec and rails versions. That cracks me up. ___ 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 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 Hop! James Deville http://devillecompanies.org [EMAIL PROTECTED] rspec r3172 rspec_on_rails r3172 rails r8331 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story runner rake task
On Dec 19, 2007, at 10:42 PM, David Chelimsky wrote: On Dec 20, 2007 12:25 AM, James Deville [EMAIL PROTECTED] wrote: On Dec 19, 2007, at 10:16 PM, David Chelimsky wrote: On Dec 19, 2007 11:50 PM, James Deville [EMAIL PROTECTED] wrote: On Dec 19, 2007, at 9:44 PM, David Chelimsky wrote: On Dec 19, 2007 11:40 PM, James Deville [EMAIL PROTECTED] wrote: On Dec 19, 2007, at 9:38 PM, David Chelimsky wrote: On Dec 19, 2007 11:34 PM, James Deville [EMAIL PROTECTED] wrote: Yeah, had a slight email conversation with David C about that in regards to bug #188. I am wondering why we don't standardize it, ya know convention over configuration and all. Because I think it's premature to call anything related to story runner a convention. I actually organize them differently from what many are calling convention, and my way is not necessarily right or better. Let's wait a while on this. We'll get there. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users Good enough for me. I just wanted a reason. May I ask how you set them up? Sure. stories/ stories/helper.rb stories/steps/ (steps go in here - that seems to be the convention) stories/stuff_related_to_one_feature stories/stuff_related_to_another_feature stories/stuff_related_to_yet_another_feature So in this case, the only thing that would be consistent across projects would be helper.rb and the steps directory. Even that should probably be called step_definitions or something. I'm not sure. Anyhow - that's where I'm at. How about you? ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users I've been doing a feature per file. So I have: stories/ stories/helper.rb stories/steps/ stories/stories/ So in stories/stories I have my stories with multiple scenarios per story. I'm definitely seeing your point, and the reason for leaving it as is. Do you use selenium or anything like that via the stories? If not, what kinds of things do you test with stories? I've got a bunch of selenium tests being driven by spec/ui. I haven't converted them to stories yet. Mostly I've been using webrat, Bryan Helmkamp's awesome Hpricot-wrapping goodness. It doesn't cover javascript, but the apps I've been working on have been very vanilla with respect to ajax, so I've been satisfied with have_rjs. Anyhow, webrat does something really cool - it ties your form submissions to the html of the rendered form. So you make steps like this: = When I go to log in do visits /session/new end When I enter $label: $value do |label, value| fills_in label, :with = value end When I submit my credentials do clicks_button end Then I should see $message do |message| response.should have_text(/#{message}/) end = And a scenario like this: = When I go to log in And I enter Username: david And I enter Password: webrat rules And I submit my credentials Then I should see Welcome david = And what webrat does is grabs the html from the response in the visits method, modifies that html with your data in the fills_in method, and then yanks the data from the html and submits it with the clicks_button method. What this means is that if the form isn't aligned with the fields you're submitting, you'll get a failure. How clean is that? ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users Um... Sweetness!!! How is it for speed? There is a ton of stuff we would love to move out of Selenium due to issues with sessions, flash, and database persistance. Obviously it's much faster than running stuff in a browser. I have nothing else to measure it against and haven't done any real benchmarking, but it is perceivably much faster than running selenium. What I'd recommend - where I'm headed as the opportunity presents itself - is to have in-memory and in-browser implementations of the same steps. Then you can run them in-memory most of the time and skip the javascript, but run them in-browser once in a while - like before commits - to make sure the javascript is all working too. There's also an interesting javascript testing framework that I think shows a lot of promise called crosscheck (http://www.thefrontside.net/crosscheck). It's basically got it's own browser-less javascript engines and runs in-memory. Last I heard it was mostly dead-on, but that it missed some things. The guy who told me that said he was running selenium for a few things that crosscheck didn't do right, but I don't know what those are :) I did toy with it for a minute, and it's blazingly fast. I just haven't made a commitment
[rspec-users] Story runner rake task
What's the status on a rake task for the story runner. If nothing is in progress, where could I start to try and build one? JD ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story runner rake task
Yeah, had a slight email conversation with David C about that in regards to bug #188. I am wondering why we don't standardize it, ya know convention over configuration and all. JD On Dec 19, 2007, at 6:28 PM, Josh Knowles wrote: On 12/19/07, James Deville [EMAIL PROTECTED] wrote: What's the status on a rake task for the story runner. If nothing is in progress, where could I start to try and build one? Until step/scenario directories are standardized you're not going to see a rake task committed. Feel free to roll your own, I wrote a simple one that just calls all.rb. -- Josh Knowles phone: 509-979-1593 email: [EMAIL PROTECTED] web:http://joshknowles.com ___ rspec-users mailing list rspec-use ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story runner rake task
What file is that in? I was looking for one in trunk earlier. JD On Dec 19, 2007, at 5:07 PM, Ben Mabey wrote: Ben Mabey wrote: James Deville wrote: What's the status on a rake task for the story runner. If nothing is in progress, where could I start to try and build one? JD ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users If you check out rspec trunk you can see that they have created one for the rspec project. It just runs the all.rb file in the stories directory. -Ben ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users This is the actual task they are using: desc Run all stories task :stories do html = 'story_server/prototype/rspec_stories.html' ruby stories/all.rb --colour --format plain --format html:#{html} unless IO.read(html) =~ /span class=param/m raise 'highlighted parameters are broken in story HTML' end end ___ 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] Story runner rake task
On Dec 19, 2007, at 9:38 PM, David Chelimsky wrote: On Dec 19, 2007 11:34 PM, James Deville [EMAIL PROTECTED] wrote: Yeah, had a slight email conversation with David C about that in regards to bug #188. I am wondering why we don't standardize it, ya know convention over configuration and all. Because I think it's premature to call anything related to story runner a convention. I actually organize them differently from what many are calling convention, and my way is not necessarily right or better. Let's wait a while on this. We'll get there. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users Good enough for me. I just wanted a reason. May I ask how you set them up? James Deville ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story runner rake task
On Dec 19, 2007, at 9:44 PM, David Chelimsky wrote: On Dec 19, 2007 11:40 PM, James Deville [EMAIL PROTECTED] wrote: On Dec 19, 2007, at 9:38 PM, David Chelimsky wrote: On Dec 19, 2007 11:34 PM, James Deville [EMAIL PROTECTED] wrote: Yeah, had a slight email conversation with David C about that in regards to bug #188. I am wondering why we don't standardize it, ya know convention over configuration and all. Because I think it's premature to call anything related to story runner a convention. I actually organize them differently from what many are calling convention, and my way is not necessarily right or better. Let's wait a while on this. We'll get there. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users Good enough for me. I just wanted a reason. May I ask how you set them up? Sure. stories/ stories/helper.rb stories/steps/ (steps go in here - that seems to be the convention) stories/stuff_related_to_one_feature stories/stuff_related_to_another_feature stories/stuff_related_to_yet_another_feature So in this case, the only thing that would be consistent across projects would be helper.rb and the steps directory. Even that should probably be called step_definitions or something. I'm not sure. Anyhow - that's where I'm at. How about you? ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users I've been doing a feature per file. So I have: stories/ stories/helper.rb stories/steps/ stories/stories/ So in stories/stories I have my stories with multiple scenarios per story. I'm definitely seeing your point, and the reason for leaving it as is. Do you use selenium or anything like that via the stories? If not, what kinds of things do you test with stories? JD ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story runner rake task
On Dec 19, 2007, at 10:16 PM, David Chelimsky wrote: On Dec 19, 2007 11:50 PM, James Deville [EMAIL PROTECTED] wrote: On Dec 19, 2007, at 9:44 PM, David Chelimsky wrote: On Dec 19, 2007 11:40 PM, James Deville [EMAIL PROTECTED] wrote: On Dec 19, 2007, at 9:38 PM, David Chelimsky wrote: On Dec 19, 2007 11:34 PM, James Deville [EMAIL PROTECTED] wrote: Yeah, had a slight email conversation with David C about that in regards to bug #188. I am wondering why we don't standardize it, ya know convention over configuration and all. Because I think it's premature to call anything related to story runner a convention. I actually organize them differently from what many are calling convention, and my way is not necessarily right or better. Let's wait a while on this. We'll get there. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users Good enough for me. I just wanted a reason. May I ask how you set them up? Sure. stories/ stories/helper.rb stories/steps/ (steps go in here - that seems to be the convention) stories/stuff_related_to_one_feature stories/stuff_related_to_another_feature stories/stuff_related_to_yet_another_feature So in this case, the only thing that would be consistent across projects would be helper.rb and the steps directory. Even that should probably be called step_definitions or something. I'm not sure. Anyhow - that's where I'm at. How about you? ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users I've been doing a feature per file. So I have: stories/ stories/helper.rb stories/steps/ stories/stories/ So in stories/stories I have my stories with multiple scenarios per story. I'm definitely seeing your point, and the reason for leaving it as is. Do you use selenium or anything like that via the stories? If not, what kinds of things do you test with stories? I've got a bunch of selenium tests being driven by spec/ui. I haven't converted them to stories yet. Mostly I've been using webrat, Bryan Helmkamp's awesome Hpricot-wrapping goodness. It doesn't cover javascript, but the apps I've been working on have been very vanilla with respect to ajax, so I've been satisfied with have_rjs. Anyhow, webrat does something really cool - it ties your form submissions to the html of the rendered form. So you make steps like this: = When I go to log in do visits /session/new end When I enter $label: $value do |label, value| fills_in label, :with = value end When I submit my credentials do clicks_button end Then I should see $message do |message| response.should have_text(/#{message}/) end = And a scenario like this: = When I go to log in And I enter Username: david And I enter Password: webrat rules And I submit my credentials Then I should see Welcome david = And what webrat does is grabs the html from the response in the visits method, modifies that html with your data in the fills_in method, and then yanks the data from the html and submits it with the clicks_button method. What this means is that if the form isn't aligned with the fields you're submitting, you'll get a failure. How clean is that? ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users Um... Sweetness!!! How is it for speed? There is a ton of stuff we would love to move out of Selenium due to issues with sessions, flash, and database persistance. JD ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Story runner rake task
On Dec 19, 2007, at 10:42 PM, David Chelimsky wrote: On Dec 20, 2007 12:25 AM, James Deville [EMAIL PROTECTED] wrote: On Dec 19, 2007, at 10:16 PM, David Chelimsky wrote: On Dec 19, 2007 11:50 PM, James Deville [EMAIL PROTECTED] wrote: On Dec 19, 2007, at 9:44 PM, David Chelimsky wrote: On Dec 19, 2007 11:40 PM, James Deville [EMAIL PROTECTED] wrote: On Dec 19, 2007, at 9:38 PM, David Chelimsky wrote: On Dec 19, 2007 11:34 PM, James Deville [EMAIL PROTECTED] wrote: Yeah, had a slight email conversation with David C about that in regards to bug #188. I am wondering why we don't standardize it, ya know convention over configuration and all. Because I think it's premature to call anything related to story runner a convention. I actually organize them differently from what many are calling convention, and my way is not necessarily right or better. Let's wait a while on this. We'll get there. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users Good enough for me. I just wanted a reason. May I ask how you set them up? Sure. stories/ stories/helper.rb stories/steps/ (steps go in here - that seems to be the convention) stories/stuff_related_to_one_feature stories/stuff_related_to_another_feature stories/stuff_related_to_yet_another_feature So in this case, the only thing that would be consistent across projects would be helper.rb and the steps directory. Even that should probably be called step_definitions or something. I'm not sure. Anyhow - that's where I'm at. How about you? ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users I've been doing a feature per file. So I have: stories/ stories/helper.rb stories/steps/ stories/stories/ So in stories/stories I have my stories with multiple scenarios per story. I'm definitely seeing your point, and the reason for leaving it as is. Do you use selenium or anything like that via the stories? If not, what kinds of things do you test with stories? I've got a bunch of selenium tests being driven by spec/ui. I haven't converted them to stories yet. Mostly I've been using webrat, Bryan Helmkamp's awesome Hpricot-wrapping goodness. It doesn't cover javascript, but the apps I've been working on have been very vanilla with respect to ajax, so I've been satisfied with have_rjs. Anyhow, webrat does something really cool - it ties your form submissions to the html of the rendered form. So you make steps like this: = When I go to log in do visits /session/new end When I enter $label: $value do |label, value| fills_in label, :with = value end When I submit my credentials do clicks_button end Then I should see $message do |message| response.should have_text(/#{message}/) end = And a scenario like this: = When I go to log in And I enter Username: david And I enter Password: webrat rules And I submit my credentials Then I should see Welcome david = And what webrat does is grabs the html from the response in the visits method, modifies that html with your data in the fills_in method, and then yanks the data from the html and submits it with the clicks_button method. What this means is that if the form isn't aligned with the fields you're submitting, you'll get a failure. How clean is that? ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users Um... Sweetness!!! How is it for speed? There is a ton of stuff we would love to move out of Selenium due to issues with sessions, flash, and database persistance. Obviously it's much faster than running stuff in a browser. I have nothing else to measure it against and haven't done any real benchmarking, but it is perceivably much faster than running selenium. What I'd recommend - where I'm headed as the opportunity presents itself - is to have in-memory and in-browser implementations of the same steps. Then you can run them in-memory most of the time and skip the javascript, but run them in-browser once in a while - like before commits - to make sure the javascript is all working too. Not a bad idea. Our tests are in terrible condition due to the length of time it takes to run selenium. There's also an interesting javascript testing framework that I think shows a lot of promise called crosscheck (http://www.thefrontside.net/crosscheck). It's basically got it's own browser-less javascript engines and runs in-memory. Last I heard it was mostly dead-on, but that it missed some things. The guy who told me that said he was running selenium for a few things that crosscheck didn't do right, but I don't know what
Re: [rspec-users] [rspec-devel] rspec_on_rails (trunk - r3070) works with Rails 2.0.1
I figured most of it out. The Spec::Rails stuff was something in the code which has been fixed by revision 3099. The test methods partially make sense. Since the test/unit code has been integrated, methods with test in them are automatically turned into specs. However, the test? method is in a lib file that isn't directly loaded into the specs. It is a convenience method: def test?; RAILS_ENV==test;end I don't know why this method is being included in my tests, every context has it as an example. Any ideas? Jim D On Dec 8, 2007, at 8:42 PM, James Deville wrote: Begin forwarded message: From: James Deville [EMAIL PROTECTED] Date: December 7, 2007 5:00:30 PM PST To: James Deville [EMAIL PROTECTED] Subject: Re: [rspec-devel] rspec_on_rails (trunk - r3070) works with Rails 2.0.1 Nope, i'm now getting a test? spec before every group, it seems related to the rspec_on_rails plugin. I'll take a look more at home, but I would appreciate any help. Person with account - test? - should obviously show last login ... Person model: A new Person - test? - should have an empty dna_contacts collection ... - test? - test? - test? (FAILED - 5) Spec::Rails::Example::FunctionalExampleGroup - test? (ERROR - 6) - test? Spec::Rails::Example::RailsExampleGroup - test? Pending: JD On Dec 7, 2007, at 4:39 PM, James Deville wrote: I think I just found it. I had rspec 1.0.8 unpacked as a gem in vendor/gems However, now I am getting a test? spec before every group. I'll try going to 3070 to see if it fixes the problem JD On Dec 7, 2007, at 4:18 PM, James Deville wrote: No change. Jim On Dec 7, 2007, at 4:06 PM, David Chelimsky wrote: On Dec 7, 2007 6:01 PM, James Deville [EMAIL PROTECTED] wrote: I'm getting an error with this fix. My versions: rspec:3072 rspec_on_rails:3073 You've got 2 different revisions of rspec, 3072 and 3073. Can you align those and try again? rails:2.0.1. Formatter in this case is Specdoc The odd part is that debugger is telling me that BaseFormatter, BaseTextFormatter and SpecdocFormatter all take one argument. I don't have the gem installed, so I'm not sure where Ruby is getting that from, as the code shows 2, options and where. Any advice on where to look, or what other information I can give you? Jim D Aragorn:mydna james$ rake spec (in /Users/james/projects/mydna) /Users/james/projects/mydna/app/models/asset.rb:23: warning: Object#id will be deprecated; use Object#object_id ./spec/models/mailers/person_notifier_spec.rb:41: warning: already initialized constant FIXTURES_PATH ./spec/models/mailers/person_notifier_spec.rb:42: warning: already initialized constant CHARSET ./spec/models/mailers/feedback_notifier_spec.rb:4: warning: already initialized constant FIXTURES_PATH ./spec/models/mailers/feedback_notifier_spec.rb:5: warning: already initialized constant CHARSET /Users/james/projects/mydna/vendor/plugins/rspec/lib/spec/runner/ options.rb:151:in `initialize': wrong number of arguments (2 for 1) (ArgumentError) from /Users/james/projects/mydna/vendor/plugins/rspec/lib/ spec/runner/ options.rb:151:in `new' from /Users/james/projects/mydna/vendor/plugins/rspec/lib/ spec/runner/ options.rb:151:in `formatters' from /Users/james/projects/mydna/vendor/plugins/rspec/lib/ spec/runner/ options.rb:144:in `map' from /Users/james/projects/mydna/vendor/plugins/rspec/lib/ spec/runner/ options.rb:144:in `formatters' from /Users/james/projects/mydna/vendor/plugins/rspec/lib/ spec/runner/ reporter.rb:71:in `formatters' from /Users/james/projects/mydna/vendor/plugins/rspec/lib/ spec/runner/ reporter.rb:58:in `dump' from /Users/james/projects/mydna/vendor/plugins/rspec/lib/ spec/runner/ example_group_runner.rb:37:in `finish' from /Users/james/projects/mydna/vendor/plugins/rspec/lib/ spec/runner/ example_group_runner.rb:26:in `run' from /Users/james/projects/mydna/vendor/plugins/rspec/lib/ spec/runner/ options.rb:85:in `run_examples' from /Users/james/projects/mydna/vendor/plugins/rspec/lib/ spec/runner/ command_line.rb:19:in `run' from /Users/james/projects/mydna/vendor/plugins/rspec/bin/ spec:3 rake aborted! On Dec 7, 2007, at 11:32 AM, David Chelimsky wrote: After a couple of quick fixes this morning, rspec_on_rails (in trunk as of rev 3070) now works correctly with Rails 2.0.1 Now that Rails 2.0 is out, we'll try to get an RSpec 1.1 release candidate out the door in the next few days. Cheers, David ___ rspec-devel mailing list [EMAIL PROTECTED] http://rubyforge.org/mailman/listinfo/rspec-devel ___ rspec-devel mailing list [EMAIL PROTECTED] http://rubyforge.org/mailman/listinfo/rspec-devel ___ rspec-devel mailing list [EMAIL PROTECTED] http://rubyforge.org/mailman/listinfo/rspec-devel
Re: [rspec-users] Note on Rails 2.0 Preview
On 10/29/07, Jamal Soueidan [EMAIL PROTECTED] wrote: Steve Ross (CWD) wrote: Make sure you get a relatively current version of rspec or you will get: /Users/me/rails/ubb/vendor/rails/activerecord/lib/../../activesupport/ lib/active_support/dependencies.rb:263:in `load_missing_constant': uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper (NameError) Hope this helps someone. This is error I'm getting :) and I downloaded the current version, but I still get the error even with Rails 1.2.5 How do I get the relatively current version? Thanks for help -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users You may need to either run Rspec edge, or go in and comment the offending lines. Jim ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users