Skip to content

Commit b66be63

Browse files
update documentation
1 parent 264e1c6 commit b66be63

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,26 @@ RSpec.describe Article do
257257
end
258258

259259
# when the touch option is provided, then we can also verify that it is set.
260+
261+
# by default, with_touch matches true when no parameters are provided.
262+
describe Article do
263+
it { is_expected.to belong_to(:author).of_type(User).as_inverse_of(:articles).with_index.with_touch }
264+
end
265+
266+
# parameters are supported for explicit matching.
267+
describe Comment do
268+
it { is_expected.to be_embedded_in(:article).as_inverse_of(:comments).with_polymorphism.with_touch(true) }
269+
end
270+
260271
describe Permalink do
261272
it { is_expected.to be_embedded_in(:linkable).as_inverse_of(:link).with_touch(false) }
262273
end
263274

275+
# touch can also take a symbol represneting a field on the parent to touch.
276+
describe Record do
277+
it { is_expected.to belong_to(:user).as_inverse_of(:record).with_touch(:record_updated_at) }
278+
end
279+
264280
RSpec.describe Comment do
265281
it { is_expected.to be_embedded_in(:article).as_inverse_of(:comments) }
266282
it { is_expected.to belong_to(:user).as_inverse_of(:comments) }

0 commit comments

Comments
 (0)