Skip to content

Commit

Permalink
Provide tests as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
simpsonjulian committed Aug 14, 2012
1 parent a871d00 commit cfd281f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,12 @@ def clean_database(sanity_check = "not_really")
false
end
end

def merge_options(options)
merged_options = options.merge!(@authentication).merge!(@parser)
merged_options[:headers].merge!(@user_agent) if merged_options[:headers]
merged_options
end

private

Expand Down Expand Up @@ -571,12 +577,6 @@ def evaluate_response(response)
end
end

def merge_options(options)
merged_options = options.merge!(@authentication).merge!(@parser)
merged_options[:headers].merge!(@user_agent) if merged_options[:headers]
merged_options
end

def get(path,options={})
evaluate_response(HTTParty.get(configuration + URI.encode(path), merge_options(options)))
end
Expand Down
20 changes: 20 additions & 0 deletions spec/integration/rest_header_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')

describe Neography::Rest do
before(:each) do
@neo = Neography::Rest.new
end

it "should not add a content-type header if there's no existing headers" do
@neo.merge_options({}).should == {:parser => OjParser}
end

it "should add a content type if there's existing headers" do
@neo.merge_options({:headers => {'Content-Type' => 'foo/bar'}}).should ==
{:headers => {'Content-Type' => "foo/bar",
"User-Agent" => "Neography/#{Neography::VERSION}"},
:parser => OjParser}
end


end

0 comments on commit cfd281f

Please sign in to comment.