washout_builder 0.15.4 → 0.15.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Appraisals +8 -8
- data/Rakefile +18 -2
- data/lib/washout_builder/document/complex_type.rb +1 -1
- data/lib/washout_builder/document/exception_model.rb +3 -3
- data/lib/washout_builder/version.rb +1 -1
- data/spec/app/controllers/washout_builder_controller_spec.rb +4 -4
- data/spec/app/helpers/washout_builder_complex_type_helper_spec.rb +4 -4
- data/spec/app/helpers/washout_builder_fault_type_helper_spec.rb +11 -11
- data/spec/app/helpers/washout_builder_method_arguments_helper_spec.rb +9 -9
- data/spec/app/helpers/washout_builder_method_list_helper_spec.rb +6 -6
- data/spec/app/helpers/washout_builder_method_return_type_helper_spec.rb +5 -5
- data/spec/dummy/config.ru +1 -1
- data/spec/lib/washout_builder/document/complex_type_spec.rb +22 -22
- data/spec/lib/washout_builder/document/exception_model_spec.rb +15 -15
- data/spec/lib/washout_builder/document/generator_spec.rb +20 -20
- data/spec/lib/washout_builder/type_spec.rb +4 -4
- data/spec/lib/washout_builder_spec.rb +69 -65
- data/spec/spec_helper.rb +7 -2
- data/spec/support/fix_minitest.rb +38 -0
- data/washout_builder.gemspec +18 -18
- metadata +89 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3a7e076b8c2fd92d9d0a3460b6c0a32aa526137
|
4
|
+
data.tar.gz: de260d94e4fde3a2b85ee69b29e24d424c418d72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c912a50fbdae3d27af8e038b6dba9b086c22d322443536f84a0dcfc74f7ee710c2b51835e4bc5ef3f0e4570586a5e094d156772175273ec3e256d404f4a99929
|
7
|
+
data.tar.gz: 5067c0aa90bd1dc0634b34a7e16c84cb428ba4dae9600df7d90d387e69d8d7f36489cddc0a43e79c3ea7dfc3cf9fd396183905516aca55faf00d81ef362d9da9
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,11 +1,3 @@
|
|
1
|
-
appraise "rails-3.2.8" do
|
2
|
-
gem "rails", "3.2.8"
|
3
|
-
end
|
4
|
-
|
5
|
-
appraise "rails-3.2.12" do
|
6
|
-
gem "rails", "3.2.12"
|
7
|
-
end
|
8
|
-
|
9
1
|
appraise "rails-4.0.0" do
|
10
2
|
gem "rails", "4.0.0"
|
11
3
|
end
|
@@ -33,3 +25,11 @@ end
|
|
33
25
|
appraise "rails-4.2.1" do
|
34
26
|
gem "rails", "4.2.1"
|
35
27
|
end
|
28
|
+
|
29
|
+
appraise "rails-4.2.2" do
|
30
|
+
gem "rails", "4.2.2"
|
31
|
+
end
|
32
|
+
|
33
|
+
appraise "rails-4.2.3" do
|
34
|
+
gem "rails", "4.2.3"
|
35
|
+
end
|
data/Rakefile
CHANGED
@@ -3,6 +3,8 @@ require 'bundler/gem_tasks'
|
|
3
3
|
require 'appraisal'
|
4
4
|
require 'rspec/core/rake_task'
|
5
5
|
require 'coveralls/rake/task'
|
6
|
+
require 'yard'
|
7
|
+
require 'yard-rspec'
|
6
8
|
Coveralls::RakeTask.new
|
7
9
|
|
8
10
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
@@ -21,7 +23,7 @@ unless ENV['TRAVIS']
|
|
21
23
|
require 'rvm-tester'
|
22
24
|
require 'wwtd/tasks'
|
23
25
|
RVM::Tester::TesterTask.new(:suite) do |t|
|
24
|
-
t.rubies = %w(
|
26
|
+
t.rubies = %w(2.1.5 2.2.2) # which versions to test (required!)
|
25
27
|
t.bundle_install = true # updates Gemfile.lock, default is true
|
26
28
|
t.use_travis = true # looks for Rubies in .travis.yml (on by default)
|
27
29
|
t.command = 'gem install bundler && bundle install && bundle exec rake' # runs plain "rake" by default
|
@@ -39,6 +41,20 @@ task :all do |_t|
|
|
39
41
|
if ENV['TRAVIS']
|
40
42
|
exec(' bundle exec phare && bundle exec appraisal install && bundle exec rake appraisal spec && bundle exec rake coveralls:push')
|
41
43
|
else
|
42
|
-
|
44
|
+
# exec(' bundle exec rubocop -a . && bundle exec phare && ')
|
45
|
+
exec ('bundle exec appraisal install && bundle exec rake appraisal spec')
|
43
46
|
end
|
44
47
|
end
|
48
|
+
|
49
|
+
YARD::Config.options[:load_plugins] = true
|
50
|
+
YARD::Config.load_plugins
|
51
|
+
|
52
|
+
YARD::Rake::YardocTask.new do |t|
|
53
|
+
t.files = ['lib/**/*.rb', 'spec/**/*_spec.rb'] # optional
|
54
|
+
t.options = ['--any', '--extra', '--opts', '--markup-provider=redcarpet', '--markup=markdown', '--debug'] # optional
|
55
|
+
t.stats_options = ['--list-undoc'] # optional
|
56
|
+
end
|
57
|
+
|
58
|
+
task :docs do
|
59
|
+
exec(' bundle exec rubocop -a . && bundle exec phare && bundle exec inch --pedantic && bundle exec yard')
|
60
|
+
end
|
@@ -6,7 +6,7 @@ module WashoutBuilder
|
|
6
6
|
include WashoutBuilder::Document::SharedComplexType
|
7
7
|
|
8
8
|
def find_complex_class_name(defined = [])
|
9
|
-
complex_class = struct? ? basic_type.
|
9
|
+
complex_class = struct? ? basic_type.tr('.', '/').camelize : nil
|
10
10
|
check_duplicate_complex_class(defined, complex_class) unless complex_class.nil? || defined.blank?
|
11
11
|
complex_class
|
12
12
|
end
|
@@ -41,7 +41,7 @@ module WashoutBuilder
|
|
41
41
|
method != :== && method != :! &&
|
42
42
|
(instance_methods.include?(:"#{method}=") ||
|
43
43
|
instance_methods.include?(:"#{method}")
|
44
|
-
|
44
|
+
)
|
45
45
|
end
|
46
46
|
|
47
47
|
def find_fault_attributes
|
@@ -49,7 +49,7 @@ module WashoutBuilder
|
|
49
49
|
attrs = instance_methods(nil).map do |method|
|
50
50
|
method.to_s if check_valid_fault_method?(method)
|
51
51
|
end
|
52
|
-
attrs = attrs.delete_if { |method| method.end_with?('=') && attrs.include?(method.
|
52
|
+
attrs = attrs.delete_if { |method| method.end_with?('=') && attrs.include?(method.delete('=')) }
|
53
53
|
attrs.concat(%w(message backtrace))
|
54
54
|
end
|
55
55
|
|
@@ -67,7 +67,7 @@ module WashoutBuilder
|
|
67
67
|
def find_fault_model_structure
|
68
68
|
h = {}
|
69
69
|
find_fault_attributes.each do |method_name|
|
70
|
-
method_name = method_name.to_s.end_with?('=') ? method_name.to_s.
|
70
|
+
method_name = method_name.to_s.end_with?('=') ? method_name.to_s.delete('=') : method_name
|
71
71
|
primitive_type = get_fault_type_method(method_name)
|
72
72
|
h["#{method_name}"] = {
|
73
73
|
primitive: "#{primitive_type}",
|
@@ -27,22 +27,22 @@ describe WashoutBuilder::WashoutBuilderController, type: :controller do
|
|
27
27
|
|
28
28
|
it 'gets the services' do
|
29
29
|
get :all
|
30
|
-
assigns(:services).
|
30
|
+
expect(assigns(:services)).to eq([{ 'service_name' => 'Api', 'namespace' => '/api/wsdl', 'endpoint' => '/api/action', 'documentation_url' => 'http://test.host/Api' }])
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'renders the template' do
|
34
34
|
get :all
|
35
|
-
response.
|
35
|
+
expect(response).to render_template('wash_with_html/all_services')
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'checks it controller is a service' do
|
39
|
-
controller.send(:controller_is_a_service?, 'api').
|
39
|
+
expect(controller.send(:controller_is_a_service?, 'api')).not_to eq nil
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'render a service documentation' do
|
43
43
|
controller.expects(:controller_is_a_service?).with(params[:name]).returns(route)
|
44
44
|
WashoutBuilder::Document::Generator.expects(:new).with(route.defaults[:controller])
|
45
45
|
get :all, params
|
46
|
-
|
46
|
+
expect(response).to render_template 'wash_with_html/doc'
|
47
47
|
end
|
48
48
|
end
|
@@ -15,7 +15,7 @@ describe WashoutBuilderComplexTypeHelper, type: :helper do
|
|
15
15
|
def expect_included_type_result(pre, element)
|
16
16
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(element.type).returns(true)
|
17
17
|
result = helper.create_element_type_html(pre, element)
|
18
|
-
result.
|
18
|
+
expect(result).to eq(["<span class='blue'>#{element.type}</span> <span class='bold'>#{element.name}</span>"])
|
19
19
|
end
|
20
20
|
|
21
21
|
def expect_excluded_type_result(pre, element)
|
@@ -60,19 +60,19 @@ describe WashoutBuilderComplexTypeHelper, type: :helper do
|
|
60
60
|
|
61
61
|
it 'returna simple type element description' do
|
62
62
|
result = helper.create_complex_element_type_html(pre, element)
|
63
|
-
result.
|
63
|
+
expect(result).to eq(["<a href='##{complex_class}'><span class='lightBlue'>#{complex_class}</span></a> <span class='bold'>#{element.name}</span>"])
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'returns an array type element description' do
|
67
67
|
element.stubs(:multiplied).returns(true)
|
68
68
|
result = helper.create_complex_element_type_html(pre, element)
|
69
|
-
result.
|
69
|
+
expect(result).to eq(["<a href='##{complex_class}'><span class='lightBlue'>Array of #{complex_class}</span></a> <span class='bold'>#{element.name}</span>"])
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'returns empty if no complex class' do
|
73
73
|
element.stubs(:find_complex_class_name).returns(nil)
|
74
74
|
result = helper.create_complex_element_type_html(pre, element)
|
75
|
-
result.
|
75
|
+
expect(result).to eq(nil)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -9,7 +9,7 @@ describe WashoutBuilderFaultTypeHelper, type: :helper do
|
|
9
9
|
def check_result(array)
|
10
10
|
attribute_primitive = array == true ? "Array of #{attr_primitive}" : "#{attr_primitive}"
|
11
11
|
result = helper. create_fault_model_complex_element_type(pre, attr_primitive, attribute, array)
|
12
|
-
result.
|
12
|
+
expect(result).to eq(["<a href='##{attr_primitive}'><span class='lightBlue'> #{attribute_primitive}</span></a> <span class='bold'>#{attribute}</span>"])
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'creates an array element ' do
|
@@ -25,14 +25,14 @@ describe WashoutBuilderFaultTypeHelper, type: :helper do
|
|
25
25
|
attr_details = { member_type: 'STRING' }
|
26
26
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(attr_details[:member_type].to_s.downcase).returns(true)
|
27
27
|
result = helper.member_type_is_basic?(attr_details)
|
28
|
-
result.
|
28
|
+
expect(result).to eq(attr_details[:member_type].to_s.downcase)
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'returns a non-basic type' do
|
32
32
|
attr_details = { member_type: 'STRING' }
|
33
33
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(attr_details[:member_type].to_s.downcase).returns(false)
|
34
34
|
result = helper.member_type_is_basic?(attr_details)
|
35
|
-
result.
|
35
|
+
expect(result).to eq(attr_details[:member_type])
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -40,13 +40,13 @@ describe WashoutBuilderFaultTypeHelper, type: :helper do
|
|
40
40
|
it 'returns true' do
|
41
41
|
attr_details = { primitive: 'STRING' }
|
42
42
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(attr_details[:primitive].to_s.downcase).returns(true)
|
43
|
-
helper.primitive_type_is_basic?(attr_details).
|
43
|
+
expect(helper.primitive_type_is_basic?(attr_details)).to eq(true)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'returns false' do
|
47
47
|
attr_details = { primitive: 'STRING' }
|
48
48
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(attr_details[:primitive].to_s.downcase).returns(false)
|
49
|
-
|
49
|
+
expect(helper.primitive_type_is_basic?(attr_details)).to eq(false)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -54,14 +54,14 @@ describe WashoutBuilderFaultTypeHelper, type: :helper do
|
|
54
54
|
%w(NILCLASS nilclass).each do |primitive|
|
55
55
|
it 'returns string in case of nilclass' do
|
56
56
|
attr_details = { primitive: primitive }
|
57
|
-
|
57
|
+
expect(helper.get_primitive_type_string(attr_details)).to eq('string')
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
%w(BLA bla).each do |primitive|
|
62
62
|
it 'returns the primitive if not niclass' do
|
63
63
|
attr_details = { primitive: primitive }
|
64
|
-
|
64
|
+
expect(helper.get_primitive_type_string(attr_details)).to eq(primitive.to_s.downcase)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -71,14 +71,14 @@ describe WashoutBuilderFaultTypeHelper, type: :helper do
|
|
71
71
|
it 'checks the member type to be basic if primitive type array' do
|
72
72
|
attr_details = { primitive: primitive }
|
73
73
|
helper.expects(:member_type_is_basic?).with(attr_details).returns(true)
|
74
|
-
helper.get_member_type_string(attr_details).
|
74
|
+
expect(helper.get_member_type_string(attr_details) ).to eq(true)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
%w(BLA Bla bla).each do |primitive|
|
79
79
|
it 'returns the primitive type as it is if not array' do
|
80
80
|
attr_details = { primitive: primitive }
|
81
|
-
|
81
|
+
expect( helper.get_member_type_string(attr_details) ).to eq(primitive)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
@@ -95,7 +95,7 @@ describe WashoutBuilderFaultTypeHelper, type: :helper do
|
|
95
95
|
type_string = 'string'
|
96
96
|
helper.expects(:get_primitive_type_string).with(attr_details).returns(type_string)
|
97
97
|
result = helper.create_html_fault_model_element_type(pre, attribute, attr_details)
|
98
|
-
result.
|
98
|
+
expect(result).to eq(["<span class='blue'>#{type_string}</span> <span class='bold'>#{attribute}</span>"])
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'returns the string element if primitive type is nilclass' do
|
@@ -120,7 +120,7 @@ describe WashoutBuilderFaultTypeHelper, type: :helper do
|
|
120
120
|
helper.expects(:get_member_type_string).with(attr_details).returns(member_type)
|
121
121
|
helper.expects(:create_fault_model_complex_element_type).with(pre, member_type, attribute, true).returns(expected)
|
122
122
|
result = helper.create_html_fault_model_element_type(pre, attribute, attr_details)
|
123
|
-
|
123
|
+
expect(result).to eq(expected)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -20,7 +20,7 @@ describe WashoutBuilderMethodArgumentsHelper, type: :helper do
|
|
20
20
|
def expect_method_arg_basic_type(mlen)
|
21
21
|
use_spacer = mlen > 1 ? true : false
|
22
22
|
result = helper.create_method_argument_element(pre, param, mlen)
|
23
|
-
result.
|
23
|
+
expect(result).to eq(["#{use_spacer ? spacer : ''}<span class='blue'>#{param.type}</span> <span class='bold'>#{param.name}</span>"])
|
24
24
|
end
|
25
25
|
|
26
26
|
[0, 1, 2, 3, 4].each do |mlen|
|
@@ -36,7 +36,7 @@ describe WashoutBuilderMethodArgumentsHelper, type: :helper do
|
|
36
36
|
param.expects(:multiplied).returns(true)
|
37
37
|
use_spacer = mlen > 1 ? true : false
|
38
38
|
result = helper.create_method_argument_element(pre, param, mlen)
|
39
|
-
result.
|
39
|
+
expect(result).to eq(["#{use_spacer ? spacer : ''}<a href='##{complex_class}'><span class='lightBlue'>Array of #{complex_class}</span></a> <span class='bold'>#{param.name}</span>"])
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -46,7 +46,7 @@ describe WashoutBuilderMethodArgumentsHelper, type: :helper do
|
|
46
46
|
param.expects(:multiplied).returns(false)
|
47
47
|
use_spacer = mlen > 1 ? true : false
|
48
48
|
result = helper.create_method_argument_element(pre, param, mlen)
|
49
|
-
result.
|
49
|
+
expect(result).to eq(["#{use_spacer ? spacer : ''}<a href='##{complex_class}'><span class='lightBlue'>#{complex_class}</span></a> <span class='bold'>#{param.name}</span>"])
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -54,28 +54,28 @@ describe WashoutBuilderMethodArgumentsHelper, type: :helper do
|
|
54
54
|
context 'create_argument_element_spacer' do
|
55
55
|
it 'returns only the ) in bold ' do
|
56
56
|
helper.create_argument_element_spacer(xml, 0, 1)
|
57
|
-
xml.target
|
57
|
+
expect(xml.target!).to eq("<span class=\"bold\">)</span>")
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'returns only the span with comma' do
|
61
61
|
helper.create_argument_element_spacer(xml, -2, 1)
|
62
|
-
xml.target
|
62
|
+
expect(xml.target!).to eq('<span>, </span>')
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'returns only the span with comma and a break ' do
|
66
66
|
helper.create_argument_element_spacer(xml, 1, 3)
|
67
|
-
xml.target
|
67
|
+
expect(xml.target!).to eq('<span>, </span><br/>')
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'returns a break and a ) sign ' do
|
71
71
|
helper.create_argument_element_spacer(xml, 2, 3)
|
72
|
-
xml.target
|
72
|
+
expect(xml.target!).to eq("<br/><span class=\"bold\">)</span>")
|
73
73
|
end
|
74
74
|
|
75
75
|
[3, 4, 4, 5, 6].each do |j_value|
|
76
76
|
it 'returns only the span with comma ' do
|
77
77
|
helper.create_argument_element_spacer(xml, j_value, 3)
|
78
|
-
xml.target
|
78
|
+
expect(xml.target!).to eq('<br/>')
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -91,7 +91,7 @@ describe WashoutBuilderMethodArgumentsHelper, type: :helper do
|
|
91
91
|
helper.stubs(:create_method_argument_element).returns('bla')
|
92
92
|
helper.stubs(:create_argument_element_spacer).returns('blabla')
|
93
93
|
helper. create_html_public_method_arguments(xml, pre, input)
|
94
|
-
xml.target
|
94
|
+
expect(xml.target!).to eq('<br/>')
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -11,13 +11,13 @@ describe WashoutBuilderMethodListHelper, type: :helper do
|
|
11
11
|
it 'returns simple type ' do
|
12
12
|
builder_elem.expects(:multiplied).returns(false)
|
13
13
|
result = helper.create_return_complex_type_list_html(xml, complex_class, builder_out)
|
14
|
-
result.
|
14
|
+
expect(result).to eq("<span class=\"pre\"><a href=\"#SomeComplexClass\"><span class=\"lightBlue\">SomeComplexClass</span></a></span>")
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'returns array type ' do
|
18
18
|
builder_elem.expects(:multiplied).returns(true)
|
19
19
|
result = helper.create_return_complex_type_list_html(xml, complex_class, builder_out)
|
20
|
-
result.
|
20
|
+
expect(result).to eq("<span class=\"pre\"><a href=\"#SomeComplexClass\"><span class=\"lightBlue\">Array of SomeComplexClass</span></a></span>")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -34,27 +34,27 @@ describe WashoutBuilderMethodListHelper, type: :helper do
|
|
34
34
|
|
35
35
|
it 'returns void for nil' do
|
36
36
|
helper.create_return_type_list_html(xml, nil)
|
37
|
-
xml.target
|
37
|
+
expect(xml.target!).to eq("<span class=\"pre\">void</span>")
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'returns basic type' do
|
41
41
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(true)
|
42
42
|
helper.create_return_type_list_html(xml, output)
|
43
|
-
xml.target
|
43
|
+
expect(xml.target!).to eq("<span class=\"pre\"><span class=\"blue\">string</span></span>")
|
44
44
|
end
|
45
45
|
it 'returns complex type' do
|
46
46
|
expected = 'some expected string'
|
47
47
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
|
48
48
|
helper.expects(:create_return_complex_type_html).with(instance_of(Builder::XmlMarkup), complex_class, output).returns(expected)
|
49
49
|
result = helper.create_return_type_list_html(xml, output)
|
50
|
-
result.
|
50
|
+
expect(result).to eq(expected)
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'returns nil if complex class is nil' do
|
54
54
|
builder_elem.stubs(:find_complex_class_name).returns(nil)
|
55
55
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
|
56
56
|
result = helper.create_return_type_list_html(xml, output)
|
57
|
-
result.
|
57
|
+
expect(result).to eq(nil)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -17,34 +17,34 @@ describe WashoutBuilderMethodReturnTypeHelper, type: :helper do
|
|
17
17
|
|
18
18
|
it 'returns void if output nil' do
|
19
19
|
result = helper.create_html_public_method_return_type(xml, pre, nil)
|
20
|
-
result.
|
20
|
+
expect(result).to eq(['void'])
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'returns basic type' do
|
24
24
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(true)
|
25
25
|
result = helper.create_html_public_method_return_type(xml, pre, output)
|
26
|
-
result.
|
26
|
+
expect(result).to eq("<span class=\"blue\">#{type}</span>")
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'returns simeple complex typel' do
|
30
30
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
|
31
31
|
builder_elem.expects(:multiplied).returns(false)
|
32
32
|
result = helper.create_html_public_method_return_type(xml, pre, output)
|
33
|
-
result.
|
33
|
+
expect(result).to eq(["<a href='##{complex_class}'><span class='lightBlue'>#{complex_class}</span></a>"])
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'returns array of complex typel' do
|
37
37
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
|
38
38
|
builder_elem.expects(:multiplied).returns(true)
|
39
39
|
result = helper.create_html_public_method_return_type(xml, pre, output)
|
40
|
-
result.
|
40
|
+
expect(result).to eq(["<a href='##{complex_class}'><span class='lightBlue'>Array of #{complex_class}</span></a>"])
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'returns nil if complex class is nil' do
|
44
44
|
WashoutBuilder::Type::BASIC_TYPES.expects(:include?).with(builder_elem.type).returns(false)
|
45
45
|
builder_elem.expects(:find_complex_class_name).returns(nil)
|
46
46
|
result = helper.create_html_public_method_return_type(xml, pre, output)
|
47
|
-
result.
|
47
|
+
expect(result).to eq(nil)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/spec/dummy/config.ru
CHANGED
@@ -14,15 +14,15 @@ describe WashoutBuilder::Document::ComplexType do
|
|
14
14
|
let(:namespaced_object) { get_wash_out_param(Api::TestType) }
|
15
15
|
|
16
16
|
it 'returns the complex class name' do
|
17
|
-
subject.find_complex_class_name.
|
17
|
+
expect(subject.find_complex_class_name).to eq('ProjectType')
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'returns the complex class name' do
|
21
|
-
subject.find_complex_class_name.
|
21
|
+
expect(subject.find_complex_class_name).to eq('ProjectType')
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'returns the complex class with namespace' do
|
25
|
-
namespaced_object.find_complex_class_name.
|
25
|
+
expect(namespaced_object.find_complex_class_name).to eq('Api::TestType')
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'returns error if classname already detected (only used for hashes)' do
|
@@ -33,55 +33,55 @@ describe WashoutBuilder::Document::ComplexType do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'returns the param structure' do
|
36
|
-
subject.find_param_structure.
|
36
|
+
expect(subject.find_param_structure).to eq('project' => 'struct')
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'fixes the first descendant ' do
|
40
40
|
descendant = get_wash_out_param(ProjectType.wash_out_param_map)
|
41
41
|
subject.fix_descendant_wash_out_type(soap_config, ProjectType)
|
42
|
-
subject.name.
|
43
|
-
subject.map[0].find_param_structure.
|
42
|
+
expect(subject.name).to eq(descendant.name)
|
43
|
+
expect(subject.map[0].find_param_structure).to eq(descendant.map[0].find_param_structure)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'same as ancestor' do
|
47
|
-
subject.get_ancestors(ProjectType).
|
47
|
+
expect(subject.get_ancestors(ProjectType)).to eq([])
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'same as ancestor' do
|
51
|
-
subject.get_ancestors('WashoutBuilderSomeInexistentClass').
|
51
|
+
expect(subject.get_ancestors('WashoutBuilderSomeInexistentClass')).to eq(nil)
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'returns the complex type ancestors' do
|
55
55
|
expected = 'some_name'
|
56
56
|
subject.stubs(:classified?).returns(true)
|
57
57
|
subject.expects(:get_class_ancestors).with(soap_config, ProjectType, []).returns(expected)
|
58
|
-
subject.complex_type_ancestors(soap_config, ProjectType, []).
|
58
|
+
expect(subject.complex_type_ancestors(soap_config, ProjectType, [])).to eq(expected)
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'returns nil for unclassified objects' do
|
62
62
|
subject.stubs(:classified?).returns(false)
|
63
|
-
subject.complex_type_ancestors(soap_config, ProjectType, []).
|
63
|
+
expect(subject.complex_type_ancestors(soap_config, ProjectType, [])).to eq(nil)
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'should remove inheritable elements' do
|
67
67
|
subject_dup = subject.dup
|
68
68
|
subject_dup.remove_type_inheritable_elements(['name'])
|
69
|
-
subject_dup.map.find { |element| element.name == 'name' }.
|
69
|
+
expect(subject_dup.map.find { |element| element.name == 'name' }).to eq(nil)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'should return true if same structure' do
|
73
|
-
subject.same_structure_as_ancestor?(subject).
|
73
|
+
expect(subject.same_structure_as_ancestor?(subject)).to eq(true)
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should return true if same structure' do
|
77
|
-
subject.same_structure_as_ancestor?(get_wash_out_param(Fluffy)).
|
77
|
+
expect(subject.same_structure_as_ancestor?(get_wash_out_param(Fluffy))).to eq(false)
|
78
78
|
end
|
79
79
|
|
80
80
|
describe '#complex_type_descendants' do
|
81
81
|
it 'returns empty array if not struct?' do
|
82
82
|
defined = []
|
83
83
|
subject.stubs(:struct?).returns(false)
|
84
|
-
subject.complex_type_descendants(soap_config, defined).
|
84
|
+
expect(subject.complex_type_descendants(soap_config, defined)).to eq(defined)
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'returns the descendants if struct?' do
|
@@ -90,7 +90,7 @@ describe WashoutBuilder::Document::ComplexType do
|
|
90
90
|
obj.expects(:get_nested_complex_types).with(soap_config, defined).returns([obj.name])
|
91
91
|
end
|
92
92
|
subject.stubs(:struct?).returns(true)
|
93
|
-
subject.complex_type_descendants(soap_config, defined).
|
93
|
+
expect(subject.complex_type_descendants(soap_config, defined)).to eq(subject.map.map(&:name))
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -107,7 +107,7 @@ describe WashoutBuilder::Document::ComplexType do
|
|
107
107
|
subject.expects(:complex_type_ancestors).with(soap_config, complex_class, defined).returns(ancestors)
|
108
108
|
subject.expects(:complex_type_hash).with(complex_class, subject, ancestors).returns(complex_type_hash)
|
109
109
|
subject.expects(:complex_type_descendants).with(soap_config, [complex_type_hash]).returns(expected)
|
110
|
-
subject.get_nested_complex_types(soap_config, defined).
|
110
|
+
expect(subject.get_nested_complex_types(soap_config, defined)).to eq(expected)
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'returns the the descendants' do
|
@@ -115,7 +115,7 @@ describe WashoutBuilder::Document::ComplexType do
|
|
115
115
|
subject.expects(:find_complex_class_name).with([]).returns(nil)
|
116
116
|
subject.expects(:fix_descendant_wash_out_type).with(soap_config, nil).returns(true)
|
117
117
|
subject.expects(:complex_type_descendants).with(soap_config, []).returns(expected)
|
118
|
-
subject.get_nested_complex_types(soap_config, defined).
|
118
|
+
expect(subject.get_nested_complex_types(soap_config, defined)).to eq(expected)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -124,7 +124,7 @@ describe WashoutBuilder::Document::ComplexType do
|
|
124
124
|
let(:ancestors) { [ancestor_class] }
|
125
125
|
|
126
126
|
it 'returns the ancestor structure' do
|
127
|
-
subject.ancestor_structure(ancestors).
|
127
|
+
expect(subject.ancestor_structure(ancestors)).to eq(ancestors[0].to_s.downcase => ancestors[0].wash_out_param_map)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -133,7 +133,7 @@ describe WashoutBuilder::Document::ComplexType do
|
|
133
133
|
let(:ancestors) { ['something'] }
|
134
134
|
|
135
135
|
it 'returns the complex_type_hash' do
|
136
|
-
subject.complex_type_hash(complex_class, subject, ancestors).
|
136
|
+
expect(subject.complex_type_hash(complex_class, subject, ancestors)).to eq('class' => complex_class, :obj => subject, :ancestors => ancestors)
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -147,7 +147,7 @@ describe WashoutBuilder::Document::ComplexType do
|
|
147
147
|
|
148
148
|
it 'returns nil if no ancestors' do
|
149
149
|
subject.expects(:get_ancestors).with(class_name).returns(nil)
|
150
|
-
subject.get_class_ancestors(soap_config, class_name, defined).
|
150
|
+
expect(subject.get_class_ancestors(soap_config, class_name, defined)).to eq(nil)
|
151
151
|
end
|
152
152
|
|
153
153
|
it 'returns the ancestors and the top ones' do
|
@@ -157,7 +157,7 @@ describe WashoutBuilder::Document::ComplexType do
|
|
157
157
|
WashOut::Param.stubs(:parse_def).returns([namespaced_object])
|
158
158
|
subject.expects(:same_structure_as_ancestor?).with(namespaced_object).returns(false)
|
159
159
|
subject.expects(:complex_type_hash).returns(complex_type_hash)
|
160
|
-
subject.get_class_ancestors(soap_config, class_name, defined).
|
160
|
+
expect(subject.get_class_ancestors(soap_config, class_name, defined)).to eq([complex_type_hash])
|
161
161
|
end
|
162
162
|
|
163
163
|
it 'returns nil if same structure as ancestor' do
|
@@ -165,7 +165,7 @@ describe WashoutBuilder::Document::ComplexType do
|
|
165
165
|
subject.expects(:ancestor_structure).with(ancestors).returns(ancestor_structure)
|
166
166
|
WashOut::Param.stubs(:parse_def).returns([namespaced_object])
|
167
167
|
subject.expects(:same_structure_as_ancestor?).with(namespaced_object).returns(true)
|
168
|
-
subject.get_class_ancestors(soap_config, class_name, defined).
|
168
|
+
expect(subject.get_class_ancestors(soap_config, class_name, defined)).to eq(nil)
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|