Pregunta

I have the following Rspec structure

shared_context.rb

shared_context 'do something' do

end

test_spec.rb

shared_examples 'testing' do 

end

describe 'do something' do 
   it_should_behave_like 'testing'
   end
end

the shared_examples is dependent on shared_context . How do i include shared_context in shared_examples.

I tried using include_context, and tried require 'support/shared_context.rb' and they didn't work

Thanks

¿Fue útil?

Solución

Just requiring the file should work. Perhaps its not finding the file in question, you should use require require Rails.root.join('spec/support/shared_context.rb') to be sure.

I normally require the entire spec/support directory in my spec_helper.rb

Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top