yujinakayama/transpec

`RSpec.context` wrongly used in a nested context

myronmarston opened this issue · 1 comments

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>'

Woops, duplicate of #89, sorry!