spec/data_item_spec.rb in amee-3.2.1 vs spec/data_item_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::Data::Item do
before(:each) do
@item = AMEE::Data::Item.new
@@ -125,19 +125,19 @@
end
it "should fail gracefully with bad XML" do
connection = flexmock "connection"
connection.should_receive(:retries).and_return(0)
- connection.should_receive(:get).with("/data/transport/plane/generic/AD63A83B4D41", {}).and_return(flexmock(:body => fixture('AD63A83B4D41.xml').first(12)))
+ connection.should_receive(:get).with("/data/transport/plane/generic/AD63A83B4D41", {}).and_return(flexmock(:body => fixture('AD63A83B4D41.xml')[0,12]))
connection.should_receive(:expire).with("/data/transport/plane/generic/AD63A83B4D41").once
lambda{AMEE::Data::Item.get(connection, "/data/transport/plane/generic/AD63A83B4D41")}.should raise_error(REXML::ParseException)
end
it "should retry if bad XML is received first time" do
connection = flexmock "connection"
connection.should_receive(:retries).and_return(2)
- connection.should_receive(:get).with("/data/transport/plane/generic/AD63A83B4D41", {}).and_return(flexmock(:body => fixture('AD63A83B4D41.xml').first(12))).twice
+ connection.should_receive(:get).with("/data/transport/plane/generic/AD63A83B4D41", {}).and_return(flexmock(:body => fixture('AD63A83B4D41.xml')[0,12])).twice
connection.should_receive(:expire).with("/data/transport/plane/generic/AD63A83B4D41").twice
connection.should_receive(:get).with("/data/transport/plane/generic/AD63A83B4D41", {}).and_return(flexmock(:body => fixture('AD63A83B4D41.xml'))).once
lambda{AMEE::Data::Item.get(connection, "/data/transport/plane/generic/AD63A83B4D41")}.should_not raise_error
end
@@ -150,18 +150,18 @@
end
it "should fail gracefully with bad JSON" do
connection = flexmock "connection"
connection.should_receive(:retries).and_return(0)
- connection.should_receive(:get).with("/data/transport/plane/generic/AD63A83B4D41", {}).and_return(flexmock(:body => fixture('AD63A83B4D41.json').first(12)))
+ connection.should_receive(:get).with("/data/transport/plane/generic/AD63A83B4D41", {}).and_return(flexmock(:body => fixture('AD63A83B4D41.json')[0,12]))
connection.should_receive(:expire).with("/data/transport/plane/generic/AD63A83B4D41").once
lambda{AMEE::Data::Item.get(connection, "/data/transport/plane/generic/AD63A83B4D41")}.should raise_error(JSON::ParserError)
end
it "should retry if bad JSON is received first time" do
connection = flexmock "connection"
connection.should_receive(:retries).and_return(2)
- connection.should_receive(:get).with("/data/transport/plane/generic/AD63A83B4D41", {}).and_return(flexmock(:body => fixture('AD63A83B4D41.json').first(12))).twice
+ connection.should_receive(:get).with("/data/transport/plane/generic/AD63A83B4D41", {}).and_return(flexmock(:body => fixture('AD63A83B4D41.json')[0,12])).twice
connection.should_receive(:expire).with("/data/transport/plane/generic/AD63A83B4D41").twice
connection.should_receive(:get).with("/data/transport/plane/generic/AD63A83B4D41", {}).and_return(flexmock(:body => fixture('AD63A83B4D41.json'))).once
lambda{AMEE::Data::Item.get(connection, "/data/transport/plane/generic/AD63A83B4D41")}.should_not raise_error
end
\ No newline at end of file