Last active
December 17, 2015 04:19
-
-
Save ptb/5549636 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require ['jquery', 'calculator'], ($, Calculator) -> | |
| $ -> | |
| calc = new Calculator() | |
| alert calc.add(4, 8) | |
| calc.paint('#item') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .red | |
| background-color: #f00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define ['jquery'], ($) -> | |
| class Calculator | |
| add: (a, b) -> | |
| a + b | |
| paint: (el) -> | |
| $(el).addClass 'red' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define ['calculator'], (Calculator) -> | |
| describe 'Calculator', -> | |
| calc = {} | |
| beforeEach -> | |
| calc = new Calculator() | |
| it 'should add two digits', -> | |
| expect(calc.add(4,4)).toBe(8) | |
| it 'should add another two digits', -> | |
| expect(calc.add(4,5)).not.toBe(8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| create_file '.ruby-version' do <<-RUBYVER | |
| 1.9.3 | |
| RUBYVER | |
| end | |
| create_file '.rvmrc' do <<-RVMRC | |
| rvm use --create ruby-1.9.3@#{app_name} | |
| rehash | |
| bundle install | |
| RVMRC | |
| end | |
| prepend_file 'Gemfile' do <<-GEMFILE | |
| ruby '1.9.3' | |
| GEMFILE | |
| end | |
| gsub_file 'Gemfile', /gem 'turbolinks'/, "# gem 'turbolinks'" | |
| gem 'devise', '~> 3.0.0.rc' | |
| gem 'obfuscate_id', github: 'ptb/obfuscate_id' | |
| gem 'requirejs-rails', github: 'jwhitley/requirejs-rails' | |
| gem 'slim-rails', '~> 1.1.1' | |
| gem 'zepto_rails', '~> 1.0' | |
| gem_group :development do | |
| # gem 'rack-mini-profiler', '~> 0.1.26' | |
| gem 'guard-bundler', '~> 1.0.0' | |
| gem 'guard-livereload', '~> 1.4.0' | |
| gem 'guard-rspec', '~> 3.0.1' | |
| gem 'guard-rubocop', '~> 0.0.3' | |
| gem 'guard-teabag', '~> 0.0.2' | |
| gem 'terminal-notifier-guard', '~> 1.5.3' | |
| gem 'rb-fsevent', '~> 0.9.3', require: false | |
| gem 'magic_encoding', github: 'prodis/magic_encoding' | |
| end | |
| gem_group :development, :test do | |
| gem 'thin', '~> 1.5.1' | |
| gem 'rspec-rails', '~> 2.13.2' | |
| gem 'factory_girl_rails', '~> 4.2.1' | |
| gem 'capybara', '~> 2.1.0' | |
| gem 'launchy', '~> 2.3.0' | |
| gem 'selenium-webdriver', '~> 2.33.0' | |
| gem 'poltergeist', '~> 1.3.0' | |
| gem 'teabag', github: 'modeset/teabag' | |
| end | |
| gem_group :test do | |
| gem 'database_cleaner', '~> 1.0.1' | |
| gem 'shoulda-matchers', '~> 2.1.0' | |
| gem 'simplecov', '~> 0.7.1', require: false | |
| gem 'simplecov-vim', '~> 0.0.1' | |
| end | |
| gem_group :production do | |
| gem 'mysql2', '~> 0.3.11' | |
| end | |
| run 'bundle update' | |
| generate 'rspec:install' | |
| run 'bundle binstubs rspec-core' | |
| generate 'teabag:install --coffee' | |
| run 'guard init bundler' | |
| run 'guard init livereload' | |
| run 'guard init rspec' | |
| run 'guard init rubocop' | |
| run 'guard init teabag' | |
| append_file '.gitignore', '/coverage*' | |
| append_file '.rspec', '--format documentation' | |
| create_file '.rubocop.yml' do <<-RUBOCOP | |
| AllCops: | |
| Includes: | |
| - Rakefile | |
| - config.ru | |
| Excludes: | |
| - bin/** | |
| - db/** | |
| - config/** | |
| - log/** | |
| - public/** | |
| - tmp/** | |
| - vendor/** | |
| RUBOCOP | |
| end | |
| create_file '.simplecov' do <<-SIMPLECOV | |
| require 'simplecov-vim/formatter' | |
| SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ | |
| SimpleCov::Formatter::HTMLFormatter, | |
| SimpleCov::Formatter::VimFormatter | |
| ] | |
| SimpleCov.start 'rails' | |
| SIMPLECOV | |
| end | |
| remove_file 'app/assets/images/rails.png' | |
| remove_file 'app/assets/javascripts/application.js' | |
| create_file 'app/assets/javascripts/application.coffee' | |
| remove_file 'app/assets/stylesheets/application.css' | |
| create_file 'app/assets/stylesheets/application.css.sass' | |
| remove_file 'app/views/layouts/application.html.erb' | |
| create_file 'app/views/layouts/application.html.slim' do <<-LAYOUT | |
| doctype 5 | |
| html.no-js[lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'] | |
| head | |
| meta[charset='UTF-8']/ | |
| title #{app_name.humanize} | |
| = stylesheet_link_tag 'application' | |
| = requirejs_include_tag 'application' | |
| = csrf_meta_tags | |
| body | |
| = yield | |
| LAYOUT | |
| end | |
| application <<-CONFIG | |
| config.generators do |g| | |
| g.assets false | |
| g.template_engine :slim | |
| g.test_framework :rspec, view_specs: false | |
| g.integration_tool :rspec | |
| end | |
| config.sass.preferred_syntax = :sass | |
| CONFIG | |
| gsub_file 'config/database.yml', /^production.*/m do <<-DATABASE | |
| production: | |
| adapter: mysql2 | |
| encoding: utf8 | |
| database: <%= ENV['RDS_DB_NAME'] %> | |
| username: <%= ENV['RDS_USERNAME'] %> | |
| password: <%= ENV['RDS_PASSWORD'] %> | |
| host: <%= ENV['RDS_HOSTNAME'] %> | |
| port: <%= ENV['RDS_PORT'] %> | |
| DATABASE | |
| end | |
| inject_into_file 'config/environments/production.rb', | |
| :before => /^end$/ do <<-PRODUCTION | |
| config.requirejs.loader = :almond | |
| PRODUCTION | |
| end | |
| inject_into_file 'config/initializers/teabag.rb', | |
| :after => 'config.suite do |suite|' do <<-TEABAGRB | |
| # https://github.com/modeset/teabag/wiki/RequireJS-with-Teabag | |
| suite.use_require = true | |
| TEABAGRB | |
| end | |
| gsub_file 'config/initializers/teabag.rb', | |
| ", 'spec/javascripts/stylesheets'", '' | |
| gsub_file 'config/initializers/teabag.rb', /"/, "'" | |
| gsub_file 'config/initializers/teabag.rb', /^\n\n/, "\n" | |
| run '/bin/mkdir -p coverage/javascripts/' | |
| run '/bin/rm -rf doc/' | |
| gsub_file 'Guardfile', 'javascripts/(.+).js', 'javascripts/(.+)\.(js|coffee)' | |
| remove_file 'public/index.html' | |
| # Thoughtbot Blog: http://bit.ly/QrzOH8 | |
| run '/bin/mkdir -p spec/features/' | |
| run '/bin/mkdir -p spec/support/features/' | |
| # http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Actions | |
| # http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Finders | |
| # http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Matchers | |
| # feature == describe ..., :type => :feature | |
| # background == before | |
| # scenario == it | |
| # given/given! == let/let! | |
| create_file 'spec/features/example_spec.rb' do <<-EXAMPLE | |
| # encoding: UTF-8 | |
| # require 'spec_helper' | |
| # | |
| # feature ExampleClassName do | |
| # feature '' do | |
| # before do | |
| # # visit '/' | |
| # # click_link '' | |
| # # click_button '' | |
| # # click_on '' | |
| # # fill_in '', with: '' | |
| # # choose 'A Radio Button' | |
| # # check 'A Checkbox' | |
| # # uncheck 'A Checkbox' | |
| # # attach_file 'Image', '/path/image.jpg' | |
| # # select 'Option', from: 'Select Box' | |
| # end | |
| # | |
| # [:rack, :phantomjs, :chrome, :firefox, :safari].each do |driver| | |
| # scenario "\#{driver}", driver: driver do | |
| # # within 'li#employee' do | |
| # # fill_in '', with: '' | |
| # # end | |
| # # within_fieldset 'Legend Tag Text' {} | |
| # # within_table 'Caption Tag Text' {} | |
| # end | |
| # end | |
| # end | |
| EXAMPLE | |
| end | |
| gsub_file 'spec/javascripts/spec_helper.coffee', | |
| '#= require application', '#= require require' | |
| prepend_file 'spec/spec_helper.rb' do <<-SPEC_HELPER | |
| require 'simplecov' | |
| SPEC_HELPER | |
| end | |
| inject_into_file 'spec/spec_helper.rb', | |
| :after => /require 'rspec\/autorun'/ do <<-SPEC_HELPER2 | |
| require 'capybara/rails' | |
| require 'capybara/rspec' | |
| require 'capybara/poltergeist' | |
| Capybara.register_driver :rack do |app| | |
| Capybara::RackTest::Driver.new(app) | |
| end | |
| # brew install phantomjs | |
| Capybara.register_driver :phantomjs do |app| | |
| Capybara::Poltergeist::Driver.new(app, inspector: true) | |
| end | |
| # brew install chromedriver | |
| Capybara.register_driver :chrome do |app| | |
| Capybara::Selenium::Driver.new(app, browser: :chrome) | |
| end | |
| Capybara.register_driver :firefox do |app| | |
| Capybara::Selenium::Driver.new(app, browser: :firefox) | |
| end | |
| # bit.ly/ZSkgEN gist.github.com/5550960 | |
| Capybara.register_driver :safari do |app| | |
| Capybara::Selenium::Driver.new(app, browser: :safari) | |
| end | |
| Capybara.default_driver = :rack | |
| Capybara.javascript_driver = :phantomjs | |
| SPEC_HELPER2 | |
| end | |
| gsub_file 'spec/spec_helper.rb',/^ config\.fixture_path.*$/, '' | |
| gsub_file 'spec/spec_helper.rb', | |
| /use_transactional_fixtures = true/, 'use_transactional_fixtures = false' | |
| inject_into_file 'spec/spec_helper.rb', | |
| :after => /use_transactional_fixtures = false/ do <<-SPEC_HELPER3 | |
| config.before(:suite) do | |
| DatabaseCleaner.strategy = :truncation | |
| end | |
| config.before(:each) do | |
| DatabaseCleaner.start | |
| end | |
| config.after(:each) do | |
| DatabaseCleaner.clean | |
| end | |
| SPEC_HELPER3 | |
| end | |
| gsub_file 'spec/spec_helper.rb', /"/, "'" | |
| gsub_file 'spec/spec_helper.rb', /^\n\n/, "\n" | |
| gsub_file 'spec/teabag_env.rb', /"/, "'" | |
| gsub_file 'spec/teabag_env.rb', /#config/, '# config' | |
| gsub_file 'spec/teabag_env.rb', | |
| /# config\.server_port.*$/, 'config.server_port = 3002' | |
| gsub_file 'spec/teabag_env.rb', | |
| /# config\.coverage\ .*$/, 'config.coverage = true' | |
| gsub_file 'spec/teabag_env.rb', | |
| /# config\.coverage_reports.*$/, "config.coverage_reports = 'text,html'" | |
| run '/bin/rm -rf test/' | |
| remove_file 'README.rdoc' | |
| run '/bin/rm -rf vendor/plugins/' | |
| run 'magic_encoding' | |
| prepend_file 'config.ru' do <<-UTF | |
| # encoding: UTF-8 | |
| UTF | |
| end | |
| prepend_file 'Rakefile' do <<-UTF | |
| # encoding: UTF-8 | |
| UTF | |
| end | |
| rake 'db:create' | |
| git :init | |
| git :add => '.', :commit => '-m "Initial commit"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment