Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
5
Help us understand the problem. What is going on with this article?
@Feel-Physics

RubyMineでRailsプロジェクトを作り、Rspecで自動テストをかける方法

More than 5 years have passed since last update.
  1. 最初にプロジェクトを作るときに「Skip Test:Unit files」をチェックする。
  2. 追記:
Gemfile
...
gem "rspec-rails", :group => [:development, :test]
  1. bundle install
  2. Tools > Run Rails Script > rails generate rspec:install
  3. Tools > Run Rails Generator > scaffold > post title:string body:text
  4. Tools > Run Rake Task > db:migrate
  5. Run > Run > spec
  6. Toggle auto-test
  7. コードを編集
spec/model/post_spec.rb
# encoding: utf-8
require 'spec_helper'

describe Post, "#title が設定されていない場合:"  do
  # pending "add some examples to (or delete) #{__FILE__}"
  before(:each) do
    @post = Post.new
  end

  it "バリデーションに失敗すること" do
    @post.should_not be_valid
  end
end
  1. 保存すると自動でテストが走り、こける
  2. バリデーションを追記
app/models/post.rb
validates :title, presence: true
  1. 保存すると自動でテストが走り、合格する

ブログやってます:PAPA-tronix !

5
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Feel-Physics
今はHoloLensのアプリを開発しており、技術記事はすべてブログ( http://weed.nagoya )に書いています。以前はSwift、OpenCV+Python、JavaScript、Objective-Cを書いていました。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
5
Help us understand the problem. What is going on with this article?