washout_builder 0.11.1 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWZiZmRhMWU0MWU5NDk2YmQ4NTdkYTYxYjU3MmY2MmZlZWVhNTY0Ng==
4
+ MWJiN2YxMDQ0NDg1ZGY0N2U4Y2Q0NWM5MjE1MjMyMTJkMjM0NzM5Nw==
5
5
  data.tar.gz: !binary |-
6
- MGNhYzg3YjFhMmMwNzIzMjhiNTY1MzQxNDk5OGU5OTRmMmE4NGE1Nw==
6
+ NjUzYzA4YTc2MTBmOTg0ZDRkZWNlZDRkZWY5NzAzYmVjZmNiOTVjMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTg5NGZlYjJlMzhiZDJmMzY1NTRhNzhiYmJjZGM2MzA0YmViNzQ1ZjU5ZmYx
10
- ZDE0NjRmOGJlY2ZhMzdiMDA3YmM3MDJhZTVhZjlmY2Y0MDJmOWU4YzRmMDFj
11
- OTE3ODk2YjA4OGNiMDgzOGRlNDEzM2YwMGYyZjExN2RlODIxZjg=
9
+ NTk4YmY4Y2ZlYjhjOWYyNzBmOGFiM2I4MjU5NmUxMmUyYzM2MDQ3OGRlNTI0
10
+ ZGNhZjNjZjBjYmY1MmUyNDg0MGVlYTVlYmQ3Nzc4OWQzOGI0MGNmNmMzMzM0
11
+ MTY4NjUzYzEyNTIxZDRmNjU5NThmYmZjM2I1YTcwYjg4ZjFhMDQ=
12
12
  data.tar.gz: !binary |-
13
- MWY0YzhmYjllZTQzNWMxZWI2NjJhZTIzNzk5NGVkMWY5NjY0YmNjMTg2ZWY1
14
- OTJkMzg5MDg0MDkwYzJjMTU1YTg0NDIyOGI1ZTRjZjVkNWRkZjA3MzRhMWI4
15
- ZTg4MTNlOTc2YWQ3ZWMwOWFkZjlmYjAwMzc4NzQzNDRlZDMwZjQ=
13
+ MjNkMmNiY2I3MzY4YmMzZTM5MTE2NzgyZTU1YjlkMmRlYzBkMWY4MzUwODc3
14
+ ZjliYWZhZDU2ZTc4YjA2NjdiYWY2ZGM4ZWRlNzUzYmYwMTE1ZmVmNDBkMWFl
15
+ NmNjODYwNDlhOWVmYzQ1Y2JiN2NjN2JkMjlhZjc2MTcxNWU3OGE=
@@ -7,8 +7,4 @@ rvm:
7
7
  - jruby-19mode
8
8
  - 2.0.0
9
9
  env:
10
- - RAILS_ENV=test RACK_ENV=test
11
- branches:
12
- only:
13
- - master
14
- - develop
10
+ - RAILS_ENV=test RACK_ENV=test
@@ -1,4 +1,4 @@
1
- = washout_builder {<img src="https://travis-ci.org/bogdanRada/washout_builder.png" />}[https://travis-ci.org/bogdanRada/washout_builder] {<img src="https://badge.fury.io/rb/washout_builder.png" alt="Gem Version" />}[http://badge.fury.io/rb/washout_builder]
1
+ = washout_builder {<img src="https://travis-ci.org/bogdanRada/washout_builder.png?branch=master,develop" />}[https://travis-ci.org/bogdanRada/washout_builder] {<img src="https://badge.fury.io/rb/washout_builder.png" alt="Gem Version" />}[http://badge.fury.io/rb/washout_builder]
2
2
 
3
3
  = Overview
4
4
  WashOutBuilder is a Soap Service Documentation generator (extends WashOut https://github.com/inossidabile/wash_out/)
@@ -20,7 +20,7 @@ The way WashOut is used is not modified, it just extends its functionality by ge
20
20
 
21
21
  1. {Ruby 1.9.x or Ruby 2.0.x}[http://www.ruby-lang.org]
22
22
  2. {Ruby on Rails}[http://rubyonrails.org].
23
- 3. {WashOut Gem version >= 0.10.0.beta.1}[https://github.com/inossidabile/wash_out]
23
+ 3. {WashOut Gem version >= 0.9.1}[https://github.com/inossidabile/wash_out]
24
24
  4. {Virtus Gem}[https://github.com/solnic/virtus]
25
25
 
26
26
  = Compatibility
data/Rakefile CHANGED
@@ -7,8 +7,20 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
7
7
  # spec.rspec_opts = ['--backtrace ']
8
8
  end
9
9
 
10
+ #desc "Prepare dummy application"
11
+ #task :prepare do
12
+ # ENV["RAILS_ENV"] ||= 'test'
13
+ #
14
+ # require File.expand_path("./spec/dummy/config/environment", File.dirname(__FILE__))
15
+ # Dummy::Application.load_tasks
16
+ #
17
+ # Rake::Task["db:test:prepare"].invoke
18
+ #end
19
+
20
+
21
+
10
22
  desc "Default: run the unit tests."
11
- task :default => [:all]
23
+ task :default => [ :all]
12
24
 
13
25
  desc 'Test the plugin under all supported Rails versions.'
14
26
  task :all => ["appraisal:install"] do |t|
@@ -30,7 +30,7 @@ end
30
30
  Virtus::InstanceMethods::Constructor.class_eval do
31
31
  alias_method :original_initialize,:initialize
32
32
  def initialize(attributes = nil)
33
- if self.class.ancestors.detect{ |fault| WashoutBuilder::Type.get_fault_classes.include?(fault) }.present? or WashoutBuilder::Type.get_fault_classes.include?(self.class)
33
+ if self.class.ancestors.detect{ |fault| WashoutBuilder::Type.get_fault_classes.include?(fault) }.present? || WashoutBuilder::Type.get_fault_classes.include?(self.class)
34
34
  attributes = {:message => attributes} unless attributes.is_a?(Hash)
35
35
  end
36
36
  original_initialize(attributes)
@@ -40,13 +40,6 @@ end
40
40
 
41
41
  WashOut::Param.send :include, WashoutBuilder::Document::ComplexType
42
42
 
43
- if defined?(WashOut::Model)
44
- WashOut::Model.class_eval do
45
- def wash_out_param_name(*args)
46
- return name.underscore
47
- end
48
- end
49
- end
50
43
 
51
44
  WashoutBuilder::Type.get_fault_classes.each do |exception_class|
52
45
  exception_class.class_eval do
@@ -37,7 +37,7 @@ module WashoutBuilder
37
37
  def fix_descendant_wash_out_type(config, complex_class)
38
38
  param_class = complex_class.is_a?(Class) ? complex_class : complex_class.constantize rescue nil
39
39
  if !param_class.nil? && param_class.ancestors.include?(WashOut::Type) && !map[0].nil?
40
- descendant = WashOut::Param.parse_def(config, param_class.wash_out_param_map)[0]
40
+ descendant = WashOut::Param.parse_builder_def(config, param_class.wash_out_param_map)[0]
41
41
  self.name = descendant.name
42
42
  self.map = descendant.map
43
43
  end
@@ -1,3 +1,3 @@
1
1
  module WashoutBuilder
2
- VERSION = "0.11.1"
2
+ VERSION = "0.11.2"
3
3
  end
@@ -1,8 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe WashoutBuilderController do
3
+
4
+ describe WashoutBuilderController, :type => :controller do
5
+
6
+ let(:soap_config) { OpenStruct.new(
7
+ camelize_wsdl: false,
8
+ namespace: "/api/wsdl",
9
+ ) }
4
10
 
11
+ before(:each) do
12
+ ApiController.stubs(:soap_config).returns(soap_config)
13
+ end
14
+
15
+ it "gets the services" do
16
+ get :all
17
+ assigns(:services).should eq([{"service_name"=>"Api", "namespace"=>"/api/wsdl", "endpoint"=>"/api/action", "documentation_url"=>"http://test.host/api/doc"}])
18
+ end
5
19
 
6
20
 
21
+ it "renders the template" do
22
+ get :all
23
+ response.should render_template("wash_with_html/all_services")
24
+ end
7
25
 
26
+
8
27
  end
@@ -5,7 +5,7 @@ mock_controller do
5
5
  soap_action 'dispatcher_method', :args => nil, :return => nil
6
6
 
7
7
  def dispatcher_method
8
- raise SOAPError.new("some message", 1001)
8
+ #nothing
9
9
  end
10
10
  end
11
11
 
@@ -23,9 +23,17 @@ describe ApiController, :type => :controller do
23
23
  WashoutBuilder::Document::Generator.expects(:new).with(
24
24
  :config => ApiController.soap_config,
25
25
  :service_class => ApiController,
26
- :soap_actions => {'dispatcher_method' =>
27
- {:args => nil, :return => nil, :in => [], :out => [],:builder_in => [], :builder_out => [], :to => 'dispatcher_method'}
28
- }
26
+ :soap_actions => {"dispatcher_method"=>{
27
+ :args=>nil,
28
+ :return=>nil,
29
+ :in=>[],
30
+ :out=>[],
31
+ :to=>"dispatcher_method",
32
+ :response_tag=>"tns:dispatcher_methodResponse",
33
+ :builder_in=>[],
34
+ :builder_out=>[]
35
+ }
36
+ }
29
37
  )
30
38
  get :_generate_doc
31
39
  end
@@ -0,0 +1,61 @@
1
+ #encoding:utf-8
2
+ require 'spec_helper'
3
+
4
+
5
+ describe WashoutBuilder::Document::ComplexType do
6
+ let(:soap_config) { OpenStruct.new(
7
+ camelize_wsdl: false,
8
+ namespace: "/api/wsdl",
9
+ description: "some description"
10
+ ) }
11
+
12
+ def get_wash_out_param(class_name_or_structure, soap_config = soap_config)
13
+ WashOut::Param.parse_builder_def(soap_config, class_name_or_structure)[0]
14
+ end
15
+
16
+ let(:subject) { get_wash_out_param(ProjectType) }
17
+ let(:namespaced_object) { get_wash_out_param(Api::TestType) }
18
+
19
+ it "returns the complex class name" do
20
+ subject.get_complex_class_name.should eq("ProjectType")
21
+ end
22
+
23
+
24
+ it "returns the complex class name" do
25
+ subject.get_complex_class_name.should eq("ProjectType")
26
+ end
27
+
28
+
29
+ it "returns the complex class with namespace" do
30
+ namespaced_object.get_complex_class_name.should eq("Api::TestType")
31
+ end
32
+
33
+
34
+ it "returns error if classname already detected (only used for hashes)" do
35
+ subject.stubs(:classified?).returns(false)
36
+ subject.stubs(:basic_type).returns("ProjectType")
37
+ defined = [ { :class= => "ProjectType" }]
38
+ defined.stubs(:detect).returns({:class => "ProjectType"})
39
+ expect {subject.get_complex_class_name(defined) }.to raise_error(RuntimeError, "Duplicate use of `ProjectType` type name. Consider using classified types.")
40
+ end
41
+
42
+ it "returns the param structure" do
43
+ subject.get_param_structure.should eq({"project"=>"struct"})
44
+ end
45
+
46
+ it "fixes the first descendant " do
47
+ descendant = get_wash_out_param(ProjectType.wash_out_param_map)
48
+ subject.fix_descendant_wash_out_type(soap_config, ProjectType)
49
+ subject.name.should eq(descendant.name)
50
+ subject.map[0].get_param_structure.should eq(descendant.map[0].get_param_structure)
51
+ end
52
+
53
+ it "same as ancestor" do
54
+ subject.get_ancestors(ProjectType).should eq([])
55
+ end
56
+
57
+
58
+
59
+
60
+
61
+ end
@@ -0,0 +1,35 @@
1
+ #encoding:utf-8
2
+ require 'spec_helper'
3
+
4
+ class SOAPError < WashOut::Dispatcher::SOAPError
5
+
6
+ end
7
+
8
+ describe WashoutBuilder::Document::VirtusModel do
9
+
10
+ let(:subject) { SOAPError}
11
+
12
+
13
+
14
+ it "gets the strcuture" do
15
+ 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}})
16
+ end
17
+
18
+ it "gets the member type for arrays" do
19
+ subject.get_virtus_member_type_primitive({:primitive=>"Array", :member_type=>"SomeInexistentClass"}).should eq("SomeInexistentClass")
20
+ end
21
+
22
+ it "gets the member type for clasified types" do
23
+ subject.get_virtus_member_type_primitive({:primitive=>"SomeInexistentClass", :member_type=>nil}).should eq("SomeInexistentClass")
24
+ end
25
+
26
+ it "returns nil because is not a classified object" do
27
+ subject.get_virtus_member_type_primitive({:primitive=>"integer", :member_type=>nil}).should eq(nil)
28
+ end
29
+
30
+
31
+ it "gets the strcuture" do
32
+ subject.remove_fault_type_inheritable_elements(["code"]).should eq({ "message"=>{:primitive=>"String", :member_type=>nil}, "backtrace"=>{:primitive=>"String", :member_type=>nil}})
33
+ end
34
+
35
+ end
@@ -5,10 +5,10 @@ require 'spec_helper'
5
5
  describe WashoutBuilder do
6
6
 
7
7
  before(:each) do
8
- WashOut::Rails::Engine.config.wash_out[:wsdl_style] = 'rpc'
9
- WashOut::Rails::Engine.config.wash_out[:parser] = :nokogiri
10
- WashOut::Rails::Engine.config.wash_out[:catch_xml_errors] = true
11
- WashOut::Rails::Engine.config.wash_out[:camelize_wsdl] = "lower"
8
+ WashOut::Engine.config.wash_out[:wsdl_style] = 'rpc'
9
+ WashOut::Engine.config.wash_out[:parser] = :nokogiri
10
+ WashOut::Engine.config.wash_out[:catch_xml_errors] = true
11
+ WashOut::Engine.config.wash_out[:camelize_wsdl] = "lower"
12
12
  end
13
13
 
14
14
  let :nori do
@@ -558,12 +558,12 @@ describe WashoutBuilder do
558
558
  end
559
559
 
560
560
  lambda { savon(:bad) }.should raise_exception(
561
- WashOut::ProgrammerError,
561
+ WashOut::Dispatcher::ProgrammerError,
562
562
  /SOAP response .*wyldness.*Array.*Hash.*stallion/
563
563
  )
564
564
 
565
565
  lambda { savon(:bad2) }.should raise_exception(
566
- WashOut::ProgrammerError,
566
+ WashOut::Dispatcher::ProgrammerError,
567
567
  /SOAP response .*oops.*String.*telephone_booths.*Array/
568
568
  )
569
569
  end
@@ -571,7 +571,7 @@ describe WashoutBuilder do
571
571
  context "custom exceptions" do
572
572
  let(:error_message) { "some message" }
573
573
  let(:error_code) { 1001 }
574
- let(:soap_exception) { SOAPError.new(error_message,error_code) }
574
+ let(:soap_exception) { WashOut::Dispatcher::SOAPError.new(error_message,error_code) }
575
575
 
576
576
  before(:each) do
577
577
  # Savon::Response.raise_errors = false
@@ -582,7 +582,7 @@ describe WashoutBuilder do
582
582
  soap_action 'bad', :args => nil, :return => nil
583
583
 
584
584
  def bad
585
- raise SOAPError.new("some message", 1001)
585
+ raise WashOut::Dispatcher::SOAPError.new("some message", 1001)
586
586
  end
587
587
  end
588
588
 
@@ -1,4 +1,4 @@
1
- class AnotherException < SOAPError
1
+ class AnotherException < WashOut::Dispatcher::SOAPError
2
2
 
3
3
  attribute :ex3_name, String
4
4
  attribute :ex3_id, Integer
@@ -1,4 +1,4 @@
1
- class Custom2 < WashOut::SOAPError
1
+ class Custom2 < WashOut::Dispatcher::SOAPError
2
2
 
3
3
  attribute :ex2_name, String
4
4
  attribute :ex2_id, Integer
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: washout_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada