Use Arbua for CLI testing. This is going to be HUGE

This commit is contained in:
Thomas Reynolds 2011-12-15 16:05:15 -08:00
parent a63334813f
commit 40986f17da
9 changed files with 78 additions and 45 deletions

View file

@ -3,32 +3,51 @@ Feature: Builder
Scenario: Checking built folder for content
Given a built app at "test-app"
Then "index.html" should exist at "test-app" and include "Comment in layout"
Then "javascripts/coffee_test.js" should exist at "test-app" and include "Array.prototype.slice"
Then "index.html" should exist at "test-app" and include "<h1>Welcome</h1>"
Then "static.html" should exist at "test-app" and include "Static, no code!"
Then "services/index.html" should exist at "test-app" and include "Services"
Then "stylesheets/site.css" should exist at "test-app" and include "html, body, div, span"
Then "stylesheets/site_scss.css" should exist at "test-app" and include "html, body, div, span"
Then "stylesheets/static.css" should exist at "test-app" and include "body"
Then "_partial.html" should not exist at "test-app"
Then "spaces in file.html" should exist at "test-app" and include "spaces"
Then "images/blank.gif" should exist at "test-app"
Then "images/Read me (example).txt" should exist at "test-app"
Then "images/Child folder/regular_file(example).txt" should exist at "test-app"
Then ".htaccess" should exist at "test-app"
Then the last exit code should be "0"
Then a directory named "build" should exist
And the exit status should be 0
When I cd to "build"
Then the following files should exist:
| index.html |
| javascripts/coffee_test.js |
| static.html |
| services/index.html |
| stylesheets/site.css |
| stylesheets/site_scss.css |
| stylesheets/static.css |
| spaces in file.html |
| images/blank.gif |
| images/Read me (example).txt |
| images/Child folder/regular_file(example).txt |
| .htaccess |
Then the following files should not exist:
| _partial |
| _liquid_partial |
| layout |
| layouts/custom |
| layouts/content_for |
And the file "index.html" should contain "Comment in layout"
And the file "index.html" should contain "<h1>Welcome</h1>"
And the file "javascripts/coffee_test.js" should contain "Array.prototype.slice"
And the file "static.html" should contain "Static, no code!"
And the file "services/index.html" should contain "Services"
And the file "stylesheets/site.css" should contain "html, body, div, span"
And the file "stylesheets/site_scss.css" should contain "html, body, div, span"
And the file "stylesheets/static.css" should contain "body"
And the file "spaces in file.html" should contain "spaces"
Scenario: Build glob
Given a built app at "glob-app" with flags "--glob '*.css'"
Then "stylesheets/site.css" should exist at "glob-app" and include "html"
Then "index.html" should not exist at "glob-app"
Then the last exit code should be "0"
Then a directory named "build" should exist
And the exit status should be 0
When I cd to "build"
Then the following files should not exist:
| index.html |
Then the following files should exist:
| stylesheets/site.css |
Scenario: Build with errors
Given a built app at "build-with-errors-app"
Then the last exit code should be "1"
# Scenario: Force relative assets
# Given a built app at "relative-app" with flags "--relative"
# Then "stylesheets/relative_assets.css" should exist at "relative-app" and include "../"
Then the exit status should be 1

View file

@ -13,7 +13,6 @@ Feature: Build Clean
Then "about/index.html" should exist at "clean-dir-app"
Given a built app at "clean-dir-app" with flags "--clean"
Then "about/index.html" should exist at "clean-dir-app"
Then cleanup built app at "clean-dir-app"
Scenario: Clean build an app that's never been built
Given a built app at "clean-dir-app" with flags "--clean"

5
features/cli.feature Normal file
View file

@ -0,0 +1,5 @@
Feature: Middleman CLI
Scenario: Create a new project
When I run `middleman init MY_PROJECT`

View file

@ -3,13 +3,18 @@ Feature: Dynamic Pages
Scenario: Checking built folder for content
Given a built app at "test-app"
Then "fake.html" should exist at "test-app" and include "I am real"
Then "fake/one.html" should exist at "test-app" and include "I am real: one"
Then "fake/two.html" should exist at "test-app" and include "I am real: two"
Then "target_ignore.html" should exist at "test-app" and include "Ignore me"
Then "should_be_ignored.html" should not exist at "test-app"
Then "should_be_ignored2.html" should not exist at "test-app"
Then "should_be_ignored3.html" should not exist at "test-app"
Then a directory named "build" should exist
When I cd to "build"
Then the following files should exist:
| fake.html |
| fake/one.html |
| fake/two.html |
| target_ignore.html |
Then the following files should not exist:
| should_be_ignored.html |
| should_be_ignored2.html |
| should_be_ignored3.html |
Scenario: Preview basic proxy
Given the Server is running at "test-app"

View file

@ -22,7 +22,9 @@ Feature: Sprockets
Scenario: Multiple engine files should build correctly
Given a built app at "test-app"
Then "javascripts/multiple_engines.js" should exist at "test-app" and include "Hello One"
When I cd to "build"
Then a file named "javascripts/multiple_engines.js" should exist
And the file "javascripts/multiple_engines.js" should contain "Hello One"
Scenario: Sprockets CSS require //require
Given the Server is running at "test-app"

View file

@ -1,6 +1,8 @@
MIDDLEMAN_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
MIDDLEMAN_BIN_PATH = File.join(MIDDLEMAN_ROOT_PATH, "bin")
ENV['PATH'] = "#{MIDDLEMAN_BIN_PATH}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
require "aruba/cucumber"
require "middleman/step_definitions/middleman_steps"
require "middleman/step_definitions/builder_steps"
require "middleman/step_definitions/generator_steps"

View file

@ -7,25 +7,23 @@ Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name|
FileUtils.cp(config_path, config_dest)
end
Given /^a built app at "([^\"]*)"$/ do |path|
target = File.join(PROJECT_ROOT_PATH, "fixtures", path)
Given /^a fixture app "([^\"]*)"$/ do |path|
step %Q{a directory named "#{path}"}
target_path = File.join(PROJECT_ROOT_PATH, "fixtures", path)
FileUtils.cp_r(target_path, current_dir)
build_target = File.join(target, "build")
FileUtils.rm_rf(build_target)
build_cmd = File.join(MIDDLEMAN_BIN_PATH, "middleman build")
`cd #{target} && #{build_cmd}`
step %Q{I cd to "#{path}"}
end
Then /^cleanup built app at "([^\"]*)"$/ do |path|
target = File.join(PROJECT_ROOT_PATH, "fixtures", path, "build")
FileUtils.rm_rf(target)
Given /^a built app at "([^\"]*)"$/ do |path|
step %Q{a fixture app "#{path}"}
step %Q{I run `middleman build`}
end
Given /^a built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path, flags|
target = File.join(PROJECT_ROOT_PATH, "fixtures", path)
build_cmd = File.join(MIDDLEMAN_BIN_PATH, "middleman build")
`cd #{target} && #{build_cmd} #{flags}`
step %Q{a fixture app "#{path}"}
step %Q{I run `middleman build #{flags}`}
end
Then /^"([^\"]*)" should exist at "([^\"]*)"$/ do |target_file, path|

View file

@ -1,3 +1,5 @@
require "fileutils"
Given /^a project at "([^\"]*)"$/ do |dirname|
@target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
end

View file

@ -47,6 +47,7 @@ Gem::Specification.new do |s|
s.add_development_dependency("coffee-filter", ["~> 0.1.1"])
s.add_development_dependency("liquid", ["~> 2.2.0"])
s.add_development_dependency("cucumber", ["~> 1.1.0"])
s.add_development_dependency("aruba")
s.add_development_dependency("rake", ["~> 0.9.2"])
s.add_development_dependency("rspec", ["~> 2.7.0"])
s.add_development_dependency("rdoc", ["~> 3.9.4"])