Html parser / assertions in a model

I am using http.get in a model to parse html code returned from a Oracle
server.

My first try was to use assertions (assert and assert_select) to test
and parse the html code. But I have problems including the methods in
the model. Have tried both “include” and copy/paste to get assertion
methods into my model. Works as a model, but I get load errors when I am
using the model from a controller.

Does anyone known the correct way to get assertion methods merged into a
model?

I am considering replace assertions with a html parser. Is there a
recommented html parser for ruby?

Ok, it looks like I have to use both load and include to prevent load
error when the model with assertions are used from a controller.

load ‘/usr/lib/ruby/1.8/test/unit/assertions.rb’
class OlapDatabaseTrans < ActiveRecord::Base
include Test::Unit::Assertions

end

Jan R. wrote:

I am using http.get in a model to parse html code returned from a Oracle
server.

My first try was to use assertions (assert and assert_select) to test
and parse the html code. But I have problems including the methods in
the model.

Why do you need assertions to parse HTML? Assertions are for tests, not
generic parsing.

Have tried both “include” and copy/paste to get assertion
methods into my model. Works as a model, but I get load errors when I am
using the model from a controller.

What do the errors say?

Does anyone known the correct way to get assertion methods merged into a
model?

I am considering replace assertions with a html parser.

Good idea.

Is there a
recommented html parser for ruby?

I think most people are using Nokogiri these days.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]