Hello, I have followed the rspec course on code-school. Now I try to make it work on my own project. Let''s say I have this model : class message < ActiveRecord::Base attr_accessible :bericht, :user belongs_to :user belongs_to :category end Now I try to make a test so I can verify that a message has a title and a body. How can I do this ? Roelof -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/vHZ8LfPhp44J. For more options, visit https://groups.google.com/groups/opt_out.
On Tue, Oct 30, 2012 at 6:29 AM, roelof <rwobben-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> I have followed the rspec course on code-school.> Now I try to make a test so I can verify that a message has a title and a > body. > > How can I do this ?I would suggest you use the rspec generators to create a model or scaffold and then use the generated tests as a guide. (Seems like something that an "rspec course" would have covered...) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Thanks for the answer. I will try to find out how this works. As far as I can find it this is not covered in this code school course. Roelof Op dinsdag 30 oktober 2012 14:48:47 UTC+1 schreef Hassan Schroeder het volgende:> On Tue, Oct 30, 2012 at 6:29 AM, roelof <rwo...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org <javascript:>> > wrote: > > > I have followed the rspec course on code-school. > > > Now I try to make a test so I can verify that a message has a title and > a > > body. > > > > How can I do this ? > > I would suggest you use the rspec generators to create a model or > scaffold and then use the generated tests as a guide. > > (Seems like something that an "rspec course" would have covered...) > > -- > Hassan Schroeder ------------------------ hassan.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<javascript:> > http://about.me/hassanschroeder > twitter: @hassan >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/YQ_LX4-zTogJ. For more options, visit https://groups.google.com/groups/opt_out.
On 30 October 2012 15:47, roelof <rwobben-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Thanks for the answer. > I will try to find out how this works. As far as I can find it this is not > covered in this code school course.Try railstutorial.org, which is free to use online. It gives a good introduction to testing. Colin> > Roelof > > Op dinsdag 30 oktober 2012 14:48:47 UTC+1 schreef Hassan Schroeder het > volgende: >> >> On Tue, Oct 30, 2012 at 6:29 AM, roelof <rwo...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: >> >> > I have followed the rspec course on code-school. >> >> > Now I try to make a test so I can verify that a message has a title and >> > a >> > body. >> > >> > How can I do this ? >> >> I would suggest you use the rspec generators to create a model or >> scaffold and then use the generated tests as a guide. >> >> (Seems like something that an "rspec course" would have covered...) >> >> -- >> Hassan Schroeder ------------------------ hassan.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> http://about.me/hassanschroeder >> twitter: @hassan > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/YQ_LX4-zTogJ. > > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
You can use the gem shoulda-matchers[1] to test it. She works very well with rspec. And it is very easy to test this. With it you can test the attributes, calls from models and stuff ... You can use the gem-rails factory-girl, best to test the interactions, writing less and being more efficient ... :) [1] -> https://github.com/thoughtbot/shoulda-matchers [2] -> https://github.com/thoughtbot/factory_girl_rails -- * Att* ___________________________ Rodrigo Martins www.rrmartins.com <http://rrmartins.github.com> tel: (28) 9882-6202 (27) 9601-9573 (21) 9942-2016 My profiles: [image: Facebook] <http://pt-br.facebook.com/rr.martins.j> [image: Twitter] <http://www.twitter.com/rr_martins> Contact me: [image: Google Talk/] rodrigo-rncPa8n6ogiakBO8gow8eQ@public.gmane.org [image: Skype/]rr_martinsj [image: MSN/] rodrigo-rncPa8n6ogiakBO8gow8eQ@public.gmane.org 2012/10/30 Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>> On 30 October 2012 15:47, roelof <rwobben-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: > > Thanks for the answer. > > I will try to find out how this works. As far as I can find it this is > not > > covered in this code school course. > > Try railstutorial.org, which is free to use online. It gives a good > introduction to testing. > > Colin > > > > > Roelof > > > > Op dinsdag 30 oktober 2012 14:48:47 UTC+1 schreef Hassan Schroeder het > > volgende: > >> > >> On Tue, Oct 30, 2012 at 6:29 AM, roelof <rwo...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: > >> > >> > I have followed the rspec course on code-school. > >> > >> > Now I try to make a test so I can verify that a message has a title > and > >> > a > >> > body. > >> > > >> > How can I do this ? > >> > >> I would suggest you use the rspec generators to create a model or > >> scaffold and then use the generated tests as a guide. > >> > >> (Seems like something that an "rspec course" would have covered...) > >> > >> -- > >> Hassan Schroeder ------------------------ hassan.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > >> http://about.me/hassanschroeder > >> twitter: @hassan > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit > > https://groups.google.com/d/msg/rubyonrails-talk/-/YQ_LX4-zTogJ. > > > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.