diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0951901a..c98c9fc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,19 +8,21 @@ jobs: matrix: ruby: [ '3.1', '3.2', '3.3', 'head' ] rails: [ '7.1', 'edge' ] + rubyopt: [""] include: - - ruby: '2.7' - rails: '6.1' - ruby: '3.0' rails: '6.1' - ruby: '3.1' rails: '7.0' + - ruby: '3.3' + rails: ['edge', '7.1'] + rubyopt: "--enable-frozen-string-literal" env: RAILS_VERSION: ${{ matrix.rails }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -29,10 +31,10 @@ jobs: bundler-cache: true - name: Run unit tests - run: bundle exec rake test:unit + run: bundle exec rake test:unit RUBYOPT="${{ matrix.rubyopt }}" timeout-minutes: 3 - name: Run acceptance tests - run: bundle exec rake test:acceptance + run: bundle exec rake test:acceptance RUBYOPT="${{ matrix.rubyopt }}" timeout-minutes: 10 if: ${{ matrix.rails != 'edge' && matrix.ruby != 'head' }} # Acceptance tests use `gem install rails && rails new` diff --git a/lib/spring/json.rb b/lib/spring/json.rb index d4d71b6e..ed09f4d5 100644 --- a/lib/spring/json.rb +++ b/lib/spring/json.rb @@ -13,7 +13,6 @@ module Spring module JSON def self.load(string) - string.force_encoding("utf-8") OkJson.decode(string) end @@ -364,7 +363,7 @@ def unquote(q) end end if rubydoesenc? - a[w] = '' << uchar + a[w] = +'' << uchar w += 1 else w += ucharenc(a, w, uchar) diff --git a/test/support/application.rb b/test/support/application.rb index baeb0092..ed3cc3cb 100644 --- a/test/support/application.rb +++ b/test/support/application.rb @@ -168,7 +168,7 @@ def read_streams end def read_stream(stream) - output = "" + output = +"" while IO.select([stream], [], [], 0.5) && !stream.eof? output << stream.readpartial(10240) end diff --git a/test/unit/json_test.rb b/test/unit/json_test.rb new file mode 100644 index 00000000..b9eecc05 --- /dev/null +++ b/test/unit/json_test.rb @@ -0,0 +1,12 @@ +require_relative "../helper" +require 'spring/json' + +class JsonTest < ActiveSupport::TestCase + test 'can decode unicode characters' do + assert_equal({"unicode_example"=>"©"}, Spring::JSON.load('{"unicode_example": "\u00A9"}')) + end + + test 'can encode' do + assert_equal('{}', Spring::JSON.dump({})) + end +end