1# 2# Licensed to the Apache Software Foundation (ASF) under one 3# or more contributor license agreements. See the NOTICE file 4# distributed with this work for additional information 5# regarding copyright ownership. The ASF licenses this file 6# to you under the Apache License, Version 2.0 (the 7# "License"); you may not use this file except in compliance 8# with the License. You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, 13# software distributed under the License is distributed on an 14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15# KIND, either express or implied. See the License for the 16# specific language governing permissions and limitations 17# under the License. 18# 19 20require 'spec_helper' 21 22describe 'namespaced generation' do 23 before do 24 require 'namespaced_spec_namespace/namespaced_nonblocking_service' 25 end 26 27 it "generated the right files" do 28 prefix = File.expand_path("../gen-rb", __FILE__) 29 ["namespaced_spec_namespace/namespaced_nonblocking_service.rb", 30 "namespaced_spec_namespace/thrift_namespaced_spec_constants.rb", 31 "namespaced_spec_namespace/thrift_namespaced_spec_types.rb", 32 "other_namespace/referenced_constants.rb", 33 "other_namespace/referenced_types.rb" 34 ].each do |name| 35 expect(File.exist?(File.join(prefix, name))).to be_truthy 36 end 37 end 38 39 it "did not generate the wrong files" do 40 prefix = File.expand_path("../gen-rb", __FILE__) 41 ["namespaced_nonblocking_service.rb", 42 "thrift_namespaced_spec_constants.rb", 43 "thrift_namespaced_spec_types.rb", 44 "referenced_constants.rb", 45 "referenced_types.rb" 46 ].each do |name| 47 expect(File.exist?(File.join(prefix, name))).not_to be_truthy 48 end 49 end 50 51 it "has a service class in the right place" do 52 expect(defined?(NamespacedSpecNamespace::NamespacedNonblockingService)).to be_truthy 53 end 54 55 it "has a struct in the right place" do 56 expect(defined?(NamespacedSpecNamespace::Hello)).to be_truthy 57 end 58 59 it "required an included file" do 60 expect(defined?(OtherNamespace::SomeEnum)).to be_truthy 61 end 62 63 it "extended a service" do 64 require "extended/extended_service" 65 end 66 67end 68