Permalink
Browse files

Added some initial specs

  • Loading branch information...
1 parent 03d1fcc commit 1bfcb9c653bffe8a3c5541185ad35d302ff75f5d @koraktor committed Jan 29, 2012
Showing with 139 additions and 0 deletions.
  1. +1 −0 .rspec
  2. +6 −0 .travis.yml
  3. +8 −0 Gemfile
  4. +19 −0 Gemfile.lock
  5. +29 −0 config/environments/test.rb
  6. +3 −0 config/mongoid.yml
  7. +18 −0 spec/models/formula_spec.rb
  8. +44 −0 spec/models/repository_spec.rb
  9. +11 −0 spec/spec_helper.rb
View
@@ -0,0 +1 @@
+--colour
View
@@ -0,0 +1,6 @@
+rvm:
+ - 1.9.2
+ - 1.9.3
+ - jruby-19mode
+ - rbx-19mode
+ - ruby-head
View
@@ -14,7 +14,15 @@ group :assets do
gem 'uglifier', '~> 1.2.1'
end
+group :development, :test do
+ gem 'rspec-rails', '~> 2.8.0'
+end
+
group :production do
gem 'airbrake', '~> 3.0.9'
gem 'newrelic_rpm', '~> 3.3.1'
end
+
+group :test do
+ gem 'mocha', '~> 0.10.0'
+end
View
@@ -38,6 +38,7 @@ GEM
builder (3.0.0)
daemons (1.1.6)
dalli (1.1.4)
+ diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (0.12.10)
execjs (1.3.0)
@@ -57,7 +58,10 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ metaclass (0.0.1)
mime-types (1.17.2)
+ mocha (0.10.0)
+ metaclass (~> 0.0.1)
mongo (1.5.2)
bson (= 1.5.2)
mongoid (2.4.3)
@@ -92,6 +96,19 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+ rspec-rails (2.8.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.8.0)
sass (3.1.12)
sass-rails (3.2.4)
railties (~> 3.2.0)
@@ -125,9 +142,11 @@ DEPENDENCIES
dalli (~> 1.1.4)
jquery-rails (~> 2.0.0)
kaminari (~> 0.13.0)
+ mocha (~> 0.10.0)
mongoid (~> 2.4.2)
newrelic_rpm (~> 3.3.1)
rails (= 3.2.1)
+ rspec-rails (~> 2.8.0)
sass-rails (~> 3.2.3)
text (~> 1.0.2)
thin (~> 1.3.1)
@@ -0,0 +1,29 @@
+Braumeister::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Configure static asset server for tests with Cache-Control for performance
+ config.serve_static_assets = true
+ config.static_cache_control = "public, max-age=3600"
+
+ # Log error messages when you accidentally call methods on nil
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
View
@@ -3,3 +3,6 @@ development:
production:
uri: <%= ENV['MONGOLAB_URI'] %>
+
+test:
+ uri: mongodb://braumeister:braumeister@localhost:27017/braumeister
@@ -0,0 +1,18 @@
+# This code is free software; you can redistribute it and/or modify it under
+# the terms of the new BSD License.
+#
+# Copyright (c) 2012, Sebastian Staudt
+
+require 'spec_helper'
+
+describe Formula do
+
+ before do
+ @formula = Formula.new name: 'git'
+ end
+
+ it 'has a path' do
+ @formula.path.should eq('Library/Formula/git.rb')
+ end
+
+end
@@ -0,0 +1,44 @@
+# This code is free software; you can redistribute it and/or modify it under
+# the terms of the new BSD License.
+#
+# Copyright (c) 2012, Sebastian Staudt
+
+require 'spec_helper'
+
+describe Repository do
+
+ before do
+ @repo = Repository.new name: 'mxcl/homebrew'
+ end
+
+ it 'has a path' do
+ @repo.path.should eq("#{Braumeister::Application.tmp_path}/repos/mxcl/homebrew")
+ end
+
+ it 'has an URL' do
+ @repo.url.should eq('git://github.com/mxcl/homebrew.git')
+ end
+
+ describe 'can call Git commands' do
+
+ before do
+ @command = "git --git-dir #{@repo.path}/.git log"
+ end
+
+ it 'successfully' do
+ @repo.expects(:`).with(@command).returns 'log output'
+ `test 0 -eq 0`
+
+ @repo.git('log').should eq('log output')
+ end
+
+ it 'with errors' do
+ @repo.expects(:`).with(@command).returns ''
+ `test 0 -eq 1`
+
+ -> { @repo.git('log') }.should raise_error(RuntimeError, "Execution of `#{@command}` failed.")
+ end
+
+ end
+
+end
View
@@ -0,0 +1,11 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+require 'rspec/autorun'
+
+RSpec.configure do |config|
+ config.mock_with :mocha
+
+ config.infer_base_class_for_anonymous_controllers = true
+end

0 comments on commit 1bfcb9c

Please sign in to comment.