1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

add tests for relative custom image paths. fixes #59

This commit is contained in:
Thomas Reynolds 2011-07-23 22:49:32 -07:00
parent 527fa3160f
commit 5c2defac6d
7 changed files with 57 additions and 26 deletions

View file

@ -3,10 +3,42 @@ Feature: Relative Assets
Scenario: Rendering css with the feature disabled Scenario: Rendering css with the feature disabled
Given "relative_assets" feature is "disabled" Given "relative_assets" feature is "disabled"
And the Server is running
When I go to "/stylesheets/relative_assets.css" When I go to "/stylesheets/relative_assets.css"
Then I should not see "url('../" Then I should not see "url('../"
And I should see "url('/images/blank.gif"
Scenario: Rendering html with the feature disabled
Given "relative_assets" feature is "disabled"
And the Server is running
When I go to "/relative_image.html"
Then I should see "/images/blank.gif"
Scenario: Rendering css with the feature enabled Scenario: Rendering css with the feature enabled
Given "relative_assets" feature is "enabled" Given "relative_assets" feature is "enabled"
And the Server is running
When I go to "/stylesheets/relative_assets.css" When I go to "/stylesheets/relative_assets.css"
Then I should see "url('../" Then I should see "url('../images/blank.gif"
Scenario: Rendering html with the feature disabled
Given "relative_assets" feature is "enabled"
And the Server is running
When I go to "/relative_image.html"
Then I should not see "/images/blank.gif"
And I should see "images/blank.gif"
Scenario: Rendering html with a custom images_dir
Given "relative_assets" feature is "enabled"
And "images_dir" is set to "img"
And the Server is running
When I go to "/stylesheets/relative_assets.css"
Then I should see "url('../img/blank.gif"
Scenario: Rendering css with a custom images_dir
Given "relative_assets" feature is "enabled"
And "images_dir" is set to "img"
And the Server is running
When I go to "/relative_image.html"
Then I should not see "/images/blank.gif"
Then I should not see "/img/blank.gif"
And I should see "img/blank.gif"

View file

@ -1,9 +1,7 @@
Given /^I am using an asset host$/ do Given /^I am using an asset host$/ do
sandbox_server = Middleman.server do @server ||= Middleman.server
activate :asset_host @server.activate :asset_host
set :asset_host do |asset| @server.set :asset_host do |asset|
"http://assets%d.example.com" % (asset.hash % 4) "http://assets%d.example.com" % (asset.hash % 4)
end
end end
@browser = Rack::Test::Session.new(Rack::MockSession.new(sandbox_server.new))
end end

View file

@ -1,11 +1,14 @@
Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state| Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
sandbox_server = Middleman.server do @server ||= Middleman.server
if state == "enabled" if state == "enabled"
activate(feature.to_sym) @server.activate(feature.to_sym)
end
set :environment, @current_env || :development
end end
@browser = Rack::Test::Session.new(Rack::MockSession.new(sandbox_server.new)) @server.set :environment, @current_env || :development
end
Given /^"([^\"]*)" is set to "([^\"]*)"$/ do |variable, value|
@server ||= Middleman.server
@server.set variable.to_sym, value
end end
Given /^current environment is "([^\"]*)"$/ do |env| Given /^current environment is "([^\"]*)"$/ do |env|
@ -13,8 +16,8 @@ Given /^current environment is "([^\"]*)"$/ do |env|
end end
Given /^the Server is running$/ do Given /^the Server is running$/ do
sandbox_server = Middleman.server @server ||= Middleman.server
@browser = Rack::Test::Session.new(Rack::MockSession.new(sandbox_server.new)) @browser = Rack::Test::Session.new(Rack::MockSession.new(@server.new))
end end
When /^I go to "([^\"]*)"$/ do |url| When /^I go to "([^\"]*)"$/ do |url|

View file

@ -1,17 +1,13 @@
Given /^page "([^\"]*)" has layout "([^\"]*)"$/ do |url, layout| Given /^page "([^\"]*)" has layout "([^\"]*)"$/ do |url, layout|
sandbox_server = Middleman.server do @server ||= Middleman.server
set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app") @server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
page(url, :layout => layout.to_sym) @server.page(url, :layout => layout.to_sym)
end
@browser = Rack::Test::Session.new(Rack::MockSession.new(sandbox_server.new))
end end
Given /^"([^\"]*)" with_layout block has layout "([^\"]*)"$/ do |url, layout| Given /^"([^\"]*)" with_layout block has layout "([^\"]*)"$/ do |url, layout|
sandbox_server = Middleman.server do @server ||= Middleman.server
set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app") @server.set :root, File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
with_layout(layout.to_sym) do @server.with_layout(layout.to_sym) do
page(url) page(url)
end
end end
@browser = Rack::Test::Session.new(Rack::MockSession.new(sandbox_server.new))
end end

View file

@ -7,6 +7,7 @@ page "/fake.html", :proxy => "/real.html", :layout => false
end end
with_layout false do with_layout false do
page "/relative_image.html"
page "/inline-css.html" page "/inline-css.html"
page "/inline-js.html" page "/inline-js.html"
page "/inline-coffeescript.html" page "/inline-coffeescript.html"

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

View file

@ -0,0 +1 @@
<%= image_tag "blank.gif" %>