Skip to content

Commit

Permalink
Adding Rack cucumber features
Browse files Browse the repository at this point in the history
Test that rack apps work and require a Gemfile

Needs verification and still need a better way to

communicate missing gemfile from CC to client...
  • Loading branch information
Ezra Zygmuntowicz committed May 13, 2011
1 parent 0550e5d commit 561807b
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/rack_app/Gemfile
@@ -0,0 +1,4 @@
source "http://rubygems.org"

gem "rack"
gem "thin"
2 changes: 2 additions & 0 deletions apps/rack_app/config.ru
@@ -0,0 +1,2 @@
require File.join(File.dirname(__FILE__), 'simple_rack_app')
run SimpleRackApp.new
7 changes: 7 additions & 0 deletions apps/rack_app/simple_rack_app.rb
@@ -0,0 +1,7 @@
class SimpleRackApp

def call(env)
[200, {'Content-Type' => 'text/html'}, ['hello']]
end

end
2 changes: 2 additions & 0 deletions apps/rack_broken_no_gemfile_app/config.ru
@@ -0,0 +1,2 @@
require File.join(File.dirname(__FILE__), 'simple_rack_app')
run SimpleRackApp.new
7 changes: 7 additions & 0 deletions apps/rack_broken_no_gemfile_app/simple_rack_app.rb
@@ -0,0 +1,7 @@
class SimpleRackApp

def call(env)
[200, {'Content-Type' => 'text/html'}, ['hello']]
end

end
18 changes: 18 additions & 0 deletions features/rack_support.feature
@@ -0,0 +1,18 @@
Feature: Ensure that Rack Applications are fully supported on AppCloud

As a user of AppCloud
I want to create applications using bare rack framework bare

Background: Rack Application creation
Given I have registered and logged in

@creates_rack_app
Scenario: start and test a rack app with Gemfile
Given I have deployed a rack application
Then The rack app should work

@creates_rack_broken_no_gemfile_app
Scenario: get crash information for a broken rack application with no Gemfile
Given I have deployed a broken rack application missing a Gemfile
When I get crash information for my application
Then I should be able to know that it failed because I am missing a Gemfile
27 changes: 27 additions & 0 deletions features/step_definitions/rack_support_steps.rb
@@ -0,0 +1,27 @@
When /^I create a rack application$/ do
@app = create_app RACK_APP, @token
end

Given /^I have deployed a rack application$/ do
@app = create_app RACK_APP, @token
upload_app @app, @token
start_app @app, @token
expected_health = 1.0
health = poll_until_done @app, expected_health, @token
health.should == expected_health
end

Then /^The rack app should work$/ do
response = get_app_contents @app, '/'
response.should_not == nil
response.response_code.should == 200
response.body_str.should == 'hello'
end

# Crash info for a broken (persistently broken) rack app with no Gemfile
Given /^I have deployed a broken rack application missing a Gemfile$/ do
@app = create_app RACK_BROKEN_NO_GEMFILE_APP, @token
upload_app @app, @token
start_app @app, @token
sleep 3
end
12 changes: 12 additions & 0 deletions features/support/env.rb
Expand Up @@ -33,6 +33,8 @@
GRAILS_APP = "grails_app"
ROO_APP = "roo_app"
SIMPLE_ERLANG_APP = "mochiweb_test"
RACK_APP = "rack_app"
RACK_BROKEN_NO_GEMFILE_APP = "rack_broken_no_gemfile_app"

After do
AppCloudHelper.instance.delete_user
Expand Down Expand Up @@ -95,6 +97,14 @@
AppCloudHelper.instance.delete_app_internal SIMPLE_ERLANG_APP
end

After("@creates_rack_app") do
AppCloudHelper.instance.delete_app_internal RACK_APP
end

After("@creates_rack_broken_no_gemfile_app") do
AppCloudHelper.instance.delete_app_internal RACK_BROKEN_NO_GEMFILE_APP
end

at_exit do
AppCloudHelper.instance.cleanup
end
Expand Down Expand Up @@ -162,6 +172,8 @@ def cleanup
delete_app_internal(DBRAILS_BROKEN_APP)
delete_app_internal(GRAILS_APP)
delete_app_internal(ROO_APP)
delete_app_internal(RACK_APP)
delete_app_internal(RACK_BROKEN_NO_GEMFILE_APP)
delete_user
end

Expand Down
10 changes: 10 additions & 0 deletions features/support/testconfig.yml
Expand Up @@ -66,3 +66,13 @@ mochiweb_test:
framework: "otp_rebar"
startup: erlangR14B02
memory: 64

rack_app:
framework: "rack"
startup: "thin start"
memory: 64

rack_broken_no_gemfile_app:
framework: "rack"
startup: "thin start"
memory: 64

0 comments on commit 561807b

Please sign in to comment.