github.com/phrase/openapi@v0.0.0-20240514140800-49e8a106740e/openapi-generator/templates/ruby-client/model_test.mustache (about) 1 require 'spec_helper' 2 require 'json' 3 require 'date' 4 5 # Unit tests for {{moduleName}}::{{classname}} 6 # Automatically generated by openapi-generator (https://openapi-generator.tech) 7 # Please update as you see appropriate 8 {{#models}} 9 {{#model}} 10 describe '{{classname}}' do 11 before do 12 # run before each test 13 @instance = {{moduleName}}::{{classname}}.new 14 end 15 16 after do 17 # run after each test 18 end 19 20 describe 'test an instance of {{classname}}' do 21 it 'should create an instance of {{classname}}' do 22 expect(@instance).to be_instance_of({{moduleName}}::{{classname}}) 23 end 24 end 25 {{#vars}} 26 describe 'test attribute "{{{name}}}"' do 27 it 'should work' do 28 {{#isEnum}} 29 # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers 30 # validator = Petstore::EnumTest::EnumAttributeValidator.new('{{{dataType}}}', [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]) 31 # validator.allowable_values.each do |value| 32 # expect { @instance.{{name}} = value }.not_to raise_error 33 # end 34 {{/isEnum}} 35 {{^isEnum}} 36 # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers 37 {{/isEnum}} 38 end 39 end 40 41 {{/vars}} 42 end 43 {{/model}} 44 {{/models}}