From 9b07bf24dd441f5e9ce75b03c05666fa8d502d2a Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 6 Dec 2011 10:28:55 -0800 Subject: [PATCH] add test for helpers in external files --- features/helpers_external.feature | 6 ++++++ fixtures/external-helpers/config.rb | 4 ++++ fixtures/external-helpers/lib/hello_helper.rb | 5 +++++ fixtures/external-helpers/source/index.html.erb | 1 + lib/middleman/core_extensions/extensions.rb | 3 +++ 5 files changed, 19 insertions(+) create mode 100644 features/helpers_external.feature create mode 100644 fixtures/external-helpers/config.rb create mode 100644 fixtures/external-helpers/lib/hello_helper.rb create mode 100644 fixtures/external-helpers/source/index.html.erb diff --git a/features/helpers_external.feature b/features/helpers_external.feature new file mode 100644 index 00000000..6e6b6f7b --- /dev/null +++ b/features/helpers_external.feature @@ -0,0 +1,6 @@ +Feature: Helpers in external files + + Scenario: Hello Helper + Given the Server is running at "external-helpers" + Then going to "/index.html" should not raise an exception + And I should see "Hello World" \ No newline at end of file diff --git a/fixtures/external-helpers/config.rb b/fixtures/external-helpers/config.rb new file mode 100644 index 00000000..3de1ebc7 --- /dev/null +++ b/fixtures/external-helpers/config.rb @@ -0,0 +1,4 @@ +require "lib/hello_helper" +helpers HelloHelper + +page "/", :layout => false \ No newline at end of file diff --git a/fixtures/external-helpers/lib/hello_helper.rb b/fixtures/external-helpers/lib/hello_helper.rb new file mode 100644 index 00000000..1b2e6e99 --- /dev/null +++ b/fixtures/external-helpers/lib/hello_helper.rb @@ -0,0 +1,5 @@ +module HelloHelper + def hello + "Hello World" + end +end \ No newline at end of file diff --git a/fixtures/external-helpers/source/index.html.erb b/fixtures/external-helpers/source/index.html.erb new file mode 100644 index 00000000..efafd361 --- /dev/null +++ b/fixtures/external-helpers/source/index.html.erb @@ -0,0 +1 @@ +<%= hello %> \ No newline at end of file diff --git a/lib/middleman/core_extensions/extensions.rb b/lib/middleman/core_extensions/extensions.rb index 6ddd1b7c..c0644ef6 100644 --- a/lib/middleman/core_extensions/extensions.rb +++ b/lib/middleman/core_extensions/extensions.rb @@ -94,6 +94,9 @@ module Middleman::CoreExtensions::Extensions run_hook :before_configuration + # Search the root of the project for required files + $LOAD_PATH.unshift(root) + # Check for and evaluate local configuration local_config = File.join(root, "config.rb") if File.exists? local_config