Skip to content

Instantly share code, notes, and snippets.

@jivagoalves
Created June 17, 2014 14:32
Show Gist options
  • Save jivagoalves/cf238e634b8967e6e14c to your computer and use it in GitHub Desktop.
Save jivagoalves/cf238e634b8967e6e14c to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe "class visibility" do
class ClassDefinedAtDescribeLevel; end
it { class ClassDefinedAtItLevel; end }
end
puts "#{ClassDefinedAtDescribeLevel} defined"
# puts "#{ClassDefinedAtItLevel} defined" # raises error
@jivagoalves
Copy link
Author

Output from spec above

$ bundle exec rspec --seed $RANDOM spec/class_visibility_spec.rb
ClassDefinedAtDescribeLevel defined
.

Finished in 2.97 seconds
1 example, 0 failures

Randomized with seed 27867

Output from spec above with puts "#{ClassDefinedAtItLevel} defined":

$ bundle exec rspec --seed $RANDOM spec/class_visibility_spec.rb
ClassDefinedAtDescribeLevel defined
/home/jivago/code/myproject/spec/class_visibility_spec.rb:10:in `<top (required)>': uninitialized constant ClassDefinedAtItLevel (NameError)
        from /home/jivago/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
        from /home/jivago/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
        from /home/jivago/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
        from /home/jivago/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
        from /home/jivago/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
        from /home/jivago/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
        from /home/jivago/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

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