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
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15741 | ptomiak | Branch HWS for my use. | ||
//guest/perforce_software/helix-web-services/main/source/helix_web_services_client/spec/open_model_spec.rb | |||||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services_client/spec/open_model_spec.rb | |||||
#2 | 15185 | tjuricek | Update user spec management implementation, tests, and documentation. | ||
#1 | 15077 | tjuricek |
Add new 'model' technique, revised branch spec operations, test Auth::Middleware. The Ruby client now does *not* strictly type anything, but extends OpenStruct with helper methods to help deal with inconsistent data formats. See the OpenModel class documentation for more details. The Auth::Middleware class is also *finally* implemented as well. This does not take into account all possible variations of server behavior (yet), but that will happen in follow-up work. |