README.md in acfs-0.26.0.1.b243 vs README.md in acfs-0.27.0
- old
+ new
@@ -145,14 +145,14 @@
```ruby
class Single < Acfs::SingletonResource
service UserService # Associate `Single` model with `UserService`.
# Define model attributes and types as with regular resources
-
+
attribute :name, :string, default: 'Anonymous'
attribute :age, :integer
-
+
end
```
The following code explains the routing for singleton resource requests:
@@ -215,12 +215,17 @@
## Stubbing
You can stub resources in applications using an Acfs service client:
```ruby
-# Enable stubs in spec helper
-Acfs::Stub.enable
+# spec_helper.rb
+# This will enable stabs before each spec and clear internal state
+# after each spec.
+require 'acfs/rspec'
+```
+
+```ruby
before do
@stub = Acfs::Stub.resource MyUser, :read, with: { id: 1 }, return: { id: 1, name: 'John Smith', age: 32 }
Acfs::Stub.resource MyUser, :read, with: { id: 2 }, raise: :not_found
Acfs::Stub.resource Session, :create, with: { ident: 'john@exmaple.org', password: 's3cr3t' }, return: { id: 'longhash', user: 1 }
Acfs::Stub.resource MyUser, :update, with: lambda { |op| op.data.include? :my_var }, raise: 400