diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 532e79a8..ceb9d506 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [2.7, '3.0', '3.1', '3.2'] + ruby: ['3.1', '3.2', '3.3', '3.4'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/ci_jruby.yml b/.github/workflows/ci_jruby.yml deleted file mode 100644 index aead15d9..00000000 --- a/.github/workflows/ci_jruby.yml +++ /dev/null @@ -1,19 +0,0 @@ -## This file is managed by Terraform. -## Do not modify this file directly, as it may be overwritten. -## Please open an issue instead. -name: CI JRuby -on: [push, pull_request] -jobs: - test: - strategy: - fail-fast: false - matrix: - ruby: [jruby, jruby-head] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - run: bundle exec rake diff --git a/.github/workflows/ci_legacy.yml b/.github/workflows/ci_legacy.yml deleted file mode 100644 index f30c3314..00000000 --- a/.github/workflows/ci_legacy.yml +++ /dev/null @@ -1,19 +0,0 @@ -## This file is managed by Terraform. -## Do not modify this file directly, as it may be overwritten. -## Please open an issue instead. -name: CI with EOL ruby versions -on: [push, pull_request] -jobs: - test: - strategy: - fail-fast: false - matrix: - ruby: [2.5, 2.6] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - run: bundle exec rake diff --git a/.github/workflows/ci_truffleruby.yml b/.github/workflows/ci_truffleruby.yml deleted file mode 100644 index d4bad045..00000000 --- a/.github/workflows/ci_truffleruby.yml +++ /dev/null @@ -1,19 +0,0 @@ -## This file is managed by Terraform. -## Do not modify this file directly, as it may be overwritten. -## Please open an issue instead. -name: CI TruffleRuby -on: [push, pull_request] -jobs: - test: - strategy: - fail-fast: false - matrix: - ruby: [truffleruby, truffleruby-head] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - run: bundle exec rake diff --git a/Gemfile b/Gemfile index da67af7d..bd9097d9 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,8 @@ group :test do gem "minitest-line" gem "multi_json", require: false gem "nokogiri", require: false + gem "mutex_m" + gem "diff-lcs" end gem 'pry-byebug' diff --git a/representable.gemspec b/representable.gemspec index 74cff19d..c90c6fc6 100644 --- a/representable.gemspec +++ b/representable.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake" spec.add_development_dependency "test_xml", ">= 0.1.6" - spec.add_development_dependency "minitest" + spec.add_development_dependency "minitest", "~> 5.9.0" spec.add_development_dependency "dry-types" spec.add_development_dependency "ruby-prof" if RUBY_ENGINE == "ruby" # mri end diff --git a/test/as_test.rb b/test/as_test.rb index 1040d19a..401e5bb0 100644 --- a/test/as_test.rb +++ b/test/as_test.rb @@ -32,8 +32,8 @@ class AsTest < MiniTest::Spec property :name, :as => ->(options) { options[:user_options].inspect } end - it { render(song, user_options: {volume: 1}).must_equal_document({"{:volume=>1}" => "Revolution"}) } - it { _(parse(song, {"{:volume=>1}" => "Wie Es Geht"}, user_options: {volume: 1}).name).must_equal "Wie Es Geht" } + it { render(song, user_options: {volume: 1}).must_equal_document({{volume: 1}.inspect => "Revolution"}) } + it { _(parse(song, {{volume: 1}.inspect => "Wie Es Geht"}, user_options: {volume: 1}).name).must_equal "Wie Es Geht" } end end end diff --git a/test/cached_test.rb b/test/cached_test.rb index 569da5f8..6297d9c5 100644 --- a/test/cached_test.rb +++ b/test/cached_test.rb @@ -21,6 +21,8 @@ def self.profile(&block) printer.printProfile(print_stream) output_stream.toString end + rescue LoadError + false end end @@ -51,6 +53,10 @@ class AlbumRepresenter < Representable::Decorator collection :songs, decorator: SongRepresenter, class: Model::Song end + before do + @profiler_available = Profiler.profile {} + end + describe "serialization" do let(:album_hash) do { @@ -68,12 +74,13 @@ class AlbumRepresenter < Representable::Decorator # album2 = Model::Album.new("Louder And Even More Dangerous", [song2, song]) # makes sure options are passed correctly. - _(representer.to_hash(user_options: {volume: 9})).must_equal( + options = {volume: 9} + _(representer.to_hash(user_options: options)).must_equal( { "name" => "Live And Dangerous", "songs" => [ - {"title"=>"Jailbreak:{:volume=>9}"}, {"title"=>"Southbound:{:volume=>9}"}, - {"title"=>"Emerald:{:volume=>9}"} + {"title"=>"Jailbreak:#{options}"}, {"title"=>"Southbound:#{options}"}, + {"title"=>"Emerald:#{options}"} ] } ) # called in Deserializer/Serializer @@ -87,6 +94,8 @@ class AlbumRepresenter < Representable::Decorator # profiling it do + skip "ruby_prof not available" unless @profiler_available + representer.to_hash data = Profiler.profile { representer.to_hash } @@ -141,6 +150,8 @@ class AlbumRepresenter < Representable::Decorator end it "xxx" do + skip "ruby_prof not available" unless @profiler_available + representer = AlbumRepresenter.new(Model::Album.new) representer.from_hash(album_hash) diff --git a/test/definition_test.rb b/test/definition_test.rb index d858b36e..ecede345 100644 --- a/test/definition_test.rb +++ b/test/definition_test.rb @@ -90,8 +90,9 @@ class DefinitionTest < MiniTest::Spec # #inspect describe "#inspect" do + options = {name: "songs", parse_filter: [], render_filter: []} it { - _(Definition.new(:songs).inspect).must_equal "#songs @options={:name=>\"songs\", :parse_filter=>[], :render_filter=>[]}>" + _(Definition.new(:songs).inspect).must_equal "#songs @options=#{options}>" } end diff --git a/test/filter_test.rb b/test/filter_test.rb index ab4bfb39..29e4144c 100644 --- a/test/filter_test.rb +++ b/test/filter_test.rb @@ -20,12 +20,14 @@ class FilterTest < MiniTest::Spec # gets doc and options. it { - song = OpenStruct.new.extend(representer).from_hash("title" => "VULCAN EARS", "track" => "Nine") + input = {"title" => "VULCAN EARS", "track" => "Nine"} + song = OpenStruct.new.extend(representer).from_hash(input) _(song.title).must_equal "VULCAN EARS" - _(song.track).must_equal "nine,{\"title\"=>\"VULCAN EARS\", \"track\"=>\"Nine\"}" + _(song.track).must_equal "nine,#{input}" } it { + val = {"title" => "vulcan ears"} _( OpenStruct.new( "title" => "vulcan ears", @@ -33,7 +35,7 @@ class FilterTest < MiniTest::Spec ).extend(representer).to_hash ).must_equal({ "title" => "vulcan ears", - "track" => "NINE,{\"title\"=>\"vulcan ears\"},{}" + "track" => "NINE,#{val},{}" }) } diff --git a/test/serialize_deserialize_test.rb b/test/serialize_deserialize_test.rb index d82caf0b..5d4d5786 100644 --- a/test/serialize_deserialize_test.rb +++ b/test/serialize_deserialize_test.rb @@ -13,7 +13,7 @@ class SerializeDeserializeTest < BaseTest } end - it { _(subject.from_hash({"song" => Object}, user_options: {volume: 9}).song).must_equal "OBJECT Object {:volume=>9}" } + it { _(subject.from_hash({"song" => Object}, user_options: {volume: 9}).song).must_equal "OBJECT Object #{{volume: 9}}" } end describe "serialize" do @@ -28,6 +28,6 @@ class SerializeDeserializeTest < BaseTest before { subject.song = "Arrested In Shanghai" } - it { _(subject.to_hash(user_options: {volume: 9})).must_equal({"song"=>"Arrested In Shanghai {:volume=>9}"}) } + it { _(subject.to_hash(user_options: {volume: 9})).must_equal({"song"=>"Arrested In Shanghai #{{volume: 9}}"}) } end end