LoginSignup
54
52

More than 5 years have passed since last update.

Rails4 + Slim + RSpec でプロジェクトをはじめる

Last updated at Posted at 2013-11-18

Railsプロジェクトのはじめかた(with Slim, RSpec)

プロジェクトの作成

mkdir ~/workspace/hoge_project
cd ~/workspace/hoge_project

bundlerでRailsインストール

bundle init
vi Gemfile
  • Gemfile (railsの前のコメント取るだけ)
 # A sample Gemfile
 source "https://rubygems.org"

 gem "rails"
  • bundle install
 bundle install --path vendor/bundle

railsプロジェクトを作成

bundle exec rails new .
  • Overwrite Gemfile? (enter "h" for help) [Ynaqdh] ときかれたらYを押して続行

プロジェクト全体の設定

  • .gitignore に以下を追加
/vendor/bundle
  • Gemfileに以下を追加
 gem 'slim-rails'

 group :test do
   gem 'rspec'
   gem 'rspec-rails'
 end
  • config/application.rb class Application < Rails::Application 内に以下を追加
 ()

 module HogeProject
     class Application < Rails::Application
       config.generators.template_engine = :slim
       config.generators.test_framework  = :rspec
       config.generators.stylesheets = false
       config.generators.javascripts = false
       config.generators.helper      = false

       ()
     end
 end
  • Gemfileに追加したモジュールをインストール
bundle install

コントローラを生成したときに slimファイルとspecファイルが生成されることを確認する

bundle exec rails g controller hoge index

#=> 以下のようにslimファイルとspecファイルがcreateされればOK
      create  app/controllers/hoge_controller.rb
       route  get "hoge/index"
      invoke  slim
      create    app/views/hoge
      create    app/views/hoge/index.html.slim
      invoke  rspec
      create    spec/controllers/hoge_controller_spec.rb
      create    spec/views/hoge
      create    spec/views/hoge/index.html.slim_spec.rb
      invoke  assets
      invoke    coffee
      invoke    scss
54
52
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
54
52