Created
March 25, 2013 21:45
-
-
Save gabetax/5241086 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/vagrant/test_spec.rb:3:in `block in <top (required)>': undefined local variable or method `foo' for #<Class:0x000000020035c8> (NameError) | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/example_group.rb:244:in `module_eval' | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/example_group.rb:244:in `subclass' | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/example_group.rb:230:in `describe' | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/dsl.rb:18:in `describe' | |
from /vagrant/test_spec.rb:1:in `<top (required)>' | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `load' | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `block in load_spec_files' | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `each' | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `load_spec_files' | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/command_line.rb:22:in `run' | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/runner.rb:80:in `run' | |
from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.1/lib/rspec/core/runner.rb:17:in `block in autorun' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "test" do | |
let(:foo) { double('my test', bar: "hooray") } | |
describe "i can access let vars: #{foo.bar}" | |
end |
cupakromer
commented
Mar 25, 2013
also you could do:
shared_example 'pass the var' do |target|
it { public_send(target).should eq 'test' }
end
describe 'test' do
let(:foo) { 'test' }
it_behaves_like 'pass the var' :foo
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment