Skip to content

Commit ce5c049

Browse files
committed
feat: to_h instead of to_json
1 parent a57db43 commit ce5c049

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/serp_parser/result.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@ def meta
2222
"template" => self.class.name
2323
}
2424
end
25+
26+
def to_json
27+
to_h.to_json
28+
end
2529
end
2630
end

lib/serp_parser/result_collection.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ def to_h
1818
@results.map(&:to_h)
1919
end
2020

21+
def to_json
22+
to_h.to_json
23+
end
24+
2125
def method_missing(method, *args, &block)
2226
if @results.respond_to?(method)
2327
@results.send(method, *args, &block)

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
def check_result(result_type, file_path)
44
expected_result = JSON.parse(File.read(file_path))
5-
actual_result = parser.send(result_type).find_by(position: expected_result["position"]).to_json
5+
actual_result = parser.send(result_type).find_by(position: expected_result["position"]).to_h
66
expect(actual_result).to be_a(Hash)
77
expect(actual_result).to match(expected_result)
88
end

0 commit comments

Comments
 (0)