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 Scenario: Checking built folder for content
Given a built app at "test-app" Given a built app at "test-app"
Then "index.html" should exist at "test-app" and include "Comment in layout" Then a directory named "build" should exist
Then "javascripts/coffee_test.js" should exist at "test-app" and include "Array.prototype.slice" And the exit status should be 0
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!" When I cd to "build"
Then "services/index.html" should exist at "test-app" and include "Services" Then the following files should exist:
Then "stylesheets/site.css" should exist at "test-app" and include "html, body, div, span" | index.html |
Then "stylesheets/site_scss.css" should exist at "test-app" and include "html, body, div, span" | javascripts/coffee_test.js |
Then "stylesheets/static.css" should exist at "test-app" and include "body" | static.html |
Then "_partial.html" should not exist at "test-app" | services/index.html |
Then "spaces in file.html" should exist at "test-app" and include "spaces" | stylesheets/site.css |
Then "images/blank.gif" should exist at "test-app" | stylesheets/site_scss.css |
Then "images/Read me (example).txt" should exist at "test-app" | stylesheets/static.css |
Then "images/Child folder/regular_file(example).txt" should exist at "test-app" | spaces in file.html |
Then ".htaccess" should exist at "test-app" | images/blank.gif |
Then the last exit code should be "0" | 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 Scenario: Build glob
Given a built app at "glob-app" with flags "--glob '*.css'" Given a built app at "glob-app" with flags "--glob '*.css'"
Then "stylesheets/site.css" should exist at "glob-app" and include "html" Then a directory named "build" should exist
Then "index.html" should not exist at "glob-app" And the exit status should be 0
Then the last exit code 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 Scenario: Build with errors
Given a built app at "build-with-errors-app" Given a built app at "build-with-errors-app"
Then the last exit code should be "1" Then the exit status 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 "../"

View file

@ -13,7 +13,6 @@ Feature: Build Clean
Then "about/index.html" should exist at "clean-dir-app" Then "about/index.html" should exist at "clean-dir-app"
Given a built app at "clean-dir-app" with flags "--clean" Given a built app at "clean-dir-app" with flags "--clean"
Then "about/index.html" should exist at "clean-dir-app" 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 Scenario: Clean build an app that's never been built
Given a built app at "clean-dir-app" with flags "--clean" 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 Scenario: Checking built folder for content
Given a built app at "test-app" Given a built app at "test-app"
Then "fake.html" should exist at "test-app" and include "I am real" Then a directory named "build" should exist
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" When I cd to "build"
Then "target_ignore.html" should exist at "test-app" and include "Ignore me" Then the following files should exist:
Then "should_be_ignored.html" should not exist at "test-app" | fake.html |
Then "should_be_ignored2.html" should not exist at "test-app" | fake/one.html |
Then "should_be_ignored3.html" should not exist at "test-app" | 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 Scenario: Preview basic proxy
Given the Server is running at "test-app" Given the Server is running at "test-app"

View file

@ -22,7 +22,9 @@ Feature: Sprockets
Scenario: Multiple engine files should build correctly Scenario: Multiple engine files should build correctly
Given a built app at "test-app" 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 Scenario: Sprockets CSS require //require
Given the Server is running at "test-app" 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_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
MIDDLEMAN_BIN_PATH = File.join(MIDDLEMAN_ROOT_PATH, "bin") 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/middleman_steps"
require "middleman/step_definitions/builder_steps" require "middleman/step_definitions/builder_steps"
require "middleman/step_definitions/generator_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) FileUtils.cp(config_path, config_dest)
end end
Given /^a built app at "([^\"]*)"$/ do |path| Given /^a fixture app "([^\"]*)"$/ do |path|
target = File.join(PROJECT_ROOT_PATH, "fixtures", path) step %Q{a directory named "#{path}"}
build_target = File.join(target, "build") target_path = File.join(PROJECT_ROOT_PATH, "fixtures", path)
FileUtils.rm_rf(build_target) FileUtils.cp_r(target_path, current_dir)
build_cmd = File.join(MIDDLEMAN_BIN_PATH, "middleman build") step %Q{I cd to "#{path}"}
`cd #{target} && #{build_cmd}`
end end
Then /^cleanup built app at "([^\"]*)"$/ do |path| Given /^a built app at "([^\"]*)"$/ do |path|
target = File.join(PROJECT_ROOT_PATH, "fixtures", path, "build") step %Q{a fixture app "#{path}"}
FileUtils.rm_rf(target) step %Q{I run `middleman build`}
end end
Given /^a built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path, flags| Given /^a built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path, flags|
target = File.join(PROJECT_ROOT_PATH, "fixtures", path) step %Q{a fixture app "#{path}"}
build_cmd = File.join(MIDDLEMAN_BIN_PATH, "middleman build") step %Q{I run `middleman build #{flags}`}
`cd #{target} && #{build_cmd} #{flags}`
end end
Then /^"([^\"]*)" should exist at "([^\"]*)"$/ do |target_file, path| Then /^"([^\"]*)" should exist at "([^\"]*)"$/ do |target_file, path|

View file

@ -1,3 +1,5 @@
require "fileutils"
Given /^a project at "([^\"]*)"$/ do |dirname| Given /^a project at "([^\"]*)"$/ do |dirname|
@target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname) @target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
end 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("coffee-filter", ["~> 0.1.1"])
s.add_development_dependency("liquid", ["~> 2.2.0"]) s.add_development_dependency("liquid", ["~> 2.2.0"])
s.add_development_dependency("cucumber", ["~> 1.1.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("rake", ["~> 0.9.2"])
s.add_development_dependency("rspec", ["~> 2.7.0"]) s.add_development_dependency("rspec", ["~> 2.7.0"])
s.add_development_dependency("rdoc", ["~> 3.9.4"]) s.add_development_dependency("rdoc", ["~> 3.9.4"])