Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

同じコンテキストに複数のexampleがあると後勝ちでdescriptionが上書きされる #39

Closed
nanophate opened this issue Feb 1, 2017 · 1 comment

Comments

@nanophate
Copy link

問題

一つの同じContextの中でinclude_examplesし、その中でdescriptionを定義すると、後勝ちでdescriptionが上書きされます。

以下のような:point_down:の内容を実行したところこのバグを発見しました。

require 'rails_helper'

RSpec.describe 'Users', :autodoc do

  describe 'GET /users/:user_id' do
    let(:user) { create(:user) }

    shared_examples 'page not found' do
     it { is_expected.to eq(404) }
    end

    shared_examples 'page accesable ' do
      it { is_expected.to eq(200) }
    end

    include_examples 'page not found' do
      let(:user_id) { user.tap(&:destroy).id }
      let(:description) { 'When user is not exist' }

    end

    include_examples 'page accesable' do
      let(:user_id) { user.id }
      let(:description) { 'When user exist' }
    end
  end
end
## GET /users/:user_id
- When user exist


### Example

#### Request

...

## GET /users/:user_id
- When user exist


### Example

#### Request
@r7kamura
Copy link
Owner

r7kamura commented Feb 1, 2017

報告ありがとうございます 🙏

include_examples に block を渡したときに、context の内容がどうなるかについて把握していませんでしたが、確かに起り得そうな話に見えます。

if @context.respond_to?(:description)
@context.description.strip_heredoc
else
example.description.sub(/\A./, &:upcase).concat('.')
end

簡単に見てみたところ、改善できるとしたらこの辺りのコードを変更すると直るかもしれないなと思って見ています。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants