---
title: "Discussion on \"RSpec - Use shared_examples to avoid duplicate test examples\" | Hashnode"
description: "Discussion on \"RSpec - Use shared_examples to avoid duplicate test examples\". It's common to see a before_action method that need executing in different controller actions. At the same time, when writing RSpec tests for these actions, it's easily to write down context blocks whose test examples are almost the same, and only a ..."
url: "https://hashnode.com/posts/rspec-use-sharedexamples-to-avoid-duplicate-test-examples/65c478150f130843bacc96c3"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [RSpec - Use shared\_examples to avoid duplicate test examples](https://lynnbright.com/rspec-use-sharedexamples-to-avoid-duplicate-test-examples?utm_source=hashnode&utm_medium=feed)

It's common to see a before\_action method that need executing in different controller actions. At the same time, when writing RSpec tests for these actions, it's easily to write down context blocks whose test examples are almost the same, and only a ...

Aug 1, 2021 · 4 min read · lynnbright.com  
Read the article

-   [#ruby-on-rails](https://hashnode.com/tag/ruby-on-rails)
-   [#rspec](https://hashnode.com/tag/rspec)

## Written by

[Lynn Chang](https://hashnode.com/@Lynnbright)

@Lynnbright · Taipei, Taiwan

  
[View profile](https://hashnode.com/@Lynnbright)

Rails Developer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
