[rspec-users] How to spec accessing a constant

Nick Hoffman nick at deadorange.com
Thu Oct 16 11:22:19 EDT 2008

On 2008-10-15, at 21:59, Craig Demyanovich wrote:
> Since class A is coupled to class B, the specs for A are also  
> coupled to class B through class A. Thus, I wouldn't worry about the  
> coupling. Why does a method of class A directly access a constant of  
> class B? Does the constant belong in class A? Does the method belong  
> in class B? If you can and want to be more specific with your code  
> and specs, I'm sure that we can all write some specs together.
> Regards,
> Craig

Hi Craig. Here're some code snippets:

Property#javascript_map_marker_code generates the Javascript code  
necessary to:
1) Create a [Google] map marker that represents a property instance.
2) Add the marker to the map.
To perform #2, RentalMap::MAP_NAME must be accessed somehow, be it  
directly, or through a method as Scott suggested.

RentalMap::MAP_NAME should definitely be part of the RentalMap model.  
It should not be part of the Property model.

Property#javascript_map_marker_code belongs in the Property model,  
because it acts upon (IE: uses several attributes of) a Property  


More information about the rspec-users mailing list