Skip to content

Instantly share code, notes, and snippets.

@TakesxiSximada
Last active October 12, 2016 10:59
Show Gist options
  • Save TakesxiSximada/1ffb968d45f931cc72f5ecfeb616756e to your computer and use it in GitHub Desktop.
Save TakesxiSximada/1ffb968d45f931cc72f5ecfeb616756e to your computer and use it in GitHub Desktop.
fake_snsで意図的にエラー状態を作る

fake_snsで意図的にエラー状態を作る

fake_snsは AmazonSNS のダミーサーバです。 開発時にAmazon SNSのAPIの代わりにfake_snsを使うことで、 本番のAPIを使うことなくアプリケーションの動作を検証することができます。

https://github.com/yourkarma/fake_sns

インストールと起動

READMEに記載があります。 https://github.com/yourkarma/fake_sns#usage

$ gem install fake_sns
$ fake_sns -p 9292

Bundlerを使って環境を作成する

bundlerでGemfileを作成します。

$ bundle init
Writing new Gemfile to /path/to/current/Gemfile$ bundle init

Gemfileにfake_snsを追加します。

Gemfile:

# frozen_string_literal: true
source "https://rubygems.org"

gem "fake_sns"

Makefileに環境作成用のコマンドを記述するのが好みなので、 Makefileを作成しbundle installするコマンドを追加します。

.PHONY: vendor
vendor:
	bundle install --path vendor

make vendor を実行してfake_snsをインストールします。

$ make vendor

実行後、bundlerがvendorディレクトリ配下に関連ファイルを作成します。 fake_snsの実行コマンドも追加しておきましょう。

.PHONY: run
run:
	bundle exec fake_sns -p 9292

fake_snsを実行します。

$ make run
.PHONY: vendor
vendor:
bundle install --path vendor
.PHONY: run
run:
bundle exec fake_sns -p 9292
# frozen_string_literal: true
source "https://rubygems.org"
gem "fake_sns"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment