Hi,
for using rspec with the SearchLogic plugin we found the following
solutions to mock/stub
the necessary objects/methods:
Views:
create search logic values
@search = mock(“search”)
@search.stub!(:page_count).and_return(2)
assigns[:search] = @search
@plannings_count = 20
assigns[:plannings_count] = @item_categories_count
stub the search form, otherwise the following error:
undefined method `spec_mocks_mock_path’ for
template.stub(:remote_form_for).and_return(true)
stub search logic helpers, otherwise the following errors:
@search object could not be inferred, please specify:
:search_obj => @search or :params_scope => :search_obj_name
template.stub(:remote_per_page_select).and_return(true)
template.stub(:remote_page_links).and_return(true)
Controllers:
scopes
@search =
Planning.with_associations.not_deleted.new_search(params[:search])
Planning.stub!(:with_associations).and_return(@search)
@search.stub!(:not_deleted).and_return(@search)
@search.stub!(:new_search).and_return(@search)
Andrea
Von: “Andrea J.” [email protected]
Gesendet: 25.03.09 15:50:06
An: [email protected]
Betreff: [rspec-users] spec for view with Searchlogic
Hi,
I’m using the Searchlogic plugin. Since I have added the search form in
the index template,
the view spec doesn’t work anymore.
Controller
def index
@search = PlPlanning.new_search(params[:search])
@search.order_by = :id
@pl_plannings, @count = @search.all, @search.count
end
view
<%= f.submit "Search" %> <% end %> <% end %>
spec
class Searchlogic::Cache::PlPlanningSearch; end
…
before(:each) do
@pl_plannings = []
assigns[:pl_plannings] = @pl_plannings
@search = Searchlogic::Cache::PlPlanningSearch.new ???
assigns[:search] = @search
& nbsp; render “/planning/pl_plannings/index”
end
…
=> Error in the line containing the remote_form_for call
undefined method `planning_searchlogic_cache_pl_planning_search_path’
for #ActionView::Base:0x6b6bf38
Has anybody experience with Searchlogic + rspec ? Can I stub
search_paths ?
Thanks
Andrea
Verschicken Sie SMS direkt vom Postfach aus - in alle deutschen und
viele
ausländische Netze zum gleichen Preis!
_______________________________________________rspec-users mailing
[email protected]://rubyforge.org/mailman/listinfo/rspec-users
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de
[http://movieflat.web.de]