wash_out 0.9.2 → 0.10.0

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.
@@ -13,19 +13,19 @@ describe WashOut::Dispatcher do
13
13
  end
14
14
 
15
15
  it "finds nested hashes" do
16
- WashOut::Dispatcher.deep_select(:foo => 1){|k,v| k == :foo}.should == [1]
17
- WashOut::Dispatcher.deep_select({:foo => {:foo => 1}}){|k,v| k == :foo}.should == [{:foo => 1}, 1]
16
+ expect(WashOut::Dispatcher.deep_select(:foo => 1){|k,v| k == :foo}).to eq [1]
17
+ expect(WashOut::Dispatcher.deep_select({:foo => {:foo => 1}}){|k,v| k == :foo}).to eq([{:foo => 1}, 1])
18
18
  end
19
19
 
20
20
  it "replaces nested hashed" do
21
- WashOut::Dispatcher.deep_replace_href({:foo => {:@href => 1}}, {1 => 2}).should == {:foo => 2}
22
- WashOut::Dispatcher.deep_replace_href({:bar => {:foo => {:@href => 1}}}, {1 => 2}).should == {:bar => {:foo => 2}}
21
+ expect(WashOut::Dispatcher.deep_replace_href({:foo => {:@href => 1}}, {1 => 2})).to eq({:foo => 2})
22
+ expect(WashOut::Dispatcher.deep_replace_href({:bar => {:foo => {:@href => 1}}}, {1 => 2})).to eq({:bar => {:foo => 2}})
23
23
  end
24
24
 
25
25
  xit "parses typical request" do
26
26
  dispatcher = Dispatcher.mock("<foo>1</foo>")
27
27
  dispatcher._parse_soap_parameters
28
- dispatcher.params.should == {:foo => "1"}
28
+ expect(dispatcher.params).to eq({:foo => "1"})
29
29
  end
30
30
 
31
31
  xit "parses href request" do
@@ -45,11 +45,11 @@ describe WashOut::Dispatcher do
45
45
  </root>
46
46
  XML
47
47
  dispatcher._parse_soap_parameters
48
- dispatcher.params[:root][:request][:entities].should == {
48
+ expect(dispatcher.params[:root][:request][:entities]).to eq({
49
49
  :foo => {:bar=>"1"},
50
50
  :sub => {:foo=>"1", :@id=>"id2"},
51
51
  :@id => "id1"
52
- }
52
+ })
53
53
  end
54
54
 
55
55
  describe "#_map_soap_parameters" do
@@ -57,13 +57,13 @@ describe WashOut::Dispatcher do
57
57
  let(:soap_config) { WashOut::SoapConfig.new(camelize_wsdl: false) }
58
58
 
59
59
  before do
60
- allow(dispatcher).to receive(:action_spec).and_return(in: WashOut::Param.parse_def(soap_config, {:empty => :string } ))
61
- allow(dispatcher).to receive(:xml_data).and_return(:empty => { :"@xsi:type" => "xsd:string" })
60
+ allow(dispatcher).to receive(:action_spec).and_return(in: WashOut::Param.parse_def(soap_config, { foo: { "@bar" => :string, empty: :string } } ))
61
+ allow(dispatcher).to receive(:xml_data).and_return(foo: { "@bar" => "buzz", empty: { :"@xsi:type" => "xsd:string" } })
62
62
  end
63
63
 
64
- it "should handle empty strings that have been parsed wrong by nori" do
64
+ it "should handle empty strings that have been parsed wrong by nori, but preserve attrs" do
65
65
  dispatcher._map_soap_parameters
66
- expect(dispatcher.params).to eq('empty' => nil)
66
+ expect(dispatcher.params).to eq("foo" => { "bar" => "buzz", "empty" => nil })
67
67
  end
68
68
  end
69
69
 
@@ -73,25 +73,25 @@ describe WashOut::Dispatcher do
73
73
  it "should load params for an array" do
74
74
  spec = WashOut::Param.parse_def(soap_config, {:my_array => [:integer] } )
75
75
  xml_data = {:my_array => [1, 2, 3]}
76
- dispatcher._load_params(spec, xml_data).should == {"my_array" => [1, 2, 3]}
76
+ expect(dispatcher._load_params(spec, xml_data)).to eq({"my_array" => [1, 2, 3]})
77
77
  end
78
78
 
79
79
  it "should load params for an empty array" do
80
80
  spec = WashOut::Param.parse_def(soap_config, {:my_array => [:integer] } )
81
81
  xml_data = {}
82
- dispatcher._load_params(spec, xml_data).should == {}
82
+ expect(dispatcher._load_params(spec, xml_data)).to eq({})
83
83
  end
84
84
 
85
85
  it "should load params for a nested array" do
86
86
  spec = WashOut::Param.parse_def(soap_config, {:nested => {:my_array => [:integer]}} )
87
87
  xml_data = {:nested => {:my_array => [1, 2, 3]}}
88
- dispatcher._load_params(spec, xml_data).should == {"nested" => {"my_array" => [1, 2, 3]}}
88
+ expect(dispatcher._load_params(spec, xml_data)).to eq({"nested" => {"my_array" => [1, 2, 3]}})
89
89
  end
90
90
 
91
91
  it "should load params for an empty nested array" do
92
92
  spec = WashOut::Param.parse_def(soap_config, {:nested => {:empty => [:integer] }} )
93
93
  xml_data = {:nested => nil}
94
- dispatcher._load_params(spec, xml_data).should == {"nested" => {}}
94
+ expect(dispatcher._load_params(spec, xml_data)).to eq({"nested" => {}})
95
95
  end
96
96
 
97
97
  end
@@ -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
@@ -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