Re: [rspec-users] Stumped with nil Class error

2011-01-07 Thread Mike Mazur
Hi, On Sat, Jan 8, 2011 at 01:58, Ants Pants wrote: > I thought that the controller.stub(:require_member).and_return(member) would > suffice for the require_member stuff but I'm obviously wrong. I've even > replaced the member for @member in my spec but to no avail. > Here's the describe example

Re: [rspec-users] when using command line -l, why do tests from other describe blocks run?

2011-01-11 Thread Mike Mazur
Hi, On Wed, Jan 12, 2011 at 02:32, Lille wrote: > I frequently use the -l option to run only tests of interest, but it's > messy in a way I don't understand... > > describe SomeModel do > >  describe "#some_method" do > >     it... # let's call this line 20 > >  end > >  describe "#some_other_met

Re: [rspec-users] Results in rspec 2.4.0

2011-01-12 Thread Mike Mazur
Hi, On Wed, Jan 12, 2011 at 15:45, Amit Kulkarni wrote: > When running the script i am getting output as > User Profile should not be created if name is blank >     Failure/Error: @contact_detail.should be_valid >       expected valid? to return true, got false >     # ./spec/models/merchant_spec

Re: [rspec-users] RSpec 2.4, named/restful routes falling apart...

2011-01-13 Thread Mike Mazur
Hi, On Thu, Jan 13, 2011 at 13:39, Jason Nah wrote: > I have the following defined in my routes file > > resources :users > > And a controller: > class UsersController < ApplicationController >    before_filter :load_user > >    def show >       redirect_to(user_path(@user)) >    end >    private

Re: [rspec-users] Preloading of data in rspec2

2011-01-13 Thread Mike Mazur
Hi, On Thu, Jan 13, 2011 at 22:08, Amit Kulkarni wrote: > I had used Fixtures and factory girl for preloading of data in earlier > version rspec. > Is there any new thing for loading of data in rspec 2 or do we have to > use the same. I have a spec/fixtures/ directory containing YAML files with

Re: [rspec-users] Sudden rspec problem

2011-01-16 Thread Mike Mazur
Hi, On Mon, Jan 17, 2011 at 06:47, Rich Price wrote: > I was using rspec 2.4.0 to test some code > and it was working fine then suddenly I get > > rich@richlaptop2:~/Documents/fakemap/rspec$ rspec block.rb > /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': > ../code/fmut

Re: [rspec-users] Rspec Nested Resources: Can someone offer an 'update' example?

2011-01-17 Thread Mike Mazur
Hi, On Fri, Jan 14, 2011 at 05:53, SpringChicken wrote: > I've just spent a day trying to write up a basic update spec for a > nested resource - all without avail. I'm quite new to RSpec & not sure > what I'm doing wrong. I can't seem to get a stub that recognises the > required association to th

Re: [rspec-users] feedback on matcher

2011-01-27 Thread Mike Mazur
Hi, On Thu, Jan 27, 2011 at 21:48, Michael Guterl wrote: > RSpec::Matchers.define :deliver do |message| >  chain :with do |*args| >    @with = args >  end > >  match do |mailer| >    mail = double >    mail.should_receive(:deliver) > >    mailer.should_receive(message).with(*@with).and_return(mai

Re: [rspec-users] specing nested models

2011-01-28 Thread Mike Mazur
Hi, On Mon, Jan 24, 2011 at 19:33, Cezar Halmagean wrote: > So I am trying to spec a nested model / form like say Post has_many Comments > and in order to build a nested form I need to build a new comment in > @posts.comments like so: > @post = Post.new > @post.comments.build > Now, my question i

Re: [rspec-users] routing error for a name-spaced nested controller

2011-02-07 Thread Mike Mazur
Hi, On Sun, Feb 6, 2011 at 05:29, slavix wrote: > Struggling with nested routing and rspec... > When I run spec/controllers/admin/website_users_controller_spec.rb > > describe Admin::WebsiteUsersController do > ... > get :index, :website => @website Does that need to be: get :index, :website

Re: [rspec-users] stubbing out after_create AR method?

2011-02-14 Thread Mike Mazur
Hi, On Tue, Feb 15, 2011 at 02:31, Fearless Fool wrote: > I have a Premise model with an after_create method, along the lines of: > > class Premise < ActiveRecord::Base >  ... >  after_create :etl_attributes >  ... > end > > In production code, etl_attributes accesses the web.  For testing I'm >

Re: [rspec-users] undefined method 'get'

2011-03-13 Thread Mike Mazur
Hi, On Mon, Mar 7, 2011 at 15:30, DBA wrote: > I was just starting a rails 3.0.5 application with rspec-rails 2.5.0 > and ruby 1.9.2-p180 and when I went to describe my controller I ran > into this undefined method 'get' error. > > Here's the spec that is causing the problem (which lives in the f

Re: [rspec-users] undefined method 'get'

2011-03-13 Thread Mike Mazur
Hi, On Mar 13, 2011 10:11 PM, "David Chelimsky" wrote: > The `get` method is available in examples (the block passed to `it` or `specify`), but here it's being called in a group (the block passed to `describe` or context`). Yeah, don't know how I missed that! Mike __

Re: [rspec-users] [rspec-rails] reload of objects in tests

2011-04-08 Thread Mike Mazur
Hi, On Fri, Apr 8, 2011 at 19:25, Clint wrote: > I am kind of confused, why this code is behaving the way it does. > In a test, I wrote something like this: > > it "should do something" do >  @some = Factory(:some) >  initial_object = @some > >  #do something with @some. e.g. update attributes et

Re: [rspec-users] Skipping callbacks that aren't necessary for what i'm testing

2011-04-13 Thread Mike Mazur
Hi, On Wed, Apr 13, 2011 at 16:56, Paul S. wrote: > I have an Address model that has a before_validation callback that goes > off and geocodes the address. > > I'm concerned that for all the tests in my Address model I'm going to be > triggering that callback, even when it's not what I'm testing.

Re: [rspec-users] warning: toplevel constant XYZ referenced Admin:XYZ

2011-04-15 Thread Mike Mazur
Hi, On Sat, Apr 16, 2011 at 00:02, dblock wrote: > I have an odd problem. I got controllers in a namespace and > controllers outside of the namespace. For example, I have a > PagesController and a Admin::PagesController. > > When I run rspec from the top, tests pass and I get the following > warn

Re: [rspec-users] "can't convert Symbol into Integer" error with Rspec and Mongoid

2011-04-19 Thread Mike Mazur
Hi, On Wed, Apr 20, 2011 at 05:32, planon wrote: > I'm running into this error while trying to run a unit test on a > Mongoid database: > >  def show >    id=params[:id] >    @user=User.find(:first,id) >  end > > My test > >  before(:each) do >    @user = Fabricate(:user) >    sign_in @user >  en

Re: [rspec-users] api (class/method) renaming, will a simple controller test verify this?

2011-05-05 Thread Mike Mazur
Hi, On Fri, May 6, 2011 at 02:28, S Ahmed wrote: > I want my tests to fail if I rename a method in my /lib folder in a rails > app. > > Say I have a class like: > > /lib > /lib/formatter.rb > > class Formatter >    def self.do_transforms(text) >   text >    end > end > > > And say I reference

Re: [rspec-users] can't access route variables

2011-07-03 Thread Mike Mazur
Hi, On Sun, Jul 3, 2011 at 09:53, John Hinnegan wrote: > I'm testing methods in my ApplicationController using anonymous controller > class (not sure if that's relevant).  I've somehow broken something such > that I do not have access to the routing variables that rails generates. > > So rather t

Re: [rspec-users] testing a post to a controller's create action

2011-11-18 Thread Mike Mazur
Hi, On Sat, Nov 19, 2011 at 09:42, Patrick J. Collins wrote: > I just spent a lot of time trying to get a test to pass that would not pass no > matter what I did, and I finally decided to just do something really simple to > verify that even that was working-- and it's not. > > class PostsControl

Re: [rspec-users] Can some one please explain why one of those two examples fails?

2012-03-13 Thread Mike Mazur
Hi, On Wed, Mar 14, 2012 at 07:55, Mohamad El-Husseini wrote: > The following are what I believe two ways of doing the same thing. Only the > first example fails, while the latter passes. In your failing example: context "generates a unique password_reset_token each time" do let(:user)

Re: [rspec-users] Can some one please explain why one of those two examples fails?

2012-03-17 Thread Mike Mazur
Hi, On Thu, Mar 15, 2012 at 20:46, Mohamad El-Husseini wrote: > Thanks, Mike. I appreciate the explanation. It's tricky knowing what runs > when, and what variable is in what scope. It seems like "code smell" to add > an instance variable to the before block. > > I don't understand what advantage

Re: [rspec-users] Why stop using mock_model in scaffold controller spec?

2012-03-27 Thread Mike Mazur
Hi, On Tue, Mar 27, 2012 at 22:10, Mike Mazur wrote: > In May last year, the controller specs generated with `rspec g > scaffold` were changed to use real model objects instead of > `mock_model`. > > I'm curious why this change was made? As soon I sent this email off, I noti

[rspec-users] Why stop using mock_model in scaffold controller spec?

2012-03-27 Thread Mike Mazur
Hi, In May last year, the controller specs generated with `rspec g scaffold` were changed to use real model objects instead of `mock_model`[1]. I'm curious why this change was made? Searching the rspec-users mailing list archives didn't turn up anything, and rspec-devel archives I found finish in