I'm trying to do something fairly simple - add a module with helper methods to a Model test, but i keep getting the following error
uninitialized constant NeighborhoodTest::NeighboorhoodTestHelper
The module is located in test/helpers/neighborhood_test_helper.rb
module NeighborhoodTestHelper
def create_polygon
points = self.geolocate
boundary = Geokit::Polygon.new(points)
end
.
.
end
Per the recommendation in this SO answer, did the following inside test/models/neighborhood_test.rb:
require 'test_helper'
require 'helpers/neighborhood_test_helper'
class NeighborhoodTest < ActiveSupport::TestCase
include NeighboorhoodTestHelper
def setup
@crime = crimes(:arrest)
@neighborhood = neighborhoods(:one)
end
test "neighborhood should contain crime" do
neighborhood_boundary = @neighborhood.create_polygon
crime_location = @crime.geolocate
assert neighborhood_boundary.contains?(crime_location)
end
end
I also tried this SO that didn't work. Anyone know why this approach doesnt work in Models?
Aucun commentaire:
Enregistrer un commentaire