Skip to content

Commit

Permalink
Merge branch 'release/v0.11.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanRada committed Dec 24, 2013
2 parents 603d78f + a55d333 commit 3fcecaa
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 4 deletions.
14 changes: 13 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
# spec.rspec_opts = ['--backtrace ']
end

#desc "Prepare dummy application"
#task :prepare do
# ENV["RAILS_ENV"] ||= 'test'
#
# require File.expand_path("./spec/dummy/config/environment", File.dirname(__FILE__))
# Dummy::Application.load_tasks
#
# Rake::Task["db:test:prepare"].invoke
#end



desc "Default: run the unit tests."
task :default => [:all]
task :default => [ :all]

desc 'Test the plugin under all supported Rails versions.'
task :all => ["appraisal:install"] do |t|
Expand Down
2 changes: 1 addition & 1 deletion lib/washout_builder/document/complex_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def remove_type_inheritable_elements( keys)
def fix_descendant_wash_out_type(config, complex_class)
param_class = complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil
if !param_class.nil? && param_class.ancestors.include?(WashOut::Type) && !map[0].nil?
descendant = WashOut::Param.parse_def(config, param_class.wash_out_param_map)[0]
descendant = WashOut::Param.parse_builder_def(config, param_class.wash_out_param_map)[0]
self.name = descendant.name
self.map = descendant.map
end
Expand Down
2 changes: 1 addition & 1 deletion lib/washout_builder/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module WashoutBuilder
VERSION = "0.11.1"
VERSION = "0.11.2"
end
21 changes: 20 additions & 1 deletion spec/app/controllers/washout_builder_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
require 'spec_helper'

describe WashoutBuilderController do

describe WashoutBuilderController, :type => :controller do

let(:soap_config) { OpenStruct.new(
camelize_wsdl: false,
namespace: "/api/wsdl",
) }

before(:each) do
ApiController.stubs(:soap_config).returns(soap_config)
end

it "gets the services" do
get :all
assigns(:services).should eq([{"service_name"=>"Api", "namespace"=>"/api/wsdl", "endpoint"=>"/api/action", "documentation_url"=>"http://test.host/api/doc"}])
end


it "renders the template" do
get :all
response.should render_template("wash_with_html/all_services")
end


end
61 changes: 61 additions & 0 deletions spec/lib/washout_builder/document/complex_type_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#encoding:utf-8
require 'spec_helper'


describe WashoutBuilder::Document::ComplexType do
let(:soap_config) { OpenStruct.new(
camelize_wsdl: false,
namespace: "/api/wsdl",
description: "some description"
) }

def get_wash_out_param(class_name_or_structure, soap_config = soap_config)
WashOut::Param.parse_builder_def(soap_config, class_name_or_structure)[0]
end

let(:subject) { get_wash_out_param(ProjectType) }
let(:namespaced_object) { get_wash_out_param(Api::TestType) }

it "returns the complex class name" do
subject.get_complex_class_name.should eq("ProjectType")
end


it "returns the complex class name" do
subject.get_complex_class_name.should eq("ProjectType")
end


it "returns the complex class with namespace" do
namespaced_object.get_complex_class_name.should eq("Api::TestType")
end


it "returns error if classname already detected (only used for hashes)" do
subject.stubs(:classified?).returns(false)
subject.stubs(:basic_type).returns("ProjectType")
defined = [ { :class= => "ProjectType" }]
defined.stubs(:detect).returns({:class => "ProjectType"})
expect {subject.get_complex_class_name(defined) }.to raise_error(RuntimeError, "Duplicate use of `ProjectType` type name. Consider using classified types.")
end

it "returns the param structure" do
subject.get_param_structure.should eq({"project"=>"struct"})
end

it "fixes the first descendant " do
descendant = get_wash_out_param(ProjectType.wash_out_param_map)
subject.fix_descendant_wash_out_type(soap_config, ProjectType)
subject.name.should eq(descendant.name)
subject.map[0].get_param_structure.should eq(descendant.map[0].get_param_structure)
end

it "same as ancestor" do
subject.get_ancestors(ProjectType).should eq([])
end





end
35 changes: 35 additions & 0 deletions spec/lib/washout_builder/document/virtus_model_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#encoding:utf-8
require 'spec_helper'

class SOAPError < WashOut::Dispatcher::SOAPError

end

describe WashoutBuilder::Document::VirtusModel do

let(:subject) { SOAPError}



it "gets the strcuture" do
subject.get_virtus_model_structure.should eq({"code"=>{:primitive=>"Integer", :member_type=>nil}, "message"=>{:primitive=>"String", :member_type=>nil}, "backtrace"=>{:primitive=>"String", :member_type=>nil}})
end

it "gets the member type for arrays" do
subject.get_virtus_member_type_primitive({:primitive=>"Array", :member_type=>"SomeInexistentClass"}).should eq("SomeInexistentClass")
end

it "gets the member type for clasified types" do
subject.get_virtus_member_type_primitive({:primitive=>"SomeInexistentClass", :member_type=>nil}).should eq("SomeInexistentClass")
end

it "returns nil because is not a classified object" do
subject.get_virtus_member_type_primitive({:primitive=>"integer", :member_type=>nil}).should eq(nil)
end


it "gets the strcuture" do
subject.remove_fault_type_inheritable_elements(["code"]).should eq({ "message"=>{:primitive=>"String", :member_type=>nil}, "backtrace"=>{:primitive=>"String", :member_type=>nil}})
end

end

0 comments on commit 3fcecaa

Please sign in to comment.