diff --git a/app/helpers/washout_builder_method_list_helper.rb b/app/helpers/washout_builder_method_list_helper.rb
index 6235ed6..cb82648 100644
--- a/app/helpers/washout_builder_method_list_helper.rb
+++ b/app/helpers/washout_builder_method_list_helper.rb
@@ -9,18 +9,16 @@ def create_return_complex_type_list_html(xml, complex_class, builder_out)
def create_return_type_list_html(xml, output)
- unless output.nil?
+ if output.nil?
+ xml.span("class" => "pre") { |sp| sp << "void" }
+ else
complex_class = output[0].get_complex_class_name
if WashoutBuilder::Type::BASIC_TYPES.include?(output[0].type)
xml.span("class" => "pre") { |xml| xml.span("class" => "blue") { |sp| sp << "#{output[0].type}" } }
else
create_return_complex_type_html(xml, complex_class, output) unless complex_class.nil?
end
- else
- xml.span("class" => "pre") { |sp| sp << "void" }
end
-
-
end
-end
\ No newline at end of file
+end
diff --git a/app/helpers/washout_builder_method_return_type_helper.rb b/app/helpers/washout_builder_method_return_type_helper.rb
index cea18c4..b85757b 100644
--- a/app/helpers/washout_builder_method_return_type_helper.rb
+++ b/app/helpers/washout_builder_method_return_type_helper.rb
@@ -6,8 +6,10 @@ def create_html_public_method_return_type(xml,pre, output)
if WashoutBuilder::Type::BASIC_TYPES.include?(output[0].type)
xml.span("class" => "blue") { |y| y<< "#{output[0].type}" }
else
- complex_return_type = output[0].multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
- pre << "#{complex_return_type}" unless complex_class.nil?
+ unless complex_class.nil?
+ complex_return_type = output[0].multiplied == false ? "#{complex_class}" : "Array of #{complex_class}"
+ pre << "#{complex_return_type}"
+ end
end
else
pre << "void"
diff --git a/spec/app/helpers/washout_builder_complex_type_helper_spec.rb b/spec/app/helpers/washout_builder_complex_type_helper_spec.rb
index c3b8402..779e709 100644
--- a/spec/app/helpers/washout_builder_complex_type_helper_spec.rb
+++ b/spec/app/helpers/washout_builder_complex_type_helper_spec.rb
@@ -1,12 +1,86 @@
require 'spec_helper'
-describe WashoutBuilderComplexTypeHelper do
+describe WashoutBuilderComplexTypeHelper, :type => :helper do
- describe '#create_element_type_html' do
+ context '#create_element_type_html' do
+ let (:pre) { [] }
+ let(:element_name) {"custom_name"}
+ let(:element) {mock}
+ before(:each) do
+ element.stubs(:type).returns("text")
+ element.stubs(:type=).with("string")
+ element.stubs(:name).returns(element_name)
+ end
+ def expect_included_type_result(pre, element)
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(element.type).returns(true)
+ result =helper.create_element_type_html(pre, element)
+ result.should eq(["#{element.type} #{element.name}"])
+ end
+
+ def expect_excluded_type_result(pre, element)
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(element.type).returns(false)
+ helper.expects(:create_complex_element_type_html).with(pre, element)
+ helper.create_element_type_html(pre, element)
+ end
+
+
+ it "returns the element of type text" do
+ element.expects(:type=).with("string")
+ expect_included_type_result(pre, element)
+ end
+
+ it "returns the element of type text" do
+ expect_excluded_type_result(pre, element)
+ end
+
+ it "returns the element of type integer" do
+ element.stubs(:type).returns("int")
+ element.expects(:type=).with("integer")
+ expect_included_type_result(pre, element)
+ end
+
+ it "returns the element of type integer" do
+ element.stubs(:type).returns("int")
+ element.expects(:type=).with("integer")
+ expect_excluded_type_result(pre, element)
+ end
+
+
+ end
+
+
+ context "create_complex_element_type_html" do
+ let (:pre) { [] }
+ let(:element_name) {"custom_name"}
+ let(:complex_class) {"SomeClass"}
+ let(:element) {mock}
+
+ before(:each) do
+ element.stubs(:get_complex_class_name).returns(complex_class)
+ element.stubs(:multiplied).returns(false)
+ element.stubs(:name).returns(element_name)
+ end
+
+ it "returna simple type element description" do
+ result = helper.create_complex_element_type_html(pre, element)
+ result.should eq(["#{complex_class} #{element.name}"])
+ end
+
+ it "returns an array type element description" do
+ element.stubs(:multiplied).returns(true)
+ result = helper.create_complex_element_type_html(pre, element)
+ result.should eq(["Array of #{complex_class} #{element.name}"])
+ end
+
+ it "returns empty if no complex class" do
+ element.stubs(:get_complex_class_name).returns(nil)
+ result = helper.create_complex_element_type_html(pre, element)
+ result.should eq(nil)
+ end
end
-end
\ No newline at end of file
+end
diff --git a/spec/app/helpers/washout_builder_fault_type_helper_spec.rb b/spec/app/helpers/washout_builder_fault_type_helper_spec.rb
new file mode 100644
index 0000000..a165c6c
--- /dev/null
+++ b/spec/app/helpers/washout_builder_fault_type_helper_spec.rb
@@ -0,0 +1,139 @@
+require "spec_helper"
+
+describe WashoutBuilderFaultTypeHelper, :type => :helper do
+
+ context " create_fault_model_complex_element_type" do
+ let(:pre) { [] }
+ let(:attr_primitive){ "string"}
+ let(:attribute) {"custom_attribute"}
+
+ def check_result(array)
+ attribute_primitive = array == true ? "Array of #{attr_primitive}" : "#{attr_primitive}"
+ result = helper. create_fault_model_complex_element_type(pre, attr_primitive, attribute, array)
+ result.should eq([" #{attribute_primitive} #{attribute}"])
+ end
+
+ it "creates an array element " do
+ check_result(true)
+ end
+ it "creates an simple element " do
+ check_result(false)
+ end
+ end
+
+ context "member_type_is_basic?" do
+
+ it "returns a basic type" do
+ attr_details = {:member_type => "STRING"}
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(attr_details[:member_type].to_s.downcase).returns(true)
+ result = helper.member_type_is_basic?(attr_details)
+ result.should eq(attr_details[:member_type].to_s.downcase)
+ end
+
+ it "returns a non-basic type" do
+ attr_details = {:member_type => "STRING" }
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(attr_details[:member_type].to_s.downcase).returns(false)
+ result = helper.member_type_is_basic?(attr_details)
+ result.should eq(attr_details[:member_type])
+ end
+
+ end
+
+ context "primitive_type_is_basic?" do
+
+ it "returns true" do
+ attr_details = {:primitive => "STRING"}
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(attr_details[:primitive].to_s.downcase).returns(true)
+ helper.primitive_type_is_basic?(attr_details).should eq(true)
+ end
+
+ it "returns false" do
+ attr_details = {:primitive => "STRING"}
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(attr_details[:primitive].to_s.downcase).returns(false)
+ helper.primitive_type_is_basic?(attr_details).should eq(false)
+ end
+
+ end
+
+ context "get_primitive_type_string" do
+
+ ["NILCLASS", "nilclass"].each do |primitive|
+ it "returns string in case of nilclass" do
+ attr_details = {:primitive => primitive}
+ helper.get_primitive_type_string(attr_details).should eq("string")
+ end
+ end
+
+ ["BLA", "bla"].each do |primitive|
+ it "returns the primitive if not niclass" do
+ attr_details = {:primitive => primitive}
+ helper.get_primitive_type_string(attr_details).should eq(primitive.to_s.downcase)
+ end
+ end
+
+ end
+
+ context "get_member_type_string" do
+
+ ["Array", "array"].each do |primitive|
+ it "checks the member type to be basic if primitive type array" do
+ attr_details = {:primitive => primitive}
+ helper.expects(:member_type_is_basic?).with(attr_details).returns(true)
+ helper.get_member_type_string(attr_details).should eq(true)
+ end
+ end
+
+
+ ["BLA", "Bla", "bla"].each do |primitive|
+ it "returns the primitive type as it is if not array" do
+ attr_details = {:primitive => primitive}
+ helper.get_member_type_string(attr_details).should eq(primitive)
+ end
+ end
+
+ end
+
+ context "create_html_fault_model_element_type" do
+ let(:pre) {[]}
+ let(:attribute) {"some_attribute"}
+
+ before(:each) do
+ helper.stubs(:primitive_type_is_basic?).returns(false)
+ end
+
+ def expect_type_string_elem_type(attr_details)
+ type_string = "string"
+ helper.expects(:get_primitive_type_string).with(attr_details).returns(type_string)
+ result =helper.create_html_fault_model_element_type(pre, attribute, attr_details)
+ result.should eq([ "#{type_string} #{attribute}"])
+ end
+
+ it "returns the string element if primitive type is nilclass" do
+ attr_details = {:primitive => "nilclass"}
+ expect_type_string_elem_type(attr_details)
+ end
+
+ ["NILCLASS", "Nilclass", "BLA"].each do |primitive|
+ it "returns the string type is primitive is basic but not nilclass" do
+ attr_details = {:primitive => primitive}
+ helper.expects(:primitive_type_is_basic?).with(attr_details).returns(true)
+ expect_type_string_elem_type(attr_details)
+ end
+ end
+
+ ["NILCLASS", "Nilclass", "BLA"].each do |primitive|
+ it "returns the complex type if not basic and not nilclass" do
+ attr_details = {:primitive => primitive}
+ member_type = "SomeMemberType"
+ expected= "Some expected string"
+ helper.expects(:primitive_type_is_basic?).with(attr_details).returns(false)
+ helper.expects(:get_member_type_string).with(attr_details).returns(member_type)
+ helper.expects(:create_fault_model_complex_element_type).with(pre, member_type, attribute, true ).returns(expected)
+ result =helper.create_html_fault_model_element_type(pre, attribute, attr_details)
+ result.should eq(expected)
+ end
+ end
+
+ end
+
+end
diff --git a/spec/app/helpers/washout_builder_method_arguments_helper_spec.rb b/spec/app/helpers/washout_builder_method_arguments_helper_spec.rb
new file mode 100644
index 0000000..0b6d954
--- /dev/null
+++ b/spec/app/helpers/washout_builder_method_arguments_helper_spec.rb
@@ -0,0 +1,108 @@
+require 'spec_helper'
+
+describe WashoutBuilderMethodArgumentsHelper, :type => :helper do
+ let!(:xml) { Builder::XmlMarkup.new}
+
+ context "create_method_argument_element" do
+ let(:spacer) { " "}
+ let(:pre){[]}
+ let(:param){ mock}
+ let(:complex_class) {"SomeComplexClass"}
+ let(:param_type) {"string"}
+ let(:param_name) {"some_param_name"}
+
+ before(:each) do
+ param.stubs(:get_complex_class_name).returns(complex_class)
+ param.stubs(:type).returns(param_type)
+ param.stubs(:name).returns(param_name)
+ end
+
+ def expect_method_arg_basic_type(mlen)
+ use_spacer = mlen > 1 ? true : false
+ result = helper.create_method_argument_element( pre, param, mlen)
+ result.should eq(["#{use_spacer ? spacer: ''}#{param.type} #{param.name}"])
+ end
+
+ [0, 1 , 2, 3, 4].each do |mlen|
+ it "returns a basic type" do
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(param.type).returns(true)
+ expect_method_arg_basic_type(mlen)
+ end
+ end
+
+ [0, 1 , 2, 3, 4].each do |mlen|
+ it "returns array of complex type" do
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(param.type).returns(false)
+ param.expects(:multiplied).returns(true)
+ use_spacer = mlen > 1 ? true : false
+ result = helper.create_method_argument_element( pre, param, mlen)
+ result.should eq( ["#{use_spacer ? spacer: ''}Array of #{complex_class} #{param.name}"])
+ end
+ end
+
+ [0, 1 , 2, 3, 4].each do |mlen|
+ it "returns simple complex type" do
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(param.type).returns(false)
+ param.expects(:multiplied).returns(false)
+ use_spacer = mlen > 1 ? true : false
+ result = helper.create_method_argument_element( pre, param, mlen)
+ result.should eq( ["#{use_spacer ? spacer: ''}#{complex_class} #{param.name}"])
+ end
+ end
+
+
+ end
+
+ context "create_argument_element_spacer" do
+
+ it "returns only the ) in bold " do
+ result = helper.create_argument_element_spacer(xml, 0, 1)
+ xml.target!.should eq(")")
+ end
+
+ it "returns only the span with comma" do
+ result = helper.create_argument_element_spacer(xml, -2, 1)
+ xml.target!.should eq(", ")
+ end
+
+ it "returns only the span with comma and a break " do
+ result = helper.create_argument_element_spacer(xml, 1, 3)
+ xml.target!.should eq(",
")
+ end
+
+ it "returns a break and a ) sign " do
+ result = helper.create_argument_element_spacer(xml, 2, 3)
+ xml.target!.should eq("
)")
+ end
+
+ [3, 4, 4, 5, 6].each do |j_value|
+ it "returns only the span with comma " do
+ result = helper.create_argument_element_spacer(xml, j_value, 3)
+ xml.target!.should eq("
")
+ end
+ end
+
+
+
+ end
+
+ context "create_html_public_method_arguments" do
+ let(:pre) {[]}
+ let(:element) {mock}
+ let(:second_element){mock}
+
+ it "returns only the span with comma " do
+ input = [element, second_element]
+
+ helper.stubs(:create_method_argument_element).returns("bla")
+ helper.stubs(:create_argument_element_spacer).returns("blabla")
+ result = helper. create_html_public_method_arguments(xml, pre, input)
+ xml.target!.should eq("
")
+ end
+
+ end
+
+
+
+
+end
diff --git a/spec/app/helpers/washout_builder_method_list_helper_spec.rb b/spec/app/helpers/washout_builder_method_list_helper_spec.rb
new file mode 100644
index 0000000..4ae6137
--- /dev/null
+++ b/spec/app/helpers/washout_builder_method_list_helper_spec.rb
@@ -0,0 +1,65 @@
+require 'spec_helper'
+
+describe WashoutBuilderMethodListHelper, :type => :helper do
+ let!(:xml) { Builder::XmlMarkup.new}
+
+
+ context "create_return_complex_type_list_html" do
+ let(:complex_class) {"SomeComplexClass"}
+ let (:builder_elem) {mock}
+ let(:builder_out) {[builder_elem]}
+
+ it "returns simple type " do
+ builder_elem.expects(:multiplied).returns(false)
+ result = helper.create_return_complex_type_list_html(xml, complex_class, builder_out)
+ result.should eq("SomeComplexClass")
+ end
+
+ it "returns array type " do
+ builder_elem.expects(:multiplied).returns(true)
+ result = helper.create_return_complex_type_list_html(xml, complex_class, builder_out)
+ result.should eq("Array of SomeComplexClass")
+ end
+
+ end
+
+
+ context "create_return_type_list_html" do
+ let(:complex_class) {"SomeComplexClass"}
+ let (:builder_elem) {mock}
+ let(:output) {[builder_elem]}
+ let(:type) {"string"}
+
+ before(:each) do
+ builder_elem.stubs(:get_complex_class_name).returns(complex_class)
+ builder_elem.stubs(:type).returns(type)
+ end
+
+ it "returns void for nil" do
+ helper.create_return_type_list_html(xml, nil)
+ xml.target!.should eq("void")
+ end
+
+ it "returns basic type" do
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(true)
+ helper.create_return_type_list_html(xml, output)
+ xml.target!.should eq("string")
+ end
+ it "returns complex type" do
+ expected ="some expected string"
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
+ helper.expects(:create_return_complex_type_html).with(instance_of(Builder::XmlMarkup), complex_class, output).returns(expected)
+ result = helper.create_return_type_list_html(xml, output)
+ result.should eq(expected)
+ end
+
+ it "returns nil if complex class is nil" do
+ builder_elem.stubs(:get_complex_class_name).returns(nil)
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
+ result = helper.create_return_type_list_html(xml, output)
+ result.should eq(nil)
+ end
+
+ end
+
+end
diff --git a/spec/app/helpers/washout_builder_method_return_type_helper_spec.rb b/spec/app/helpers/washout_builder_method_return_type_helper_spec.rb
new file mode 100644
index 0000000..22dce5c
--- /dev/null
+++ b/spec/app/helpers/washout_builder_method_return_type_helper_spec.rb
@@ -0,0 +1,52 @@
+require "spec_helper"
+
+describe WashoutBuilderMethodReturnTypeHelper, :type => :helper do
+ let!(:xml) { Builder::XmlMarkup.new}
+ let(:pre) {[]}
+
+ context "create_html_public_method_return_type" do
+ let(:complex_class) {"SomeComplexClass"}
+ let (:builder_elem) {mock}
+ let(:output) {[builder_elem]}
+ let(:type) {"string"}
+
+ before(:each) do
+ builder_elem.stubs(:get_complex_class_name).returns(complex_class)
+ builder_elem.stubs(:type).returns(type)
+ end
+
+ it "returns void if output nil" do
+ result = helper.create_html_public_method_return_type(xml, pre, nil)
+ result.should eq(["void"])
+ end
+
+ it "returns basic type" do
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(true)
+ result = helper.create_html_public_method_return_type(xml, pre, output)
+ result.should eq("#{type}")
+ end
+
+ it "returns simeple complex typel" do
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
+ builder_elem.expects(:multiplied).returns(false)
+ result = helper.create_html_public_method_return_type(xml, pre, output)
+ result.should eq(["#{complex_class}"])
+ end
+
+ it "returns array of complex typel" do
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
+ builder_elem.expects(:multiplied).returns(true)
+ result = helper.create_html_public_method_return_type(xml, pre, output)
+ result.should eq(["Array of #{complex_class}"])
+ end
+
+ it "returns nil if complex class is nil" do
+ WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
+ builder_elem.expects(:get_complex_class_name).returns(nil)
+ result = helper.create_html_public_method_return_type(xml, pre, output)
+ result.should eq(nil)
+ end
+
+ end
+
+end
diff --git a/spec/lib/washout_builder/document/exception_model_spec.rb b/spec/lib/washout_builder/document/exception_model_spec.rb
index 7addf50..5e92bda 100644
--- a/spec/lib/washout_builder/document/exception_model_spec.rb
+++ b/spec/lib/washout_builder/document/exception_model_spec.rb
@@ -1,6 +1,11 @@
#encoding:utf-8
require 'spec_helper'
+class InheritedExceptionModel
+ include WashoutBuilder::Document::ExceptionModel
+
+end
+
describe WashoutBuilder::Document::ExceptionModel do
@@ -16,6 +21,7 @@
specify { described_class.included_modules.should include(extension) }
end
+ specify {InheritedExceptionModel.included_modules.should include(WashoutBuilder::Document::SharedComplexType) }
def fault_ancestor_hash(subject, structure, ancestors)
{:fault => subject,:structure =>structure ,:ancestors => ancestors }
@@ -79,4 +85,4 @@ def fault_ancestor_hash(subject, structure, ancestors)
subject.get_fault_class_ancestors([])
end
-end
\ No newline at end of file
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index b2a56a5..0ae3b7b 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -15,10 +15,10 @@
Coveralls.wear!
-SimpleCov.start do
+SimpleCov.start "rails" do
add_filter 'spec'
- add_group 'Library', 'lib'
- add_group 'App', 'app'
+ #add_group 'Library', 'lib'
+ # add_group 'App', 'app'
at_exit do; end
end
@@ -116,4 +116,4 @@ class WashoutBuilderTestError < base_exception
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
\ No newline at end of file
+end