ruby 1.9.3 - Rspec test issue not producing proper response -
i receive following response when try run rspec tests.
user.respond_to?(:name)
should "true" following error instead
(added) **nameerror: undefined local variable or method `user' main:object (irb):2 /users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2nded/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start' /users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2nded/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start' /users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2nded/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>' script/rails:6:in `require' script/rails:6:in `<main>'
instead of receiving "true" or "false" response. ideas?
from gemfile gem 'rails', '3.2.13' gem 'rspec-rails', '2.11.0' ruby '1.9.3'
here exact test , erro hartl tutorial 6.2.2 validating presence
user = user.new(name: "", email: "mhartl@example.com") >> user.save => false
*false response supposed get, error above receive.
here user.rb file
class user < activerecord::base attr_accessible :name, :email validates :name, presence: true end
here user_spec.rb file
require 'spec_helper' describe user before { @user = user.new(name: "example user", email: "user@example.com") } subject { @user } { should respond_to(:name) } { should respond_to(:email) } end
Comments
Post a Comment