Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable to inject settings_gist_id instead of the settings #63

Merged
merged 4 commits into from
Aug 6, 2017

Conversation

masutaka
Copy link
Owner

@masutaka masutaka commented Aug 6, 2017

Related to #59

  • IN: $GITHUB_NIPPOU_SETTINGS_GIST_ID
  • OUT: github-nippou.settings in ~/.gitconfig and $GITHUB_NIPPOU_SETTINGS

#58 (comment) の辺りで話した件。

Dockerize も見据えると、Gist ID を環境変数で Inject 出来たほうが都合が良い(~/.gitconfig の github-nippou.settings-gist-id はすでに Inject 出来ていた)。

@@ -2,18 +2,14 @@
let(:client) { Octokit::Client.new(login: 'taro', access_token: '1234abcd') }
let(:settings) { described_class.new(client: client) }

before do
ENV['GITHUB_NIPPOU_SETTINGS_GIST_ID'] = '12345'
allow(client).to receive(:gist).and_return( files: { 'settings.yml': { content: settings_yaml } } )
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebMock gem だとどうしてもうまくいかなかったので、この辺で妥協しておく。

WebMock.stub_request に JSON(つまり String)を渡すと、Octokit::Client#gist が Hash ライクなオブジェクト(Sawyer::Resource)ではなく、JSON を返してしまう。

https://stackoverflow.com/questions/37621783/how-to-correctly-replicate-response-body-of-an-octokit-requests-response-for-we

WebMock::Response::InvalidBody: must be one of: [Proc, IO, Pathname, String, Array]. 'Hash' given

ならばと Hash を渡すと上記のエラーに遭遇。

config.include LoadFixtureHelper

config.before(:all) { silence_stdout }
config.after(:all){ enable_stdout }
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github::Nippou::Settings#data で puts しており、rspec の結果が Noisy になるため。YAML syntax error は発生しやすいと思うので、親切に教えてあげたい。

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

いわゆる printf デバッグできないのでリバートしました...。→ 7a75ef5

@masutaka masutaka merged commit 3bb3c4e into master Aug 6, 2017
@masutaka masutaka deleted the enable-to-inject-gistid branch August 6, 2017 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant