Commit 8d743567eab60e239c912c6aec8b8ba4800d389f
1 parent
ddd5ea9b
Exists in
master
and in
1 other branch
Refactor Github issue spec
Showing
1 changed file
with
20 additions
and
11 deletions
Show diff stats
spec/models/issue_trackers/github_issues_tracker_spec.rb
1 | 1 | require 'spec_helper' |
2 | 2 | |
3 | 3 | describe IssueTrackers::GithubIssuesTracker do |
4 | - it "should create an issue on GitHub Issues with problem params, and set issue link for problem" do | |
5 | - repo = "test_user/test_repo" | |
6 | - notice = Fabricate :notice | |
4 | + | |
5 | + let(:repo) { "test_user/test_repo" } | |
6 | + | |
7 | + let(:notice) do | |
8 | + Fabricate :notice | |
9 | + end | |
10 | + | |
11 | + let(:problem) do | |
12 | + notice.problem | |
13 | + end | |
14 | + | |
15 | + let!(:tracker) do | |
7 | 16 | notice.app.github_repo = repo |
8 | - tracker = Fabricate :github_issues_tracker, :app => notice.app | |
9 | - problem = notice.problem | |
17 | + Fabricate :github_issues_tracker, app: notice.app | |
18 | + end | |
10 | 19 | |
20 | + it "should create an issue on GitHub Issues with problem params, and set issue link for problem" do | |
11 | 21 | number = 5 |
12 | - @issue_link = "https://github.com/#{repo}/issues/#{number}" | |
22 | + issue_link = "https://github.com/#{repo}/issues/#{number}" | |
13 | 23 | body = <<EOF |
14 | 24 | { |
15 | 25 | "position": 1.0, |
... | ... | @@ -21,7 +31,7 @@ describe IssueTrackers::GithubIssuesTracker do |
21 | 31 | "title": "Test Issue", |
22 | 32 | "user": "test_user", |
23 | 33 | "state": "open", |
24 | - "html_url": "#{@issue_link}" | |
34 | + "html_url": "#{issue_link}" | |
25 | 35 | } |
26 | 36 | EOF |
27 | 37 | |
... | ... | @@ -29,10 +39,10 @@ EOF |
29 | 39 | "https://#{tracker.username}:#{tracker.password}@api.github.com/repos/#{repo}/issues"). |
30 | 40 | to_return(:status => 201, |
31 | 41 | :headers => { |
32 | - 'Location' => @issue_link, | |
42 | + 'Location' => issue_link, | |
33 | 43 | 'Content-Type' => 'application/json', |
34 | 44 | }, |
35 | - :body => body ) | |
45 | + :body => body ) | |
36 | 46 | |
37 | 47 | problem.app.issue_tracker.create_issue(problem) |
38 | 48 | problem.reload |
... | ... | @@ -41,7 +51,6 @@ EOF |
41 | 51 | expect(WebMock).to requested.with(:body => /[production][foo#bar] FooError: Too Much Bar/) |
42 | 52 | expect(WebMock).to requested.with(:body => /See this exception on Errbit/) |
43 | 53 | |
44 | - expect(problem.issue_link).to eq @issue_link | |
54 | + expect(problem.issue_link).to eq issue_link | |
45 | 55 | end |
46 | 56 | end |
47 | - | ... | ... |