mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-21 17:50:13 +01:00
Changes you will need to make: * In your environment.rb, you will need to update references to a few files per environment.rb.tmpl * In your environment.rb, you will need to specify the local time zone of the computer that is running your Tracks install. Other notes on my changes: * Modified our code to take advantage of Rails 2.1's slick time zone support. * Upgraded will_paginate for compatibility * Hacked the Selenium on Rails plugin, which has not been updated in some time and does not support Rails 2.1 * Verified that all tests pass on my machine, including Selenium tests -- I'd like confirmation from others, too.
68 lines
1.5 KiB
Ruby
68 lines
1.5 KiB
Ruby
require 'abstract_unit'
|
|
|
|
class NodeTest < Test::Unit::TestCase
|
|
|
|
class MockNode
|
|
def initialize(matched, value)
|
|
@matched = matched
|
|
@value = value
|
|
end
|
|
|
|
def find(conditions)
|
|
@matched && self
|
|
end
|
|
|
|
def to_s
|
|
@value.to_s
|
|
end
|
|
end
|
|
|
|
def setup
|
|
@node = HTML::Node.new("parent")
|
|
@node.children.concat [MockNode.new(false,1), MockNode.new(true,"two"), MockNode.new(false,:three)]
|
|
end
|
|
|
|
def test_match
|
|
assert !@node.match("foo")
|
|
end
|
|
|
|
def test_tag
|
|
assert !@node.tag?
|
|
end
|
|
|
|
def test_to_s
|
|
assert_equal "1twothree", @node.to_s
|
|
end
|
|
|
|
def test_find
|
|
assert_equal "two", @node.find('blah').to_s
|
|
end
|
|
|
|
def test_parse_strict
|
|
s = "<b foo='hello'' bar='baz'>"
|
|
assert_raise(RuntimeError) { HTML::Node.parse(nil,0,0,s) }
|
|
end
|
|
|
|
def test_parse_relaxed
|
|
s = "<b foo='hello'' bar='baz'>"
|
|
node = nil
|
|
assert_nothing_raised { node = HTML::Node.parse(nil,0,0,s,false) }
|
|
assert node.attributes.has_key?("foo")
|
|
assert !node.attributes.has_key?("bar")
|
|
end
|
|
|
|
def test_to_s_with_boolean_attrs
|
|
s = "<b foo bar>"
|
|
node = HTML::Node.parse(nil,0,0,s)
|
|
assert node.attributes.has_key?("foo")
|
|
assert node.attributes.has_key?("bar")
|
|
assert "<b foo bar>", node.to_s
|
|
end
|
|
|
|
def test_parse_with_unclosed_tag
|
|
s = "<span onmouseover='bang'"
|
|
node = nil
|
|
assert_nothing_raised { node = HTML::Node.parse(nil,0,0,s,false) }
|
|
assert node.attributes.has_key?("onmouseover")
|
|
end
|
|
end
|