Skip to content

Commit

Permalink
Updated tests to use assert_eschaton_output language
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilio Karadanais committed May 28, 2009
1 parent c28eac7 commit faac15f
Show file tree
Hide file tree
Showing 21 changed files with 410 additions and 574 deletions.
34 changes: 14 additions & 20 deletions test/bounds_test.rb
Expand Up @@ -6,15 +6,13 @@ class BoundsTest < Test::Unit::TestCase

def test_initialize
with_eschaton do |script|
assert_output_fixture "bounds = new GLatLngBounds(new GLatLng(-34.947, 19.462), new GLatLng(-35.947, 20.462));",
script.record_for_test {
assert_eschaton_output "bounds = new GLatLngBounds(new GLatLng(-34.947, 19.462), new GLatLng(-35.947, 20.462));" do
Google::Bounds.new(:south_west_point => [-34.947, 19.462], :north_east_point => [-35.947, 20.462])
}
end

assert_output_fixture "bounds = new GLatLngBounds();",
script.record_for_test {
assert_eschaton_output "bounds = new GLatLngBounds();" do
Google::Bounds.new
}
end

end
end
Expand All @@ -23,31 +21,27 @@ def test_extend
with_eschaton do |script|
bounds = Google::Bounds.new

assert_output_fixture "bounds.extend(marker.getLatLng());",
script.record_for_test {
assert_eschaton_output "bounds.extend(marker.getLatLng());" do
bounds.extend 'marker.getLatLng()'
}
end

assert_output_fixture "bounds.extend(new GLatLng(-36.947, 21.462));",
script.record_for_test {
assert_eschaton_output "bounds.extend(new GLatLng(-36.947, 21.462));" do
bounds.extend [-36.947, 21.462]
}
end

other_bounds = Google::Bounds.new(:south_west_point => [-34.947, 19.462], :north_east_point => [-35.947, 20.462])

assert_output_fixture "bounds.extend(new GLatLng(-34.947, 19.462));
bounds.extend(new GLatLng(-35.947, 20.462));",
script.record_for_test {
assert_eschaton_output "bounds.extend(new GLatLng(-34.947, 19.462));
bounds.extend(new GLatLng(-35.947, 20.462));" do
bounds.extend other_bounds
}
end

assert_output_fixture "bounds.extend(marker.getLatLng());
assert_eschaton_output "bounds.extend(marker.getLatLng());
bounds.extend(new GLatLng(-36.947, 21.462));
bounds.extend(new GLatLng(-34.947, 19.462));
bounds.extend(new GLatLng(-35.947, 20.462));",
script.record_for_test {
bounds.extend(new GLatLng(-35.947, 20.462));" do
bounds.extend 'marker.getLatLng()', [-36.947, 21.462], other_bounds
}
end
end
end

Expand Down
35 changes: 14 additions & 21 deletions test/circle_test.rb
Expand Up @@ -8,46 +8,39 @@ def test_initialize
with_eschaton do |script|
location = {:latitude => -35.0, :longitude => 18.0}

assert_output_fixture 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1.5, 40, null, 2, null, "#0055ff", null);',
script.record_for_test {
assert_eschaton_output 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1.5, 40, null, 2, null, "#0055ff", null);' do
Google::Circle.new :location => location
}
end

assert_output_fixture 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, null, 2, null, "#0055ff", null);',
script.record_for_test {
assert_eschaton_output 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, null, 2, null, "#0055ff", null);' do
Google::Circle.new :location => location, :radius => 1000
}
end

assert_output_fixture 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, "red", 2, null, "#0055ff", null);',
script.record_for_test {
assert_eschaton_output 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, "red", 2, null, "#0055ff", null);' do
Google::Circle.new :location => location, :radius => 1000, :border_colour => 'red'
}
end

assert_output_fixture 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, "red", 5, null, "#0055ff", null);',
script.record_for_test {
assert_eschaton_output 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, "red", 5, null, "#0055ff", null);' do
Google::Circle.new :location => location, :radius => 1000, :border_colour => 'red',
:border_width => 5
}
end

assert_output_fixture 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, "red", 5, 0.7, "#0055ff", null);',
script.record_for_test {
assert_eschaton_output 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, "red", 5, 0.7, "#0055ff", null);' do
Google::Circle.new :location => location, :radius => 1000, :border_colour => 'red',
:border_width => 5, :border_opacity => 0.7
}
end

assert_output_fixture 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, "red", 5, 0.7, "black", null);',
script.record_for_test {
assert_eschaton_output 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, "red", 5, 0.7, "black", null);' do
Google::Circle.new :location => location, :radius => 1000, :border_colour => 'red',
:border_width => 5, :border_opacity => 0.7,
:fill_colour => 'black'
}
end

assert_output_fixture 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, "red", 5, 0.7, "black", 1);',
script.record_for_test {
assert_eschaton_output 'circle = drawCircle(new GLatLng(-35.0, 18.0), 1000, 40, "red", 5, 0.7, "black", 1);' do
Google::Circle.new :location => location, :radius => 1000, :border_colour => 'red',
:border_width => 5, :border_opacity => 0.7,
:fill_colour => 'black', :fill_opacity => 1
}
end
end
end

Expand Down
7 changes: 3 additions & 4 deletions test/eschaton_test.rb
Expand Up @@ -24,12 +24,11 @@ def test_current_view

def test_write_to_global_script
with_eschaton do |script|
assert_output_fixture 'One!
Two!',
script.record_for_test {
assert_eschaton_output 'One!
Two!' do
TestJavascriptObject.write_one
TestJavascriptObject.new.write_two
}
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/expander_test.rb
Expand Up @@ -31,7 +31,7 @@ def test_expander_with_scriptstore

Store.clear(:before_map_script)

assert_output_fixture 'Before expander
assert_eschaton_output 'Before expander
Before Map Script
/* This is before the map script! */
After expander',
Expand Down
53 changes: 24 additions & 29 deletions test/google_generator_ext_test.rb
Expand Up @@ -11,7 +11,7 @@ def test_global_map_var
map = Google::Map.new :center => :cape_town, :zoom => 9
end

assert_output_fixture "var map;
assert_eschaton_output "var map;
jQuery(document).ready(function() {
window.onunload = GUnload;
if (GBrowserIsCompatible()) {
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_mapping_scripts
generator.comment "Map script"
end

assert_output_fixture "/* Before 1 */
assert_eschaton_output "/* Before 1 */
/* Before 2 */
jQuery(document).ready(function() {
window.onunload = GUnload;
Expand All @@ -69,57 +69,52 @@ def test_mapping_scripts
def test_google_map_script
with_eschaton do |script|

assert_output_fixture :google_map_script_no_body, script.record_for_test {
script.google_map_script {}
}
assert_eschaton_output :google_map_script_no_body do
script.google_map_script {}
end

assert_output_fixture :google_map_script_with_body, script.record_for_test {
script.google_map_script do
script.comment "This is some test code!"
script.alert("Hello!")
end
}

assert_eschaton_output :google_map_script_with_body do
script.google_map_script do
script.comment "This is some test code!"
script.alert("Hello!")
end
end
end
end

def test_set_coordinate_elements
with_eschaton do |script|

assert_output_fixture "$('latitude').value = location.lat();
$('longitude').value = location.lng();",
script.record_for_test {
assert_eschaton_output "$('latitude').value = location.lat();
$('longitude').value = location.lng();" do
script.set_coordinate_elements :location => :location
}
end

map = Google::Map.new :center => {:latitude => -35.0, :longitude => 19.0}

# Testing with map center
assert_output_fixture "$('latitude').value = map.getCenter().lat();
$('longitude').value = map.getCenter().lng();",
script.record_for_test {
assert_eschaton_output "$('latitude').value = map.getCenter().lat();
$('longitude').value = map.getCenter().lng();" do
script.set_coordinate_elements :location => map.center
}
end

marker = map.add_marker(:var => :marker, :location => map.center)

# Testing with a marker location
assert_output_fixture "$('latitude').value = marker.getLatLng().lat();
$('longitude').value = marker.getLatLng().lng();",
script.record_for_test {
assert_eschaton_output "$('latitude').value = marker.getLatLng().lat();
$('longitude').value = marker.getLatLng().lng();" do
script.set_coordinate_elements :location => marker.location
}
end

# With specific element names
assert_output_fixture "$('location_latitude').value = location.lat();
$('location_longitude').value = location.lng();",
script.record_for_test {
assert_eschaton_output "$('location_latitude').value = location.lat();
$('location_longitude').value = location.lng();" do
script.set_coordinate_elements :location => :location,
:latitude_element => :location_latitude,
:longitude_element => :location_longitude
}
end
end

end

end
20 changes: 8 additions & 12 deletions test/gravatar_icon_test.rb
Expand Up @@ -6,26 +6,22 @@ class GravatarIconTest < Test::Unit::TestCase

def test_initialize
with_eschaton do |script|
assert_output_fixture :gravatar,
script.record_for_test {
assert_eschaton_output :gravatar do
Google::GravatarIcon.new :email_address => 'yawningman@eschaton.com'
}
end

assert_output_fixture :gravatar_with_size,
script.record_for_test {
assert_eschaton_output :gravatar_with_size do
Google::GravatarIcon.new :email_address => 'yawningman@eschaton.com', :size => 50
}
end

assert_output_fixture :gravatar_with_default_icon,
script.record_for_test {
assert_eschaton_output :gravatar_with_default_icon do
Google::GravatarIcon.new :email_address => 'yawningman@eschaton.com', :default => 'http://localhost:3000/images/blue.png'
}
end

assert_output_fixture :gravatar_with_size_and_default_icon,
script.record_for_test {
assert_eschaton_output :gravatar_with_size_and_default_icon do
Google::GravatarIcon.new :email_address => 'yawningman@eschaton.com', :default => 'http://localhost:3000/images/blue.png',
:size => 50
}
end
end
end

Expand Down
15 changes: 6 additions & 9 deletions test/ground_overlay_test.rb
Expand Up @@ -10,27 +10,24 @@ def test_initialize
ground_overlay = new GGroundOverlay('http://battlestar/images/cylon_base_star.png', bounds);"

# Using explicit points for Bounds
assert_output_fixture output,
script.record_for_test {
assert_eschaton_output output do
Google::GroundOverlay.new :image => "http://battlestar/images/cylon_base_star.png",
:south_west_point => [-33.947, 18.462],
:north_east_point => [-34.947, 19.462]
}
end

# Using a bounds object
assert_output_fixture output,
script.record_for_test {
assert_eschaton_output output do
Google::GroundOverlay.new :image => "http://battlestar/images/cylon_base_star.png",
:bounds => Google::Bounds.new(:south_west_point => [-33.947, 18.462],
:north_east_point => [-34.947, 19.462])
}
end

# using Bounds in array form
assert_output_fixture output,
script.record_for_test {
assert_eschaton_output output do
Google::GroundOverlay.new :image => "http://battlestar/images/cylon_base_star.png",
:bounds => [[-33.947, 18.462], [-34.947, 19.462]]
}
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/javascript_object_test.rb
Expand Up @@ -60,7 +60,7 @@ def test_translation
object.set_options_on('map', {:zoom => 15, :controls => :small_map})
object.enable_dragging!

assert_output_fixture 'map.setZoom(12);
assert_eschaton_output 'map.setZoom(12);
map.setZoom(12);
map.zoomIn();
map.zoomOut();
Expand All @@ -86,7 +86,7 @@ def test_add_to_script

object << "var i = 1;"

assert_output_fixture "var i = 1;", script
assert_eschaton_output "var i = 1;", script
end
end

Expand Down

0 comments on commit faac15f

Please sign in to comment.