spec/lib/shamu/services/request_support_spec.rb in shamu-0.0.9 vs spec/lib/shamu/services/request_support_spec.rb in shamu-0.0.11
- old
+ new
@@ -47,10 +47,19 @@
model :record
attribute :id, on: :record
attribute :level, on: :record
attribute :amount, on: :record
end
+
+ class UsersService < Shamu::Services::Service
+ include Shamu::Services::RequestSupport
+ end
+
+ module UserRequest
+ class Change < Shamu::Services::Request
+ end
+ end
end
describe Shamu::Services::RequestSupport do
let( :service ) { scorpion.new RequestSupportSpec::Service }
@@ -70,10 +79,15 @@
Class.new( Shamu::Services::Service ) do
include Shamu::Services::RequestSupport
end.request_class( :change )
end.to raise_error Shamu::Services::IncompleteSetupError, /Request/
end
+
+ it "singularizes service namespace" do
+ service = scorpion.new RequestSupportSpec::UsersService
+ expect( service.request_class( :change ) ).to be RequestSupportSpec::UserRequest::Change
+ end
it "uses common alias fallback new -> create" do
expect( service.request_class( :new ) ).to be RequestSupportSpec::Request::Create
end
@@ -148,6 +162,6 @@
it "returns request" do
request = service.request_for( :create )
expect( request ).to be_a Shamu::Services::Request
end
end
-end
\ No newline at end of file
+end