Access data from a hash via dot notation.
require 'ostruct'
it 'should response to .color' do
# hash
car = { color: 'red', top_speed: 180, make: 'Porsche'}
# structure
car_structure = OpenStruct.new(car)
expect(car_structure).to respond_to(:color)
en
output$: .
output$: 1 Test Passing
Written by Rob Guilfoyle
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#