From 3d036499b8cc1096e5976ae7aec91185a3da119a Mon Sep 17 00:00:00 2001 From: "Jeffrey S. Morgan" Date: Thu, 27 Oct 2011 15:24:18 -0400 Subject: [PATCH] added env.rb items for require_all --- features/with_lib_option.feature | 10 +++++++++- lib/testgen/generators/project/Gemfile.tt | 2 -- lib/testgen/generators/project/env.rb.tt | 9 +++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/features/with_lib_option.feature b/features/with_lib_option.feature index 52fb0ab..3269060 100644 --- a/features/with_lib_option.feature +++ b/features/with_lib_option.feature @@ -6,11 +6,19 @@ Feature: Adding the --with-lib flag Scenario: Adding the require_all gem to Gemfile Then a file named "sample/Gemfile" should exist And the file "sample/Gemfile" should contain "gem 'require_all'" - And the file "sample/Gemfile" should contain "require_all 'lib'" Scenario: Creating the lib directory Then a directory named "sample/lib" should exist Scenario: Creating the pages directory in lib Then a directory named "sample/lib/pages" should exist + + Scenario: Adding lib to loadpath in env.rb + Then a file named "sample/features/support/env.rb" should exist + And the file "sample/features/support/env.rb" should contain "$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))" + + Scenario: Adding require_all stuff to the env.rb + Then a file named "sample/features/support/env.rb" should exist + And the file "sample/features/support/env.rb" should contain "require 'require_all'" + And the file "sample/features/support/env.rb" should contain "require_all 'lib'" \ No newline at end of file diff --git a/lib/testgen/generators/project/Gemfile.tt b/lib/testgen/generators/project/Gemfile.tt index 2aba748..b9d25f4 100644 --- a/lib/testgen/generators/project/Gemfile.tt +++ b/lib/testgen/generators/project/Gemfile.tt @@ -5,7 +5,5 @@ gem 'page-object' <% end -%> <% if with_lib == 'true' -%> gem 'require_all' - -require_all 'lib' <% end -%> diff --git a/lib/testgen/generators/project/env.rb.tt b/lib/testgen/generators/project/env.rb.tt index 0cb5da6..7d1ab52 100644 --- a/lib/testgen/generators/project/env.rb.tt +++ b/lib/testgen/generators/project/env.rb.tt @@ -1,8 +1,17 @@ +<% if with_lib == 'true' -%> +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib')) +<% end -%> + require 'rspec-expectations' <% unless pageobject_driver.downcase == 'none' -%> require 'page-object' require 'page-object/page_factory' <% end %> +<% if with_lib == 'true' -%> +require 'require_all' + +require_all 'lib' +<% end -%> <% unless pageobject_driver.downcase == 'none' -%>