Closed linuxonrails closed 12 years ago
I can't have any idea with the few info you give.
What's your code?
What's the exact error message?
Sent from my iPhone
On 14 oct. 2012, at 20:11, Linux on Rails notifications@github.com wrote:
I have in unit test:
should validate_presence_of(:from) And I have in model:
validates :from, presence: true acts_as_gmappable check_process: false, validation: false When I execut the unit test i have always the next error:
Error: test: Trip should require from to be set. (TripTest) NoMethodError: undefined method `empty?' — Reply to this email directly or view it on GitHub.
I'm sorry:
app/models/trip.rb
class Trip < ActiveRecord::Base
validates :from, :to, :end_date, :start_date, :trip_type, presence: true
acts_as_gmappable :validation => false, :check_process => false
# ... etc...
def gmaps4rails_address
self.from
end
end
test/units/trip_test.rb
require 'test_helper'
class TripTest < ActiveSupport::TestCase
should validate_presence_of(:from)
should validate_presence_of(:to)
should validate_presence_of(:start_date)
should validate_presence_of(:end_date)
should validate_presence_of(:trip_type)
# ...etc...
end
$ ruby -Itest test/unit/trip_test.rb
Loaded suite test/unit/trip_test
Started
E
===============================================================================
Error: test: Trip should require end_date to be set. (TripTest)
NoMethodError: undefined method `gmaps4rails_address' for #<Trip:0x0000000809ee78>
===============================================================================
E
===============================================================================
Error: test: Trip should require from to be set. (TripTest)
NoMethodError: undefined method `gmaps4rails_address' for #<Trip:0x000000076938c0>
===============================================================================
E
===============================================================================
Error: test: Trip should require start_date to be set. (TripTest)
NoMethodError: undefined method `gmaps4rails_address' for #<Trip:0x0000000715a6b0>
===============================================================================
E
===============================================================================
Error: test: Trip should require to to be set. (TripTest)
NoMethodError: undefined method `gmaps4rails_address' for #<Trip:0x00000008b8d348>
===============================================================================
E
===============================================================================
Error: test: Trip should require trip_type to be set. (TripTest)
NoMethodError: undefined method `gmaps4rails_address' for #<Trip:0x00000008655790>
===============================================================================
Finished in 0.431218635 seconds.
5 tests, 0 assertions, 0 failures, 5 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
why didn't you define the gmaps4rails_address
method?
It's necessary for the gem to work.
def gmaps4rails_address
self.from
end
I'm sorry again :-)
The error is that the method is undefined.
I can't tell much more from what you provide.
uhm???
Trip.new.gmaps4rails_address works.
maybe, but I can't know why you have:
undefined method `gmaps4rails_address' for #<Trip:0x00000008655790>
I have in unit test:
And I have in model:
When I execut the unit test i have always the next error: