LoginSignup
1
1

More than 3 years have passed since last update.

【RSpec】【CircleCI】はじめの一歩小さなサンプルメモ

Last updated at Posted at 2018-06-07

前提

  • Ruby
  • RSpec
  • CircleCI 1.0
  • GitHub連携
  • ビルドするまでの簡単小さなメモ。とりあえず動くとこまでで、パラメータは適当

手順サンプルメモ

GitHubにリポジトリ作成

ローカルにリポジトリ作成

command
% git init

Gemfile

command
% bundle init

Gemfileができるので、rspec関連を追加

Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"
gem 'rspec'
gem 'rspec_junit_formatter'
command
% bundle install

RSpec関連

テストファイルなどは適当に準備する

command
★
% rspec --init 
% vim spec/person.rb ★テスト対象のクラスを作成
% vim spec/person_spec.rb ★テストファイルを作成
person.rb
class Person
  attr_accessor :name
  def initialize
    @name = "kure"
  end
end

class Person2
  attr_accessor :name
  def initialize
    @name = "kure2"
  end
end
person_spec.rb
require 'person'

RSpec.describe Person do

  it "name is kure" do
    person = Person.new
    expect(person.name).to eq("kure")
  end

  it "name is kure(subject)" do
    expect(subject.name).to eq("kure")
  end
end

動作確認

テストが通ればOK

> bundle exec rspec
2 examples, 0 failures

CircleCI関連

command
% mkdir .circle
% vim .circle/config.yml

適当に最小限

config.yml
machine:
  timezone:
    Asia/Tokyo
  ruby:
    version: 2.4.0
test:
  post:
    - bundle exec rspec

準備できたらGitHubにpushしておく

CircleCIに連携

  • サインアップ
  • 「ADD PROJECTS」
  • 作成したGitHubのリポジトリを「Set Up Project」

うまくいけば↓の通りSuccessするかな

ScreenClip.png

1
1
0

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
1
1