[rspec-users] RSpec doesn't see the DATA constant
shamaoke at hotmail.com
Thu Feb 24 01:35:51 EST 2011
In Ruby there's the `DATA` constant which contains the lines following
the `__END__` keyword in the source file. For some reason RSpec
doesn't see it.
Here's the example:
describe 'DATA' do
it 'contains lines following the __END__ keyword' do
DATA.read.should == "Hello from underground!\n"
Hello from underground!
If then I run `$ rspec data_spec.rb`, I'm getting 'NameError:
uninitialized constant RSpec::Core::ExampleGroup::Nested_1::DATA'.
However, if I use `$ ruby data_spec.rb` all works fine.
Why RSpec doesn't see the constant when I use the `rspec` command? How
can I solve the problem?
Debian GNU/Linux 5.0.7;
More information about the rspec-users