[rspec-users] [NoMethodError] simple problem

Andrew WC Brown omen.king at gmail.com
Sun May 27 11:49:54 EDT 2007


Oh it all just clicked.
What I wanted to do was:

  def full_name
    [first_name, last_name].join(' ')
  end

  it "should return full name" do
    person = Person.create(:first_name => "Andrew",:last_name => "Brown")
    person.full_name.should eql("Andrew Brown")
  end

 Still getting use to RSpec but I'm loving it.

On 5/27/07, David Chelimsky <dchelimsky at gmail.com> wrote:
>
> On 5/27/07, Andrew WC Brown <omen.king at gmail.com> wrote:
> > I think this test should pass but it doesn't
> >
> > 1)
> > NoMethodError in 'Person should return full name'
> > undefined method `full_name?' for #<Person:0x3567964>
> > ./spec/models/person_spec.rb:43:
> >
> > describe Person do
> >  it "should return full name" do
> >     person = Person.new
> >     person.should be_full_name
> >   end
> > end
> >
> > class Person < ActiveRecord::Base
> >   def full_name
> >     true
> >   end
> > end
>
> The error message says that what is missing is full_name?, not
> full_name. Try this:
>
> class Person < ActiveRecord::Base
>   def full_name?
>     true
>   end
> end
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070527/e5496ad3/attachment.html 


More information about the rspec-users mailing list