Skip to content

Commit d90f13d

Browse files
committed
Merge pull request #2520 from mirkode/main
Add a scenario for using subdomain constrained routes
1 parent 69cc6c8 commit d90f13d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

features/request_specs/request_spec.feature

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,27 @@ Feature: request spec
152152
"""
153153
When I run `rspec spec`
154154
Then the example should pass
155+
156+
Scenario: testing subdomain constrained requests
157+
Given a file named "spec/requests/widgets_spec.rb" with:
158+
"""ruby
159+
require "rails_helper"
160+
161+
Rails.application.routes.draw do
162+
resources :widgets, constraints: { subdomain: "api" }
163+
end
164+
165+
RSpec.describe "Widget management", :type => :request do
166+
before { host! "api.example.com" }
167+
168+
it "creates a Widget" do
169+
headers = { "ACCEPT" => "application/json" }
170+
post "/widgets", :params => { :widget => { :name => "My Widget" } }, :headers => headers
171+
172+
expect(response.content_type).to start_with("application/json")
173+
expect(response).to have_http_status(:created)
174+
end
175+
end
176+
"""
177+
When I run `rspec spec`
178+
Then the example should pass

0 commit comments

Comments
 (0)