spec/lib/ghn/notification_spec.rb in ghn-2.0.0.pre2 vs spec/lib/ghn/notification_spec.rb in ghn-2.0.0.pre3

- old
+ new

@@ -1,60 +1,111 @@ require 'spec_helper' describe Ghn::Notification do - subject { Ghn::Notification.new(notification) } + describe '#type_class' do + subject { Ghn::Notification.new(notification).type_class } - describe '#to_url' do context 'issue' do - subject { Ghn::Notification.new fixture('issue.json') } + let(:notification) { fixture('issue.json') } - it { expect(subject.to_url).to eq 'https://github.com/username/reponame/issues/305' } + it { is_expected.to eq Ghn::IssueNotification } end - context 'issue comment' do - subject { Ghn::Notification.new fixture('issue_with_comment.json') } + context 'pull request' do + let(:notification) { fixture('pull_request.json') } - it { expect(subject.to_url).to eq 'https://github.com/username/reponame/issues/305#issuecomment-53070200' } + it { is_expected.to eq Ghn::PullRequestNotification } end - context 'pull request' do - subject { Ghn::Notification.new fixture('pull_request.json') } + context 'commit' do + let(:notification) { fixture('commit.json') } - it { expect(subject.to_url).to eq 'https://github.com/username/reponame/pull/22' } + it { is_expected.to eq Ghn::CommitNotification } end - context 'pull request with comment' do - subject { Ghn::Notification.new fixture('pull_request_with_comment.json') } + context 'release' do + let(:notification) { fixture('release.json') } - it { expect(subject.to_url).to eq 'https://github.com/username/reponame/pull/22#issuecomment-16607215' } + it { is_expected.to eq Ghn::ReleaseNotification } end - context 'commit' do - subject { Ghn::Notification.new fixture('commit.json') } + context 'unknown' do + let(:notification) { fixture('unknown.json') } - it { expect(subject.to_url).to eq 'https://github.com/username/reponame/commit/6a4a135335acef4dfe15912d231429c07d4ad143' } + it { is_expected.to eq Ghn::UnknownNotification } end + end - context 'commit with comment' do - subject { Ghn::Notification.new fixture('commit_with_comment.json') } + describe Ghn::IssueNotification do + describe '#url' do + it do + expect( + Ghn::IssueNotification.new(fixture('issue.json')).url + ).to eq 'https://github.com/username/reponame/issues/305' + end - it { expect(subject.to_url).to eq 'https://github.com/username/reponame/commit/6a4a135335acef4dfe15912d231429c07d4ad143#issuecomment-7491006' } + context 'with comment' do + it do + expect( + Ghn::IssueNotification.new(fixture('issue_with_comment.json')).url + ).to eq 'https://github.com/username/reponame/issues/305#issuecomment-53070200' + end + end end + end - # TODO: Release type JSON is unknown - context 'release' do - subject { Ghn::Notification.new fixture('release.json') } + describe Ghn::PullRequestNotification do + describe '#url' do + it do + expect( + Ghn::PullRequestNotification.new(fixture('pull_request.json')).url + ).to eq 'https://github.com/username/reponame/pull/22' + end - it "does not raise error" do - expect(subject.to_url).to be nil + context 'with comment' do + it do + expect( + Ghn::PullRequestNotification.new(fixture('pull_request_with_comment.json')).url + ).to eq 'https://github.com/username/reponame/pull/22#issuecomment-16607215' + end end end + end - context 'unknown' do - subject { Ghn::Notification.new fixture('unknown.json') } + describe Ghn::CommitNotification do + describe '#url' do + it do + expect( + Ghn::CommitNotification.new(fixture('commit.json')).url + ).to eq 'https://github.com/username/reponame/commit/6a4a135335acef4dfe15912d231429c07d4ad143' + end - it "does not raise error" do - expect(subject.to_url).to be nil + context 'with comment' do + it do + expect( + Ghn::CommitNotification.new(fixture('commit_with_comment.json')).url + ).to eq 'https://github.com/username/reponame/commit/6a4a135335acef4dfe15912d231429c07d4ad143#issuecomment-7491006' + end + end + end + end + + describe Ghn::ReleaseNotification do + describe '#url' do + it do + expect( + Ghn::ReleaseNotification.new(fixture('release.json')).url + ).to eq 'https://github.com/yandod/candycane/releases/tag/v0.9.4' + end + end + end + + describe Ghn::UnknownNotification do + describe '#url' do + it do + expect( + Ghn::UnknownNotification.new(fixture('release.json')).url + ).to be nil end end end end