Skip to content

Clarity around using a construct in a before block for rspec #5

Description

@programingnotes

hi @bhb I am currently experiencing a situation similar to that discussed in this issue

describe '#create_domain_dir' do 
  context 'when directory does exist' do 
    before do 
      within_construct do |construct|
        @created_here = file_creator.create_domain_dir(domain_name)
      end
    end

    it 'returns said directory' do 
      within_construct do |construct|
        created = file_creator.create_domain_dir(domain_name)
        expect(created).to eq(@created_here)
      end
    end
  end
end

the feedback in the issue referred to suggests to " use the RSpec integration and make calls in
your setup block" but doing this results in an error:

RSpec::Core::ExampleGroup::WrongScopeError: `example` is not available from 
within an example (e.g. an `it` block) or from constructs that run in the scope of 
an example (e.g. `before`, `let`, etc). It is only available on an example group 
(e.g. a `describe` or `context` block).

I have looked through rspec_integration but can't seem to figure out how to accomplish keeping the construct around till my example block runs.

Would appreciate feedback please. thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions