Browse files

Merge pull request #52 from dblock/gemfile-bundle

Updated gemfile, rspec and added a few basic specs
  • Loading branch information...
2 parents 8208fe6 + eb31312 commit d7f50846db7cd9772104bdc78b3ee218e2958613 @Sutto committed Sep 3, 2011
Showing with 208 additions and 32 deletions.
  1. +3 −1 .gitignore
  2. +9 −4 Gemfile
  3. +87 −1 Gemfile.lock
  4. +34 −17 Rakefile
  5. +3 −0 spec/assets/alert.coffee
  6. +56 −4 spec/barista_spec.rb
  7. +16 −5 spec/spec_helper.rb
View
4 .gitignore
@@ -20,4 +20,6 @@ pkg
## PROJECT::SPECIFIC
-.rvmrc
+.rvmrc
+public
+
View
13 Gemfile
@@ -3,7 +3,12 @@ source "http://rubygems.org"
gem 'coffee-script', '~> 2.2'
group :development, :test do
- gem 'jeweler', '~> 1.0'
- gem 'rspec', '~> 2.1'
- gem 'rr', '~> 1.0'
-end
+ gem 'rails', '~> 3.0'
+ gem 'jeweler', '~> 1.0'
+ gem 'rspec', '~> 2.6'
+ gem 'rspec-rails', '~> 2.6'
+ gem 'rspec-core', '~> 2.6'
+ gem 'rdoc', '~> 2.4'
+ gem 'rr', '~> 1.0'
+ gem 'ruby-debug19', '~> 0.11'
+end
View
88 Gemfile.lock
@@ -1,20 +1,82 @@
GEM
remote: http://rubygems.org/
specs:
+ abstract (1.0.0)
+ actionmailer (3.0.8)
+ actionpack (= 3.0.8)
+ mail (~> 2.2.19)
+ actionpack (3.0.8)
+ activemodel (= 3.0.8)
+ activesupport (= 3.0.8)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.5.0)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.14)
+ rack-test (~> 0.5.7)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.8)
+ activesupport (= 3.0.8)
+ builder (~> 2.1.2)
+ i18n (~> 0.5.0)
+ activerecord (3.0.8)
+ activemodel (= 3.0.8)
+ activesupport (= 3.0.8)
+ arel (~> 2.0.10)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.8)
+ activemodel (= 3.0.8)
+ activesupport (= 3.0.8)
+ activesupport (3.0.8)
+ archive-tar-minitar (0.5.2)
+ arel (2.0.10)
+ builder (2.1.2)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.1)
+ columnize (0.3.4)
diff-lcs (1.1.2)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
execjs (1.1.0)
multi_json (~> 1.0)
git (1.2.5)
+ i18n (0.5.0)
jeweler (1.6.2)
bundler (~> 1.0)
git (>= 1.2.5)
rake
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
+ mail (2.2.19)
+ activesupport (>= 2.3.6)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
multi_json (1.0.3)
+ polyglot (0.3.1)
+ rack (1.2.3)
+ rack-mount (0.6.14)
+ rack (>= 1.0.0)
+ rack-test (0.5.7)
+ rack (>= 1.0)
+ rails (3.0.8)
+ actionmailer (= 3.0.8)
+ actionpack (= 3.0.8)
+ activerecord (= 3.0.8)
+ activeresource (= 3.0.8)
+ activesupport (= 3.0.8)
+ bundler (~> 1.0)
+ railties (= 3.0.8)
+ railties (3.0.8)
+ actionpack (= 3.0.8)
+ activesupport (= 3.0.8)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
rake (0.9.1)
+ rdoc (2.5.11)
rr (1.0.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
@@ -24,12 +86,36 @@ GEM
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
+ rspec-rails (2.6.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.6.0)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+ thor (0.14.6)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.29)
PLATFORMS
ruby
DEPENDENCIES
coffee-script (~> 2.2)
jeweler (~> 1.0)
+ rails (~> 3.0)
+ rdoc (~> 2.4)
rr (~> 1.0)
- rspec (~> 2.1)
+ rspec (~> 2.6)
+ rspec-core (~> 2.6)
+ rspec-rails (~> 2.6)
+ ruby-debug19 (~> 0.11)
View
51 Rakefile
@@ -1,29 +1,46 @@
require 'rubygems'
+require 'bundler'
+
+begin
+ Bundler.setup(:default, :development)
+rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems."
+ exit e.status_code
+end
+
require 'rake'
+require 'rspec/core/rake_task'
-require 'lib/barista/version'
+require 'barista/version'
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gem|
- gem.name = "barista"
- gem.summary = %Q{Simple, transparent coffeescript integration for Rails and Rack applications.}
- gem.description = File.read(File.expand_path('DESCRIPTION', File.dirname(__FILE__)))
- gem.email = "sutto@sutto.net"
- gem.homepage = "http://github.com/Sutto/barista"
- gem.version = Barista::Version::STRING
- gem.authors = ["Darcy Laycock"]
- end
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
+require 'jeweler'
+Jeweler::Tasks.new do |gem|
+ gem.name = "barista"
+ gem.summary = %Q{Simple, transparent coffeescript integration for Rails and Rack applications.}
+ gem.description = File.read(File.expand_path('DESCRIPTION', File.dirname(__FILE__)))
+ gem.email = "sutto@sutto.net"
+ gem.homepage = "http://github.com/Sutto/barista"
+ gem.version = Barista::Version::STRING
+ gem.authors = ["Darcy Laycock"]
end
+Jeweler::GemcutterTasks.new
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rdoc|
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = "spec/**/*_spec.rb"
+end
+
+require 'rdoc/task'
+RDoc::Task.new do |rdoc|
version = Barista::Version::STRING
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "barista #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
+
+task :default => :spec
+
+require 'barista'
+
+
View
3 spec/assets/alert.coffee
@@ -0,0 +1,3 @@
+hello ->
+ alert 'hello world'
+
View
60 spec/barista_spec.rb
@@ -1,15 +1,67 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Barista do
context 'hooks'
context 'configuration'
- context 'setting the root'
+ context 'setting app_root' do
+ it "defaults to Rails.root" do
+ Barista::app_root.should == Rails.root
+ end
+ it "can be set to another directory" do
+ new_path = File.expand_path("../../public/javascripts", __FILE__)
+ Barista.configure do |c|
+ c.app_root = new_path
+ end
+ Barista::app_root.to_s.should == new_path
+ end
+ end
+
+ context 'preamble' do
+ before(:each) do
+ @assets_path = File.expand_path("../assets", __FILE__)
+ @public_path = File.expand_path("../public", __FILE__)
+ Barista.configure do |c|
+ c.root = @assets_path
+ c.output_root = @public_path
+ end
+ FileUtils.rm_rf @public_path if Dir.exist?(@public_path)
+ end
+ it "is written by default" do
+ Barista.add_preamble = true
+ Barista::compile_all!
+ alert_js = IO.read(File.join(@public_path, "alert.js"))
+ alert_js.should include "DO NOT MODIFY"
+ end
+ it "can be disabled" do
+ Barista.add_preamble = false
+ Barista::compile_all!
+ alert_js = IO.read(File.join(@public_path, "alert.js"))
+ alert_js.should_not include "DO NOT MODIFY"
+ end
+ end
context 'compiling files'
- context 'compiling all'
+ context 'compiling all' do
+ before(:each) do
+ @assets_path = File.expand_path("../assets", __FILE__)
+ @public_path = File.expand_path("../public", __FILE__)
+ Barista.configure do |c|
+ c.root = @assets_path
+ c.output_root = @public_path
+ end
+ FileUtils.rm_rf @public_path if Dir.exist?(@public_path)
+ end
+ it "compiles nothing" do
+ lambda { Barista::compile_all! false, false }.should_not raise_error
+ end
+ it "produces alert.js" do
+ Barista::compile_all!
+ File.exist?(File.join(@public_path, "alert.js")).should be_true
+ end
+ end
-end
+end
View
21 spec/spec_helper.rb
@@ -1,11 +1,22 @@
+require 'rubygems'
+
ENV['RAILS_ENV'] ||= 'test'
+ENV['RAILS_ROOT'] ||= File.expand_path("..", __FILE__)
+
+require "action_controller/railtie"
+require "action_mailer/railtie"
+require "active_resource/railtie"
-require 'bundler/setup'
+require 'rspec/rails'
-spec_dir = Rails.root.join("spec")
+Bundler.require(:default, Rails.env) if defined?(Bundler)
-Dir[spec_dir.join("support/**/*.rb")].each { |f| require f }
+class Application < Rails::Application; end
+
+require 'barista'
RSpec.configure do |config|
- config.mock_with :rr
-end
+ config.mock_with :rspec
+ config.expect_with :rspec
+end
+

0 comments on commit d7f5084

Please sign in to comment.