Skip to content

Commit 1dbf134

Browse files
committed
Add specs for Routing#namespace
1 parent 2b1b0c6 commit 1dbf134

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/grape/dsl/routing.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def route(methods, paths = ['/'], route_options = {}, &block)
134134
end
135135
end
136136

137-
def namespace(space = nil, options = {}, &block)
137+
def namespace(space = nil, options = {}, &block)
138138
if space || block_given?
139139
within_namespace do
140140
previous_namespace_description = @namespace_description

spec/grape/dsl/routing_spec.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,24 @@ class Dummy
152152
end
153153
end
154154

155-
xdescribe '.namespace' do
156-
it 'does some thing'
155+
describe '.namespace' do
156+
let(:new_namespace) { Object.new }
157+
158+
it 'creates a new namespace with given name and options' do
159+
expect(subject).to receive(:within_namespace).and_yield
160+
expect(subject).to receive(:nest).and_yield
161+
expect(Namespace).to receive(:new).with(:foo, foo: 'bar').and_return(new_namespace)
162+
expect(subject).to receive(:namespace_stackable).with(:namespace, new_namespace)
163+
164+
subject.namespace :foo, foo: 'bar', &proc{}
165+
end
166+
167+
it 'calls #joined_space_path on Namespace' do
168+
result_of_namspace_stackable = Object.new
169+
allow(subject).to receive(:namespace_stackable).and_return(result_of_namspace_stackable)
170+
expect(Namespace).to receive(:joined_space_path).with(result_of_namspace_stackable)
171+
subject.namespace
172+
end
157173
end
158174

159175
describe '.group' do

0 commit comments

Comments
 (0)