Forum: RSpec Passing parameters to Rspec scripts

Posted by Levi Conley (Guest)
on 2010-02-03 04:57
(Received via mailing list)
Newbie here.  I'm hoping someone can give me an outline of how to
re-use rspec scripts by passing them parameters.

The situation I have is testing a web application (using watir) for
about 30 different customers.  Some of the customers have unique
features in their particular application instance, but much of the
codebase is shared (about 90%).  So what I need to be able to do is
write rspec tests covering that shared codebase.  But I need to in
some way pass in the customer name so that watir can log into the
right application instance.

Any help with this is greatly appreciated.  I still have much to learn
about Rspec, but so far this seemingly simple task has me stumped.

Thanks
Posted by Matt Wynne (mattwynne)
on 2010-02-03 09:38
(Received via mailing list)
One way would be to use an environment variable:

     $ CUSTOMER=foo spec spec

Then read out the customer name in your specs:

     login = ENV['CUSTOMER']

Otherwise, I would guess you might be able to look at ARGV from
within, say, spec_helper.rb but I've never tried it.

On 3 Feb 2010, at 03:51, Levi Conley wrote:

>
> Any help with this is greatly appreciated.  I still have much to learn
> about Rspec, but so far this seemingly simple task has me stumped.
>
> Thanks
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

cheers,
Matt

http://mattwynne.net
+447974 430184
Posted by Levi Conley (Guest)
on 2010-02-04 18:43
(Received via mailing list)
Thanks for the response. That's an interesting approach.  I will try
that and see how far I can get with it.

If my ruby chops were a little better, I suspect I could find a more
elegant solution.  Any other ideas out there?


On 2/3/10, Matt Wynne <matt@mattwynne.net> wrote:
>
>> some way pass in the customer name so that watir can log into the
>
>
--
My mother used to say to me, "In this world, Elwood, you must be oh so
smart or oh so pleasant."  Well, for years I was smart.  I recommend
pleasant.  You may quote me.
Posted by J. B. Rainsberger (Guest)
on 2010-02-04 22:13
(Received via mailing list)
On Thu, Feb 4, 2010 at 12:35, Levi Conley <zenshade@gmail.com> wrote:

> Thanks for the response. That's an interesting approach.  I will try
> that and see how far I can get with it.
>
> If my ruby chops were a little better, I suspect I could find a more
> elegant solution.  Any other ideas out there?

It sounds like you want a configuration file of some kind. In Java,
I'd suggest starting with a properties file. Could you externalize the
per-customer differences to any kind of configuration file (yaml would
be the standard, no?)? Then you could build a rake task to supply the
right configuration file for each customer, or even iterate over them.
--
J. B. (Joe) Rainsberger :: http://www.jbrains.ca ::
http://blog.thecodewhisperer.com
Diaspar Software Services :: http://www.diasparsoftware.com
Author, JUnit Recipes
2005 Gordon Pask Award for contribution to Agile practice :: Agile
2010: Learn. Practice. Explore.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.