require 'helix_web_services_client/open_model' describe OpenModel do it 'can find a method with the captialized version of the symbol' do model = OpenModel.new({ 'Depot' => 'test_name' }) expect(model.depot).to eq('test_name') end it 'can match a snake_case name with snakeCase' do model = OpenModel.new({'depotFile' => 'test_file'}) expect(model.depot_file).to eq('test_file') end it 'can find alternatives using [name]_or_[name]' do model = OpenModel.new({'Rev' => '1234'}) expect(model.rev_or_revision).to eq('1234') model = OpenModel.new({'Revision' => '1234'}) expect(model.rev_or_revision).to eq('1234') end it 'can convert numeric-style strings to Time via [name]_as_time' do model = OpenModel.new({Update: '1437153920'}) expect(model.update_as_time).to be_a_kind_of(Time) end it 'can convert string dates to Time via [name]_as_time(offset)' do model = OpenModel.new({Update: '2015/07/17 10:25:20'}) t = model.update_as_time('-0700 PDT') expect(t).to be_a_kind_of(Time) expect(t.year).to eq(2015) end end