From 35d3f587dd8d28c17967166f1c778bd33c242fc3 Mon Sep 17 00:00:00 2001 From: Joe Ferris Date: Sun, 19 Oct 2008 16:17:08 -0400 Subject: [PATCH] Fixed tests for Javascript maps --- test/functional/stores_controller_test.rb | 2 +- test/shoulda_macros/should_have_map.rb | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/functional/stores_controller_test.rb b/test/functional/stores_controller_test.rb index 98bd31e..2df3410 100644 --- a/test/functional/stores_controller_test.rb +++ b/test/functional/stores_controller_test.rb @@ -47,7 +47,7 @@ class StoresControllerTest < ActionController::TestCase get :index end - should_have_map + should_have_store_map should_assign_to :stores should "only display 4 stores" do diff --git a/test/shoulda_macros/should_have_map.rb b/test/shoulda_macros/should_have_map.rb index 89fd6c7..a9529da 100644 --- a/test/shoulda_macros/should_have_map.rb +++ b/test/shoulda_macros/should_have_map.rb @@ -24,4 +24,12 @@ def self.should_have_map_observer(field) @response.body end end -end \ No newline at end of file + + def self.should_have_store_map + should "have a map displaying stores" do + json = Regexp.escape(assigns(:stores).to_json) + assert_match /new StoreViewer\(\{.*mapContainer:.*,.*stores: *#{json}.*\}.*\)/m, + @response.body + end + end +end