Sha256: 4a39c5b4ebd59bb0dc97e535135581a2ceb408be185b7b7b356ae2cc38e669a0
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require 'spec_helper' require 'windcharger/hash_transformer' describe Windcharger::HashTransformer do describe "#transform" do it "returns a hash with attribute names as keys and their method results as values" do transformer_class = Class.new do extend Windcharger::Attributes include Windcharger::HashTransformer attribute def foo; 42; end attribute def bar; 'colorless green ideas'; end def baz; end end transformer = transformer_class.new expect(transformer.transform).to eq({ foo: 42, bar: 'colorless green ideas', }) end it "does not call private methods" do transformer_class = Class.new do extend Windcharger::Attributes include Windcharger::HashTransformer private attribute def foo; 42; end end transformer = transformer_class.new expect { transformer.transform }.to raise_error NoMethodError, /private/ end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
windcharger-0.4.0 | spec/windcharger/hash_transformer_spec.rb |