Forum: RSpec How to improve this spec

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
49de4cd2f26705785cbef2b15a9df7aa?d=identicon&s=25 Nick Hoffman (Guest)
on 2008-10-11 23:25
(Received via mailing list)
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", so I'm not sure how to go
about this. Any suggestions? I'm all ears!

Thanks,
Nick
48641c4be1fbe167929fb16c9fd94990?d=identicon&s=25 Mark Wilden (Guest)
on 2008-10-11 23:32
(Received via mailing list)
On Sat, Oct 11, 2008 at 2:19 PM, Nick Hoffman <nick@deadorange.com>
wrote:

> 109        ]
>
>
> 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
49de4cd2f26705785cbef2b15a9df7aa?d=identicon&s=25 Nick Hoffman (Guest)
on 2008-10-13 05:21
(Received via mailing list)
On 2008-10-11, at 17:31, Mark Wilden wrote:
> If you mocked the Property.find call, you'd have @properties.

Hah, good point. Apologies for the obvious question.

Cheers,
Nick
This topic is locked and can not be replied to.