spec/shapewear/dsl_spec.rb in shapewear-0.0.2 vs spec/shapewear/dsl_spec.rb in shapewear-0.0.3

- old
+ new

@@ -3,51 +3,41 @@ describe Shapewear::DSL do let(:xmlns) { {'wsdl' => 'http://schemas.xmlsoap.org/wsdl/', 'soap' => 'http://schemas.xmlsoap.org/wsdl/soap/'} } describe "basic DSL" do - it "should describe parameterless, 'hello world' services" do - class ParameterlessHelloWorldService - include Shapewear - - def hello_world - "hello" - end - end - - wsdl = ParameterlessHelloWorldService.to_wsdl + it "should describe a minimal working service" do + wsdl = MinimalWorkingService.to_wsdl puts wsdl - wsdl_doc = nil - expect { wsdl_doc = Nokogiri::XML(wsdl) { |c| c.strict } }.not_to raise_error - # there should be a definition with the class' name - wsdl_def = wsdl_doc.xpath("/wsdl:definitions[@name='ParameterlessHelloWorldService']", xmlns) - wsdl_def.should have(1).node - wsdl_def.xpath("wsdl:service[@name='ParameterlessHelloWorldService']/wsdl:port[@name='ParameterlessHelloWorldServicePort']/soap:address", xmlns).should have(1).node + # wsdl should be valid XML (duh!) + expect { Nokogiri::XML(wsdl) { |c| c.strict } }.not_to raise_error - # the message element for the input should not be there, as the method does not accept parameters - wsdl_def.xpath("wsdl:message[@name='HelloWorldInput']", xmlns).should have(0).node + # wasabi should be able to parse it + wdoc = nil + expect { wdoc = Wasabi.document wsdl }.not_to raise_error - # the message element for the output must be there, as a simple string - wsdl_def.xpath("wsdl:message[@name='HelloWorldOutput']/wsdl:part[@name='body']", xmlns).should have(1).node + wdoc.namespace.should match /MinimalWorkingService/ + wdoc.soap_actions.should == [:hello_world] - # there must be an operation named 'HelloWorld' - wsdl_def.xpath("wsdl:portType/wsdl:operation[@name='HelloWorld']", xmlns).should have(1).node - wsdl_def.xpath("wsdl:binding/wsdl:operation[@name='HelloWorld']", xmlns).should have(1).node + wdoc.operations[:hello_world].should_not be_nil + wdoc.operations[:hello_world][:input].should == 'HelloWorld' + wdoc.operations[:hello_world][:input].should match /HelloWorld$/ end - it "should describe services with basic parameters and return values" - it "should describe services with array parameters" end describe "complex types DSL" do - it "should allow definition of complex types using class introspection" - it "should allow definition of complex types using a builder-like DSL" it "should accept complex types as input" it "should accept complex types as output" + it "should accept arrays as input" + it "should accept arrays as output" + it "should allow definition of complex types using class introspection" + it "should allow definition of complex types using a DSL" end describe "WSDL customization" do - it "should allow customization of namespace" + it "should allow customization of target namespace" + it "should allow customization of schema namespace" end describe "existing WSDL" do it "should accept an existing WSDL" end