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
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:
> 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
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
cheers,
Matt
http://mattwynne.net
+447974 430184
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 at mattwynne.net> wrote:> 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: > >> 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 >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > cheers, > Matt > > http://mattwynne.net > +447974 430184 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- 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.
On Thu, Feb 4, 2010 at 12:35, Levi Conley <zenshade at 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.