From 8d743567eab60e239c912c6aec8b8ba4800d389f Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Sun, 30 Mar 2014 15:08:23 -0400 Subject: [PATCH] Refactor Github issue spec --- spec/models/issue_trackers/github_issues_tracker_spec.rb | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/spec/models/issue_trackers/github_issues_tracker_spec.rb b/spec/models/issue_trackers/github_issues_tracker_spec.rb index 5fc0aec..2b1e35f 100644 --- a/spec/models/issue_trackers/github_issues_tracker_spec.rb +++ b/spec/models/issue_trackers/github_issues_tracker_spec.rb @@ -1,15 +1,25 @@ require 'spec_helper' describe IssueTrackers::GithubIssuesTracker do - it "should create an issue on GitHub Issues with problem params, and set issue link for problem" do - repo = "test_user/test_repo" - notice = Fabricate :notice + + let(:repo) { "test_user/test_repo" } + + let(:notice) do + Fabricate :notice + end + + let(:problem) do + notice.problem + end + + let!(:tracker) do notice.app.github_repo = repo - tracker = Fabricate :github_issues_tracker, :app => notice.app - problem = notice.problem + Fabricate :github_issues_tracker, app: notice.app + end + it "should create an issue on GitHub Issues with problem params, and set issue link for problem" do number = 5 - @issue_link = "https://github.com/#{repo}/issues/#{number}" + issue_link = "https://github.com/#{repo}/issues/#{number}" body = < 201, :headers => { - 'Location' => @issue_link, + 'Location' => issue_link, 'Content-Type' => 'application/json', }, - :body => body ) + :body => body ) problem.app.issue_tracker.create_issue(problem) problem.reload @@ -41,7 +51,6 @@ EOF expect(WebMock).to requested.with(:body => /[production][foo#bar] FooError: Too Much Bar/) expect(WebMock).to requested.with(:body => /See this exception on Errbit/) - expect(problem.issue_link).to eq @issue_link + expect(problem.issue_link).to eq issue_link end end - -- libgit2 0.21.2