Re: [rspec-users] Newbie testing questions
On Fri, Sep 7, 2012 at 2:14 PM, Anand K V R. li...@ruby-forum.com wrote: Hi Friends. I'm an absolute Tester (little experience on development upto college level) and had been asked to Test an application developed in Rails. As our client selected Rspec, I have no other go. Can anyone help me with a basic program in Rspec how to open GMAIL, enter username / password , then login. Thanks in advance , Aishwarya Take a look at https://github.com/jnicklas/capybara. Everything you need is referenced in the README on that page. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Newbie testing questions
Hi Friends. I'm an absolute Tester (little experience on development upto college level) and had been asked to Test an application developed in Rails. As our client selected Rspec, I have no other go. Can anyone help me with a basic program in Rspec how to open GMAIL, enter username / password , then login. Thanks in advance , Aishwarya -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Newbie testing questions
I recently wrote my first gem and am now in the process of learning how to write tests for it before I release. My gem is pretty basic and really just has a few class files with some methods for using GET to an API that returns some JSON data. I'm trying to come up with what I should be testing for, but to be honest this is where testing has always stumped me. If I have a class file that looks like the following: module MyModule class MyClass MyParentClass def search(keyword) MyModule.get(/someurl/#{keyword}) end end end The method in this class uses the HTTParty gem and just does a get on this URL which returns JSON. Is it a valid use case to test for the keyword argument? I am not sure if there is any benefit to testing this since it's so very basic. It's a good experiment for me since I am so new to testing but I really want to understand what specifically I should be testing. Any guidance would be greatly appreicated. Thanks, Ben -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Newbie testing questions
Hi Ben, On 1 Jun 2012, at 16:46, Ben Densmore wrote: I recently wrote my first gem and am now in the process of learning how to write tests for it before I release. My gem is pretty basic and really just has a few class files with some methods for using GET to an API that returns some JSON data. I'm trying to come up with what I should be testing for, but to be honest this is where testing has always stumped me. If I have a class file that looks like the following: module MyModule class MyClass MyParentClass def search(keyword) MyModule.get(/someurl/#{keyword}) end end end The method in this class uses the HTTParty gem and just does a get on this URL which returns JSON. Is it a valid use case to test for the keyword argument? I am not sure if there is any benefit to testing this since it's so very basic. It's a good experiment for me since I am so new to testing but I really want to understand what specifically I should be testing. Any guidance would be greatly appreicated. Thanks, Ben You want to aim to test logic, or behaviour. Think about each test as a warning light that you're fitting to your system; if someone comes along later and inadvertently changes the behaviour, the warning light will go off and alert them to their mistake. In this example, the only behaviour you have is mapping the keyword into a URL, so your warning light could check something like describe MyClass context searching do it calls the web service with the correct URL do MyModule.should_receive(:get).with(/someurl/example-keyword) MyClass.new.search('example-keyword') end end end Because there's so little actual behaviour in the example you've given above, this test looks a bit pointless. If you have some more examples of code where there's more risk that something could get broken in the future, let us see that and we can probably give you more useful advice. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users cheers, Matt -- Freelance programmer coach Author, http://pragprog.com/book/hwcuc/the-cucumber-book Founder, http://www.relishapp.com/ Twitter, https://twitter.com/mattwynne ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users