I''m new to RSpec. I''ve just installed the gem and begun experimenting with developing several scripts. From what I''ve seen thus far, it looks like it will aid our QA team in testing many web applications. Is there a way to execute multiple rspec test scripts from one central file? -- Regards, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080710/d47b27e7/attachment.html>
On Jul 10, 2008, at 7:19 PM, Robert Stagner wrote:> I''m new to RSpec. I''ve just installed the gem and begun > experimenting with developing several scripts. From what I''ve seen > thus far, it looks like it will aid our QA team in testing many web > applications. Is there a way to execute multiple rspec test scripts > from one central file?I assume you''re using Rails, from there you can see what RSpec tasks are available via "rake -T spec" Matt Darby, M.S. Rails | PHP | Linux | MySQL | IT Email: matt at matt-darby.com Skype: matt-darby Web: http://blog.matt-darby.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080710/0e0aa894/attachment.html>
Robert Stagner wrote:> I''m new to RSpec. I''ve just installed the gem and begun experimenting > with developing several scripts. From what I''ve seen thus far, it > looks like it will aid our QA team in testing many web applications. > Is there a way to execute multiple rspec test scripts from one central > file? > > -- > Regards, > RobertRobert, Welcome to rspec! There are a number of ways you can do this. You can do it with the command line: spec spec/*_spec.rb The way it is generally done is by using a rake task however... Are you using rails? If so.. have you run "./script/generate rspec"? That will install a spec task for you so you just have to type "rake spec" to run all of your specs. If you are in a normal ruby app then you can create your own spec task by putting this in your Rakefile or tasks dir: require ''rubygems'' require ''spec'' require ''spec/rake/spectask'' desc "Run the specs under spec/models" Spec::Rake::SpecTask.new do |t| t.spec_files = FileList[''spec/*_spec.rb''] end If you provide more information on what your setup is we could help more. -Ben http://benmabey.com
Actually, I''m a member of the QA team (limited development experience). So, we are attempting to use RSpec without rails. What is Rake? Near the end of your response, you list a way of running multiple spec files by creating a spec task. Since, I''m not a developer, could you please provide me with a clear example on how to do this? Or, if there is an alternative method on doing this, please let me know. Thanks again. My current setup is: 1 spec file that relies on accessing a module of classes to perform Watir web app testing. I''ve included a sample of the code below describe LoginWelcomeScreen do describe "using IE Explorer" do before(:each) do @login = LoginWelcomeScreen.new(IEWebBrowser.instance) end it "should support a username text field" do @login.test_username_field.should be_an_instance_of(Watir::TextField) end it "should support a password text field" do @login.test_password_field.should be_an_instance_of(Watir::TextField) end . . . . end On Thu, Jul 10, 2008 at 8:17 PM, Ben Mabey <ben at benmabey.com> wrote:> Robert Stagner wrote: > >> I''m new to RSpec. I''ve just installed the gem and begun experimenting >> with developing several scripts. From what I''ve seen thus far, it looks like >> it will aid our QA team in testing many web applications. Is there a way to >> execute multiple rspec test scripts from one central file? >> >> -- >> Regards, >> Robert >> > > Robert, > Welcome to rspec! There are a number of ways you can do this. You can > do it with the command line: > spec spec/*_spec.rb > > The way it is generally done is by using a rake task however... > Are you using rails? If so.. have you run "./script/generate rspec"? > That will install a spec task for you so you just have to type "rake > spec" to run all of your specs. > > If you are in a normal ruby app then you can create your own spec task > by putting this in your Rakefile or tasks dir: > > require ''rubygems'' > require ''spec'' > require ''spec/rake/spectask'' > > desc "Run the specs under spec/models" > Spec::Rake::SpecTask.new do |t| > t.spec_files = FileList[''spec/*_spec.rb''] > end > > If you provide more information on what your setup is we could help more. > > -Ben > http://benmabey.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- Regards, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080711/31681bb3/attachment.html>
Another way to do it instead of the Rake method is what I do... I create a suite.rb in the spec folder with this... # suite.rb - run all my tests in this folder and below if __FILE__ == $0 dir = File.dirname(__FILE__) tests= Dir["#{dir}/**/test_*.rb"] # anything named test_*.rb tests.concat Dir["#{dir}/**/*_spec.rb"] # anything named *_spec.rb # add additional tests that don;t follow conventional naming schemes %w(anotherfile, onemorefile).each do |f| tests << File.join(dir, f) + ".rb" end puts "Testing: #{tests.join('', '')}" tests.each do |file| load file, true end end then you can run all your tests via... > ruby suite.rb You could also use require instead of load, but I use nasty globals in my tests and I believe the load doesn''t carry over globals. YMMV Robert Stagner wrote:> Actually, I''m a member of the QA team (limited development experience). > So, we are attempting to use RSpec without rails. What is Rake? Near > the end of your response, you list a way of running multiple spec files > by creating a spec task. Since, I''m not a developer, could you please > provide me with a clear example on how to do this? Or, if there is an > alternative method on doing this, please let me know. Thanks again. > > My current setup is: > > 1 spec file that relies on accessing a module of classes to perform > Watir web app testing. I''ve included a sample of the code below > > describe LoginWelcomeScreen do > describe "using IE Explorer" do > before(:each) do > @login = LoginWelcomeScreen.new(IEWebBrowser.instance) > end > > it "should support a username text field" do > @login.test_username_field.should be_an_instance_of(Watir::TextField) > end > > it "should support a password text field" do > @login.test_password_field.should > be_an_instance_of(Watir::TextField) > end > . > . > . > . > end > > > On Thu, Jul 10, 2008 at 8:17 PM, Ben Mabey <ben at benmabey.com > <mailto:ben at benmabey.com>> wrote: > > Robert Stagner wrote: > > I''m new to RSpec. I''ve just installed the gem and begun > experimenting with developing several scripts. From what I''ve > seen thus far, it looks like it will aid our QA team in testing > many web applications. Is there a way to execute multiple rspec > test scripts from one central file? > > -- > Regards, > Robert > > > Robert, > Welcome to rspec! There are a number of ways you can do this. You can > do it with the command line: > spec spec/*_spec.rb > > The way it is generally done is by using a rake task however... > Are you using rails? If so.. have you run "./script/generate rspec"? > That will install a spec task for you so you just have to type "rake > spec" to run all of your specs. > > If you are in a normal ruby app then you can create your own spec task > by putting this in your Rakefile or tasks dir: > > require ''rubygems'' > require ''spec'' > require ''spec/rake/spectask'' > > desc "Run the specs under spec/models" > Spec::Rake::SpecTask.new do |t| > t.spec_files = FileList[''spec/*_spec.rb''] > end > > If you provide more information on what your setup is we could help > more. > > -Ben > http://benmabey.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org <mailto:rspec-users at rubyforge.org> > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > -- > Regards, > Robert > > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users-- Jim Morris, http://blog.wolfman.com
Wow!! That is also very, very helpful. I was able to get rake to work as described in an earlier posting, but not without several hours of tinkering and reading the RSpec and Rake documentation. Your solution is certainly much more direct. Thanks. On Sat, Jul 12, 2008 at 5:34 PM, Jim Morris <ml at e4net.com> wrote:> Another way to do it instead of the Rake method is what I do... > > I create a suite.rb in the spec folder with this... > > # suite.rb - run all my tests in this folder and below > if __FILE__ == $0 > dir = File.dirname(__FILE__) > tests= Dir["#{dir}/**/test_*.rb"] # anything named test_*.rb > tests.concat Dir["#{dir}/**/*_spec.rb"] # anything named *_spec.rb > > # add additional tests that don;t follow conventional naming schemes > %w(anotherfile, onemorefile).each do |f| > tests << File.join(dir, f) + ".rb" > end > > puts "Testing: #{tests.join('', '')}" > > tests.each do |file| > load file, true > end > end > > > then you can run all your tests via... > > > ruby suite.rb > > You could also use require instead of load, but I use nasty globals in my > tests and I believe the load doesn''t carry over globals. > > YMMV > > > Robert Stagner wrote: > >> Actually, I''m a member of the QA team (limited development experience). >> So, we are attempting to use RSpec without rails. What is Rake? Near the >> end of your response, you list a way of running multiple spec files by >> creating a spec task. Since, I''m not a developer, could you please provide >> me with a clear example on how to do this? Or, if there is an alternative >> method on doing this, please let me know. Thanks again. >> >> My current setup is: >> >> 1 spec file that relies on accessing a module of classes to perform Watir >> web app testing. I''ve included a sample of the code below >> >> describe LoginWelcomeScreen do >> describe "using IE Explorer" do >> before(:each) do >> @login = LoginWelcomeScreen.new(IEWebBrowser.instance) end >> it "should support a username text field" do >> @login.test_username_field.should be_an_instance_of(Watir::TextField) >> end >> it "should support a password text field" do >> @login.test_password_field.should be_an_instance_of(Watir::TextField) >> end >> . >> . >> . >> . >> end >> >> >> On Thu, Jul 10, 2008 at 8:17 PM, Ben Mabey <ben at benmabey.com <mailto: >> ben at benmabey.com>> wrote: >> >> Robert Stagner wrote: >> >> I''m new to RSpec. I''ve just installed the gem and begun >> experimenting with developing several scripts. From what I''ve >> seen thus far, it looks like it will aid our QA team in testing >> many web applications. Is there a way to execute multiple rspec >> test scripts from one central file? >> >> -- Regards, >> Robert >> >> >> Robert, >> Welcome to rspec! There are a number of ways you can do this. You can >> do it with the command line: >> spec spec/*_spec.rb >> >> The way it is generally done is by using a rake task however... >> Are you using rails? If so.. have you run "./script/generate rspec"? >> That will install a spec task for you so you just have to type "rake >> spec" to run all of your specs. >> >> If you are in a normal ruby app then you can create your own spec task >> by putting this in your Rakefile or tasks dir: >> >> require ''rubygems'' >> require ''spec'' >> require ''spec/rake/spectask'' >> >> desc "Run the specs under spec/models" >> Spec::Rake::SpecTask.new do |t| >> t.spec_files = FileList[''spec/*_spec.rb''] >> end >> >> If you provide more information on what your setup is we could help >> more. >> >> -Ben >> http://benmabey.com >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org <mailto:rspec-users at rubyforge.org> >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> >> -- >> Regards, >> Robert >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > -- > Jim Morris, http://blog.wolfman.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- Regards, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080712/fc0f7fa1/attachment-0001.html>