similar to: Down with Lambda!!

Displaying 20 results from an estimated 5000 matches similar to: "Down with Lambda!!"

2007 Sep 20
4
alias :calling :lambda
Sprinkling my examples with ''lambda'' has always seemed like a bit of a wart to me. I''ve gotten into the habit of adding ''alias :calling :lambda'' to my spec suites. My examples then look like: calling { Foo }.should raise_error calling { Bar }.should_not raise_error Is there a reason that RSpec core has chosen not to make exception expectations more
2007 May 20
9
How to test for exceptions
Hi folks, I''m in the process of converting a Test::Unit functional test to RSpec, but I''ve run into a slight problem. I tried looking through the documentation but I still don''t know what I missed. Thanks in advance, Blake describe VenuesController, "on update" do before(:each) do @venue = mock("venue")
2007 Sep 05
6
Caveman Questions
Hello! I''m just a caveman with some caveman questions. I''ve been parsing Rspec for quite a while, and I''m writing my first series of specs. My initial impressions are "Verbose, but understandable. Helpful and intuitive, but so much to digest." I want to congratulate the folks who are dedicating a chunk of their lives to writing this, and ask 2 caveman
2007 Oct 26
5
specing rescue, ensure and else blocks of an Exception
Greetings, I''m using rspec with rcov for my applications and there is one issue which I cannot solve nor can find any proper information regarding it: specing what is in a rescue block in case of an exception. I''m using Ruby on Rails and I usually make use of exceptions in my controllers, like the following example: def action @foo = Foo.find(1)
2008 Jan 30
9
catching errors, rspec basics
Trying to spec the following but don''t know if I''m using the right matcher. How do I spec? Plz, sugar on tops. Audience.stats - should have a stats of 80 when passed a flux of 10 - should return an error when passed a string (ERROR - 1) 1) TypeError in ''Audience.stats should return an error when passed a string'' String can''t be coerced into Fixnum
2006 Mar 19
2
Functional Testing
Hey all, I have a many-to-many relationship (Questions has_and_belongs_to_many Answers), and when I destroy the Question (the one) I also destroy all the Answers (the many). Since the following doesn''t seem to work for has_and_belongs_to_many: class Question < AR::Base... has_and_belongs_to_many :answers, :dependent => :destroy end I have this embedded in a transaction block
2009 May 02
10
Problem verifying routing error
Hi, When upgrading to rspec/rspec-rails 1.2.6 gem (from 1.1.12), I''m having a new problem verifying routes that should not exist. This is to support something like this in routes.rb: map.resources :orders do |orders| orders.resources :items, :except => [:index,:show] end I used to use lambda {}.should_raise( routing error ), but it stopped detecting any raised error.
2008 May 20
5
How to write a test for validates_uniqueness_of
Hi, I have a spec it "should have a unique username " I have a code: validates_uniqueness_of :user_name Now, I don''t know how to test this code. In order to test this, do I need to run `save`? For example, @user = User.create(:username => "mike") @another = User.create(:username => "mike") @another.save.should be_false This messes up test
2008 Mar 17
4
RSpec''ing model association callbacks
Hi all, i''m learning rspec and i must admit i really love it. But at the time i started learning it, i already developed my models classes and their callbacks. Now i''m trying to get a 100% coverage of my code but i cannot reach it because i do not understand how to spec my callbacks. Look at this for example: ----------------- User Model class User < ActiveRecord::Base
2007 Sep 05
3
Rspec Caveman questions.
Hello! I''m just a caveman with some caveman questions. I''ve been parsing Rspec for quite a while, and I''m writing my first series of specs. My initial impressions are "Verbose, but understandable. Helpful and intuitive, but so much to digest." I want to congratulate the folks who are dedicating a chunk of their lives to writing this, and ask 2 caveman
2007 Apr 04
11
ANN: RSpec 0.9.0 beta-1 available for download.
We''d like to get some feedback on RSpec 0.9 before we start pushing out releases via Rubyforge''s gem server and update the website. We have therefore made the first beta of 0.9 available - both prepackaged and tagged in subversion (see below). RSpec 0.9 introduces a new API for expectations, which essentially means that your underscores go away (there has been other discussions
2007 Apr 17
8
Verifying that a block calls a method
I have something like the following: def my_fun my_fun2 do raise Error end end I know that I can verify that the method receives my_fun2. How can I mock/stub out the example to verify that it calls raise Error? Scott
2007 Apr 17
1
updating textmate bundle
Just to let you know - in the textmate bundle the snippet shra => "Should raise error" is missing an open parenthesis. The snippet code should be this: lambda { $1 }.should raise_error(${2:error}) $0 and not this: lambda { $1 }.should raise_error${2:error}) $0 Best, Scott
2007 Nov 21
7
describe scope
Hi, Googling ''RSpec describe scope'' didn''t yield much, so apologies if this question has been dealt with. It seem well known that a ruby class is ''visible'' between describes, and if this is a problem then you should use some counter as prefix or suffix: ''class Item_001; ... end'' Is there any work underway, or sheduled release where
2007 May 24
25
Specs for ApplicationController, where to put them?
The Rails ApplicationController (app/controllers/application.rb) serves as an abstract superclass for all other controllers in a Rails application and is a good place to put methods and filters which you want all of your controllers to use. In my case I''m using it to provide methods such as "current_user" and "logged_in?" etc. By default, RSpec
2011 Mar 04
5
How to intercept an instance method from StdLib (1.9.2)
Hi, I''m struggling with something that seems to be simple, and I''ve not had any joy following the RSpec books suggestions (p. 187). I''d like to test that a method raises and error when a file is not found. I''ve tried adding this in my example just before I call my method, but it never seems to get invoked. Pathname.stub(:exist?).and_return(false) The whole
2009 Aug 10
2
testing exception notification plugin with rspec
Hi, I''m trying to install exception notification plugin and test it with rspec. The problem that I have is that when running the server in production mode : at the end of the log i get this when I have a critical error rendering section "request" rendering section "session" rendering section "environment" rendering section "backtrace" Sent mail to
2007 Nov 01
3
autotest debugger?
Hi, I keep facing problems with autotest, and I don''t know what''s happening in the background, is there anyway to know what''s happening while testing? Example: @user = User.new @user.email = "testcom" @user.errors.on(:email).should_not be_empty ...throws error failure - You have a nil object when you didn''t expect it! - You might have expected an
2010 Nov 06
2
Custom File List for Rails 3 Spec Task
I have some javascript specs (using the jspec javascript framework) in my rails 3 project, living in the spec/javascript directory. How can I exclude the ruby files in the jspec project from being run when I run "rake spec"? RSpec::Core::RakeTask used to take a file list (which was usually generated with a glob pattern and an explicit call to Dir.glob). Now it only takes a glob
2010 Nov 02
7
Testing attr_accessible (and/or attr_protected)
I''ve been puzzling over how to test that attr_accessible has been set for the correct columns; but the tests I''ve come up with so far seem to fail to fail when I expect. I came across this old message from this list: http://www.mail-archive.com/rspec-users at rubyforge.org/msg01570.html Which seemed like a plausible example, but my attempt (modeled on the example)