Last Updated: February 25, 2016
·
1.622K
· robguilfoyle

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