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

RSpec.context wrongly used in a nested context #89

Closed
myronmarston opened this issue Aug 27, 2014 · 2 comments
Closed

RSpec.context wrongly used in a nested context #89

myronmarston opened this issue Aug 27, 2014 · 2 comments

Comments

@myronmarston
Copy link

Using the same transpec version, ruby version, rspec-mocks SHA, transpec command, etc as I documented in #88, I found that transpec wrongly transformed some spec files that had nesting like this:

describe "Outer group" do
  context "some inner context" do
  end
end

...into:

RSpec.describe "Outer group" do
  RSpec.context "some inner context" do
  end
end

...which leads to an RSpec error:

/Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/example_group.rb:214:in `block in define_example_group_method': Creating an isolated context from within a context is not allowed. Change `RSpec.context` to `context` or move this to a top-level scope. (RuntimeError)
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/dsl.rb:41:in `block in expose_example_group_alias'
    from /Users/myron/code/rspec-dev/repos/rspec-mocks/spec/rspec/mocks/expiration_spec.rb:57:in `block in <module:Mocks>'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/example_group.rb:333:in `module_exec'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/example_group.rb:333:in `subclass'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/example_group.rb:229:in `block in define_example_group_method'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/dsl.rb:41:in `block in expose_example_group_alias'
    from /Users/myron/code/rspec-dev/repos/rspec-mocks/spec/rspec/mocks/expiration_spec.rb:3:in `<module:Mocks>'
    from /Users/myron/code/rspec-dev/repos/rspec-mocks/spec/rspec/mocks/expiration_spec.rb:2:in `<module:RSpec>'
    from /Users/myron/code/rspec-dev/repos/rspec-mocks/spec/rspec/mocks/expiration_spec.rb:1:in `<top (required)>'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/configuration.rb:1078:in `load'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/configuration.rb:1078:in `block in load_spec_files'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/configuration.rb:1078:in `each'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/configuration.rb:1078:in `load_spec_files'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/runner.rb:97:in `setup'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/runner.rb:85:in `run'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/runner.rb:70:in `run'
    from /Users/myron/code/rspec-dev/repos/rspec-core/lib/rspec/core/runner.rb:38:in `invoke'
    from /Users/myron/code/rspec-dev/repos/rspec-core/exe/rspec:4:in `<top (required)>'
    from bin/rspec:12:in `load'
    from bin/rspec:12:in `<main>'
@yujinakayama
Copy link
Owner

This also seems to be caused by -s/--skip-dynamic-analysis, but maybe this can be handled with the static context inspector (of course not perfect though). I'll take a look.

@myronmarston
Copy link
Author

Thanks. I didn't realize how important the dynamic analysis was. From prior conversations I knew it got involved in things like picking how to convert the collection matchers but had no idea it got involved in the RSpec. bit.

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