Re: [rspec-users] [Rails] Controller testing problem

2009-07-01 Thread Fernando Perez
> Is there a way for RSpec to skip the filters in tests? Or to stop > ApplicationController to derive from SiteController? That's a perfect use case for mocks and/or stubs. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-user

Re: [rspec-users] Mocking find_by_sql

2009-06-06 Thread Fernando Perez
> Same deal as your other post about find_by_sql. Set the message > expectation on the method on the class: > > Post.should_receive(:paginate) Unfortunately it doesn't work :-( I'll have to dive into the will_paginate source code to find out how it plugs itself in AR. -- Posted via http://www.r

[rspec-users] Mocking find_by_sql

2009-06-05 Thread Fernando Perez
Hi, I cannot manage to mock a call to find_by_sql. Which class is actually getting called? It is not the model, and I tried ActiveRecord which didn't work either. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforg

Re: [rspec-users] Mocking find_by_sql

2009-06-05 Thread Fernando Perez
Damn I can't mock will_paginate's paginate method either!!! -- 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] response.should be_success -- what does this prove?

2009-06-05 Thread Fernando Perez
> It's useful when you're doing TDD as it's the simplest thing to expect > a controller to do. If you break something it's also quite a nice > first-failure to have. Hmm, I'm not sure about that. If the view fails to render, then Rails returns the error page, i.e: response.should be_success is tot

Re: [rspec-users] How to spec two lines in application_controller.rb

2009-05-26 Thread Fernando Perez
Hunt Jon wrote: > I need to spec the following lines: No you don't. They are thoroughly tested in the Rails framework and you didn't add any behavior to them, so reading them makes it immediately clear what they are doing. Don't worry without specing these 2 lines you'll still get your 100% cov

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Fernando Perez
> Hi Fernando. I'm not sure what you mean by "the code never gets out of > this require statement". I should have said 'the interpreter never ...' > However, that doesn't really matter. The call to #require shouldn't > happen, because the method is supposed to be stubbed out. You are making a lot

Re: [rspec-users] Is stubbing a call to super possible?

2009-05-24 Thread Fernando Perez
> In the meantime I have used alias_method_chain to override the method > in the super class. I up this old post, but I was having the same problem mocking super() so I had to alias_method_chain my method. -- Posted via http://www.ruby-forum.com/. ___ r

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Fernando Perez
> Hi Fernando. In this case, I don't think it's a matter of using the > debugger. I suspect a problem in: require 'lib/adsense_heaven_parser', the code maybe never gets out of this require statement. The debugger would allow you to immediately clear things out. -- Posted via http://www.ruby-fo

Re: [rspec-users] Writing specs pointed out I need to refactor my admin area

2009-05-24 Thread Fernando Perez
So I tried to implement Django's AutoAdmin, but actually it quite quickly blew in my face. Although the views all look similar, there almost as many little differences as they are models and that's painful to abstract. So I prefer to write my views for each model. Now I have another problem, so

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Fernando Perez
> I've been beating my head against this for a couple of hours. Any > thoughts? The easiest for you is to use the debugger and go through each line in the controller. Maybe @keyword_list.save is returning false? Stub it out and see by yourself. -- Posted via http://www.ruby-forum.com/. __

[rspec-users] Writing specs pointed out I need to refactor my admin area

2009-05-23 Thread Fernando Perez
Hi, My app now nearly has 100% coverage and when refactoring the code, potential bugs are immediately pointed out. So that's a big win. Moreover when writing specs for my controllers and views of the admin zone, I quickly realized that I was often copying/pasting code and tests. That annoyed me.

Re: [rspec-users] Using resource_controller (make_resourceful etc) and tes

2009-05-21 Thread Fernando Perez
Andrew Premdas wrote: > Hi all, > > Trying to get some opinions about the use of such plugins and in > particular > about how they test, and how we test with them. Can they work well with > BDD > or do they do to much magic and create difficulties for features and > tests 5 months after the ini

Re: [rspec-users] Unable to post to an update action in a controller spec

2009-05-14 Thread Fernando Perez
> put :update, :item => 1 etc. > I tried that but didn't work. I managed to get it working by simply doing: post :update, {:id => 'dummy', :item => {'1' => ...}} For some reason, I previously tried with :id => 'update' but Rails didn't like it. -- Posted via http://www.ruby-forum.com/. _

[rspec-users] Unable to post to an update action in a controller spec

2009-05-13 Thread Fernando Perez
Hi, I use restful routes. In one of my views I have a form that looks like: <%- form_tag '/items/update', :method => :put do -%> ... <%= submit_tag "Recalculate" %> <%- end -%> I know I cheated a bit, as I should be submitting to /items/1 instead. Anyway, now how can I trigger the update act

[rspec-users] Using Rails observers and testability

2009-05-04 Thread Fernando Perez
Hi, Before I do anything stupid, I'd like to know if there are any gotchas when using Rails observers instead of writing my own methods or callbacks? Are they easy to spec/test or will I run into troubles? Are they easily mockable? -- Posted via http://www.ruby-forum.com/. ___

Re: [rspec-users] RSpecers point of view about how to create rails association

2009-05-02 Thread Fernando Perez
> You *could* write wrapper methods for chains like this and make Demeter > happy, but to do that for every single call... Thank you for your experience. I myself used to wrap these kind of associations but I felt it started to clutter the Model file, so I started to use association callbacks.

[rspec-users] RSpecers point of view about how to create rails association

2009-05-02 Thread Fernando Perez
Hi, Using Ruby on Rails, let's says I have an Article model and Comment model. An Article has_many :comments, Using Rais idiom, one would do something like that in the comments_controller/create: @article = Article.find(params[:id]) @article.comments.create(params[:comment]) I don't like too mu

Re: [rspec-users] Depot app, Demeter's law and troubles cleanly spe cing

2009-04-23 Thread Fernando Perez
Rails definitely entices you to break Demeter's law just so often. Now how to cleanly spec: @comment = @article.comments.build(params[:comment]) ? Mocking and stubbing is starting to get ugly now. -- Posted via http://www.ruby-forum.com/. ___ rspec-u

Re: [rspec-users] Depot app, Demeter's law and troubles cleanly specing

2009-04-19 Thread Fernando Perez
>http://spin.atomicobject.com/2008/01/27/the-exceptional-presenter Interesting idea too. So basically I need to totally rethink and refactor the way my views display the information to the customer: Let's see how I currently display or not an add to cart button depending whether or not the

Re: [rspec-users] Depot app, Demeter's law and troubles cleanly specing

2009-04-19 Thread Fernando Perez
> This is where I start to introduce a presenter layer in between the > view and the models. Very interesting. Thank you very much. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/ma

Re: [rspec-users] Depot app, Demeter's law and troubles cleanly specing

2009-04-19 Thread Fernando Perez
>@order.product_titles do |product_title| > <%= product_title %> >end > Another problem, is that not only do I need the title, but also a clickable permalink which uses a url helper (not available to models), the product price, and maybe other stuff in the future. So I might end u

[rspec-users] Depot app, Demeter's law and troubles cleanly specing

2009-04-18 Thread Fernando Perez
Hi, Let's take the example of the depot app. In my controller I set @order. Then in the view comes the bad stuff: @order.items.each do |item| item.product.title end Now I'm having problems specing item.product.title. A quick and dirty fix is to trade a for for an underscore, so I create Item#p

Re: [rspec-users] Testing discovered a problem in my code

2009-04-16 Thread Fernando Perez
> This is one example of how global variables suck. > > Also your code doesn't make sense to me. I'd you called it twice, each > with different users, you would get the same result which is prob not > what you want. Yup, that's why I corrected it. Now the method is an instance method of User, so

Re: [rspec-users] [RSpec] rcov and/or rexml bug?

2009-04-16 Thread Fernando Perez
> I thought he meant ruby setup.rb installed it. Thanks for reading my message :-) The problem is that it seems spicycode-rcov installs itself as an ersatz of rcov with same names, so I cannot grep or locate spicycode-rcov specific files, and I don't want to mess up my gem system. I tried to l

Re: [rspec-users] [RSpec] rcov and/or rexml bug?

2009-04-16 Thread Fernando Perez
Chad Humphries wrote: > Githubs recent gem builder changes have caused some issues with > this. We are looking into it today in more detail. Pulling it down > and manually building should definitely work in the meantime. How can I uninstall a manually installed spicycode-rcov gem? I'd like to

Re: [rspec-users] Testing discovered a problem in my code

2009-04-16 Thread Fernando Perez
> @expiry_date_cache ||= {} > @expiry_date_cache[user.id] ||= find_if_expiry_date_for(user) >From the beginning my code was silly. The cache has to be tied to an object that only exists for the current request being processed. So I have refactored it. tdd/bdd/rspec/test::unit/whatever helped m

Re: [rspec-users] Testing discovered a problem in my code

2009-04-16 Thread Fernando Perez
> But I thing that I really have a flaw in my code I confirm, my code had a big flaw. -- 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] Testing discovered a problem in my code

2009-04-16 Thread Fernando Perez
Matthew Krom wrote: > Your single test may be relying on database data that is set up (and The tests don't hit the database. Only one previous test hits the same method and forces the class to set this instance variable. But I thing that I really have a flaw in my code, as this class instance v

[rspec-users] Testing discovered a problem in my code

2009-04-16 Thread Fernando Perez
When trying to test using sqlite in-memory in ran into a problem: - rake test raises an error on a test - running the failing test alone works perfectly. So what's the problem? here is the method giving the trouble: def self.expiry_date_for(user) @expiry_date_cache ||= find_if_expiry_date_for(

Re: [rspec-users] Rate my code: refactoring from spec

2009-04-16 Thread Fernando Perez
> What's up will nullDB? I once saw the developper post a few message on > the mailing-list. Anyone using it with success? I saw a post by Pat Maddox and he talked about Sqlite in-memory, so I decided to give it a try using this tutorial: http://www.mathewabonyi.com/articles/2006/11/26/superfast

Re: [rspec-users] Rate my code: refactoring from spec

2009-04-16 Thread Fernando Perez
Joaquin Rivera Padron wrote: > hey there, > maybe you should take a look at solutions that fake your database in > memory > for such cases, saving your time doing all that stubbing and mocking Yeah you are right. I am refactoring (messing up?) code because I have a DB constraint, so instead of re

Re: [rspec-users] Rate my code: refactoring from spec

2009-04-16 Thread Fernando Perez
By the way in Rails I am now finding myself replacing: update_attributes, create! and their friends with something that looks like: new(...) save! Then in the spec I stub the save! method so that it doesn't hit the DB, and then I can easily compare the object attributes if they are as expecte

Re: [rspec-users] Rate my code: refactoring from spec

2009-04-16 Thread Fernando Perez
> So to recap, I would test this behavior via the Paypal examples, > because that's where the behavior originates. I may or may not mock > the call to order.update_from_paypal depending on how complex it is. > > Does that make sense? Argh! I had sent you an answer but for some reason my session

[rspec-users] Rate my code: refactoring from spec

2009-04-15 Thread Fernando Perez
Hi, I used to have the following method: def Paypal.process_ipn(params) ... paypal = create!(params) paypal.order.update_from_ipn(completed?) end That method obviously is not easily specable because of the double dot method call, and when specing it, it would hit the DB for nothing. I used

Re: [rspec-users] RSpec makes me want to write better code

2009-04-15 Thread Fernando Perez
> 6 months since my initial post, what happened in between? Damn! BDD + writing specs that don't hit the database, also taught me to not break Demeter's law :-D It's simply a huge pain to spec a double dot method call, i.e: user.membership.paid? ActiveRecord associations are super, but they c

Re: [rspec-users] How to test/spec an ActiveRecord find that uses :include

2009-04-15 Thread Fernando Perez
> What's wrong with hitting the database? Actually it slows tests down like hell. I was able to ÷10 my testing time by not hitting the DB as much as I used to. But I think that hitting DB for such case is acceptable. -- Posted via http://www.ruby-forum.com/. _

[rspec-users] How to test/spec an ActiveRecord find that uses :include

2009-04-15 Thread Fernando Perez
Hi, I was refactoring my model specs so that they don't hit the database, but how to handle a custom find that uses :joins or :include with some important :conditions? I can't see a way to not hit the database. Should that spec actually belong to an integration spec? -- Posted via http://www.rub

Re: [rspec-users] undefined local variable or method `params' for #

2009-04-14 Thread Fernando Perez
> it "should be active if controller is same" do > params = {:controller => 'royalty_statement'} > tab_class('royalty_statement').should include('active') > end > > but it doesn't work out. it gives me same error as previous. Nah it doesn't work that way, because remember that RSpec is

Re: [rspec-users] undefined local variable or method `params' for #

2009-04-14 Thread Fernando Perez
Try with that: controller.stub!(:params).and_return({:controller => 'your_controller_name'}) -- 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] undefined local variable or method `params' for #

2009-04-14 Thread Fernando Perez
> it gives me following error > > undefined local variable or method `params' for That's normal. Remember that params exists because there is an http request issued. In your spec, you don't tell Rspec anything about any request. So you could create a mock for params. If I recall correctly you

Re: [rspec-users] App can't start on production server due to RSpec missing

2009-04-13 Thread Fernando Perez
>> A quick fix is to install rspec and rspec-rails gems on production >> server, but I don't get why the app wants them installed. > > This is a tricky business. > > We put that in there in response to a user who works on a team. One > team member had pulled code and tried t run specs and got an

Re: [rspec-users] Good introduction to rspec

2009-04-01 Thread Fernando Perez
> http://peepcode.com/products/rspec-basics > http://peepcode.com/products/rspec-mocks-and-models > http://peepcode.com/products/rspec-controllers-and-tools > I didn't like at all the peepcode episodes on RSpec. You'll have to rewrite his valid_attributes trick from scratch if your models use a

Re: [rspec-users] RSpec makes me want to write better code

2009-03-31 Thread Fernando Perez
> Please be careful when making absolute statements like this. First of > all, even "just a bug reporting tool" adds tremendous value for the > customer, because your catching bugs before they make it to > production. Value is what a customer is something he is ready to pay more money for. Well, w

Re: [rspec-users] Good introduction to rspec

2009-03-31 Thread Fernando Perez
Pablo L. de Miranda wrote: > Hi guys, > Someone know some good introduction to rspec, I`m wanting to use Rspec > with > my Rails projects, but I don't found a good introduction. > >From my own experience: Write specs for your models and their class / instance methods. If you find yourself stru

Re: [rspec-users] Expecting nil or false

2009-03-31 Thread Fernando Perez
> What is the full expression? i.e. what is it that should be false (or > nil)? Basically: def is_it_cool? find(blabla, :conditions => 'coolness > 1000') end In order to stay consistent and as the question mark suggests that true or false will be returned, I have updated my method too: def

Re: [rspec-users] RSpec makes me want to write better code

2009-03-31 Thread Fernando Perez
> Or, conversely, autotest is awesome if you take the time to learn how to > use it: > > http://blog.davidchelimsky.net/2008/3/5/limiting-scope-of-autotest Well, I find it easier to simply type: $ rake spec Then depending on what failed I will from time to time run a single spec file: $ spec

Re: [rspec-users] Expecting nil or false

2009-03-31 Thread Fernando Perez
>> Do I have to rewrite my return values to always return true or false? > No, but you may have to use different matchers. What are you using? I use: should be_false Rspec complains it receives nil when it is expecting false. -- Posted via http://www.ruby-forum.com/. ___

[rspec-users] Expecting nil or false

2009-03-31 Thread Fernando Perez
Hi, I just ran into this issue. I have a method that returns: false, true, nil or an object. This method is used by another method to test for true/false. In Ruby that's easy to handle as nil and false evaluate to false, and everything else evaluates to true, but RSpec seems to expect an exact va

Re: [rspec-users] RSpec makes me want to write better code

2009-03-31 Thread Fernando Perez
> By "getting", do you mean new controllers arrive skinny? Or that you > have > refactored the same fat controllers, over time, until they are skinny? > > The latter is preferred, because we should not be writing the same sites > over > and over again. In theory! My good ole' fat pig controller

Re: [rspec-users] RSpec makes me want to write better code

2009-03-31 Thread Fernando Perez
Fernando Perez wrote: > Hi, > > Today is a big day. I officially transitioned from manually testing by > clicking around in my app, to automated testing with RSpec + Autotest. 6 months since my initial post, what happened in between? - My controllers are getting anorexic, and tha

Re: [rspec-users] validate_presence_of

2009-02-19 Thread Fernando Perez
> Wrong. You don't have to test validates_presence_of. What matters, > and therefore what you should test, is whether the model will complain > at you if a particular value is left empty. > ... > If your spec breaks because you changed a method call, you're not > testing behavior any more. You'r

Re: [rspec-users] validate_presence_of

2009-02-18 Thread Fernando Perez
Yi Wen wrote: > Hello, > > according to this post: > http://blog.davidchelimsky.net/2009/1/13/rspec-1-1-12-is-released > > I should be able to write: > > describe User do > it {should valdate_presence_of(:login)} > end What's the point in testing validates_presence_of for a model? It's alrea

Re: [rspec-users] Testing misc methods in ApplicationController

2009-02-14 Thread Fernando Perez
> You spec the public interface that calls (or causes to be called) the > protected methods. Ok I see. Thanks for the clarification. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/m

Re: [rspec-users] Testing misc methods in ApplicationController

2009-02-13 Thread Fernando Perez
How do you spec protected controller methods such as before_filters and helpers that with the params and session hashes? I cannot call controller.my_method if my_method is protected. > Try this: > > controller.andreplace("foo and bar").should eql("+foo +bar") -- Posted via http://www.ruby-foru

Re: [rspec-users] [RSpec] rcov and/or rexml bug?

2009-02-13 Thread Fernando Perez
> You shouldn't have to clone and install rcov manually. > > Just do this: > > gem install spicycode-rcov --source http://gems.github.com > > It will install just like any other gem. > Except it didn't work for me, the rcov binary doesn't get installed or is not defined properly. Is anyone el

Re: [rspec-users] [RSpec] rcov and/or rexml bug?

2009-02-07 Thread Fernando Perez
> Something got screwed when uninstalling the old rcov gem, I now get the > following error message: > Finally got things back to 'almost' normal, I had to edit my $PATH var to make rcov 0.8.1.2 work and bug on: /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `[]': no imp

Re: [rspec-users] [RSpec] rcov and/or rexml bug?

2009-02-07 Thread Fernando Perez
> So I uninstalled rcov, and installed instead: spicycode-rcov, but now it > cannot find the binary file. Using spicycode do I need to make any tweak > to a rake file? I finally got everything working with no bugs by doing: 1) git clone git://github.com/spicycode/rcov.git 2) cd rcov 3) sudo ru

Re: [rspec-users] [RSpec] rcov and/or rexml bug?

2009-02-07 Thread Fernando Perez
David Chelimsky wrote: > On Tue, Feb 3, 2009 at 7:32 AM, James Byrne > wrote: >> >> thinking that maybe RSpec 1.1.12, Rails 2.2.2 and perhaps Rcov 0.8.1 >> have some incompatibilities. > > Try spicycode's rcov: > > [sudo] gem install spicycode-rcov --source http://gems.github.com Something got

Re: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing)

2009-02-07 Thread Fernando Perez
Joaquin Rivera Padron wrote: > hey fernando, > maybe you want to take a look at > http://www.patmaddox.com/blog/2009/1/15/how-i-test-controllers-2009-remix > and give Cucumber a try regarding controllers spec-ing > hth, > joaquin Hi, I already use Cucumber+Webrat for testing that my publicly acce

Re: [rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing)

2009-02-06 Thread Fernando Perez
Pat Maddox wrote: > On Thu, Feb 5, 2009 at 8:17 AM, Ben Mabey wrote: >> Any thoughts? Are Ruby's Object Mothers really Test Data Builders? > > Here's what I think is important: > > * Make fixture setup explicit by inlining it on a per example/group > basis > * Keep fixture setup short by hidin

[rspec-users] [RSpec] rcov and/or rexml bug?

2009-02-02 Thread Fernando Perez
Hi, Running: Ruby 1.8.7 p72, RSpec 1.1.12 and rcov 0.8.1.2.0, I get the following error message with $ rake spec:rcov -- /usr/local/ruby1.8.7//lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `[]': no implicit conversion from nil to integer (TypeError) from /usr/local/ruby1.8.7//lib/ruby/1.

Re: [rspec-users] [RSpec] Cannot save or be_valid when using xss_terminate

2009-02-02 Thread Fernando Perez
> I rspec models that use xss_terminate with no problem. I have not see > the error you're getting. > > linoj Thanks. Knowing that it is possible to spec models that use xss_terminate I was able to figure out that in one of my attributes I was passing a Time object, so simply converting it to

[rspec-users] [RSpec] Cannot save or be_valid when using xss_terminate

2009-02-02 Thread Fernando Perez
Hi, I have a Rails app that uses xss_terminate to sanitize the user input before it gets saved to the DB. In my specs when I call @product.should be_valid or @product.save, I get the following error message: -- NoMethodError in 'Creating a product with all necessary attributes should be valid' und

Re: [rspec-users] [Cucumber, BDD] When not to use Cucumber?

2009-01-23 Thread Fernando Perez
> My own experience is quite limited, [...] Hi James, are you saying that you only use Cucumber and not RSpec at all? -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo

Re: [rspec-users] [Cucumber, Webrat] I should see behaves strangely with html

2009-01-19 Thread Fernando Perez
Pau Cor wrote: > Can you please post the contents of your step definition? I don't have any step definition, I simply use: Then I should see "Hello world, its definition is in webrat_steps.rb However yesterday I looked in the code of a project (mephistoblog was it?), and I noticed that they hav

[rspec-users] [Cucumber, Webrat] I should see behaves strangely with html

2009-01-18 Thread Fernando Perez
Hi, In my tests, I check to see if a given html tag such as ... has the expected value, sometimes it works sometimes it tells me it couldn't find the string, although I see it printed out in the error screen. I think it comes form the fact that double-quotes are escaped and slashes too, and some

Re: [rspec-users] Reorganize documentation for Cucumber at Github

2009-01-18 Thread Fernando Perez
Andrew Premdas wrote: > I'd just like to point out that the Github wiki tool is somewhat > challenged Yeah I also think that the github wiki is showing its limits. It works when the project only requires a few pages of documentation, but not for Cucumber. Github should only be used for what Git

Re: [rspec-users] [Cucumber, Webrat] Unable to run 2 features in a row

2009-01-17 Thread Fernando Perez
Fernando Perez wrote: > Hi, > > I have written 2 features that each have 1 scenario. When I execute each > feature separately with "rake features FEATURE=features/..." they each > pass, but when I do "rake features", the first feature passes, and the > secon

[rspec-users] [Cucumber, Webrat] Unable to run 2 features in a row

2009-01-17 Thread Fernando Perez
Hi, I have written 2 features that each have 1 scenario. When I execute each feature separately with "rake features FEATURE=features/..." they each pass, but when I do "rake features", the first feature passes, and the second one fails. In my Given steps, I populate the DB, and some Given steps a

Re: [rspec-users] [RSpec] Putting shared specs in a separate file

2009-01-17 Thread Fernando Perez
> http://www.benmabey.com/2008/06/08/writing-macros-in-rspec/ > Too bad the font and colors are completely unreadable by human eyes. How do you handle such websites? I remember on Mac there is an app that can invert colors of the display. -- Posted via http://www.ruby-forum.com/. _

Re: [rspec-users] [Cucumber] Struggling with "multiple step definitions"

2009-01-17 Thread Fernando Perez
Bart Zonneveld wrote: > Hey gang, > > Multiple step definitions That's because you have defined more than once a step, so instead of defining the same step for each feature, group step definitions by resource / domain concept / model / whatever-you-call-it for instance. here is a good document

[rspec-users] Reorganize documentation for Cucumber at Github

2009-01-17 Thread Fernando Perez
Hi, I actually just noticed that Cucumber has plenty good documentation on its wiki at github. But the problems are: - The homepage is badly designed as it doesn't really outline an order to read other pages - It is impossible to make the difference between internal links to the wiki and links th

Re: [rspec-users] App can't start on production server due to RSpec missing

2009-01-17 Thread Fernando Perez
> Make it print the message to STDERR instead of raising an error? Plus > add a > blurb like "You can ignore this warning if you didn't intend to run > specs" > > Aslak I like that too, +1 for me. > Obviously if your production code is explicitly calling rspec, you've > got bigger problems. As

Re: [rspec-users] Testing file attachment with Paperclip

2009-01-17 Thread Fernando Perez
> G'day again Fernando. IIRC, Paperclip's #save_attached_files is what > takes care of saving the attachment to disk, uploading it to S3, etc. > Here's a small gist that tests the allowance of JPG files, and ensures > that the file isn't saved [to disk, for me]: > http://gist.github.com/48264 > >

Re: [rspec-users] newbie: errors getting started with cucumber

2009-01-16 Thread Fernando Perez
Aslak Hellesøy wrote: > On Thu, Dec 25, 2008 at 2:04 PM, Manasi Vora > wrote: > >> >> I am using webrat 0.3.2 cucumber 0.1.13 activerecord 2.1.1 >> > > You need a newer webrat - for example gem install aslakhellesoy-webrat > > Aslak Thanks that help me out. It installed 0.3.2.2 which works, w

Re: [rspec-users] App can't start on production server due to RSpec missing

2009-01-16 Thread Fernando Perez
> > I would delete that rake task file (lib/rspec.rake) if you don't have > rspec installed. > > Scott I run rspec on my dev machine, but obviously not on my production machine, what would be the nicest way to handle such scenario? At the top of rspec.rake I could add a check on the environmen

Re: [rspec-users] Testing file attachment with Paperclip

2009-01-16 Thread Fernando Perez
Nicholas Wieland wrote: > Does someone have an example on faking a file upload for just ensuring > it gets called, without actually uploading the file to s3. > I thought that stubbing Model.has_attached_file would be enough, but > it doesn't seem so ... > > This is what I did: > > Video.stub!( :h

[rspec-users] App can't start on production server due to RSpec missing

2009-01-16 Thread Fernando Perez
Hi, I just run in the following problem when starting a Rails app on my production server: You have rspec rake tasks installed in /home/thomas/rails_apps/video_on_demand/lib/tasks/rspec.rake, but rspec can not be found in vendor/gems, vendor/plugins or on the system. Obviously I don't wan

Re: [rspec-users] Documentation about the returns method

2009-01-16 Thread Fernando Perez
David Chelimsky wrote: > On Wed, Jan 14, 2009 at 3:53 PM, Fernando Perez > wrote: >>> >>> Here are my questions: >>> - What does the returns(Episode.all) mean? > Okay I get it now. Thank you very much. --

[rspec-users] Documentation about the returns method

2009-01-14 Thread Fernando Perez
Hi, >From the railscasts website source code, in the episodes_controller_spec I read: it "index action with search should search published episodes" do Episode.expects(:search_published).with('foo').returns(Episode.all) get :index, :search => 'foo' end Here are my questions: - What d

Re: [rspec-users] Documentation about the returns method

2009-01-14 Thread Fernando Perez
Fernando Perez wrote: > Hi, > > From the railscasts website source code, in the episodes_controller_spec > I read: > > it "index action with search should search published episodes" do > Episode.expects(:search_published).with('foo').returns(Episo

Re: [rspec-users] autospec is not picking latest changes

2009-01-14 Thread Fernando Perez
Hi, I am facing a similar problem. Actually what happens, is that when I edit specs and then save, then autospec detects it and runs the specs, but when I edit the application's code only, then autospec doesn't run. Is that a normal behavior because of people fed up of autospec running 10 time

Re: [rspec-users] Specing based on user roles

2008-11-11 Thread Fernando Perez
> > I am using restful_authentication. I tried to look at their specs, but > they are unreadable. So I am trying to throw together my own > authentication mocker/stuber but with no luck. Just to clear things out, can you tell me which snippet is correct: 1) get :index response.should be_redir

Re: [rspec-users] Specing based on user roles

2008-11-11 Thread Fernando Perez
Nick Hoffman wrote: > On 2008-11-11, at 17:24, Fernando Perez wrote: >>> describe OrdersController do >>>for_roles :admin, :sysadmin do |role| >> login_as >> look like? And where do you put this code? I am not sure mine (if >> working) gets initialized c

Re: [rspec-users] Specing based on user roles

2008-11-11 Thread Fernando Perez
> I've really moved away from shared example groups and started writing > more targeted macros. So I might do something like this: > > def for_roles *roles > roles.each do |role| > before(:each) { login_as role } > yield > end > end > > describe OrdersController do > describe "GET i

Re: [rspec-users] How to expect no layout

2008-11-11 Thread Fernando Perez
Nick Hoffman wrote: > Hey guys. I've told one of my controllers to not render a layout for a > certain action: >layout false, :only => :map_info_window > > Now I'm trying to spec that, but this: >it 'should not render a layout' do > controller.expect_render :layout > do_get >

Re: [rspec-users] A smarter autospec?

2008-11-09 Thread Fernando Perez
> Why are you routinely changing the code without updating the specs in > advance? > > Ashley That's not the point of my question. Anyway I have just discovered TextMate has a "save-all" keyboard shortcut that works exactly as I want it. Now autospec runs only once. Sweet :-) -- Posted via htt

[rspec-users] A smarter autospec?

2008-11-09 Thread Fernando Perez
Let's say I change a method in one of my models in a Rails app. I hit save: autospec kicks in and starts specing. But I haven't yet edited my spec(s) to the new method name so the specs will obviously fail, but I already know that. So I edit my specs. Autospec will run a second time (or even more

Re: [rspec-users] TextMate File Type Detection for RSpec & Rails

2008-11-09 Thread Fernando Perez
Carl Porth wrote: > For those of you struggling with TextMate not properly detecting > rspec files, Allan Odgaard (the author of TextMate) has kindly > provided a tutorial on how to set up TextMate to associate all .rb > files with rails and all _spec.rb files with rspec. > > http://macromates.com

Re: [rspec-users] rspec gem vs "rspec plugin" vs "rspec-rails plugin" ???

2008-11-07 Thread Fernando Perez
> forgot to clarify - for rails development you'll need both rspec and > rspec-rails. What I meant is that you can go plugin-less, you just have to install the two following gems: rspec and rspec-rails, then bootstrap your app by generating a few files. And your set. I personally prefer using g

Re: [rspec-users] rspec gem vs "rspec plugin" vs "rspec-rails plugin" ???

2008-11-07 Thread Fernando Perez
Greg Hauptmann wrote: > Hi, > > I've got the rspec gem installed, as well as the two plugins "rspec" & > "rspec-rails". I can't remember which is actual used and which isn't > for my rails app when I go "rake spec"? Anyone know? > > Could I remove either of the core rpec gem OR the "rspec plugi

Re: [rspec-users] Specing based on user roles

2008-11-06 Thread Fernando Perez
> And why wouldn't you want to test that? > I want to test for it, it's just that I don't want to copy/paste spec like an idiot. > def for_roles *roles > roles.each do |role| > before(:each) { login_as role } > yield > end > end > > describe OrdersController do > describe "GET in

Re: [rspec-users] Testing variables in controllers?

2008-11-06 Thread Fernando Perez
Ramon Tayag wrote: > How do you test that your controller fetched the right records? > > I have an action that returns a different set of records based on > whether or not the current_user is the "owner" of the profile being > viewed. > > Code is here http://pastie.org/308685. > > "controller.su

[rspec-users] Specing based on user roles

2008-11-06 Thread Fernando Perez
On my website each user can have the following roles: 1) Not logged in 2) Logged in - active - administrator - sysadministrator How would you write DRY specs to test each action of a controller? Currently I am doing somethings that looks like: -- describe 'a non admin is signed in', :share

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Fernando Perez
> This expectation: >@cart.should_receive(:amount=).with(50) > is what you really want, because it's ensuring that Order#amount= is > being called with the correct value. > > So, just remove the "should eql(50)" expectation, and you're all set! > -Nick You are perfectly right Nick, I had just

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Fernando Perez
> Please make sure, when you ask a question, that you quote enough of > the thread so that the readers can understand what you're asking. Hmmm, I don't have this problem as I am using ruby-forum.com to browse threads, it is x100 times more readable with basic color highlighting. I'll do my best t

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Fernando Perez
> @cart.should_receive(:amount=).with(50) > > amount and amount= are two different methods :) Thanks Dave! So now if I test for: @cart.amount.should eql(50) Why do I get this error: expected 50, got 0 (using .eql?) I have to add that the @cart is not saved in DB after its amount attribute is

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Fernando Perez
To make RSpec happy, I tried to test for the following: -- @cart.amount.should eql(50) -- And now I get: -- FAILED expected 50, got 0 (using .eql?) -- So is @cart.amount being set to 50 or not in the spec? When I test manually it works fine. -- Posted via http://www.ruby-forum.com/. __

[rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Fernando Perez
In have the following code: def index @items = Item.find_for_payment(session[:order_id], @site.id) @cart.amount = @items.sum { |item| item.price.to_i * item.quantity.to_i } end @cart is set by a before_filter called find_cart which I stub. find_for_payment is stubbed too. In my spec I simply

  1   2   >