diff --git a/Gemfile b/Gemfile index 204f146..ef66eb0 100644 --- a/Gemfile +++ b/Gemfile @@ -18,15 +18,14 @@ gem 'tzinfo' gem 'pry' gem 'simplecov' gem 'simplecov-summary' + gem 'nori' gem 'nokogiri' + gem 'capybara', '1.1.4' gem 'selenium-webdriver', '~> 2.37.0' gem 'headless' gem 'capybara-firebug' gem 'mocha', '~> 0.13.3', :require => false -gem 'factory_girl_rails' -gem 'forgery' gem 'webmock' -gem 'rspec-instafail' diff --git a/lib/washout_builder/document/generator.rb b/lib/washout_builder/document/generator.rb index aae471d..91f981e 100644 --- a/lib/washout_builder/document/generator.rb +++ b/lib/washout_builder/document/generator.rb @@ -37,9 +37,11 @@ def operations def input_types types = [] - soap_actions.each do |operation, formats| - (formats[:in]).each do |p| - types << p + unless soap_actions.blank? + soap_actions.each do |operation, formats| + (formats[:in]).each do |p| + types << p + end end end types @@ -47,9 +49,11 @@ def input_types def output_types types = [] - soap_actions.each do |operation, formats| - (formats[:out]).each do |p| - types << p + unless soap_actions.blank? + soap_actions.each do |operation, formats| + (formats[:out]).each do |p| + types << p + end end end types diff --git a/spec/lib/washout_builder/dispatcher_spec.rb b/spec/lib/washout_builder/dispatcher_spec.rb index 8c944a2..d8d2f4c 100644 --- a/spec/lib/washout_builder/dispatcher_spec.rb +++ b/spec/lib/washout_builder/dispatcher_spec.rb @@ -16,7 +16,7 @@ def dispatcher_method render_views(false) before(:each) do - WashoutBuilder::Document::Generator.stub(:new).and_return(document) + WashoutBuilder::Document::Generator.stubs(:new).returns(document) end it "inits the document generator" do diff --git a/spec/lib/washout_builder/document/generator_spec.rb b/spec/lib/washout_builder/document/generator_spec.rb index 5b785e7..44f45cf 100644 --- a/spec/lib/washout_builder/document/generator_spec.rb +++ b/spec/lib/washout_builder/document/generator_spec.rb @@ -4,7 +4,131 @@ describe WashoutBuilder::Document::Generator do - let(:generator) { FactoryGirl.build(:generator)} + let(:soap_config) { OpenStruct.new( + camelize_wsdl: false, + namespace: "/api/wsdl", + description: "some description" + ) } + + let(:soap_actions) { + {'dispatcher_method' => + {:args => nil, :return => nil, :in => [], :out => [], :to => 'dispatcher_method'} + } + } + let(:service_class) { ApiController } + let(:attributes) { + { + :config => soap_config, + :service_class => service_class, + :soap_actions => soap_actions + }} + + before(:each) do + @document = WashoutBuilder::Document::Generator.new(attributes) + end + + context "initialize" do + + it "sets the config " do + @document.config.should eq(soap_config) + end + + it "sets the service_class " do + @document.service_class.should eq(service_class) + end + + it "sets the soap_actions " do + @document.soap_actions.should eq(soap_actions) + end + + end + + + context "namespace" do + specify { @document.namespace.should eq(soap_config.namespace) } + end + + context "endpoint" do + specify { @document.endpoint.should eq(soap_config.namespace.gsub("/wsdl", "/action")) } + end + + context "service" do + specify { @document.service.should eq(service_class.name.underscore.gsub("_controller", "").camelize) } + end + + context "description" do + specify {@document.service_description.should eq(soap_config.description )} + end + + context "operations" do + specify { @document.operations.should eq(soap_actions.map { |operation, formats| operation }) } + end + + + context "input types" do + let(:expected) { types = [] + soap_actions.each do |operation, formats| + (formats[:in]).each do |p| + types << p + end + end + types } + + specify { @document.input_types.should eq(expected) } + + end + + context "output types" do + let(:expected) { types = [] + soap_actions.each do |operation, formats| + (formats[:out]).each do |p| + types << p + end + end + types } + + specify { @document.output_types.should eq(expected) } + + end + + + context "get_soap_action_names" do + + let(:expected) {soap_actions.map { |operation, formats| operation }.map(&:to_s).sort_by { |name| name.downcase }.uniq} + + specify { @document.get_soap_action_names.should eq(expected) } + + + it "returns nil on empty soap actions" do + @document.stubs(:soap_actions).returns(nil) + @document.get_soap_action_names.should eq(nil) + end + + end + + + + context "complex types" do + + let(:expected){ + + } + + + it "returns nil on empty soap actions" do + @document.stubs(:soap_actions).returns(nil) + @document.complex_types.should eq(nil) + end + + it "returns nil if no complex types detected" do + @document.complex_types.should eq(nil) + end + + + + + + end end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 46f25a6..78e22e1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -24,7 +24,6 @@ require 'capybara/rspec' require 'capybara/rails' require 'capybara/firebug/rspec' -require 'forgery/forgery' require 'webmock/rspec' require 'headless' @@ -37,15 +36,8 @@ require 'rspec/expectations' config.include RSpec::Matchers - # mock framework - # config.mock_with :mocha - - #config.include Savon::Spec::Macros - #config.include AbstractController::Translation config.before(:suite) do - # Reload factories in spec/factories. - FactoryGirl.reload # Blocks all remote HTTP requests by default, they need to be stubbed. WebMock.disable_net_connect!(:allow_localhost => true) if !RUBY_PLATFORM.downcase.include?('darwin') && !ENV['NO_HEADLESS'] @@ -53,7 +45,7 @@ end end - config.mock_with :rspec + config.mock_with :mocha config.before(:all) do WashoutBuilder::Engine.config.wash_out = { snakecase_input: false,