wash_out 0.9.2 → 0.11.0.beta.1

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +31 -4
  4. data/Appraisals +11 -10
  5. data/Gemfile +1 -1
  6. data/README.md +41 -7
  7. data/Rakefile +6 -7
  8. data/app/helpers/wash_out_helper.rb +59 -24
  9. data/app/views/{wash_with_soap → wash_out}/document/error.builder +0 -0
  10. data/app/views/{wash_with_soap → wash_out}/document/response.builder +0 -0
  11. data/app/views/{wash_with_soap → wash_out}/document/wsdl.builder +14 -14
  12. data/app/views/{wash_with_soap → wash_out}/rpc/error.builder +0 -0
  13. data/app/views/{wash_with_soap → wash_out}/rpc/response.builder +0 -0
  14. data/app/views/{wash_with_soap → wash_out}/rpc/wsdl.builder +15 -15
  15. data/gemfiles/rails_3.2.13.gemfile +21 -0
  16. data/gemfiles/rails_4.0.0.gemfile +20 -0
  17. data/gemfiles/rails_4.1.0.gemfile +20 -0
  18. data/gemfiles/rails_4.2.0.gemfile +20 -0
  19. data/gemfiles/rails_5.0.0.beta2.gemfile +19 -0
  20. data/lib/wash_out/dispatcher.rb +68 -38
  21. data/lib/wash_out/param.rb +14 -2
  22. data/lib/wash_out/router.rb +40 -21
  23. data/lib/wash_out/soap.rb +1 -0
  24. data/lib/wash_out/version.rb +1 -1
  25. data/lib/wash_out/wsse.rb +3 -3
  26. data/lib/wash_out.rb +17 -4
  27. data/spec/dummy/config/environments/test.rb +1 -0
  28. data/spec/fixtures/nested_refs_to_arrays.xml +19 -0
  29. data/spec/fixtures/ref_to_one_array.xml +11 -0
  30. data/spec/fixtures/refs_to_arrays.xml +16 -0
  31. data/spec/lib/wash_out/dispatcher_spec.rb +124 -17
  32. data/spec/lib/wash_out/middleware_spec.rb +8 -8
  33. data/spec/lib/wash_out/param_spec.rb +43 -11
  34. data/spec/lib/wash_out/router_spec.rb +33 -5
  35. data/spec/lib/wash_out/type_spec.rb +9 -9
  36. data/spec/lib/wash_out_spec.rb +160 -102
  37. data/spec/spec_helper.rb +24 -4
  38. metadata +19 -11
@@ -11,23 +11,23 @@ describe WashOut::Middleware do
11
11
  end
12
12
 
13
13
  env = {}
14
- lambda {
14
+ expect {
15
15
  WashOut::Middleware.raise_or_render_rexml_parse_error err, env
16
- }.should raise_exception
16
+ }.to raise_exception(REXML::ParseException)
17
17
 
18
18
  env['HTTP_SOAPACTION'] = 'pretend_action'
19
19
  env['rack.errors'] = double 'logger', {:puts => true}
20
20
  env['rack.input'] = double 'basic-rack-input', {:string => '<hi>'}
21
21
  result = WashOut::Middleware.raise_or_render_rexml_parse_error err, env
22
- result[0].should == 400
23
- result[1]['Content-Type'].should == 'text/xml'
22
+ expect(result[0]).to eq 400
23
+ expect(result[1]['Content-Type']).to eq 'text/xml'
24
24
  msg = result[2][0]
25
- msg.should include 'Error parsing SOAP Request XML'
26
- msg.should include 'soap:Fault'
27
- msg.should_not include __FILE__
25
+ expect(msg).to include 'Error parsing SOAP Request XML'
26
+ expect(msg).to include 'soap:Fault'
27
+ expect(msg).not_to include __FILE__
28
28
 
29
29
  env['rack.input'] = double 'passenger-input', {:read => '<hi>'}
30
30
  result = WashOut::Middleware.raise_or_render_rexml_parse_error err, env
31
- result[0].should == 400
31
+ expect(result[0]).to eq 400
32
32
  end
33
33
  end
@@ -21,9 +21,9 @@ describe WashOut::Param do
21
21
  soap_config = WashOut::SoapConfig.new({ camelize_wsdl: false })
22
22
  map = WashOut::Param.parse_def soap_config, Abraka2
23
23
 
24
- map.should be_a_kind_of(Array)
25
- map[0].name.should == 'foo'
26
- map[0].map[0].name.should == 'test'
24
+ expect(map).to be_a_kind_of(Array)
25
+ expect(map[0].name).to eq 'foo'
26
+ expect(map[0].map[0].name).to eq 'test'
27
27
  end
28
28
 
29
29
  it "respects camelization setting" do
@@ -31,16 +31,16 @@ describe WashOut::Param do
31
31
 
32
32
  map = WashOut::Param.parse_def soap_config, Abraka2
33
33
 
34
- map.should be_a_kind_of(Array)
35
- map[0].name.should == 'Foo'
36
- map[0].map[0].name.should == 'Test'
34
+ expect(map).to be_a_kind_of(Array)
35
+ expect(map[0].name).to eq 'Foo'
36
+ expect(map[0].map[0].name).to eq 'Test'
37
37
  end
38
38
  end
39
39
 
40
40
  it "should accept nested empty arrays" do
41
41
  soap_config = WashOut::SoapConfig.new({ camelize_wsdl: false })
42
42
  map = WashOut::Param.parse_def(soap_config, {:nested => {:some_attr => :string, :empty => [:integer] }} )
43
- map[0].load( {:nested => nil}, :nested).should == {}
43
+ expect(map[0].load( {:nested => nil}, :nested)).to eq({})
44
44
  end
45
45
 
46
46
  describe "booleans" do
@@ -50,13 +50,45 @@ describe WashOut::Param do
50
50
  let(:map) { WashOut::Param.parse_def(soap_config, :value => :boolean) }
51
51
 
52
52
  it "should accept 'true' and '1'" do
53
- map[0].load({:value => true}, :value).should be_true
54
- map[0].load({:value => "1"}, :value).should be_true
53
+ expect(map[0].load({:value => true}, :value)).to be true
54
+ expect(map[0].load({:value => "1"}, :value)).to be true
55
55
  end
56
56
 
57
57
  it "should accept 'false' and '0'" do
58
- map[0].load({:value => false}, :value).should be_false
59
- map[0].load({:value => "0"}, :value).should be_false
58
+ expect(map[0].load({:value => false}, :value)).to be false
59
+ expect(map[0].load({:value => "0"}, :value)).to be false
60
+ end
61
+ end
62
+
63
+ describe 'longs' do
64
+ let(:soap_config) { WashOut::SoapConfig.new({ camelize_wsdl: false }) }
65
+ let(:map) { WashOut::Param.parse_def(soap_config, :value => :long) }
66
+
67
+ it "should accept positive long" do
68
+ expect(map[0].load({:value => 9223372036854775807}, :value)).to eq 9223372036854775807
69
+ end
70
+
71
+ it "should accept negative long" do
72
+ expect(map[0].load({:value => -9223372036854775807}, :value)).to eq -9223372036854775807
73
+ end
74
+ end
75
+
76
+ describe '#flat_copy' do
77
+ it 'should copy everything' do
78
+ soap_config = WashOut::SoapConfig.new({})
79
+ type = :foo
80
+ multiplied = "of course"
81
+
82
+ param = WashOut::Param.new(soap_config, 'name', type, multiplied)
83
+ param.source_class = "middle class"
84
+ evil_clone = param.flat_copy
85
+
86
+ expect(evil_clone.source_class).to eq "middle class"
87
+ expect(evil_clone.name).to eq 'name'
88
+ expect(evil_clone.raw_name).to eq 'name'
89
+ expect(evil_clone.type).to eq "foo"
90
+ expect(evil_clone.multiplied).to eq "of course"
91
+ expect(evil_clone.soap_config).to eq soap_config
60
92
  end
61
93
  end
62
94
  end
@@ -11,12 +11,40 @@ describe WashOut::Router do
11
11
  env = {}
12
12
  env['REQUEST_METHOD'] = 'GET'
13
13
  env['rack.input'] = double 'basic-rack-input', {:string => ''}
14
- result = WashOut::Router.new('Api').call env
14
+ result = WashOut::Router.new('Route::Space::Api').call env
15
15
 
16
- expect(result[0]).to eq(200)
17
- #expect(result[1]['Content-Type']).to eq('text/xml')
16
+ expect(result[0]).to eq(500)
17
+ expect(result[1]['Content-Type']).to eq('text/xml; charset=utf-8')
18
+ end
19
+
20
+ def parse_soap_params_from_xml(filename)
21
+ xml = File.read(File.expand_path("../../../fixtures/#{filename}", __FILE__))
22
+ env = {'rack.input' => StringIO.new(xml)}
23
+
24
+ router = WashOut::Router.new('')
25
+ controller = double("controller", soap_config: WashOut::SoapConfig.new)
26
+ allow(router).to receive(:controller).and_return(controller)
27
+
28
+ router.parse_soap_parameters(env)[:Envelope][:Body]
29
+ end
30
+
31
+ it "returns refs to arrays correctly" do
32
+ body = parse_soap_params_from_xml('ref_to_one_array.xml')
33
+
34
+ expect(body[:list][:Item]).to eq(["1", "2"])
35
+ end
36
+
37
+ it "returns refs to multiple arrays correctly" do
38
+ body = parse_soap_params_from_xml('refs_to_arrays.xml')
39
+
40
+ expect(body[:first_list][:Item]).to eq(["1", "2"])
41
+ expect(body[:second_list][:Item]).to eq(["11", "22"])
42
+ end
43
+
44
+ it "returns nested refs to multiple arrays correctly" do
45
+ body = parse_soap_params_from_xml('nested_refs_to_arrays.xml')
18
46
 
19
- msg = result[2][0]
20
- expect(msg).to eq('OK')
47
+ expect(body[:parent][:first_list][:Item]).to eq(["1", "2"])
48
+ expect(body[:parent][:second_list][:Item]).to eq(["11", "22"])
21
49
  end
22
50
  end
@@ -1,4 +1,4 @@
1
- #encoding:utf-8
1
+ #encoding:utf-8
2
2
 
3
3
  require 'spec_helper'
4
4
 
@@ -15,11 +15,11 @@ describe WashOut::Type do
15
15
  map :foo => Abraka1
16
16
  end
17
17
 
18
- Abraka1.wash_out_param_name.should == 'abraka1'
19
- Abraka1.wash_out_param_map.should == {:test => :string}
18
+ expect(Abraka1.wash_out_param_name).to eq 'abraka1'
19
+ expect(Abraka1.wash_out_param_map).to eq({:test => :string})
20
20
 
21
- Abraka2.wash_out_param_name.should == 'test'
22
- Abraka2.wash_out_param_map.should == {:foo => Abraka1}
21
+ expect(Abraka2.wash_out_param_name).to eq 'test'
22
+ expect(Abraka2.wash_out_param_map).to eq({:foo => Abraka1})
23
23
  end
24
24
 
25
25
  it "allows arrays inside custom types" do
@@ -31,11 +31,11 @@ describe WashOut::Type do
31
31
  map :foo => [:bar => Abraka1]
32
32
  end
33
33
 
34
- Abraka1.wash_out_param_name.should == 'abraka1'
35
- Abraka1.wash_out_param_map.should == {:test => :string}
34
+ expect(Abraka1.wash_out_param_name).to eq 'abraka1'
35
+ expect(Abraka1.wash_out_param_map).to eq({:test => :string})
36
36
 
37
- Abraka2.wash_out_param_name.should == 'test'
38
- Abraka2.wash_out_param_map.should == {:foo => [:bar => Abraka1]}
37
+ expect(Abraka2.wash_out_param_name).to eq 'test'
38
+ expect(Abraka2.wash_out_param_map).to eq({:foo => [:bar => Abraka1]})
39
39
  end
40
40
 
41
41
  end