spec/client/template_spec.rb in mirage-3.0.0.alpha.2 vs spec/client/template_spec.rb in mirage-3.0.0.alpha.3
- old
+ new
@@ -1,12 +1,10 @@
require 'spec_helper'
require 'mirage/client'
describe Mirage::Template do
- Template = Mirage::Template
- Request = Mirage::Request
describe 'get' do
it 'should load a template given its id' do
endpoint = "endpoint"
id = 1
@@ -14,10 +12,11 @@
value = "Hello"
default = false
delay = 1.2
content_type = "application/json"
status = 201
+ headers = {'header' => 'value'}
required_parameters = {"name" => 'joe'}
required_body_content = %{content}
required_headers = {"header" => 'value'}
@@ -31,10 +30,11 @@
default: default,
body: value,
delay: delay,
content_type: content_type,
status: status,
+ headers: headers
},
request: {
parameters: required_parameters,
body_content: required_body_content,
headers: required_headers,
@@ -53,10 +53,11 @@
template.default.should == default
template.default.should == default
template.delay.should == delay
template.content_type.should == content_type
template.status.should == status
+ template.headers.should == headers
template.required_parameters.should == required_parameters
template.required_body_content.should == required_body_content
template.required_headers.should == required_headers
template.http_method.should == http_method
@@ -233,9 +234,16 @@
content_type = "application/json"
response = Template.new "endpoint", "value"
response.content_type = content_type
JSON.parse(response.to_json)["response"]["content_type"].should == content_type
end
+ end
+
+ it 'should set headers' do
+ header, value = 'header', 'value'
+ template = Template.new 'endpoint', value
+ template.headers[header] = value
+ JSON.parse(template.to_json)["response"]["headers"].should == {header => value}
end
end
end