├── .gitignore
├── .rvmrc
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── README.textile
├── Rakefile
├── coffeebeans.gemspec
├── lib
└── coffeebeans.rb
└── spec
├── dummy
├── .gitignore
├── Gemfile
├── Gemfile.lock
├── app
│ ├── controllers
│ │ ├── application_controller.rb
│ │ └── drinks_controller.rb
│ ├── helpers
│ │ └── application_helper.rb
│ └── views
│ │ ├── drinks
│ │ ├── index.html.erb
│ │ └── index.js.coffee
│ │ └── layouts
│ │ └── application.html.erb
├── config.ru
├── config
│ ├── application.rb
│ ├── boot.rb
│ ├── environment.rb
│ ├── environments
│ │ ├── development.rb
│ │ ├── production.rb
│ │ └── test.rb
│ ├── initializers
│ │ ├── backtrace_silencers.rb
│ │ ├── inflections.rb
│ │ ├── mime_types.rb
│ │ ├── secret_token.rb
│ │ └── session_store.rb
│ ├── locales
│ │ └── en.yml
│ └── routes.rb
├── db
│ └── seeds.rb
├── lib
│ └── tasks
│ │ └── .gitkeep
├── script
│ └── rails
└── vendor
│ └── plugins
│ └── .gitkeep
├── request
└── coffee_script_spec.rb
└── spec_helper.rb
/.gitignore:
--------------------------------------------------------------------------------
1 | *.log
2 | .DS_Store
3 | doc
4 | tmp
5 | pkg
6 | *.gem
7 | *.pid
8 | coverage
9 | coverage.data
10 | build/*
11 | *.pbxuser
12 | *.mode1v3
13 | .svn
14 | profile
15 | .console_history
16 | .sass-cache/*
17 |
--------------------------------------------------------------------------------
/.rvmrc:
--------------------------------------------------------------------------------
1 | rvm use ruby-1.9.2@coffeescript_rails
2 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 |
3 | gem 'rake'
4 | gem 'rails'
5 | gem "rspec-rails", "2.6.0"
6 | gem 'gemstub', ">= 2.0.0"
7 | gem 'coffee-script'
8 | gem 'sqlite3'
9 | gem 'capybara', :git => 'git://github.com/jnicklas/capybara.git'
10 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GIT
2 | remote: git://github.com/jnicklas/capybara.git
3 | revision: 4c3ce57430a1b07e534450dca8a2e551b5363539
4 | specs:
5 | capybara (1.0.0.beta1)
6 | mime-types (>= 1.16)
7 | nokogiri (>= 1.3.3)
8 | rack (>= 1.0.0)
9 | rack-test (>= 0.5.4)
10 | selenium-webdriver (~> 0.2.0)
11 | xpath (~> 0.1.4)
12 |
13 | GEM
14 | remote: http://rubygems.org/
15 | specs:
16 | abstract (1.0.0)
17 | actionmailer (3.0.7)
18 | actionpack (= 3.0.7)
19 | mail (~> 2.2.15)
20 | actionpack (3.0.7)
21 | activemodel (= 3.0.7)
22 | activesupport (= 3.0.7)
23 | builder (~> 2.1.2)
24 | erubis (~> 2.6.6)
25 | i18n (~> 0.5.0)
26 | rack (~> 1.2.1)
27 | rack-mount (~> 0.6.14)
28 | rack-test (~> 0.5.7)
29 | tzinfo (~> 0.3.23)
30 | activemodel (3.0.7)
31 | activesupport (= 3.0.7)
32 | builder (~> 2.1.2)
33 | i18n (~> 0.5.0)
34 | activerecord (3.0.7)
35 | activemodel (= 3.0.7)
36 | activesupport (= 3.0.7)
37 | arel (~> 2.0.2)
38 | tzinfo (~> 0.3.23)
39 | activeresource (3.0.7)
40 | activemodel (= 3.0.7)
41 | activesupport (= 3.0.7)
42 | activesupport (3.0.7)
43 | arel (2.0.10)
44 | builder (2.1.2)
45 | childprocess (0.1.9)
46 | ffi (~> 1.0.6)
47 | coffee-script (2.2.0)
48 | coffee-script-source
49 | execjs
50 | coffee-script-source (1.1.0)
51 | diff-lcs (1.1.2)
52 | erubis (2.6.6)
53 | abstract (>= 1.0.0)
54 | execjs (1.0.0)
55 | multi_json (~> 1.0)
56 | ffi (1.0.8)
57 | gemstub (2.0.3)
58 | activesupport (>= 3.0.0)
59 | genosaurus
60 | mark_facets
61 | rspec (>= 2.0.0)
62 | genosaurus (1.2.4)
63 | erubis
64 | hashie (1.0.0)
65 | i18n (0.5.0)
66 | json_pure (1.5.1)
67 | mail (2.2.19)
68 | activesupport (>= 2.3.6)
69 | i18n (>= 0.4.0)
70 | mime-types (~> 1.16)
71 | treetop (~> 1.4.8)
72 | mark_facets (0.2.0)
73 | hashie
74 | mime-types (1.16)
75 | multi_json (1.0.2)
76 | nokogiri (1.4.4)
77 | polyglot (0.3.1)
78 | rack (1.2.2)
79 | rack-mount (0.6.14)
80 | rack (>= 1.0.0)
81 | rack-test (0.5.7)
82 | rack (>= 1.0)
83 | rails (3.0.7)
84 | actionmailer (= 3.0.7)
85 | actionpack (= 3.0.7)
86 | activerecord (= 3.0.7)
87 | activeresource (= 3.0.7)
88 | activesupport (= 3.0.7)
89 | bundler (~> 1.0)
90 | railties (= 3.0.7)
91 | railties (3.0.7)
92 | actionpack (= 3.0.7)
93 | activesupport (= 3.0.7)
94 | rake (>= 0.8.7)
95 | thor (~> 0.14.4)
96 | rake (0.8.7)
97 | rspec (2.6.0)
98 | rspec-core (~> 2.6.0)
99 | rspec-expectations (~> 2.6.0)
100 | rspec-mocks (~> 2.6.0)
101 | rspec-core (2.6.0)
102 | rspec-expectations (2.6.0)
103 | diff-lcs (~> 1.1.2)
104 | rspec-mocks (2.6.0)
105 | rspec-rails (2.6.0)
106 | actionpack (~> 3.0)
107 | activesupport (~> 3.0)
108 | railties (~> 3.0)
109 | rspec (~> 2.6.0)
110 | rubyzip (0.9.4)
111 | selenium-webdriver (0.2.0)
112 | childprocess (>= 0.1.7)
113 | ffi (>= 1.0.7)
114 | json_pure
115 | rubyzip
116 | sqlite3 (1.3.3)
117 | thor (0.14.6)
118 | treetop (1.4.9)
119 | polyglot (>= 0.3.1)
120 | tzinfo (0.3.27)
121 | xpath (0.1.4)
122 | nokogiri (~> 1.3)
123 |
124 | PLATFORMS
125 | ruby
126 |
127 | DEPENDENCIES
128 | capybara!
129 | coffee-script
130 | gemstub (>= 2.0.0)
131 | rails
132 | rake
133 | rspec-rails (= 2.6.0)
134 | sqlite3
135 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2011 markbates
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.textile:
--------------------------------------------------------------------------------
1 | h1. CoffeeBeans
2 |
3 | Rails 3.1 has made quite a splash with its inclusion of "CoffeeScript":http://www.coffeescript.org. I for one am very excited about being able to write JavaScript in an easier and more beautiful way. However, when CoffeeScript was added to Rails 3.1 they forgot one very important part, the ability to use it when responding to JavaScript (JS) requests!
4 |
5 | In Rails 3.1 it's incredibly easy to build your application's JavaScript using CoffeeScript, however if you fire off an AJAX request to your application you can only write your response using regular JavaScript and not CoffeeScript, at least until CoffeeBeans came along.
6 |
7 | h2. Installation
8 |
9 | Installing CoffeeBeans is simple. In your Rails 3.x project (yes, this works in Rails 3.0.x as well as Rails 3.1) add the following to your Gemfile
:
10 |
11 |
gem 'coffeebeans'
12 |
13 | Then run:
14 |
15 | $ bundle install
16 |
17 | That's it! CoffeeBeans is now installed and ready to help you make the most of CoffeeScript in your Rails app. Enjoy!
18 |
19 | h2. Usage
20 |
21 | Usage of CoffeeBeans is incredibly simple. Let's say you want to respond to a JavaScript (JS) request using CoffeeScript just name your view something like this:
22 |
23 | app/views/users/index.js.coffee
24 |
25 | That's it! You're done. Now you can use CoffeeScript (and ERB) in that file. Nothing else special to do, tweak or change.
26 |
27 | h2. But Wait, There's More!
28 |
29 | Act now and we'll throw in two view helper methods to help make it easy for you to write CoffeeScript in your views as well:
30 |
31 | h3. coffee_script_tag
32 |
33 | The coffee_script_tag
helper method will compile your CoffeeScript code and place it between script
tags:
34 |
35 |
36 | <%= coffee_script_tag do %>
37 | alert 'coffee script is awesome!'
38 | <% end %>
39 |
40 |
41 | Will generate:
42 |
43 |
44 |
49 |
50 |
51 | h3. coffee_script
52 |
53 | Alternatively, if you want to place/compile CoffeeScript between script tags that are already on your page, then you can simply use the coffee_script
helper to do that.
54 |
55 |
56 |
61 |
62 |
63 | Will generate:
64 |
65 |
66 |
71 |
72 |
73 | h2. Footnote
74 |
75 | I really hope that this gem doesn't have to be around too long and that the Rails team decides to actually add this into Rails proper. It seems like a no-brainer as far as I'm concerned. I did submit a "pull request":https://github.com/rails/rails/pull/1130 but it wasn't accepted because they may want to refactor the rendering system in the future.
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 |
3 | # Set up gems listed in the Gemfile.
4 | gemfile = File.expand_path('../Gemfile', __FILE__)
5 | begin
6 | ENV['BUNDLE_GEMFILE'] = gemfile
7 | require 'bundler'
8 | Bundler.setup
9 | rescue Bundler::GemNotFound => e
10 | STDERR.puts e.message
11 | STDERR.puts "Try running `bundle install`."
12 | exit!
13 | end if File.exist?(gemfile)
14 |
15 | Bundler.require
16 |
17 | Gemstub.test_framework = :rspec
18 |
19 | Gemstub.gem_spec do |s|
20 | s.version = '1.0.1'
21 | # s.rubyforge_project = 'coffeescript_rails'
22 | s.add_dependency('coffee-script')
23 | s.add_dependency('actionpack', '>= 3.0.0')
24 | s.email = 'mark+github@markbates.com'
25 | s.homepage = 'http://github.com/markbates/coffeebeans'
26 | end
27 |
28 | Gemstub.rdoc do |rd|
29 | rd.title = 'coffeebeans'
30 | end
31 |
--------------------------------------------------------------------------------
/coffeebeans.gemspec:
--------------------------------------------------------------------------------
1 | # -*- encoding: utf-8 -*-
2 |
3 | Gem::Specification.new do |s|
4 | s.name = %q{coffeebeans}
5 | s.version = "1.0.1.20110527114144"
6 |
7 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8 | s.authors = [%q{markbates}]
9 | s.date = %q{2011-05-27}
10 | s.description = %q{coffeebeans was developed by: markbates}
11 | s.email = %q{mark+github@markbates.com}
12 | s.extra_rdoc_files = [%q{LICENSE}]
13 | s.files = [%q{lib/coffeebeans.rb}, %q{LICENSE}]
14 | s.homepage = %q{http://github.com/markbates/coffeebeans}
15 | s.require_paths = [%q{lib}]
16 | s.rubygems_version = %q{1.8.2}
17 | s.summary = %q{coffeebeans}
18 |
19 | if s.respond_to? :specification_version then
20 | s.specification_version = 3
21 |
22 | if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
23 | s.add_runtime_dependency(%q, [">= 0"])
24 | s.add_runtime_dependency(%q, [">= 3.0.0"])
25 | else
26 | s.add_dependency(%q, [">= 0"])
27 | s.add_dependency(%q, [">= 3.0.0"])
28 | end
29 | else
30 | s.add_dependency(%q, [">= 0"])
31 | s.add_dependency(%q, [">= 3.0.0"])
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/lib/coffeebeans.rb:
--------------------------------------------------------------------------------
1 | require 'coffee-script'
2 |
3 | module CoffeeBeans
4 | module Handlers
5 | module CoffeeScript
6 | def self.erb_handler
7 | @@erb_handler ||= ActionView::Template.registered_template_handler(:erb)
8 | end
9 |
10 | def self.call(template)
11 | compiled_source = erb_handler.call(template)
12 | "::CoffeeScript.compile(begin;#{compiled_source};end).html_safe"
13 | end
14 | end
15 | end
16 |
17 | module ViewHelpers
18 |
19 | def coffee_script_tag(&block)
20 | content_tag(:script, coffee_script(&block), :type => 'text/javascript')
21 | end
22 |
23 | def coffee_script(&block)
24 | ::CoffeeScript.compile(capture(&block)).html_safe
25 | end
26 |
27 | end
28 |
29 | end
30 |
31 | ActionView::Template.register_template_handler :coffee, CoffeeBeans::Handlers::CoffeeScript
32 | ActionView::Base.send :include, CoffeeBeans::ViewHelpers
33 |
--------------------------------------------------------------------------------
/spec/dummy/.gitignore:
--------------------------------------------------------------------------------
1 | .bundle
2 | db/*.sqlite3
3 | log/*.log
4 | tmp/
5 |
--------------------------------------------------------------------------------
/spec/dummy/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 |
3 | gem 'rails', '3.0.7'
4 |
5 | gem 'coffeebeans', :path => '~/gemdev/coffeebeans'
6 |
7 | # Bundle edge Rails instead:
8 | # gem 'rails', :git => 'git://github.com/rails/rails.git'
9 |
10 |
11 | # Use unicorn as the web server
12 | # gem 'unicorn'
13 |
14 | # Deploy with Capistrano
15 | # gem 'capistrano'
16 |
17 | # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
18 | # gem 'ruby-debug'
19 | # gem 'ruby-debug19', :require => 'ruby-debug'
20 |
21 | # Bundle the extra gems:
22 | # gem 'bj'
23 | # gem 'nokogiri'
24 | # gem 'sqlite3-ruby', :require => 'sqlite3'
25 | # gem 'aws-s3', :require => 'aws/s3'
26 |
27 | # Bundle gems for the local environment. Make sure to
28 | # put test-only gems in this group so their generators
29 | # and rake tasks are available in development mode:
30 | # group :development, :test do
31 | # gem 'webrat'
32 | # end
33 |
--------------------------------------------------------------------------------
/spec/dummy/Gemfile.lock:
--------------------------------------------------------------------------------
1 | PATH
2 | remote: ~/gemdev/coffeebeans
3 | specs:
4 | coffeebeans (1.0.0.20110519132850)
5 | actionpack (>= 3.0.0)
6 | coffee-script
7 |
8 | GEM
9 | remote: http://rubygems.org/
10 | specs:
11 | abstract (1.0.0)
12 | actionmailer (3.0.7)
13 | actionpack (= 3.0.7)
14 | mail (~> 2.2.15)
15 | actionpack (3.0.7)
16 | activemodel (= 3.0.7)
17 | activesupport (= 3.0.7)
18 | builder (~> 2.1.2)
19 | erubis (~> 2.6.6)
20 | i18n (~> 0.5.0)
21 | rack (~> 1.2.1)
22 | rack-mount (~> 0.6.14)
23 | rack-test (~> 0.5.7)
24 | tzinfo (~> 0.3.23)
25 | activemodel (3.0.7)
26 | activesupport (= 3.0.7)
27 | builder (~> 2.1.2)
28 | i18n (~> 0.5.0)
29 | activerecord (3.0.7)
30 | activemodel (= 3.0.7)
31 | activesupport (= 3.0.7)
32 | arel (~> 2.0.2)
33 | tzinfo (~> 0.3.23)
34 | activeresource (3.0.7)
35 | activemodel (= 3.0.7)
36 | activesupport (= 3.0.7)
37 | activesupport (3.0.7)
38 | arel (2.0.10)
39 | builder (2.1.2)
40 | coffee-script (2.2.0)
41 | coffee-script-source
42 | execjs
43 | coffee-script-source (1.1.0)
44 | erubis (2.6.6)
45 | abstract (>= 1.0.0)
46 | execjs (1.0.0)
47 | multi_json (~> 1.0)
48 | i18n (0.5.0)
49 | mail (2.2.19)
50 | activesupport (>= 2.3.6)
51 | i18n (>= 0.4.0)
52 | mime-types (~> 1.16)
53 | treetop (~> 1.4.8)
54 | mime-types (1.16)
55 | multi_json (1.0.2)
56 | polyglot (0.3.1)
57 | rack (1.2.2)
58 | rack-mount (0.6.14)
59 | rack (>= 1.0.0)
60 | rack-test (0.5.7)
61 | rack (>= 1.0)
62 | rails (3.0.7)
63 | actionmailer (= 3.0.7)
64 | actionpack (= 3.0.7)
65 | activerecord (= 3.0.7)
66 | activeresource (= 3.0.7)
67 | activesupport (= 3.0.7)
68 | bundler (~> 1.0)
69 | railties (= 3.0.7)
70 | railties (3.0.7)
71 | actionpack (= 3.0.7)
72 | activesupport (= 3.0.7)
73 | rake (>= 0.8.7)
74 | thor (~> 0.14.4)
75 | rake (0.8.7)
76 | thor (0.14.6)
77 | treetop (1.4.9)
78 | polyglot (>= 0.3.1)
79 | tzinfo (0.3.27)
80 |
81 | PLATFORMS
82 | ruby
83 |
84 | DEPENDENCIES
85 | coffeebeans!
86 | rails (= 3.0.7)
87 |
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | protect_from_forgery
3 | end
4 |
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/drinks_controller.rb:
--------------------------------------------------------------------------------
1 | class DrinksController < ApplicationController
2 | respond_to :js, :html
3 |
4 | def index
5 | render(:action => 'index', :layout => false)
6 | end
7 |
8 | end
--------------------------------------------------------------------------------
/spec/dummy/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/spec/dummy/app/views/drinks/index.html.erb:
--------------------------------------------------------------------------------
1 | <%= coffee_script_tag do %>
2 | alert "coffee script is awesome!"
3 | <% end %>
4 |
5 |
--------------------------------------------------------------------------------
/spec/dummy/app/views/drinks/index.js.coffee:
--------------------------------------------------------------------------------
1 | alert "i like coffee!"
--------------------------------------------------------------------------------
/spec/dummy/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 | <%= yield %>
--------------------------------------------------------------------------------
/spec/dummy/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Dummy::Application
5 |
--------------------------------------------------------------------------------
/spec/dummy/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | # Pick the frameworks you want:
4 | # require "active_record/railtie"
5 | require "action_controller/railtie"
6 | require "action_mailer/railtie"
7 | require "active_resource/railtie"
8 | require "rails/test_unit/railtie"
9 |
10 | # If you have a Gemfile, require the gems listed there, including any gems
11 | # you've limited to :test, :development, or :production.
12 | Bundler.require(:default, Rails.env) if defined?(Bundler)
13 |
14 | module Dummy
15 | class Application < Rails::Application
16 | # Settings in config/environments/* take precedence over those specified here.
17 | # Application configuration should go into files in config/initializers
18 | # -- all .rb files in that directory are automatically loaded.
19 |
20 | # Custom directories with classes and modules you want to be autoloadable.
21 | # config.autoload_paths += %W(#{config.root}/extras)
22 |
23 | # Only load the plugins named here, in the order given (default is alphabetical).
24 | # :all can be used as a placeholder for all plugins not explicitly named.
25 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26 |
27 | # Activate observers that should always be running.
28 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
29 |
30 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
31 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
32 | # config.time_zone = 'Central Time (US & Canada)'
33 |
34 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
35 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
36 | # config.i18n.default_locale = :de
37 |
38 | # JavaScript files you want as :defaults (application.js is always included).
39 | config.action_view.javascript_expansions[:defaults] = %w()
40 |
41 | # Configure the default encoding used in templates for Ruby 1.9.
42 | config.encoding = "utf-8"
43 |
44 | # Configure sensitive parameters which will be filtered from the log file.
45 | config.filter_parameters += [:password]
46 | end
47 | end
48 |
--------------------------------------------------------------------------------
/spec/dummy/config/boot.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 |
3 | # Set up gems listed in the Gemfile.
4 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5 |
6 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
7 |
--------------------------------------------------------------------------------
/spec/dummy/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the rails application
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the rails application
5 | Dummy::Application.initialize!
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the webserver when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Log error messages when you accidentally call methods on nil.
10 | config.whiny_nils = true
11 |
12 | # Show full error reports and disable caching
13 | config.consider_all_requests_local = true
14 | config.action_view.debug_rjs = true
15 | config.action_controller.perform_caching = false
16 |
17 | # Don't care if the mailer can't send
18 | config.action_mailer.raise_delivery_errors = false
19 |
20 | # Print deprecation notices to the Rails logger
21 | config.active_support.deprecation = :log
22 |
23 | # Only use best-standards-support built into browsers
24 | config.action_dispatch.best_standards_support = :builtin
25 | end
26 |
27 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # The production environment is meant for finished, "live" apps.
5 | # Code is not reloaded between requests
6 | config.cache_classes = true
7 |
8 | # Full error reports are disabled and caching is turned on
9 | config.consider_all_requests_local = false
10 | config.action_controller.perform_caching = true
11 |
12 | # Specifies the header that your server uses for sending files
13 | config.action_dispatch.x_sendfile_header = "X-Sendfile"
14 |
15 | # For nginx:
16 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17 |
18 | # If you have no front-end server that supports something like X-Sendfile,
19 | # just comment this out and Rails will serve the files
20 |
21 | # See everything in the log (default is :info)
22 | # config.log_level = :debug
23 |
24 | # Use a different logger for distributed setups
25 | # config.logger = SyslogLogger.new
26 |
27 | # Use a different cache store in production
28 | # config.cache_store = :mem_cache_store
29 |
30 | # Disable Rails's static asset server
31 | # In production, Apache or nginx will already do this
32 | config.serve_static_assets = false
33 |
34 | # Enable serving of images, stylesheets, and javascripts from an asset server
35 | # config.action_controller.asset_host = "http://assets.example.com"
36 |
37 | # Disable delivery errors, bad email addresses will be ignored
38 | # config.action_mailer.raise_delivery_errors = false
39 |
40 | # Enable threaded mode
41 | # config.threadsafe!
42 |
43 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44 | # the I18n.default_locale when a translation can not be found)
45 | config.i18n.fallbacks = true
46 |
47 | # Send deprecation notices to registered listeners
48 | config.active_support.deprecation = :notify
49 | end
50 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Log error messages when you accidentally call methods on nil.
11 | config.whiny_nils = true
12 |
13 | # Show full error reports and disable caching
14 | config.consider_all_requests_local = true
15 | config.action_controller.perform_caching = false
16 |
17 | # Raise exceptions instead of rendering exception templates
18 | config.action_dispatch.show_exceptions = false
19 |
20 | # Disable request forgery protection in test environment
21 | config.action_controller.allow_forgery_protection = false
22 |
23 | # Tell Action Mailer not to deliver emails to the real world.
24 | # The :test delivery method accumulates sent emails in the
25 | # ActionMailer::Base.deliveries array.
26 | config.action_mailer.delivery_method = :test
27 |
28 | # Use SQL instead of Active Record's schema dumper when creating the test database.
29 | # This is necessary if your schema can't be completely dumped by the schema dumper,
30 | # like if you have constraints or database-specific column types
31 | # config.active_record.schema_format = :sql
32 |
33 | # Print deprecation notices to the stderr
34 | config.active_support.deprecation = :stderr
35 | end
36 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format
4 | # (all these examples are active by default):
5 | # ActiveSupport::Inflector.inflections do |inflect|
6 | # inflect.plural /^(ox)$/i, '\1en'
7 | # inflect.singular /^(ox)en/i, '\1'
8 | # inflect.irregular 'person', 'people'
9 | # inflect.uncountable %w( fish sheep )
10 | # end
11 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 | # Mime::Type.register_alias "text/html", :iphone
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 | # Make sure the secret is at least 30 characters and all random,
6 | # no regular words or you'll be exposed to dictionary attacks.
7 | Dummy::Application.config.secret_token = '0d98c544fe5edc4a3e519ae3a1b44c4862db73da445e5993b4b6c7b4b6d63d7aff5dcee58c6adba4203565e7d4d52e1cc132ffd8791933d2354692bb25780ac5'
8 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
4 |
5 | # Use the database for sessions instead of the cookie-based default,
6 | # which shouldn't be used to store highly confidential information
7 | # (create the session table with "rails generate session_migration")
8 | # Dummy::Application.config.session_store :active_record_store
9 |
--------------------------------------------------------------------------------
/spec/dummy/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/routes.rb:
--------------------------------------------------------------------------------
1 | Dummy::Application.routes.draw do
2 | match '/drinks(.:format)', :to => 'drinks#index', :as => :drinks
3 | # The priority is based upon order of creation:
4 | # first created -> highest priority.
5 |
6 | # Sample of regular route:
7 | # match 'products/:id' => 'catalog#view'
8 | # Keep in mind you can assign values other than :controller and :action
9 |
10 | # Sample of named route:
11 | # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
12 | # This route can be invoked with purchase_url(:id => product.id)
13 |
14 | # Sample resource route (maps HTTP verbs to controller actions automatically):
15 | # resources :products
16 |
17 | # Sample resource route with options:
18 | # resources :products do
19 | # member do
20 | # get 'short'
21 | # post 'toggle'
22 | # end
23 | #
24 | # collection do
25 | # get 'sold'
26 | # end
27 | # end
28 |
29 | # Sample resource route with sub-resources:
30 | # resources :products do
31 | # resources :comments, :sales
32 | # resource :seller
33 | # end
34 |
35 | # Sample resource route with more complex sub-resources
36 | # resources :products do
37 | # resources :comments
38 | # resources :sales do
39 | # get 'recent', :on => :collection
40 | # end
41 | # end
42 |
43 | # Sample resource route within a namespace:
44 | # namespace :admin do
45 | # # Directs /admin/products/* to Admin::ProductsController
46 | # # (app/controllers/admin/products_controller.rb)
47 | # resources :products
48 | # end
49 |
50 | # You can have the root of your site routed with "root"
51 | # just remember to delete public/index.html.
52 | root :to => "drinks#index"
53 |
54 | # See how all your routes lay out with "rake routes"
55 |
56 | # This is a legacy wild controller route that's not recommended for RESTful applications.
57 | # Note: This route will make all actions in every controller accessible via GET requests.
58 | # match ':controller(/:action(/:id(.:format)))'
59 | end
60 |
--------------------------------------------------------------------------------
/spec/dummy/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7 | # Mayor.create(:name => 'Daley', :city => cities.first)
8 |
--------------------------------------------------------------------------------
/spec/dummy/lib/tasks/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markbates/coffeebeans/cd25de2db8e0d14eb5fe765c088af33e1c5e95b1/spec/dummy/lib/tasks/.gitkeep
--------------------------------------------------------------------------------
/spec/dummy/script/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3 |
4 | APP_PATH = File.expand_path('../../config/application', __FILE__)
5 | require File.expand_path('../../config/boot', __FILE__)
6 | require 'rails/commands'
7 |
--------------------------------------------------------------------------------
/spec/dummy/vendor/plugins/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markbates/coffeebeans/cd25de2db8e0d14eb5fe765c088af33e1c5e95b1/spec/dummy/vendor/plugins/.gitkeep
--------------------------------------------------------------------------------
/spec/request/coffee_script_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | feature "CoffeeScript" do
4 |
5 | scenario "should render a .js.coffee file." do
6 | visit drinks_url(:format => 'js')
7 |
8 | page.should have_content('(function() { alert("i like coffee!"); }).call(this);')
9 | end
10 |
11 | scenario "should render a block with helper tags" do
12 | visit drinks_url
13 |
14 | page.body.to_s.should == %{\n\n\n\n\n}
15 |
16 | end
17 |
18 | end
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | ENV["RAILS_ENV"] = "test"
2 |
3 | require File.expand_path("../dummy/config/environment.rb", __FILE__)
4 |
5 | require 'rubygems'
6 | require 'rspec/rails'
7 |
8 | ActionMailer::Base.delivery_method = :test
9 | ActionMailer::Base.perform_deliveries = true
10 | ActionMailer::Base.default_url_options[:host] = "test.com"
11 |
12 | Rails.backtrace_cleaner.remove_silencers!
13 |
14 | require File.join(File.dirname(__FILE__), '..', 'lib', 'coffeebeans')
15 |
16 | require "capybara/rails"
17 | # Capybara.default_driver = :rack_test
18 | # Capybara.default_selector = :css
19 |
20 | RSpec.configure do |config|
21 |
22 | config.before(:all) do
23 |
24 | end
25 |
26 | config.after(:all) do
27 |
28 | end
29 |
30 | config.before(:each) do
31 |
32 | end
33 |
34 | config.after(:each) do
35 |
36 | end
37 |
38 | end
39 |
--------------------------------------------------------------------------------