Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specs are now in modules so that constants aren't shared. Added herok…
…u_zenslap which is responsible for loading all code for plugin and autotest
- Loading branch information
Showing
5 changed files
with
211 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
require 'rubygems' | ||
require File.dirname(__FILE__) + '/lib/zenslap/console_error.rb' | ||
require File.dirname(__FILE__) + '/lib/zenslap/zenslap_client.rb' | ||
require File.dirname(__FILE__) + '/lib/zenslap/github_client.rb' | ||
require File.dirname(__FILE__) + '/lib/zenslap/repo.rb' | ||
require File.dirname(__FILE__) + '/lib/heroku/commands/zenslap' | ||
|
||
|
||
Heroku::Command::Help.group('zenslap') do |group| | ||
group.command 'add', 'adds continuous integration to your project' | ||
end | ||
require 'lib/heroku_zenslap' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/zenslap/console_error' | ||
require File.dirname(__FILE__) + '/zenslap/zenslap_client' | ||
require File.dirname(__FILE__) + '/zenslap/git_repo' | ||
require File.dirname(__FILE__) + '/heroku/commands/zenslap' | ||
|
||
Heroku::Command::Help.group('zenslap') do |group| | ||
group.command 'add', 'adds continuous integration to your project' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,96 @@ | ||
require 'spec_helper.rb' | ||
require 'heroku' | ||
|
||
describe Heroku::Command::Zenslap do | ||
ZENSLAP_ID = 1 | ||
GITHUB_URL = "git@github.com:opsb/conference_hub" | ||
GITHUB_REPO_OWNER = "opsb" | ||
GITHUB_REPO_NAME = "conference_hub" | ||
GITHUB_LOGIN = "jimbo" | ||
GITHUB_TOKEN = "df67sd6f67" | ||
GITHUB_CREDENTIALS = { :login => GITHUB_LOGIN, :token => GITHUB_TOKEN } | ||
HEROKU_EMAIL = "jim@bob.com" | ||
HEROKU_PASSWORD = "password" | ||
HEROKU_APP = "conference_hub" | ||
ADDON_NAME = "zenslap2" | ||
|
||
def stub_git | ||
@git_repo = stub do | ||
stubs(:github_url).returns(GITHUB_URL) | ||
stubs(:github_credentials).returns(GITHUB_CREDENTIALS) | ||
stubs(:github_owner).returns(GITHUB_REPO_OWNER) | ||
stubs(:github_name).returns(GITHUB_REPO_NAME) | ||
stubs(:add_zenslap_remote) | ||
stubs(:zenslap_app).returns(HEROKU_APP) | ||
end | ||
GitRepo.stubs(:new).returns(@git_repo) | ||
end | ||
module ZenslapSpec | ||
|
||
def stub_zenslap | ||
ZenslapClient.stubs(:configure) | ||
end | ||
describe Heroku::Command::Zenslap do | ||
ZENSLAP_ID = 1 | ||
GITHUB_URL = "git@github.com:opsb/conference_hub" | ||
GITHUB_REPO_OWNER = "opsb" | ||
GITHUB_REPO_NAME = "conference_hub" | ||
GITHUB_LOGIN = "jimbo" | ||
GITHUB_TOKEN = "df67sd6f67" | ||
GITHUB_CREDENTIALS = { :login => GITHUB_LOGIN, :token => GITHUB_TOKEN } | ||
HEROKU_EMAIL = "jim@bob.com" | ||
HEROKU_PASSWORD = "password" | ||
HEROKU_APP = "conference_hub" | ||
ADDON_NAME = "zenslap2" | ||
|
||
def stub_heroku | ||
@heroku = stub do | ||
stubs(:user).returns(HEROKU_EMAIL) | ||
stubs(:password).returns(HEROKU_PASSWORD) | ||
stubs(:create).returns(HEROKU_APP) | ||
stubs(:add_collaborator) | ||
stubs(:install_addon) | ||
stubs(:config_vars).returns({ "ZENSLAP_ID" => ZENSLAP_ID }) | ||
stubs(:destroy) | ||
def stub_git | ||
@git_repo = stub do | ||
stubs(:github_url).returns(GITHUB_URL) | ||
stubs(:github_credentials).returns(GITHUB_CREDENTIALS) | ||
stubs(:github_owner).returns(GITHUB_REPO_OWNER) | ||
stubs(:github_name).returns(GITHUB_REPO_NAME) | ||
stubs(:add_zenslap_remote) | ||
stubs(:zenslap_app).returns(HEROKU_APP) | ||
end | ||
GitRepo.stubs(:new).returns(@git_repo) | ||
end | ||
@command.stubs(:heroku).returns(@heroku) | ||
end | ||
|
||
context "zenslap" do | ||
before do | ||
@command = Heroku::Command::Zenslap.new nil | ||
stub_git | ||
stub_zenslap | ||
stub_heroku | ||
def stub_zenslap | ||
ZenslapClient.stubs(:configure) | ||
end | ||
|
||
context "#create" do | ||
def stub_heroku | ||
@heroku = stub do | ||
stubs(:user).returns(HEROKU_EMAIL) | ||
stubs(:password).returns(HEROKU_PASSWORD) | ||
stubs(:create).returns(HEROKU_APP) | ||
stubs(:add_collaborator) | ||
stubs(:install_addon) | ||
stubs(:config_vars).returns({ "ZENSLAP_ID" => ZENSLAP_ID }) | ||
stubs(:destroy) | ||
end | ||
@command.stubs(:heroku).returns(@heroku) | ||
end | ||
|
||
context "zenslap" do | ||
before do | ||
@command.create | ||
@command = Heroku::Command::Zenslap.new nil | ||
stub_git | ||
stub_zenslap | ||
stub_heroku | ||
end | ||
|
||
it "should create new heroku app to be used for running tests and billing" do | ||
assert_received @heroku, :create | ||
end | ||
context "#create" do | ||
|
||
it "should add zenslap remote" do | ||
assert_received @git_repo, :add_zenslap_remote, &with( HEROKU_APP ) | ||
end | ||
before do | ||
@command.create | ||
end | ||
|
||
it "should add zenslap as a collaborator to heroku app" do | ||
assert_received @heroku, :add_collaborator, &with( HEROKU_APP, "admin@zenslap.me" ) | ||
end | ||
it "should create new heroku app to be used for running tests and billing" do | ||
assert_received @heroku, :create | ||
end | ||
|
||
it "should install addon" do | ||
assert_received @heroku, :install_addon, &with( "conference_hub", ADDON_NAME ) | ||
end | ||
it "should add zenslap remote" do | ||
assert_received @git_repo, :add_zenslap_remote, &with( HEROKU_APP ) | ||
end | ||
|
||
it "should configure zenslap with github and heroku details" do | ||
assert_received ZenslapClient, :configure, | ||
&with( ZENSLAP_ID, GITHUB_REPO_OWNER, GITHUB_REPO_NAME, GITHUB_CREDENTIALS, HEROKU_APP ) | ||
end | ||
it "should add zenslap as a collaborator to heroku app" do | ||
assert_received @heroku, :add_collaborator, &with( HEROKU_APP, "admin@zenslap.me" ) | ||
end | ||
|
||
end | ||
it "should install addon" do | ||
assert_received @heroku, :install_addon, &with( "conference_hub", ADDON_NAME ) | ||
end | ||
|
||
it "should configure zenslap with github and heroku details" do | ||
assert_received ZenslapClient, :configure, | ||
&with( ZENSLAP_ID, GITHUB_REPO_OWNER, GITHUB_REPO_NAME, GITHUB_CREDENTIALS, HEROKU_APP ) | ||
end | ||
|
||
context "#destroy" do | ||
before do | ||
@command.destroy | ||
end | ||
|
||
it "should destroy heroku app" do | ||
assert_received @heroku, :destroy, &with(HEROKU_APP) | ||
context "#destroy" do | ||
before do | ||
@command.destroy | ||
end | ||
|
||
it "should destroy heroku app" do | ||
assert_received @heroku, :destroy, &with(HEROKU_APP) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.