spec/item_definition_spec.rb in amee-3.2.1 vs spec/item_definition_spec.rb in amee-4.0.0
- old
+ new
@@ -1,9 +1,9 @@
# Copyright (C) 2008-2011 AMEE UK Ltd. - http://www.amee.com
# Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.
-require File.dirname(__FILE__) + '/spec_helper.rb'
+require 'spec_helper.rb'
describe AMEE::Admin::ItemDefinition do
before(:each) do
@item_definition = AMEE::Admin::ItemDefinition.new
@@ -33,11 +33,11 @@
describe AMEE::Admin::ItemDefinition, "with an authenticated connection" do
it "should parse XML correctly" do
connection = flexmock "connection"
- connection.should_receive(:v3_get).with("/#{AMEE::Connection.api_version}/definitions/BD88D30D1214;full", {}).and_return(fixture('BD88D30D1214.xml'))
+ connection.should_receive(:v3_get).with("/3.3/definitions/BD88D30D1214;full", {}).and_return(fixture('BD88D30D1214.xml'))
@data = AMEE::Admin::ItemDefinition.load(connection,"BD88D30D1214")
@data.uid.should == "BD88D30D1214"
@data.created.should == DateTime.new(2007,7,27,7,30,44)
@data.modified.should == DateTime.new(2011,2,16,8,40,06)
@data.name.should == "Bus Generic"
@@ -45,11 +45,11 @@
@data.full_path.should == '/definitions/itemDefinitions/BD88D30D1214'
end
it "should parse JSON correctly" do
connection = flexmock "connection"
- connection.should_receive(:v3_get).with("/#{AMEE::Connection.api_version}/definitions/BD88D30D1214;full", {}).and_return(fixture('BD88D30D1214.xml'))
+ connection.should_receive(:v3_get).with("/3.3/definitions/BD88D30D1214;full", {}).and_return(fixture('BD88D30D1214.xml'))
@data = AMEE::Admin::ItemDefinition.load(connection,"BD88D30D1214")
@data.uid.should == "BD88D30D1214"
@data.created.should == DateTime.new(2007,7,27,7,30,44)
@data.modified.should == DateTime.new(2011,2,16,8,40,06)
@data.name.should == "Bus Generic"
@@ -57,13 +57,13 @@
@data.full_path.should == '/definitions/itemDefinitions/BD88D30D1214'
end
it "should be able to load an item value definition list" do
connection = flexmock "connection"
- connection.should_receive(:v3_get).with("/#{AMEE::Connection.api_version}/definitions/BD88D30D1214;full", {}).and_return(fixture('BD88D30D1214.xml'))
+ connection.should_receive(:v3_get).with("/3.3/definitions/BD88D30D1214;full", {}).and_return(fixture('BD88D30D1214.xml'))
connection.should_receive(:retries).and_return(0).once
- connection.should_receive(:v3_get).with("/#{AMEE::Connection.api_version}/definitions/BD88D30D1214/values;full", {:resultStart=>0, :resultLimit=>10}).and_return(fixture('ivdlist_BD88D30D1214.xml')).once
+ connection.should_receive(:v3_get).with("/3.3/definitions/BD88D30D1214/values;full", {:resultStart=>0, :resultLimit=>10}).and_return(fixture('ivdlist_BD88D30D1214.xml')).once
@data = AMEE::Admin::ItemDefinition.load(connection,"BD88D30D1214")
@data.uid.should == "BD88D30D1214"
@list=@data.item_value_definition_list
@list.length.should==15
@list.first.uid.should=='9813267B616E'
@@ -269,11 +269,11 @@
it "Should retry on parse failures" do
connection = flexmock "connection"
connection.should_receive(:retries).and_return(2).once
connection.should_receive(:get).with("/definitions/itemDefinitions",{}).twice.
- and_return flexmock(:body =>DefinitionsListResponse.first(12))
+ and_return flexmock(:body =>DefinitionsListResponse[0,12])
connection.should_receive(:expire).with("/definitions/itemDefinitions").times(2)
connection.should_receive(:get).with("/definitions/itemDefinitions",{}).once.
and_return flexmock(:body =>DefinitionsListResponse)
@list=AMEE::Admin::ItemDefinitionList.new(connection)
@list.first.should be_a AMEE::Admin::ItemDefinition
@@ -284,10 +284,10 @@
it "Should retry on parse failures and bubble up failure if never successful" do
connection = flexmock "connection"
connection.should_receive(:retries).and_return(2).once
connection.should_receive(:get).with("/definitions/itemDefinitions",{}).times(3).
- and_return flexmock(:body =>DefinitionsListResponse.first(12))
+ and_return flexmock(:body =>DefinitionsListResponse[0,12])
connection.should_receive(:expire).with("/definitions/itemDefinitions").times(3)
lambda {
AMEE::Admin::ItemDefinitionList.new(connection)
}.should raise_error(Nokogiri::XML::SyntaxError)
end
\ No newline at end of file