similar to: What does using a lambda in rspec tests accomplish?

Displaying 20 results from an estimated 2000 matches similar to: "What does using a lambda in rspec tests accomplish?"

2009 Mar 19
6
[Cucumber 0.2] Failure to use should
I have a step definition like this: Then "the account should be created" do account = Account.find_by_name("my shiny new account") p account.class account.should_not be_blank end When running this step, I got the error message: Account(id: integer, name: string, state: string, next_renewal_at: date, created_at: datetime, updated_at: datetime, full_domain: string,
2007 Jul 26
6
response.should_not redirect_to
Hey, May be it is just too deep night over here and I''m missing something though I got this failure on {{{response.should_not redirect_to}}}: ''QueuesController should allow authenticated user to access ''show'''' FAILED Matcher does not support should_not. See Spec::Matchers for more information about matchers. Also I''ve found this in
2008 Nov 04
18
Can I do foo.should (be_nil || be_empty) in rspec
Is there any way to do foo.should (be_nil || be_empty) in rspec. Thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081104/ee43c9c9/attachment.html>
2007 May 19
2
have_text matcher does not support should_not.
Hello Guys, Doing conversion of some test for some controllers, still with integrated views. Anyway, I have this: it "should not see Join This Group button on profile page as member" do get "show", :id => @group.id response.should be_success response.should_not have_text(/Join This Group/) end But running with spec (0.9.4), drop me the folling error:
2009 Apr 16
6
Cucumber - step negating another expecting step
On 16 Apr 2009, at 11:22, Joaquin Rivera Padron wrote: > at the moment I do it this way, hiding the complexity out of the > steps: > > Then /^I should see the people search form$/ do > people_search_form_exists > end > > Then /^I should not see the people search form$/ do > people_search_form_exists "not" > end > > and then the method: > >
2008 Jun 07
3
Match render :nothing
Hello guys, Is there any way to match a render :nothing? I coudn''t find any way to do this so i''ve just changed my controllers to do a "head :ok", but it would be nice to know if there is any other way :) -- Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) Jo?o Pessoa, PB, +55 83 8867-7208
2007 May 30
9
Specify attr_protected
This is kind of a two part question. Question One: I want to be sure that an Order model is protecting sensitive attributes from mass assignment. The example looks like this: describe Order do it "should protect total attribute from mass assignment" do @order = Order.new(:total => 0.05) @order.total.should_not == 0.05 end end And the code to implement it: class Order
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 Feb 02
7
Coming Soon...
Dear spec''ers, As many of you already know, we''re gearing up for a pretty big 0.8 release of RSpec in the next couple of weeks. I''m writing in advance because I want to give you a heads up about upcoming changes and how they may impact your existing specs. Two important things to note first: 1. We will provide a translator that you''ll be able to use to
2011 Apr 16
11
added new cool matcher into my framework WatirSplash - #in
Hello! I''ve just added a new cool matcher #in into my framework WatirSplash and thought that this could be integrated into RSpec directly actually if there''s any interest. WatirSplash uses Watir (or Watir-like) frameworks for testing web pages via browser. If you''re not familiar with it then here is a short example how you had to test ajax-heavy application before:
2008 Jun 20
15
before_save model callback rspec testing
hi all, i''m learning rspec and i can''t figure out how to test if a callback is executed in a model. my model code is: class User < ActiveRecord::Base before_save :encrypt_password ... def encrypt(password) self.class.encrypt(password, salt) end thanks a lot, cs. -- Posted via http://www.ruby-forum.com/.
2007 Sep 04
16
Failure Messages in RSpec
Having used JUnit and Test::Unit, I''m quite used to having the ability to insert a failure message, which helps when tests fail. For instance, the example RSpec that is generated for a model class specifies that the model class is valid. Assuming this were supposed to be true, and it failed, I''ve now got to duplicate the code in the test in order to find out why it
2008 Jul 11
4
how to debug using rspec stories
Hello. I just started to use rspec stories. I followed the following tutorial: http://www.tomtenthij.co.uk/2008/1/25/rspec-plain-text-story-runner-on-a-fresh-rails-app So I implemented my story and some of the steps are: (...) When "user creates a product" do post "products/new", :name => @name end Then "there should be a product named
2010 Sep 08
4
Re-using Rspec Matchers
Hey Everyone, Is it good practice to call matchers from within matchers? Kinda like this pattern: See: http://gist.github.com/570467 -- Brian
2007 Feb 13
16
Error against latest trunk while testing via spec for model
Hi I just did an update to lates trunk ================= context "Given a generated venue_spec.rb with fixtures loaded" do fixtures :venues specify "fixtures should load two Venues" do Venue.should have(2).records end end ================== gives me ========== 1) TypeError in ''Given a generated venue_spec.rb with fixtures loaded fixtures should load two
2007 Oct 16
12
Example for attr_accessible?
Is anyone out there writing specs to check attr_accessible fields? I had originally written my spec to check for allowing the desired fields, and then none of the other regular db fields. Unfortunately this isn''t satisfactory, because attr_protected could have been used instead, which of course wouldn''t prevent mass assignment to any whatever=(val) method. I''m thinking
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 Aug 06
3
hash_excluding/hash_only?
I know there is a hash_including, which is quite useful. Are there by chance any matchers for ensuring a hash includes only the specified values, or that it doesn''t have certain values? Thanks, Steve
2008 May 10
4
Newbie: lambda do...end.should change(Model, :count).by(1). Doesn''t work
Hi to everyone, I''m an RSpec, and BDD in general, newbie so in order to learn I have chosen to use my personal website as a tesbed. I''m having difficulties juggling with mocks, and in particula with the following code. Here''s the controller action: def create @album = Album.new(params[:album]) if @album.save flash[:notice] = "album saved"
2010 Jun 02
5
Programmatically counting RSpec tests?
If I have an object `obj` that is a SpecTask, and subsequently invoke it, is there a way to programmatically determine the number of tests that were successful, failed, and pending as a result of running that SpecTask? -- John Feminella Principal Consultant, Distilled Brilliance