Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

accessing constants from another module within Examples doesn't work #41

Closed
@jarmo

Description

@jarmo

When including module within ExampleGroup then constants from that module should be accessible directly without specifying module name:

module MyModule 
  MyConstant = 1 
  
  def my_method 
    2 
  end 
end 

describe "including modules" do 
  include MyModule 

  it "works" do 
    my_method.should == 2 
    MyModule::MyConstant.should == 1 
  end 

  it "doesn't work, but should" do 
    MyConstant.should == 1 
  end 
end 

Running this simple spec will produce one failure with this message:

1) 
NameError in 'including modules doesn't work' 
uninitialized constant MyConstant

But in regular Ruby everything works as expected:

class MyClass
  include MyModule

  def initialize
    p my_method
    p MyModule::MyConstant
    p MyConstant
  end
end

MyClass.new # produces 2 1 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions