Skip to content

Commit d0df4ab

Browse files
committed
Update RSC payload spec for RC wire format
1 parent 23cd58a commit d0df4ab

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

spec/requests/server_components_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require "rails_helper"
4+
require "react_on_rails/length_prefixed_parser"
45

56
describe "Server Components" do
67
it "GET /server-components returns the demo page shell" do
@@ -11,12 +12,11 @@
1112

1213
describe "RSC payload endpoint" do
1314
def parsed_chunks
14-
response.body.each_line.filter_map do |line|
15-
stripped = line.strip
16-
next if stripped.empty?
17-
18-
JSON.parse(stripped)
19-
end
15+
chunks = []
16+
parser = ReactOnRails::LengthPrefixedParser.new
17+
parser.feed(response.body.b) { |chunk| chunks << chunk }
18+
parser.flush
19+
chunks
2020
end
2121

2222
def expect_valid_rsc_payload

0 commit comments

Comments
 (0)