On Jul 22, 2011, at 8:23 AM, Jarmo Pertman wrote: > Hi! > > I have a directory structure something similar to: > spec/a/a_helper.rb > spec/a/a_spec.rb > spec/b/b_spec.rb > > In a_helper.rb i'd like to do something like this: > RSpec.configure do |config| > config.before :each do > # do something for every example under "a" directory > end > end > > It works okay if i run: > rspec spec/a > > or > > rspec spec/b > > > If however i'd like to run all specs, then i get the following > deprecation notice: > ***************************************************************** > DEPRECATION WARNING: you are using deprecated behaviour that will > be removed from RSpec 3. > > You have set some configuration options after an example group has > already been defined. In RSpec 3, this will not be allowed. All > configuration should happen before the first example group is > defined. The configuration is happening at: > > ./spec/a/a_helper.rb:2 > ***************************************************************** > > > How would i approach this problem differently where i'd like to set up > some global before :each block for all the examples under directory > "a", but doesn't want to run that block for all other examples? Is > there any meaningful way to solve that problem without any need to > write code for every example group under directory "a"? > > Jarmo
Take a look at how we do it in rspec-rails: https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/example.rb#L10-38 _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users