1mod extractor;
7mod mapper;
8mod parser_impl;
9mod visitor;
10
11pub use parser_impl::RubyParser;
12
13#[cfg(test)]
14mod tests {
15 use super::*;
16 use codegraph::CodeGraph;
17 use codegraph_parser_api::CodeParser;
18 use std::path::Path;
19
20 #[test]
21 fn test_parser_creation() {
22 let parser = RubyParser::new();
23 assert_eq!(parser.language(), "ruby");
24 }
25
26 #[test]
27 fn test_parse_simple_source() {
28 let parser = RubyParser::new();
29 let mut graph = CodeGraph::in_memory().unwrap();
30
31 let source = r#"
32class Calculator
33 def add(a, b)
34 a + b
35 end
36end
37"#;
38
39 let result = parser.parse_source(source, Path::new("calculator.rb"), &mut graph);
40 assert!(result.is_ok());
41
42 let file_info = result.unwrap();
43 assert_eq!(file_info.classes.len(), 1);
44 let class_node = graph.get_node(file_info.classes[0]).unwrap();
46 assert_eq!(
47 class_node.properties.get("name"),
48 Some(&codegraph::PropertyValue::String("Calculator".to_string()))
49 );
50 }
51}