Skip to content

Commit

Permalink
Test: moved serialization spec from Groupie::Group to Groupie
Browse files Browse the repository at this point in the history
It's more useful to test the entire Groupie can be serialized than just
one.
  • Loading branch information
Narnach committed Feb 16, 2022
1 parent a471f58 commit c8a02ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 0 additions & 9 deletions spec/groupie/group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'spec_helper'
require 'yaml'

RSpec.describe Groupie::Group do
let(:group) { Groupie::Group.new('test') }
Expand All @@ -26,12 +25,4 @@
group.method(:add).should == group.method(:<<)
end
end

it 'can be serialized and loaded through YAML' do
group = Groupie::Group.new 'group'
group.add %w[buy flowers]
loaded_group = YAML.safe_load(group.to_yaml, permitted_classes: [Groupie::Group])
loaded_group.add %w[buy candy]
loaded_group.count('candy').should == 1
end
end
11 changes: 11 additions & 0 deletions spec/groupie_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'spec_helper'
require 'yaml'

RSpec.describe Groupie do
it 'has a version' do
Expand Down Expand Up @@ -279,4 +280,14 @@
end
end
end

it 'can be serialized and loaded through YAML' do
groupie = Groupie.new
groupie['one'].add %w[buy flowers]
groupie['two'].add %w[buy roses]

loaded = YAML.unsafe_load(YAML.dump(groupie))

expect(loaded.classify_text(%w[buy candy])).to eq(groupie.classify_text(%w[buy candy]))
end
end

0 comments on commit c8a02ad

Please sign in to comment.