On Aug 7, 2010, at 8:23 AM, Kristian Mandrup wrote: > I simply want all methods of a module to be always available within > the context of an Example group. > > module RSpec > module Generator > def with_generator &block > ... > end > > def setup_generator test_method_name=nil, &block > ... > end > end > end > > How do I achieve this? > > In RSpec 1 I think you would use ExampleGroupFactory > > I thought I could do it something like this with RSpec 2? > > RSpec.configure do |c| > c.extend RSpec::Generator > end > > I want to be able to do something like this > > before :each do
before hooks are eval'd in the scope of an example, which is an _instance_ of the example group class. Try using include instead of extend: c.include RSpec::Generator HTH, David > setup_generator 'migration_generator' do > tests MigrationGenerator > end > end > > it "should generate create_user migration" do > with_generator do |g| > ... > end > > Whereas now I have to do it like this, which I find a bit ugly and > cumbersome > > it "should generate create_user migration" do > RSpec::Generator.with_generator do |g| > name = 'create_users' > end > end > > Thanks. > _______________________________________________ > rspec-users mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
