require File.dirname(__FILE__) + '/test_helper'
class SeleneseTest < Test::Unit::TestCase
def setup
@view = TestView.new
@view.extend(SeleniumOnRails::PathsTestHelper)
@sel = SeleniumOnRails::Selenese.new(@view)
end
def render_selenese(page_title, input)
create_sel_file_from(input, "html.sel")
@sel.render ActionView::Template.new(test_path_for("html.sel")), {'page_title' => page_title}
end
def create_sel_file_from(input, name)
File.open(test_path_for(name), 'w+') { |index_file| index_file << input }
end
def test_path_for(name)
"#{File.expand_path(File.dirname(__FILE__) + "/../test_data")}/#{name}"
end
def assert_selenese expected, name, input
assert_text_equal expected, render_selenese(name, input)
end
def test_empty
expected = <
END
input = ''
assert_selenese expected, 'Empty', ''
end
def test_one_line
expected = <Empty One line
END
input = '|open|/|'
assert_selenese expected, 'One line', input
end
def test_comments_only
expected = <open /
Comment 2
| Only comments |
|---|
Comment 1
Comment 2
END input = <Comment 2
| Comments and commands | ||
|---|---|---|
| goBack | ||
| fireEvent | textField | focus |
Comment 2
| Comments, commands and comments | ||
|---|---|---|
| goBack | ||
| fireEvent | textField | focus |
Comment 3
END input = <