Hi All, I want to test my application with rspec. In order to test my views, I have written few specs as given in the examples. Is there any way to test the user acceptance? i.e suppose the field takes a string. I want to test it for integers, float values, alphanumeric values, etc and run tests against that. I need to get the tests failed as it takes only string. I would be really thankful if someone can guide me on this. Please help me with a simple example so that I can understand it quickly and move ahead. Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091027/c8b86811/attachment.html>
Hi But you haven''t given any example On Oct 28, 10:29 am, Rails ROR <developra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi All, > > I want to test my application with rspec. > > In order to test my views, I have written few specs as given in the > examples. > > Is there any way to test the user acceptance? > > i.e suppose the field takes a string. > > I want to test it for integers, float values, alphanumeric values, etc and > run tests against that. > > I need to get the tests failed as it takes only string. > > I would be really thankful if someone can guide me on this. > > Please help me with a simple example so that I can understand it quickly and > move ahead. > > Thanks in advance.
Hi, Example if the view has a form with few fields and a submit button, I want to test whether the data that i enter is according to the database,i.e the model(Having all validations[Null]) and the page gets redirected to success page. For Example: require ''spec_helper'' describe "/admin/books/new.html.erb" do include Admin::BooksHelper before(:each) do assigns[:book] = stub_model(Book, :new_record? => true, :sku_number => "value for sku_number", :title => "value for title", :author1 => "value for author1", :author2 => "value for author2", :author3 => "value for author3", :author4 => "value for author4", :author5 => "value for author5" ) end it "renders new book form" do render response.should have_tag("form[action=?][method=post]", admin_books_path) do with_tag("input#book_sku_number[name=?]", "book[sku_number]") with_tag("input#book_title[name=?]", "book[title]") with_tag("input#book_author1[name=?]", "book[author1]") with_tag("input#book_author2[name=?]", "book[author2]") with_tag("input#book_author3[name=?]", "book[author3]") with_tag("input#book_author4[name=?]", "book[author4]") with_tag("input#book_author5[name=?]", "book[author5]") end end end Now, i am testing whether the form renders to new book form. Similarly for each input box, i want to test my data with different values and also test whether the form has been rendered to show page after submitting this new form. I would be thankful to you if you can guide me on this. Thanks!! On Wed, Oct 28, 2009 at 2:19 AM, bagwan.pankaj <bagwanpankaj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > Hi > > But you haven''t given any example > > On Oct 28, 10:29 am, Rails ROR <developra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi All, > > > > I want to test my application with rspec. > > > > In order to test my views, I have written few specs as given in the > > examples. > > > > Is there any way to test the user acceptance? > > > > i.e suppose the field takes a string. > > > > I want to test it for integers, float values, alphanumeric values, etc > and > > run tests against that. > > > > I need to get the tests failed as it takes only string. > > > > I would be really thankful if someone can guide me on this. > > > > Please help me with a simple example so that I can understand it quickly > and > > move ahead. > > > > Thanks in advance. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rails ROR wrote:> Hi, > > Example if the view has a form with few fields and a submit button, I > want > to test whether the data that i enter is according to the database,i.e > the > model(Having all validations[Null]) and the page gets redirected to > success > page.Views are dumb. What you want to test is actually controller functionality. And although you can do it with just RSpec, I''d recommend using Cucumber for anything at the feature or acceptance level. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
2009/10/28 Rails ROR <developrails at gmail.com>> Hi All, > > I want to test my application with rspec. > > In order to test my views, I have written few specs as given in the > examples. > > Is there any way to test the user acceptance? > > i.e suppose the field takes a string. > > I want to test it for integers, float values, alphanumeric values, etc and > run tests against that. > > I need to get the tests failed as it takes only string. > > I would be really thankful if someone can guide me on this. > > Please help me with a simple example so that I can understand it quickly > and move ahead. > > Thanks in advance. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >I would suggest buying a copy of the RSpec book (a beta PDF is available at (http://pragprog.com/). This is by far the best resource for learning how to test with rspec and cucumber, and also is very up to date. Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091028/5a8adad8/attachment-0001.html>
Rails ROR wrote:> Hi All, > > I want to test my application with rspec. > > In order to test my views, I have written few specs as given in the > examples. > > Is there any way to test the user acceptance? > > i.e suppose the field takes a string. > > I want to test it for integers, float values, alphanumeric values, etc > and > run tests against that.These sound like unit tests for the model to me. As mentioned views are dumb (unless you''re talking about client-side JavaScript validation). What you really care about is whether invalid data can make it through your model validation.> I need to get the tests failed as it takes only string. > > I would be really thankful if someone can guide me on this.The kinds of things you want to test in your view specs is whether the text field gets rendered, that it''s the right kind of control, has the right style class or id applied to it, that it has the right label, etc. If you want to create specs for user acceptance then integration specs are the place to do that. As also mentioned; Cucumber provides a great way to provide those integration specs. Cucumber makes the acceptance test easy for the stakeholder to read and understand, which is vital to good user acceptance scripts. -- Posted via http://www.ruby-forum.com/.