Skip to content
Browse files

Merge branch 'sinatra' of github.com:winton/gem_template

Conflicts:
	Rakefile
	config/gemsets.yml
	config/gemspec.yml
	lib/application/haml.rb
	lib/application/lilypad.rb
	lib/application/session.rb
	lib/application/sinatra.rb
	lib/gem_template.rb
	lib/gem_template/boot/haml.rb
	lib/gem_template/boot/lilypad.rb
	lib/gem_template/boot/session.rb
	lib/gem_template/boot/sinatra.rb
	lib/maitre_d/boot/application.rb
	lib/maitre_d/boot/haml.rb
	lib/maitre_d/boot/lilypad.rb
	lib/maitre_d/boot/redis.rb
	lib/maitre_d/boot/session.rb
	lib/maitre_d/boot/sinatra.rb
	lib/maitre_d/gems.rb
	maitre_d.gemspec
	script/console
	spec/gem_template_spec.rb
	spec/maitre_d/gems_spec.rb
	spec/spec_helper.rb
  • Loading branch information...
2 parents d295864 + 1b6cb3b commit 4c4c079ef3f152d2b42958e6f59b27efa806adba @winton committed
View
3 .gitignore
@@ -1,10 +1,9 @@
+.bundle
.DS_Store
*.gem
*.log
config/database.yml
config/deploy.rb
-config/mail.yml
-coverage
log
pkg
tmp
View
12 Gemfile
@@ -0,0 +1,12 @@
+source "http://rubygems.org"
+
+group :development do
+ gem "rack-test", "= 0.6.1"
+ gem "rspec", "~> 1.0"
+end
+
+gem "haml", "= 3.1.2"
+gem "lilypad", "= 0.3.1"
+gem "redis", "= 2.2.2"
+gem "sinatra", "= 1.2.6"
+gem "yajl-ruby", "= 1.0.0"
View
31 Gemfile.lock
@@ -0,0 +1,31 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ builder (3.0.0)
+ haml (3.1.2)
+ lilypad (0.3.1)
+ builder (>= 2.1.2)
+ require (= 0.2.6)
+ rack (1.3.4)
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ redis (2.2.2)
+ require (0.2.6)
+ rspec (1.3.2)
+ sinatra (1.2.6)
+ rack (~> 1.1)
+ tilt (>= 1.2.2, < 2.0)
+ tilt (1.3.3)
+ yajl-ruby (1.0.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ haml (= 3.1.2)
+ lilypad (= 0.3.1)
+ rack-test (= 0.6.1)
+ redis (= 2.2.2)
+ rspec (~> 1.0)
+ sinatra (= 1.2.6)
+ yajl-ruby (= 1.0.0)
View
102 Rakefile
@@ -1,101 +1 @@
-require File.dirname(__FILE__) + '/lib/maitre_d/gems'
-
-MaitreD::Gems.activate %w(rake rspec)
-
-require 'rake'
-
-begin
- require 'spec/rake/spectask'
-rescue Exception => e
-end
-
-def gemspec
- @gemspec ||= begin
- file = File.expand_path('../maitre_d.gemspec', __FILE__)
- eval(File.read(file), binding, file)
- end
-end
-
-if defined?(ActiveWrapper::Tasks)
- ActiveWrapper::Tasks.new(
- :base => File.dirname(__FILE__),
- :env => ENV['ENV']
- )
-end
-
-if defined?(Spec::Rake::SpecTask)
- desc "Run specs"
- Spec::Rake::SpecTask.new do |t|
- t.spec_files = FileList['spec/**/*_spec.rb']
- t.spec_opts = %w(-fs --color)
- t.warning = true
- end
- task :spec
- task :default => :spec
-end
-
-desc "Build gem(s)"
-task :gem do
- old_gemset = ENV['GEMSET']
- root = File.expand_path('../', __FILE__)
- pkg = "#{root}/pkg"
- system "rm -Rf #{pkg}"
- MaitreD::Gems.gemset_names.each do |gemset|
- ENV['GEMSET'] = gemset.to_s
- system "cd #{root} && gem build maitre_d.gemspec"
- system "mkdir -p #{pkg} && mv *.gem pkg"
- end
- ENV['GEMSET'] = old_gemset
-end
-
-namespace :gem do
- desc "Install gem(s)"
- task :install do
- Rake::Task['gem'].invoke
- Dir["#{File.dirname(__FILE__)}/pkg/*.gem"].each do |pkg|
- system "gem install #{pkg} --no-ri --no-rdoc"
- end
- end
-
- desc "Push gem(s)"
- task :push do
- Rake::Task['gem'].invoke
- Dir["#{File.dirname(__FILE__)}/pkg/*.gem"].each do |pkg|
- system "gem push #{pkg}"
- end
- end
-end
-
-namespace :gems do
- desc "Install gem dependencies (DEV=0 DOCS=0 GEMSPEC=default SUDO=0)"
- task :install do
- dev = ENV['DEV'] == '1'
- docs = ENV['DOCS'] == '1' ? '' : '--no-ri --no-rdoc'
- gemset = ENV['GEMSET']
- sudo = ENV['SUDO'] == '1' ? 'sudo' : ''
-
- MaitreD::Gems.gemset = gemset if gemset
-
- if dev
- gems = MaitreD::Gems.gemspec.development_dependencies
- else
- gems = MaitreD::Gems.gemspec.dependencies
- end
-
- gems.each do |name|
- name = name.to_s
- version = MaitreD::Gems.versions[name.to_sym]
- if Gem.source_index.find_name(name, version).empty?
- version = version ? "-v #{version}" : ''
- system "#{sudo} gem install #{name} #{version} #{docs}"
- else
- puts "already installed: #{name} #{version}"
- end
- end
- end
-end
-
-desc "Validate the gemspec"
-task :gemspec do
- gemspec.validate
-end
+require 'bundler/gem_tasks'
View
3 bin/gem_template
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+
+require File.expand_path("../../lib/gem_template", __FILE__)
View
10 config/gemsets.yml
@@ -1,10 +0,0 @@
-maitre_d:
- rake: >=0.8.7
- rspec: ~>1.0
- default:
- haml: =3.1.2
- lilypad: =0.3.1
- rack-test: =0.6.1
- redis: =2.2.2
- sinatra: =1.2.6
- yajl-ruby: =0.8.3
View
17 config/gemspec.yml
@@ -1,17 +0,0 @@
-name: maitre_d
-version: 0.1.0
-authors:
- -
-email:
-homepage:
-summary:
-description:
-dependencies:
- - haml
- - lilypad
- - redis
- - sinatra
-development_dependencies:
- - rake
- - rspec
- - rack-test
View
6 lib/application/controller.rb
@@ -0,0 +1,6 @@
+Application.class_eval do
+
+ Dir["#{root}/lib/#{app_name}/controller/*.rb"].sort.each do |path|
+ require path
+ end
+end
View
0 lib/maitre_d/boot/haml.rb → lib/application/haml.rb
File renamed without changes.
View
6 lib/application/helper.rb
@@ -0,0 +1,6 @@
+Application.class_eval do
+
+ Dir["#{root}/lib/#{app_name}/helper/*.rb"].sort.each do |path|
+ require path
+ end
+end
View
0 lib/maitre_d/boot/lilypad.rb → lib/application/lilypad.rb
File renamed without changes.
View
2 lib/maitre_d/boot/log.rb → lib/application/log.rb
@@ -1,5 +1,5 @@
Application.class_eval do
-
+
unless File.basename($0) == 'spec'
log = File.new("#{root}/log/#{environment}.log", "a")
STDOUT.reopen(log)
View
0 lib/maitre_d/boot/model.rb → lib/application/model.rb
File renamed without changes.
View
26 lib/application/redis.rb
@@ -0,0 +1,26 @@
+require 'redis'
+
+def redis
+ $redis ||= (
+
+ env = ENV['RACK_ENV'] || 'development'
+
+ if File.exists?('config/redis.yml')
+ yaml = YAML.load(File.read('config/redis.yml'))[env]
+
+ db = yaml.keys.first
+ config = yaml[db]
+ config['db'] = db
+
+ $redis_url = "#{config['host']}:#{config['port']}/#{config['db']}"
+
+ ::Redis.new(
+ :host => config['host'],
+ :port => config['port'],
+ :db => config['db']
+ )
+ end
+ )
+end
+
+redis
View
0 lib/maitre_d/boot/session.rb → lib/application/session.rb
File renamed without changes.
View
4 lib/maitre_d/boot/sinatra.rb → lib/application/sinatra.rb
@@ -1,9 +1,9 @@
Application.class_eval do
set :environment, $testing ? :test : environment
- set :root, File.expand_path("#{File.dirname(__FILE__)}/../../../")
+ set :root, File.expand_path("#{File.dirname(__FILE__)}/../../")
set :public, "#{root}/public"
set :logging, true
set :static, true
- set :views, "#{root}/lib/maitre_d/view"
+ set :views, "#{root}/lib/#{app_name}/view"
end
View
28 lib/maitre_d.rb
@@ -1,17 +1,19 @@
-require File.dirname(__FILE__) + '/maitre_d/gems'
+require "rubygems"
+require "bundler"
-MaitreD::Gems.activate %w(haml lilypad sinatra yajl-ruby)
+Bundler.setup(:default)
$:.unshift File.dirname(__FILE__)
-require 'maitre_d/boot/core_ext'
-require 'maitre_d/boot/application'
-require 'maitre_d/boot/sinatra'
-require 'maitre_d/boot/log'
-require 'maitre_d/boot/session'
-require 'maitre_d/boot/haml'
-require 'maitre_d/boot/lilypad'
-require 'maitre_d/boot/redis'
-require 'maitre_d/boot/model'
-require 'maitre_d/boot/controller'
-require 'maitre_d/boot/helper'
+require 'maitre_d/application'
+require 'maitre_d/core_ext'
+
+require 'application/sinatra'
+require 'application/log'
+require 'application/session'
+require 'application/haml'
+require 'application/lilypad'
+require 'application/redis'
+require 'application/model'
+require 'application/controller'
+require 'application/helper'
View
1 lib/maitre_d/boot/application.rb → lib/maitre_d/application.rb
@@ -1,4 +1,5 @@
require 'sinatra/base'
class Application < Sinatra::Base
+ set :app_name, 'maitre_d'
end
View
7 lib/maitre_d/boot/console.rb
@@ -1,7 +0,0 @@
-require File.expand_path('../../gems', __FILE__)
-
-MaitreD::Gems.activate %w(sinatra)
-
-require File.dirname(__FILE__) + '/application'
-require File.dirname(__FILE__) + '/sinatra'
-require File.dirname(__FILE__) + '/model'
View
6 lib/maitre_d/boot/controller.rb
@@ -1,6 +0,0 @@
-Application.class_eval do
-
- Dir["#{root}/lib/maitre_d/controller/*.rb"].sort.each do |path|
- require path
- end
-end
View
6 lib/maitre_d/boot/helper.rb
@@ -1,6 +0,0 @@
-Application.class_eval do
-
- Dir["#{root}/lib/maitre_d/helper/*.rb"].sort.each do |path|
- require path
- end
-end
View
23 lib/maitre_d/boot/redis.rb
@@ -1,23 +0,0 @@
-require 'redis'
-
-def redis
- $redis ||= (
-
- env = ENV['RACK_ENV'] || 'development'
- yaml = YAML.load(File.read('config/redis.yml'))[env]
-
- db = yaml.keys.first
- config = yaml[db]
- config['db'] = db
-
- $redis_url = "#{config['host']}:#{config['port']}/#{config['db']}"
-
- ::Redis.new(
- :host => config['host'],
- :port => config['port'],
- :db => config['db']
- )
- )
-end
-
-redis
View
7 lib/maitre_d/console.rb
@@ -0,0 +1,7 @@
+require 'rubygems'
+require 'bundler'
+
+Bundler.require
+
+require File.dirname(__FILE__) + '/application'
+require File.expand_path('../../application/sinatra', __FILE__)
View
3 lib/maitre_d/controller/reservations.rb
@@ -1,8 +1,6 @@
Application.class_eval do
get '/reservations/create' do
- puts '@@@'
- puts params.inspect
reservation = Reservation.find(params)
create =
@@ -15,7 +13,6 @@
end
get '/reservations/show' do
- puts '!!!'
Reservation.find(params).to_response
end
View
0 lib/maitre_d/boot/core_ext.rb → lib/maitre_d/core_ext.rb
File renamed without changes.
View
159 lib/maitre_d/gems.rb
@@ -1,159 +0,0 @@
-unless defined?(MaitreD::Gems)
-
- require 'yaml'
-
- module MaitreD
- module Gems
- class <<self
-
- attr_accessor :config
- attr_reader :gemset, :gemsets, :versions
-
- class SimpleStruct
- attr_reader :hash
-
- def initialize(hash)
- @hash = hash
- @hash.each do |key, value|
- self.class.send(:define_method, key) { @hash[key] }
- self.class.send(:define_method, "#{key}=") { |v| @hash[key] = v }
- end
- end
- end
-
- Gems.config = SimpleStruct.new(
- :gemsets => [ "#{File.expand_path('../../../', __FILE__)}/config/gemsets.yml" ],
- :gemspec => "#{File.expand_path('../../../', __FILE__)}/config/gemspec.yml",
- :warn => true
- )
-
- def activate(*gems)
- begin
- require 'rubygems' unless defined?(::Gem)
- rescue LoadError
- puts "rubygems library could not be required" if @config.warn
- end
-
- self.gemset ||= gemset_from_loaded_specs
-
- gems.flatten.collect { |g| g.to_sym }.each do |name|
- version = @versions[name]
- vendor = File.expand_path("../../../vendor/#{name}/lib", __FILE__)
- warning = "#{name} #{"(#{version})" if version} failed to activate"
- if File.exists?(vendor)
- $:.unshift vendor
- elsif defined?(gem)
- begin
- gem name.to_s, version
- rescue Exception => e
- puts warning if @config.warn
- end
- else
- puts warning if @config.warn
- end
- end
- end
-
- def dependencies
- dependency_filter(@gemspec.dependencies, @gemset)
- end
-
- def development_dependencies
- dependency_filter(@gemspec.development_dependencies, @gemset)
- end
-
- def gemset=(gemset)
- if gemset
- @gemset = gemset.to_sym
-
- @gemsets = @config.gemsets.reverse.collect { |config|
- if config.is_a?(::String)
- YAML::load(File.read(config)) rescue {}
- elsif config.is_a?(::Hash)
- config
- end
- }.inject({}) do |hash, config|
- deep_merge(hash, symbolize_keys(config))
- end
-
- @versions = (@gemsets[gemspec.name.to_sym] || {}).inject({}) do |hash, (key, value)|
- if !value.is_a?(::Hash) && value
- hash[key] = value
- elsif key == @gemset
- (value || {}).each { |k, v| hash[k] = v }
- end
- hash
- end
- else
- @gemset = nil
- @gemsets = nil
- @versions = nil
- end
- end
-
- def gemset_names
- (
- [ :default ] +
- @gemsets[gemspec.name.to_sym].inject([]) { |array, (key, value)|
- array.push(key) if value.is_a?(::Hash) || value.nil?
- array
- }
- ).uniq
- end
-
- def gemspec(reload=false)
- if @gemspec && !reload
- @gemspec
- else
- data = YAML::load(File.read(@config.gemspec)) rescue {}
- @gemspec = SimpleStruct.new(data)
- end
- end
-
- private
-
- def deep_merge(first, second)
- merger = lambda do |key, v1, v2|
- Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2
- end
- first.merge(second, &merger)
- end
-
- def dependency_filter(dependencies, match)
- (dependencies || []).inject([]) { |array, value|
- if value.is_a?(::Hash)
- array += value[match.to_s] if value[match.to_s]
- else
- array << value
- end
- array
- }.uniq.collect(&:to_sym)
- end
-
- def gemset_from_loaded_specs
- if defined?(Gem)
- Gem.loaded_specs.each do |name, spec|
- if name == gemspec.name
- return :default
- elsif name[0..gemspec.name.length] == "#{gemspec.name}-"
- return name[gemspec.name.length+1..-1].to_sym
- end
- end
- :default
- else
- :none
- end
- end
-
- def symbolize_keys(hash)
- return {} unless hash.is_a?(::Hash)
- hash.inject({}) do |options, (key, value)|
- value = symbolize_keys(value) if value.is_a?(::Hash)
- options[(key.to_sym rescue key) || key] = value
- options
- end
- end
- end
- end
- end
-end
View
29 maitre_d.gemspec
@@ -1,29 +1,18 @@
# -*- encoding: utf-8 -*-
root = File.expand_path('../', __FILE__)
lib = "#{root}/lib"
+
$:.unshift lib unless $:.include?(lib)
-
-require 'maitre_d/gems'
-MaitreD::Gems.gemset ||= ENV['GEMSET'] || :default
Gem::Specification.new do |s|
- MaitreD::Gems.gemspec.hash.each do |key, value|
- if key == 'name' && MaitreD::Gems.gemset != :default
- s.name = "#{value}-#{MaitreD::Gems.gemset}"
- elsif key == 'summary' && MaitreD::Gems.gemset == :solo
- s.summary = value + " (no dependencies)"
- elsif !%w(dependencies development_dependencies).include?(key)
- s.send "#{key}=", value
- end
- end
-
- MaitreD::Gems.dependencies.each do |g|
- s.add_dependency g.to_s, MaitreD::Gems.versions[g]
- end
-
- MaitreD::Gems.development_dependencies.each do |g|
- s.add_development_dependency g.to_s, MaitreD::Gems.versions[g]
- end
+ s.name = "maitre_d"
+ s.version = '0.1.0'
+ s.platform = Gem::Platform::RUBY
+ s.authors = [ "Winton Welsh" ]
+ s.email = [ "mail@wintoni.us" ]
+ s.homepage = "http://github.com/winton/maitre_d"
+ s.summary = %q{A reservation API for deploy environments}
+ s.description = %q{A reservation API for deploy environments.}
s.executables = `cd #{root} && git ls-files bin/*`.split("\n").collect { |f| File.basename(f) }
s.files = `cd #{root} && git ls-files`.split("\n")
View
4 script/console
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
-lib = File.expand_path(File.dirname(__FILE__) + "/../lib/maitre_d")
-exec "irb -r #{lib}/boot/console"
+lib = File.expand_path(File.dirname(__FILE__) + "/../lib")
+exec "irb -r #{lib}/maitre_d/console"
View
9 spec/fixtures/gemsets.yml
@@ -1,9 +0,0 @@
-name:
- rake: =0.8.7
- default:
- mysql: =2.8.1
- rspec: =1.3.1
- rspec2:
- mysql2: =0.2.6
- rspec: =2.3.0
- solo: null
View
15 spec/fixtures/gemspec.yml
@@ -1,15 +0,0 @@
-name: name
-version: 0.1.0
-authors:
- - Author
-email: email@email.com
-homepage: http://github.com/author/name
-summary: Summary
-description: Description
-dependencies:
- - rake
- - default:
- - mysql
- - rspec2:
- - mysql2
-development_dependencies: null
View
2 spec/maitre_d/controller/reservations_spec.rb
@@ -13,7 +13,7 @@ def app
end
it "should create a reservation" do
- post '/reservations/create', {
+ get '/reservations/create', {
:environment => 'test',
:seconds => @expires - Time.now.to_i,
:user => 'tester'
View
249 spec/maitre_d/gems_spec.rb
@@ -1,249 +0,0 @@
-require 'spec_helper'
-
-describe MaitreD::Gems do
-
- before(:each) do
- @old_config = MaitreD::Gems.config
-
- MaitreD::Gems.config.gemspec = "#{$root}/spec/fixtures/gemspec.yml"
- MaitreD::Gems.config.gemsets = [
- "#{$root}/spec/fixtures/gemsets.yml"
- ]
- MaitreD::Gems.config.warn = true
-
- MaitreD::Gems.gemspec true
- MaitreD::Gems.gemset = nil
- end
-
- after(:each) do
- MaitreD::Gems.config = @old_config
- end
-
- describe :activate do
- it "should activate gems" do
- MaitreD::Gems.stub!(:gem)
- MaitreD::Gems.should_receive(:gem).with('rspec', '=1.3.1')
- MaitreD::Gems.should_receive(:gem).with('rake', '=0.8.7')
- MaitreD::Gems.activate :rspec, 'rake'
- end
- end
-
- describe :gemset= do
- before(:each) do
- MaitreD::Gems.config.gemsets = [
- {
- :name => {
- :rake => '>0.8.6',
- :default => {
- :externals => '=1.0.2'
- }
- }
- },
- "#{$root}/spec/fixtures/gemsets.yml"
- ]
- end
-
- describe :default do
- before(:each) do
- MaitreD::Gems.gemset = :default
- end
-
- it "should set @gemset" do
- MaitreD::Gems.gemset.should == :default
- end
-
- it "should set @gemsets" do
- MaitreD::Gems.gemsets.should == {
- :name => {
- :rake => ">0.8.6",
- :default => {
- :externals => '=1.0.2',
- :mysql => "=2.8.1",
- :rspec => "=1.3.1"
- },
- :rspec2 => {
- :mysql2 => "=0.2.6",
- :rspec => "=2.3.0"
- },
- :solo => nil
- }
- }
- end
-
- it "should set Gems.versions" do
- MaitreD::Gems.versions.should == {
- :externals => "=1.0.2",
- :mysql => "=2.8.1",
- :rake => ">0.8.6",
- :rspec => "=1.3.1"
- }
- end
-
- it "should return proper values for Gems.dependencies" do
- MaitreD::Gems.dependencies.should == [ :rake, :mysql ]
- MaitreD::Gems.development_dependencies.should == []
- end
-
- it "should return proper values for Gems.gemset_names" do
- MaitreD::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
- end
- end
-
- describe :rspec2 do
- before(:each) do
- MaitreD::Gems.gemset = "rspec2"
- end
-
- it "should set @gemset" do
- MaitreD::Gems.gemset.should == :rspec2
- end
-
- it "should set @gemsets" do
- MaitreD::Gems.gemsets.should == {
- :name => {
- :rake => ">0.8.6",
- :default => {
- :externals => '=1.0.2',
- :mysql => "=2.8.1",
- :rspec => "=1.3.1"
- },
- :rspec2 => {
- :mysql2=>"=0.2.6",
- :rspec => "=2.3.0"
- },
- :solo => nil
- }
- }
- end
-
- it "should set Gems.versions" do
- MaitreD::Gems.versions.should == {
- :mysql2 => "=0.2.6",
- :rake => ">0.8.6",
- :rspec => "=2.3.0"
- }
- end
-
- it "should return proper values for Gems.dependencies" do
- MaitreD::Gems.dependencies.should == [ :rake, :mysql2 ]
- MaitreD::Gems.development_dependencies.should == []
- end
-
- it "should return proper values for Gems.gemset_names" do
- MaitreD::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
- end
- end
-
- describe :solo do
- before(:each) do
- MaitreD::Gems.gemset = :solo
- end
-
- it "should set @gemset" do
- MaitreD::Gems.gemset.should == :solo
- end
-
- it "should set @gemsets" do
- MaitreD::Gems.gemsets.should == {
- :name => {
- :rake => ">0.8.6",
- :default => {
- :externals => '=1.0.2',
- :mysql => "=2.8.1",
- :rspec => "=1.3.1"
- },
- :rspec2 => {
- :mysql2=>"=0.2.6",
- :rspec => "=2.3.0"
- },
- :solo => nil
- }
- }
- end
-
- it "should set Gems.versions" do
- MaitreD::Gems.versions.should == {:rake=>">0.8.6"}
- end
-
- it "should return proper values for Gems.dependencies" do
- MaitreD::Gems.dependencies.should == [:rake]
- MaitreD::Gems.development_dependencies.should == []
- end
-
- it "should return proper values for Gems.gemset_names" do
- MaitreD::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
- end
- end
-
- describe :nil do
- before(:each) do
- MaitreD::Gems.gemset = nil
- end
-
- it "should set everything to nil" do
- MaitreD::Gems.gemset.should == nil
- MaitreD::Gems.gemsets.should == nil
- MaitreD::Gems.versions.should == nil
- end
- end
- end
-
- describe :gemset_from_loaded_specs do
- before(:each) do
- Gem.stub!(:loaded_specs)
- end
-
- it "should return the correct gemset for name gem" do
- Gem.should_receive(:loaded_specs).and_return({ "name" => nil })
- MaitreD::Gems.send(:gemset_from_loaded_specs).should == :default
- end
-
- it "should return the correct gemset for name-rspec gem" do
- Gem.should_receive(:loaded_specs).and_return({ "name-rspec2" => nil })
- MaitreD::Gems.send(:gemset_from_loaded_specs).should == :rspec2
- end
- end
-
- describe :reload_gemspec do
- it "should populate @gemspec" do
- MaitreD::Gems.gemspec.hash.should == {
- "name" => "name",
- "version" => "0.1.0",
- "authors" => ["Author"],
- "email" => "email@email.com",
- "homepage" => "http://github.com/author/name",
- "summary" => "Summary",
- "description" => "Description",
- "dependencies" => [
- "rake",
- { "default" => [ "mysql" ] },
- { "rspec2" => [ "mysql2" ] }
- ],
- "development_dependencies" => nil
- }
- end
-
- it "should create methods from keys of @gemspec" do
- MaitreD::Gems.gemspec.name.should == "name"
- MaitreD::Gems.gemspec.version.should == "0.1.0"
- MaitreD::Gems.gemspec.authors.should == ["Author"]
- MaitreD::Gems.gemspec.email.should == "email@email.com"
- MaitreD::Gems.gemspec.homepage.should == "http://github.com/author/name"
- MaitreD::Gems.gemspec.summary.should == "Summary"
- MaitreD::Gems.gemspec.description.should == "Description"
- MaitreD::Gems.gemspec.dependencies.should == [
- "rake",
- { "default" => ["mysql"] },
- { "rspec2" => [ "mysql2" ] }
- ]
- MaitreD::Gems.gemspec.development_dependencies.should == nil
- end
-
- it "should produce a valid gemspec" do
- MaitreD::Gems.gemset = :default
- gemspec = File.expand_path("../../../maitre_d.gemspec", __FILE__)
- gemspec = eval(File.read(gemspec), binding, gemspec)
- gemspec.validate.should == true
- end
- end
-end
View
4 spec/maitre_d_spec.rb
@@ -1,4 +0,0 @@
-require 'spec_helper'
-
-describe MaitreD do
-end
View
16 spec/spec_helper.rb
@@ -1,13 +1,9 @@
-require 'pp'
+require "pp"
+require "bundler"
-$root = File.expand_path('../../', __FILE__)
-require "#{$root}/lib/maitre_d/gems"
-
-MaitreD::Gems.activate %w(rack-test rspec)
+Bundler.require(:development)
+require "rack/test"
-require 'rack/test'
-
-require "#{$root}/lib/maitre_d"
+$root = File.expand_path('../../', __FILE__)
-Spec::Runner.configure do |config|
-end
+require "#{$root}/lib/maitre_d"

0 comments on commit 4c4c079

Please sign in to comment.
Something went wrong with that request. Please try again.