-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from syucream/feature/hostname
Fix #76 Support Request#hostname
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require '../support/factory_girl_helper' | ||
include FactoryGirlHelper | ||
|
||
# generate template | ||
puts <<EOS | ||
template = "#{get(:request).template}" | ||
req = ATS::Request.new | ||
ATS::echo template % {hostname: req.hostname} | ||
EOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Request | ||
attr_accessor :path, :keys, :template | ||
end | ||
|
||
FactoryGirl.define do | ||
factory :request do | ||
keyhash = { | ||
'ATS::Request#hostname' => 'hostname' | ||
} | ||
|
||
path '/ats_request' | ||
keys keyhash | ||
template "{\n" + | ||
(keyhash.map do |k, v| " '#{k}': %{#{v}}" end).join("\n") + | ||
"\n}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require './spec_helper' | ||
|
||
describe 'ATS::Request class', :js => false do | ||
let (:request) { get(:request) } | ||
|
||
describe 'getter' do | ||
it 'gets request info' do | ||
visit request.path | ||
|
||
keys = request.keys | ||
keys.each do |k, v| | ||
expect(page.body).to match(/'#{k}': .+\n/) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters