[rspec-users] How to improve this spec

Mark Wilden mark at mwilden.com
Sat Oct 11 17:31:22 EDT 2008


On Sat, Oct 11, 2008 at 2:19 PM, Nick Hoffman <nick at deadorange.com> wrote:

> Hi guys. One of my specs is very weak, and I'd really like to improve it.
>
> Lines 111-116 are what I'm having trouble speccing, and depend on lines
> 105-109.
>
> 105      # Grab all of the properties, filtering using the given
> conditions.
> 106      @properties = Property.find :all, :conditions => [
> 107        processed_conditions[:conditions_string],
> 108        processed_conditions[:conditions_hash]
> 109        ]
> 110
> 111      # Generate a table of properties to list.
> 112      @property_data = render_to_string(
> 113        :partial    => 'properties/map_properties_table',
> 114        :collection => @properties,
> 115        :locals     => {:index_of_last_row => @properties.size}
> 116        )
> 117
> 118      @number_of_properties_found_sentence = render_to_string :partial
> => 'properties/number_of_properties_found'
>
>
> My spec for lines 104-108 are fine. Below is what I have for 111-16, which
> I'd like to improve:
>
> 498      it "should render the 'map_properties_table' partial" do
> 499        pending
> 500
>  controller.should_receive(:render_to_string).with(any_args()).twice
> 501        do_xhr @params
> 502      end
>
> Specifically, I'd like to improve what's passed to #with . However, my
> specs don't have the variable "@properties"


If you mocked the Property.find call, you'd have @properties.

///ark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081011/03793b5c/attachment.html>


More information about the rspec-users mailing list