Permalink
Browse files

add moar specs

  • Loading branch information...
Sven Fuchs
Sven Fuchs committed Mar 27, 2012
1 parent 7a7a3aa commit a7d3b5d241ec7d45ed261c7e1628fd10d71d90f8
View
@@ -0,0 +1,12 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ ansi (1.4.2)
+ hashr (0.0.19)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ ansi
+ hashr
View
@@ -18,7 +18,7 @@ module Space
autoload :View, 'space/view'
TEMPLATES = {
- :project => 'templates/project.erb',
- :repo => 'templates/repository.erb'
+ :project => 'lib/space/templates/project.erb',
+ :repo => 'lib/space/templates/repository.erb'
}
end
View
@@ -49,6 +49,7 @@ def unscope
end
def execute(command)
+ puts
repo.execute(command)
puts "\n--- hit any key to continue ---\n"
STDIN.getc
View
@@ -21,7 +21,7 @@ def initialize
end
def prompt
- "#{scope ? scope.name : ''} > "
+ "#{scope ? scope.name : ''} >".strip + ' '
end
def run
@@ -5,7 +5,7 @@ class Bundle
COMMANDS = {
:check => 'bundle check',
:list => 'bundle list',
- :config => 'bundle config --global'
+ :config => 'bundle config'
}
attr_reader :app
@@ -1,3 +1,5 @@
+require 'ansi/code'
+
module Space
class Command
attr_reader :path, :command
@@ -20,7 +22,7 @@ def chdir(&block)
end
def strip_ansi(string)
- string.gsub(/\e\[\d+m/, '')
+ string.gsub(ANSI::Code::PATTERN, '')
end
end
end
@@ -13,7 +13,7 @@ def [](index)
end
def each(&block)
- scoped.each(&block)
+ all.each(&block)
end
def find_by_name(name)
View
@@ -9,7 +9,7 @@ def initialize(app)
def render
system 'clear'
puts render_project
- app.repos.each { |repo| puts render_repo(repo) }
+ app.repos.scoped.each { |repo| puts render_repo(repo) }
end
private
View
@@ -1,21 +0,0 @@
-module Space
- module System
- attr_reader :path
-
- def initialize(path = '~')
- @path = File.expand_path(path)
- end
-
- def run(cmd)
- chdir { `#{cmd}` }
- end
-
- def chdir(&block)
- Dir.chdir(path, &block)
- end
-
- def strip_ansi(string)
- string.gsub(/\e\[\d+m/, '')
- end
- end
-end
File renamed without changes.
File renamed without changes.
View
@@ -1,13 +1,9 @@
name: travis
base_dir: ~/Development/projects/travis
repositories:
- - travis-pro-ci
- - travis-pro-hub
- # - travis-pro-listener
- # - travis-pro-core
- # - travis-ci
- # - travis-hub
- # - travis-listener
+ - travis-ci
+ - travis-hub
+ - travis-listener
- travis-core
- # - travis-support
+ - travis-support
View
@@ -1,8 +1,6 @@
require 'spec_helper'
describe Action do
- let(:app) { stub('app', :repos => repos) }
- let(:repos) { stub('repos', :names => names) }
let(:names) { %w(travis-ci) }
describe 'parse_repo' do
View
@@ -0,0 +1,53 @@
+require 'spec_helper'
+
+describe Bundle do
+ let(:app) { stub('app', :name => 'travis') }
+ let(:repo) { stub('repo', :name => 'travis-ci') }
+ let(:bundle) { Bundle.new(app, 'path/to/repo') }
+
+ before :each do
+ app.stubs(:repos).returns([repo])
+ end
+
+ describe 'clean?' do
+ it 'returns true if info includes "dependencies are satisfied"' do
+ bundle.stubs(:info).returns("The Gemfile's dependencies are satisfied")
+ bundle.clean?.should be_true
+ end
+
+ it 'returns false if info does not include "dependencies are satisfied"' do
+ bundle.stubs(:info).returns("Your Gemfile's dependencies could not be satisfied")
+ bundle.clean?.should be_false
+ end
+ end
+
+ describe 'info' do
+ it 'returns the first line from `bundle check`' do
+ bundle.stubs(:result).with(:check).returns("first line\nsecond line")
+ bundle.info.should == 'first line'
+ end
+ end
+
+ describe 'deps' do
+ it 'returns dependencies listend in `bundle list` that match the app name' do
+ bundle.stubs(:result).with(:list).returns(" * ansi (1.4.2)\n * travis-ci (0.0.1 123456)")
+ dep = bundle.deps.first
+ [dep.name, dep.ref].should == ['travis-ci', '123456']
+ end
+ end
+
+ describe 'local_repos' do
+ it 'returns local repositories as defined in the bundle config' do
+ bundle.stubs(:config).returns('foo' => 'bar', 'local.travis-core' => 'path/to/travis-core')
+ bundle.local_repos.first.should == 'travis-core'
+ end
+ end
+
+ describe 'config' do
+ it 'returns a hash of config key value pairs as defined in `bundle config``' do
+ bundle.stubs(:result).with(:config).returns("Settings are listed in order of priority. The top value will be used.\n\nlocal.travis-core\nSet for the current user (path/to/config): \"path/to/travis-core\"")
+ bundle.config.should == { 'local.travis-core' => 'path/to/travis-core' }
+ end
+ end
+end
+
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe Command do
+ describe 'result' do
+ it 'changes to the path'
+ it 'calls the command'
+ it 'removes ansi codes'
+ end
+
+ describe 'strip_ansi' do
+ it 'removes \e[34m'
+ it 'removes \e[0m'
+ end
+end
+
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe Commands do
+ describe 'result' do
+ it 'returns the result from the given command'
+ end
+
+ describe 'commands' do
+ it 'returns a hash of commands as defined for this class'
+ end
+
+ describe 'reset' do
+ it 'calls reset on all commands'
+ end
+end
+
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe Dependency do
+ describe 'fresh?' do
+ it 'returns true if the (locked) dep ref is the actual current repository ref'
+ it 'returns false if the (locked) dep ref differs from the actual current repository ref'
+ end
+
+ describe 'repo' do
+ it 'it returns the repository this dependency refers to'
+ end
+end
+
View
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe Git do
+ describe 'clean?' do
+ it 'returns true if `git status -s` is empty'
+ it 'returns false if `git status -s` is not empty'
+ end
+
+ describe 'branch' do
+ it 'returns the current branch name from `git branch --no-color`'
+ end
+
+ describe 'commit' do
+ it 'it returns the commit hash from `git log -1 head`'
+ end
+end
+
View
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe Repo do
+ describe 'name' do
+ it 'returns the basename of the repository directory' do
+ end
+ end
+
+ describe 'ref' do
+ it 'returns the git commit' do
+
+ end
+ end
+
+ describe 'current?' do
+ it 'returns true when the app scope is the current repo'
+ it 'returns false when the app scope is not the current repo'
+ end
+
+ describe 'dependent_repos' do
+ it 'returns repos that this repo depends on'
+ end
+
+ describe 'reset' do
+ it 'resets its git'
+ it 'resets its bundle'
+ end
+
+ describe 'execute' do
+ it 'changes to the repository directory'
+ it 'runds the given command'
+ end
+end
+
View
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe Repos do
+ describe 'scoped' do
+ it 'returns all repositories when the app does not have a scope'
+ it 'returns the current app scope repository and all of its dependent repos'
+ end
+
+ describe 'all' do
+ it 'returns all repositories for paths defined in the config'
+ end
+
+ describe 'find_by_name' do
+ it 'finds the repo by its name'
+ end
+end
+
View
@@ -1,3 +1,4 @@
+require 'mocha'
require 'space'
include Space

0 comments on commit a7d3b5d

Please sign in to comment.