spec/subroute_spec.rb in lookout-rack-utils-1.4.0 vs spec/subroute_spec.rb in lookout-rack-utils-1.5.0
- old
+ new
@@ -11,14 +11,31 @@
class RouteHelpers::Server
include Lookout::Rack::Utils::Subroute
get '/subrouted' do
subroute!('/test_route')
end
+
+ get '/subrouted/:id' do |id|
+ subroute!('/test_route', :id => id)
+ end
end
end
- it 'should return the status code and body of the route' do
- expect([subrouted.status, subrouted.body]).to eql [original.status, original.body]
+ context "without params" do
+ it 'should return the status code and body of the route' do
+ expect([subrouted.status, subrouted.body]).to eql [original.status, original.body]
+ end
+ end
+
+ context "with params" do
+ let(:id) { 1 }
+ let(:body) { { :key => 'value', :id => "#{id}" }.to_json }
+
+ subject(:subrouted) { get "/subrouted/#{id}?key=value" }
+
+ it 'should return expected value' do
+ expect([subrouted.status, subrouted.body]).to eql [200, body]
+ end
end
end
describe '#succeeded?' do
subject { SubrouteTestHelper.new.succeeded?(status) }