diff --git a/features/preview_changes.feature b/features/preview_changes.feature new file mode 100644 index 00000000..f3a3bda1 --- /dev/null +++ b/features/preview_changes.feature @@ -0,0 +1,18 @@ +Feature: Preview Changes + In order to run quickly, we should update internal caches on file changes + + Scenario: A template changes contents during preview + Given the Server is running at "preview-app" + And the file "source/content.html.erb" has the contents + """ + Hello World + """ + When I go to "/content.html" + Then I should see "Hello World" + And the file "source/content.html.erb" has the contents + """ + Hola Mundo + """ + When I go to "/content.html" + Then I should see "Hola Mundo" + \ No newline at end of file diff --git a/fixtures/preview-app/config.rb b/fixtures/preview-app/config.rb new file mode 100644 index 00000000..e69de29b diff --git a/fixtures/preview-app/source/content.html.erb b/fixtures/preview-app/source/content.html.erb new file mode 100644 index 00000000..ade1f58b --- /dev/null +++ b/fixtures/preview-app/source/content.html.erb @@ -0,0 +1 @@ +Hola Mundo \ No newline at end of file diff --git a/fixtures/preview-app/source/layout.erb b/fixtures/preview-app/source/layout.erb new file mode 100644 index 00000000..cd9bb66d --- /dev/null +++ b/fixtures/preview-app/source/layout.erb @@ -0,0 +1 @@ +<%= yield %> \ No newline at end of file diff --git a/lib/middleman/step_definitions/middleman_steps.rb b/lib/middleman/step_definitions/middleman_steps.rb index 02139beb..b0c9ed77 100644 --- a/lib/middleman/step_definitions/middleman_steps.rb +++ b/lib/middleman/step_definitions/middleman_steps.rb @@ -1,3 +1,13 @@ Given /^a project at "([^\"]*)"$/ do |dirname| @target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname) +end + +Then /^the file "([^\"]*)" has the contents$/ do |path, contents| + file_path = File.expand_path(path, @target) + File.open(file_path, 'w') { |f| f.write(contents) } + step %Q{the file "#{path}" did change} +end + +Then /^the file "([^\"]*)" did change$/ do |path| + @server_inst.file_did_change(path) end \ No newline at end of file diff --git a/lib/middleman/step_definitions/server_steps.rb b/lib/middleman/step_definitions/server_steps.rb index d0f44041..189b0733 100644 --- a/lib/middleman/step_definitions/server_steps.rb +++ b/lib/middleman/step_definitions/server_steps.rb @@ -22,6 +22,8 @@ Given /^current environment is "([^\"]*)"$/ do |env| end Given /^the Server is running at "([^\"]*)"$/ do |app_path| + step %Q{a project at "#{app_path}"} + initialize_commands = @initialize_commands || [] initialize_commands.unshift lambda { set :root, File.join(PROJECT_ROOT_PATH, "fixtures", app_path)