From: Michal Fojtik <[email protected]>
Signed-off-by: Michal fojtik <[email protected]> --- server/spec/spec_helper.rb | 2 +- .../cimi/features/step_definitions/common_steps.rb | 10 ++++------ .../features/step_definitions/machines_steps.rb | 16 +++++++++++----- server/tests/cimi/features/support/env.rb | 8 ++++++-- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/server/spec/spec_helper.rb b/server/spec/spec_helper.rb index 69d4797..8599a71 100644 --- a/server/spec/spec_helper.rb +++ b/server/spec/spec_helper.rb @@ -16,7 +16,7 @@ require 'rubygems' require 'pp' -require 'rspec' +require 'rspec/core' require 'deltacloud/core_ext' require 'cimi/model' require 'xmlsimple' diff --git a/server/tests/cimi/features/step_definitions/common_steps.rb b/server/tests/cimi/features/step_definitions/common_steps.rb index 9131171..a0a0cb7 100644 --- a/server/tests/cimi/features/step_definitions/common_steps.rb +++ b/server/tests/cimi/features/step_definitions/common_steps.rb @@ -17,18 +17,17 @@ When /^client lists ([\w ]+) collection$/ do |col_name| header 'Accept', 'application/xml' get "/cimi/%s" % col_name.to_collection_uri last_response.status.should == 200 - puts last_response.body end Then /^client should get list of all ([\w ]+)$/ do |col_name| - root_name = "#{col_name.to_class_name}Collection" + root_name = "#{col_name.to_collection_name}Collection" last_xml_response.root.name.should == root_name (last_xml_response/"#{root_name}/name").size.should == 1 (last_xml_response/"#{root_name}/name").first.text.should == 'default' (last_xml_response/"#{root_name}/uri").size.should == 1 (last_xml_response/"#{root_name}/uri").first.text.should == last_request.url - (last_xml_response/"#{root_name}/#{col_name.to_class_name}").size.should == 3 - (last_xml_response/"#{root_name}/#{col_name.to_class_name}").each do |machine_img| + (last_xml_response/"#{root_name}/#{col_name.to_entity_name}").size.should == 3 + (last_xml_response/"#{root_name}/#{col_name.to_entity_name}").each do |machine_img| machine_img[:href].should_not be_nil machine_img[:href].should =~ /http:\/\/example\.org\/cimi\/#{col_name.to_collection_uri}\/img(\d)/ end @@ -39,7 +38,6 @@ When /^client( should be able to)? query for '(\w+)' ([\w ]+) entity$/ do |s, en header 'Accept', 'application/xml' get "/cimi/%s/%s" % [entity_name.to_entity_uri, entity_id] last_response.status.should == 200 - puts last_response.body @entity_id = entity_id end @@ -50,7 +48,7 @@ Then /^client should verify that this ([\w ]+) exists$/ do |entity_name| end Then /^client should verify that this ([\w ]+) has set$/ do |entity, attrs| - model = CIMI::Model.const_get(entity.to_entity_name).from_xml(last_response.body) + model = CIMI::Model.const_get(entity.to_class_name).from_xml(last_response.body) attrs.rows_hash.each do |key, value| if key =~ /^\*/ model.send(key.gsub(/^\*/, '').intern).href.should == value diff --git a/server/tests/cimi/features/step_definitions/machines_steps.rb b/server/tests/cimi/features/step_definitions/machines_steps.rb index a8b63d0..0073634 100644 --- a/server/tests/cimi/features/step_definitions/machines_steps.rb +++ b/server/tests/cimi/features/step_definitions/machines_steps.rb @@ -23,12 +23,12 @@ When /^client specifies a new Machine using$/ do |machine| @machine_configuration.should_not be_nil @new_machine_name = machine.raw[0][1] @builder = Nokogiri::XML::Builder.new do |xml| - xml.Machine(:xmlns => CMWG_NAMESPACE) { + xml.MachineCreate(:xmlns => CMWG_NAMESPACE) { xml.name @new_machine_name xml.description machine.raw[1][1] - xml.MachineTemplate { - xml.MachineConfig( :href => @machine_configuration.uri ) - xml.MachineImage( :href => @machine_image.uri ) + xml.machineTemplate { + xml.machineConfig( :href => @machine_configuration.uri ) + xml.machineImage( :href => @machine_image.uri ) } } end @@ -38,6 +38,9 @@ Then /^client should be able to create this Machine$/ do authorize 'mockuser', 'mockpassword' header 'Content-Type', 'application/xml' post '/cimi/machines', @builder.to_xml + if [500, 501, 502].include? last_response.status + puts last_response.body + end last_response.status.should == 201 set_new_machine(CIMI::Model::Machine.from_xml(last_response.body)) end @@ -46,6 +49,9 @@ Then /^client query for created Machine entity$/ do authorize 'mockuser', 'mockpassword' header 'Content-Type', 'application/xml' get "/cimi/machines/%s" % new_machine.name + if [500, 501, 502].include? last_response.status + puts last_response.body + end if @delete_operation last_response.status.should == 404 else @@ -75,7 +81,7 @@ When /^client executes (\w+) operation on created Machine$/ do |operation| authorize 'mockuser', 'mockpassword' header 'Content-Type', 'application/xml' if operation == 'delete' - delete "/cimi/machines/%s/delete" % new_machine.name + delete "/cimi/machines/%s" % new_machine.name last_response.status.should == 200 last_response.body.should be_empty @delete_operation = true diff --git a/server/tests/cimi/features/support/env.rb b/server/tests/cimi/features/support/env.rb index 06ff3d6..c5e2bf0 100644 --- a/server/tests/cimi/features/support/env.rb +++ b/server/tests/cimi/features/support/env.rb @@ -27,11 +27,15 @@ end class String def to_class_name - to_entity_name.singularize + to_collection_name end def to_entity_name - self.tr(' ', '') + to_collection_name.uncapitalize + end + + def to_collection_name + self.tr(' ', '').singularize end def to_collection_uri -- 1.7.4.4
