Hi everybody,

David and Pat, thanks for the tip on using "described_type" to access the
model class. I actually figured that one out like 10 minutes after sending
the email. 2 learnings there, first, sometimes explaining the problem helps
solve the problem, and second, maybe I should sit on those emails for 10
minutes before sending them ;-)

Scott, to answer your question, basically I'd love to find something less
verbose. I'm really liking rspec, but am finding my specs are getting longer
and longer, and I'm basically in the process of investigating what options
are out there in terms of shortening the commonly done stuff in specs
(specifically in the context of Rails). Technoweenie has done some stuff on
this, as has awfreeman on github. I'm in the process of diving deeper into
those concepts to maybe pull together a plugin or something, will let this
group know.

Cheers!
Cameron




> Message: 6
> Date: Wed, 29 Oct 2008 01:40:08 -0400
> From: Scott Taylor <[EMAIL PROTECTED]>
> Subject: Re: [rspec-users] Accessing the model class from within an
>        rspec-rails spec
> To: rspec-users <rspec-users@rubyforge.org>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> On Oct 28, 2008, at 9:09 AM, Cameron Booth wrote:
>
> > Hi everybody,
> >
> > New to the list, so apologies if this has been answered elsewhere,
> > but I didn't find it. I'm trying to build up a plugin of useful
> > rspec macros for rails development, eg. things like:
> >
> > it_should_return_success
> > it_should_redirect_to { some_url }
> >
> > I'm basing my ideas off of some stuff technoweenie has done, as well
> > as a few others.
> >
> > One thing I'd love to do is be able to figure out the model class in
> > a rails model spec, so I can do something like:
> >
> > describe User do
> >   it_should_validate_presence_of :name
> > end
> >
> > I can get it working if I pass in User as an argument:
> >
> > describe User do
> >   it_should_validate_presence_of User, :name
> > end
> >
> > but that feels redundant. Is there a way to access the class itself
> > that I'm missing? On the controller spec side, I see there is
> > controller_class_name, but that needs to be set with the
> > controller_name method. I could go for something like that if
> > required, but somehow it seems like it would be overkill.
> >
> > Any advice would be greatly appreciated, thanks!!
>
> Why not something like this:
>
> before(:each) { @user = User.new }
>
> it { @user.validate_presence_of(:name) }
>
> Scott
>
>
>
> ------------------------------
>
> Message: 7
> Date: Wed, 29 Oct 2008 01:15:43 -0400
> From: "Stephen Eley" <[EMAIL PROTECTED]>
> Subject: Re: [rspec-users] Should acceptance tests be run against a
>        production environment?
> To: rspec-users <rspec-users@rubyforge.org>
> Message-ID:
>        <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Tue, Oct 28, 2008 at 1:08 PM, Pat Maddox <[EMAIL PROTECTED]> wrote:
> > When you do end-to-end acceptance testing with Selenium, I think it
> > should be run against a production environment.  Not THE production
> > environment, mind you, but simply a new Rails app running with
> > RAILS_ENV=production.
>
> I believe that's what the angels call a "staging environment."
>
> And yes.
>
> --
> Have Fun,
>   Steve Eley ([EMAIL PROTECTED])
>   ESCAPE POD - The Science Fiction Podcast Magazine
>   http://www.escapepod.org
>
>
> ------------------------------
>
> Message: 8
> Date: Tue, 28 Oct 2008 22:11:39 -0700
> From: Pat Maddox <[EMAIL PROTECTED]>
> Subject: Re: [rspec-users] Accessing the model class from within an
>        rspec-rails spec
> To: rspec-users <rspec-users@rubyforge.org>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=us-ascii
>
> "Cameron Booth" <[EMAIL PROTECTED]> writes:
>
> > Is there a way to access the class itself that I'm missing?
>
> described_type
>
> Pat
>
>
> ------------------------------
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
> End of rspec-users Digest, Vol 28, Issue 76
> *******************************************
>
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to