spec/service_spec.rb in ruby_odata-0.1.1 vs spec/service_spec.rb in ruby_odata-0.1.2
- old
+ new
@@ -34,10 +34,27 @@
it "should call the correct metadata uri when additional_params are passed in" do
svc = OData::Service.new "http://test.com/test.svc/", { :additional_params => { :x => 1, :y => 2 } }
a_request(:get, "http://test.com/test.svc/$metadata?x=1&y=2").should have_been_made
end
end
+
+ describe "rest-client options" do
+ before(:each) do
+ # Required for the build_classes method
+ stub_request(:get, /http:\/\/test\.com\/test\.svc\/\$metadata(?:\?.+)?/).
+ with(:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate'}).
+ to_return(:status => 200, :body => File.new(File.expand_path("../fixtures/edmx_empty.xml", __FILE__)), :headers => {})
+ end
+ it "should accept in options that will be passed to the rest-client lib" do
+ svc = OData::Service.new "http://test.com/test.svc/", { :rest_options => { :ssl_ca_file => "ca_certificate.pem" } }
+ svc.options[:rest_options].should eq Hash[:ssl_ca_file => "ca_certificate.pem"]
+ end
+ it "should merge the rest options with the built in options" do
+ svc = OData::Service.new "http://test.com/test.svc/", { :rest_options => { :ssl_ca_file => "ca_certificate.pem" } }
+ svc.instance_variable_get(:@rest_options).should eq Hash[:verify_ssl => 1, :user => nil, :password => nil, :ssl_ca_file => "ca_certificate.pem"]
+ end
+ end
end
describe "additional query string parameters" do
before(:each) do
# Required for the build_classes method
stub_request(:any, /http:\/\/test\.com\/test\.svc(?:.*)/).
@@ -464,10 +481,19 @@
svc.load_property(category, "Products")
category.Products.first.should be_a Product
category.Products[0].Id.should eq 1
category.Products[1].Id.should eq 2
end
+
+ it "should not mutate the object's metadata" do
+ svc = OData::Service.new "http://test.com/test.svc/"
+ svc.Products(1)
+ product = svc.execute.first
+ original_metadata = product.__metadata.to_json
+ svc.load_property(product, "Category")
+ product.__metadata.to_json.should == original_metadata
+ end
end
describe "find, create, add, update, and delete" do
after(:each) do
Object.send(:remove_const, 'Product') if Object.const_defined? 'Product'
@@ -702,10 +728,16 @@
it { should eq @category }
end
end
end
end
+
+ describe "restful options" do
+ it "should allow " do
+
+ end
+ end
end
describe_private OData::Service do
describe "parse value" do
before(:each) do
@@ -721,6 +753,6 @@
element_to_parse = Nokogiri::XML.parse('<d:AvailableFrom m:type="Edm.DateTime">2100-01-01T00:00:00</d:AvailableFrom>').elements[0]
lambda { svc.parse_value(element_to_parse) }.should_not raise_exception
end
end
end
-end
\ No newline at end of file
+end