Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/ci_jruby.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/ci_legacy.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/ci_truffleruby.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'

2 changes: 1 addition & 1 deletion representable.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions test/as_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions test/cached_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def self.profile(&block)
printer.printProfile(print_stream)
output_stream.toString
end
rescue LoadError
false
end
end

Expand Down Expand Up @@ -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
{
Expand All @@ -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
Expand All @@ -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 }
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion test/definition_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 "#<Representable::Definition ==>songs @options={:name=>\"songs\", :parse_filter=>[], :render_filter=>[]}>"
_(Definition.new(:songs).inspect).must_equal "#<Representable::Definition ==>songs @options=#{options}>"
}
end

Expand Down
8 changes: 5 additions & 3 deletions test/filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ 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",
"track" => "Nine"
).extend(representer).to_hash
).must_equal({
"title" => "vulcan ears",
"track" => "NINE,{\"title\"=>\"vulcan ears\"},{}"
"track" => "NINE,#{val},{}"
})
}

Expand Down
4 changes: 2 additions & 2 deletions test/serialize_deserialize_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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