{"action":"created","comment":{"url":"https://api.github.com/repos/giftcardzen/la_gear/pulls/comments/32158506","id":32158506,"diff_hunk":"@@ -0,0 +1,173 @@\n+require_relative 'helper'\n+\n+class TestPublisher < LaGear::Test\n+  describe LaGear::Publisher do\n+    attr_reader :mock_bunny\n+\n+    before do\n+      Sneakers.clear!\n+      logger = Logger.new(STDOUT)\n+      logger.level = Logger::ERROR\n+      Sneakers.configure(log: logger)\n+      @expected_routing_key = 'fresh_prince'\n+      @expected_msg = { of: 'bel air' }\n+      @expected_default_opts = Sneakers::CONFIG\n+      mock_exchange = MiniTest::Mock.new\n+      mock_exchange.expect(:publish, nil, [String, Hash])\n+      mock_channel = MiniTest::Mock.new\n+      mock_channel.expect(:exchange, mock_exchange, [String, Hash])\n+      @mock_bunny = MiniTest::Mock.new\n+      mock_bunny.expect(:start, nil)\n+      mock_bunny.expect(:create_channel, mock_channel)\n+    end\n+\n+    describe 'when amqp_publish is not set' do\n+      it 'must use the default amqp for the Bunny connection' do\n+        mock_bunny_new = MiniTest::Mock.new\n+        mock_bunny_new.expect(\n+          :call,\n+          mock_bunny,\n+          [\n+            @expected_default_opts[:amqp],\n+            { heartbeat: @expected_default_opts[:heartbeat], vhost: @expected_default_opts[:vhost] }\n+          ]\n+        )\n+        Bunny.stub :new, mock_bunny_new do\n+          LaGear::Publisher.new.publish(@expected_msg, to_queue: @expected_routing_key)\n+        end\n+        mock_bunny_new.verify\n+      end\n+    end\n+\n+    describe 'when amqp_publish is set' do\n+      before do\n+        @opts = { amqp_publish: 'amqp_publish_uri' }\n+      end\n+\n+      it 'must use the amqp_publish_uri for the Bunny connection' do\n+        mock_bunny_new = MiniTest::Mock.new\n+        mock_bunny_new.expect(\n+          :call,\n+          mock_bunny,\n+          [\n+            @opts[:amqp_publish],\n+            { heartbeat: @expected_default_opts[:heartbeat], vhost: @expected_default_opts[:vhost] }\n+          ]\n+        )\n+        Bunny.stub :new, mock_bunny_new do\n+          LaGear::Publisher.new(@opts).publish(@expected_msg, to_queue: @expected_routing_key)\n+        end\n+        mock_bunny_new.verify\n+      end\n+    end\n+\n+    it 'must use JSON serialization for message' do\n+      mock_exchange = MiniTest::Mock.new\n+      mock_exchange.expect(:publish, nil, [@expected_msg.to_json, Hash])\n+      mock_channel = MiniTest::Mock.new\n+      mock_channel.expect(:exchange, mock_exchange, [String, Hash])\n+      mock_bunny = MiniTest::Mock.new\n+      mock_bunny.expect(:start, nil)\n+      mock_bunny.expect(:create_channel, mock_channel)\n+      mock_bunny_new = MiniTest::Mock.new\n+      mock_bunny_new.expect(:call, mock_bunny, [String, Hash])\n+      Bunny.stub :new, mock_bunny_new do\n+        LaGear::Publisher.new.publish(@expected_msg, to_queue: @expected_routing_key)\n+      end\n+      mock_exchange.verify\n+    end\n+  end\n+\n+  describe 'when serialize is overriden to be a no-op' do\n+    require 'rr'\n+\n+    class PumpItUpPublisher < LaGear::Publisher\n+      protected\n+\n+      def self.serialize(msg)\n+        msg\n+      end\n+    end\n+\n+    # These are just tweaked tests from sneakers\n+    describe '#publish' do\n+      before do\n+        Sneakers.clear!\n+        Sneakers.configure(:log => 'sneakers.log')\n+      end\n+\n+      it 'should publish a message to an exchange' do\n+        xchg = Object.new\n+        mock(xchg).publish('test msg', routing_key: 'downloads')\n+\n+        p = PumpItUpPublisher.new\n+        p.instance_variable_set(:@exchange, xchg)\n+\n+        mock(p).ensure_connection! {}\n+        p.publish('test msg', to_queue: 'downloads')\n+      end\n+\n+      it 'should publish with the persistence specified' do\n+        xchg = Object.new\n+        mock(xchg).publish('test msg', routing_key: 'downloads', persistence: true)\n+\n+        p = PumpItUpPublisher.new\n+        p.instance_variable_set(:@exchange, xchg)\n+\n+        mock(p).ensure_connection! {}\n+        p.publish('test msg', to_queue: 'downloads', persistence: true)\n+      end\n+\n+      it 'should publish with arbitrary metadata specified' do\n+        xchg = Object.new\n+        mock(xchg).publish('test msg', routing_key: 'downloads', expiration: 1, headers: {foo: 'bar'})\n+\n+        p = PumpItUpPublisher.new\n+        p.instance_variable_set(:@exchange, xchg)\n+\n+        mock(p).ensure_connection! {}\n+        p.publish('test msg', to_queue: 'downloads', expiration: 1, headers: {foo: 'bar'})\n+      end\n+\n+      it 'should not reconnect if already connected' do\n+        xchg = Object.new\n+        mock(xchg).publish('test msg', routing_key: 'downloads')\n+\n+        p = PumpItUpPublisher.new\n+        p.instance_variable_set(:@exchange, xchg)\n+\n+        mock(p).connected? { true }\n+        mock(p).ensure_connection!.times(0)\n+\n+        p.publish('test msg', to_queue: 'downloads')\n+      end\n+\n+      it 'should connect to rabbitmq configured on Sneakers.configure' do\n+        skip 'need to fix'\n+        logger = Logger.new('/dev/null')\n+        Sneakers.configure(\n+          amqp: 'amqp://someuser:somepassword@somehost:5672',\n+          heartbeat: 1, exchange: 'another_exchange',\n+          exchange_type: :topic,\n+          log: logger,\n+          durable: false)\n+\n+        channel = Object.new\n+        mock(channel).exchange('another_exchange', type: :topic, durable: false) do\n+          mock(Object.new).publish('test msg', routing_key: 'downloads')\n+        end\n+\n+        bunny = Object.new\n+        mock(bunny).start\n+        mock(bunny).create_channel { channel }\n+\n+        mock(Bunny).new('amqp://someuser:somepassword@somehost:5672', heartbeat: 1, vhost: '/', logger: logger) { bunny }\n+\n+        p = PumpItUpPublisher.new\n+\n+        p.publish('test msg', to_queue: 'downloads')\n+","path":"test/test_publisher.rb","position":169,"original_position":169,"commit_id":"7e163811e874f9d3a6e250711af5c2715ba78f0d","original_commit_id":"7e163811e874f9d3a6e250711af5c2715ba78f0d","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Extra empty line detected at block body end.","created_at":"2015-06-10T19:49:24Z","updated_at":"2015-06-10T19:49:24Z","html_url":"https://github.com/giftcardzen/la_gear/pull/25#discussion_r32158506","pull_request_url":"https://api.github.com/repos/giftcardzen/la_gear/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/giftcardzen/la_gear/pulls/comments/32158506"},"html":{"href":"https://github.com/giftcardzen/la_gear/pull/25#discussion_r32158506"},"pull_request":{"href":"https://api.github.com/repos/giftcardzen/la_gear/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/giftcardzen/la_gear/pulls/25","id":37395880,"html_url":"https://github.com/giftcardzen/la_gear/pull/25","diff_url":"https://github.com/giftcardzen/la_gear/pull/25.diff","patch_url":"https://github.com/giftcardzen/la_gear/pull/25.patch","issue_url":"https://api.github.com/repos/giftcardzen/la_gear/issues/25","number":25,"state":"open","locked":false,"title":"Release/1.1.0 (master)","user":{"login":"gabrieljoelc","id":147849,"avatar_url":"https://avatars.githubusercontent.com/u/147849?v=3","gravatar_id":"","url":"https://api.github.com/users/gabrieljoelc","html_url":"https://github.com/gabrieljoelc","followers_url":"https://api.github.com/users/gabrieljoelc/followers","following_url":"https://api.github.com/users/gabrieljoelc/following{/other_user}","gists_url":"https://api.github.com/users/gabrieljoelc/gists{/gist_id}","starred_url":"https://api.github.com/users/gabrieljoelc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabrieljoelc/subscriptions","organizations_url":"https://api.github.com/users/gabrieljoelc/orgs","repos_url":"https://api.github.com/users/gabrieljoelc/repos","events_url":"https://api.github.com/users/gabrieljoelc/events{/privacy}","received_events_url":"https://api.github.com/users/gabrieljoelc/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-10T19:37:10Z","updated_at":"2015-06-10T19:49:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3a6722812986df8aa8b32779c13213de52ed0ca1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/giftcardzen/la_gear/pulls/25/commits","review_comments_url":"https://api.github.com/repos/giftcardzen/la_gear/pulls/25/comments","review_comment_url":"https://api.github.com/repos/giftcardzen/la_gear/pulls/comments{/number}","comments_url":"https://api.github.com/repos/giftcardzen/la_gear/issues/25/comments","statuses_url":"https://api.github.com/repos/giftcardzen/la_gear/statuses/7e163811e874f9d3a6e250711af5c2715ba78f0d","head":{"label":"giftcardzen:release/1.1.0","ref":"release/1.1.0","sha":"7e163811e874f9d3a6e250711af5c2715ba78f0d","user":{"login":"giftcardzen","id":7176061,"avatar_url":"https://avatars.githubusercontent.com/u/7176061?v=3","gravatar_id":"","url":"https://api.github.com/users/giftcardzen","html_url":"https://github.com/giftcardzen","followers_url":"https://api.github.com/users/giftcardzen/followers","following_url":"https://api.github.com/users/giftcardzen/following{/other_user}","gists_url":"https://api.github.com/users/giftcardzen/gists{/gist_id}","starred_url":"https://api.github.com/users/giftcardzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giftcardzen/subscriptions","organizations_url":"https://api.github.com/users/giftcardzen/orgs","repos_url":"https://api.github.com/users/giftcardzen/repos","events_url":"https://api.github.com/users/giftcardzen/events{/privacy}","received_events_url":"https://api.github.com/users/giftcardzen/received_events","type":"Organization","site_admin":false},"repo":{"id":23089940,"name":"la_gear","full_name":"giftcardzen/la_gear","owner":{"login":"giftcardzen","id":7176061,"avatar_url":"https://avatars.githubusercontent.com/u/7176061?v=3","gravatar_id":"","url":"https://api.github.com/users/giftcardzen","html_url":"https://github.com/giftcardzen","followers_url":"https://api.github.com/users/giftcardzen/followers","following_url":"https://api.github.com/users/giftcardzen/following{/other_user}","gists_url":"https://api.github.com/users/giftcardzen/gists{/gist_id}","starred_url":"https://api.github.com/users/giftcardzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giftcardzen/subscriptions","organizations_url":"https://api.github.com/users/giftcardzen/orgs","repos_url":"https://api.github.com/users/giftcardzen/repos","events_url":"https://api.github.com/users/giftcardzen/events{/privacy}","received_events_url":"https://api.github.com/users/giftcardzen/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/giftcardzen/la_gear","description":"What do you get when you glue sneakers and sidekiq together? la_gear! Pump it up!","fork":false,"url":"https://api.github.com/repos/giftcardzen/la_gear","forks_url":"https://api.github.com/repos/giftcardzen/la_gear/forks","keys_url":"https://api.github.com/repos/giftcardzen/la_gear/keys{/key_id}","collaborators_url":"https://api.github.com/repos/giftcardzen/la_gear/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/giftcardzen/la_gear/teams","hooks_url":"https://api.github.com/repos/giftcardzen/la_gear/hooks","issue_events_url":"https://api.github.com/repos/giftcardzen/la_gear/issues/events{/number}","events_url":"https://api.github.com/repos/giftcardzen/la_gear/events","assignees_url":"https://api.github.com/repos/giftcardzen/la_gear/assignees{/user}","branches_url":"https://api.github.com/repos/giftcardzen/la_gear/branches{/branch}","tags_url":"https://api.github.com/repos/giftcardzen/la_gear/tags","blobs_url":"https://api.github.com/repos/giftcardzen/la_gear/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/giftcardzen/la_gear/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/giftcardzen/la_gear/git/refs{/sha}","trees_url":"https://api.github.com/repos/giftcardzen/la_gear/git/trees{/sha}","statuses_url":"https://api.github.com/repos/giftcardzen/la_gear/statuses/{sha}","languages_url":"https://api.github.com/repos/giftcardzen/la_gear/languages","stargazers_url":"https://api.github.com/repos/giftcardzen/la_gear/stargazers","contributors_url":"https://api.github.com/repos/giftcardzen/la_gear/contributors","subscribers_url":"https://api.github.com/repos/giftcardzen/la_gear/subscribers","subscription_url":"https://api.github.com/repos/giftcardzen/la_gear/subscription","commits_url":"https://api.github.com/repos/giftcardzen/la_gear/commits{/sha}","git_commits_url":"https://api.github.com/repos/giftcardzen/la_gear/git/commits{/sha}","comments_url":"https://api.github.com/repos/giftcardzen/la_gear/comments{/number}","issue_comment_url":"https://api.github.com/repos/giftcardzen/la_gear/issues/comments{/number}","contents_url":"https://api.github.com/repos/giftcardzen/la_gear/contents/{+path}","compare_url":"https://api.github.com/repos/giftcardzen/la_gear/compare/{base}...{head}","merges_url":"https://api.github.com/repos/giftcardzen/la_gear/merges","archive_url":"https://api.github.com/repos/giftcardzen/la_gear/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/giftcardzen/la_gear/downloads","issues_url":"https://api.github.com/repos/giftcardzen/la_gear/issues{/number}","pulls_url":"https://api.github.com/repos/giftcardzen/la_gear/pulls{/number}","milestones_url":"https://api.github.com/repos/giftcardzen/la_gear/milestones{/number}","notifications_url":"https://api.github.com/repos/giftcardzen/la_gear/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/giftcardzen/la_gear/labels{/name}","releases_url":"https://api.github.com/repos/giftcardzen/la_gear/releases{/id}","created_at":"2014-08-18T23:29:18Z","updated_at":"2015-04-07T19:47:32Z","pushed_at":"2015-06-10T19:49:09Z","git_url":"git://github.com/giftcardzen/la_gear.git","ssh_url":"git@github.com:giftcardzen/la_gear.git","clone_url":"https://github.com/giftcardzen/la_gear.git","svn_url":"https://github.com/giftcardzen/la_gear","homepage":"","size":576,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":1,"default_branch":"develop"}},"base":{"label":"giftcardzen:master","ref":"master","sha":"d011fe2eeb920cc31ed26db4c6f3d2607f49e3d9","user":{"login":"giftcardzen","id":7176061,"avatar_url":"https://avatars.githubusercontent.com/u/7176061?v=3","gravatar_id":"","url":"https://api.github.com/users/giftcardzen","html_url":"https://github.com/giftcardzen","followers_url":"https://api.github.com/users/giftcardzen/followers","following_url":"https://api.github.com/users/giftcardzen/following{/other_user}","gists_url":"https://api.github.com/users/giftcardzen/gists{/gist_id}","starred_url":"https://api.github.com/users/giftcardzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giftcardzen/subscriptions","organizations_url":"https://api.github.com/users/giftcardzen/orgs","repos_url":"https://api.github.com/users/giftcardzen/repos","events_url":"https://api.github.com/users/giftcardzen/events{/privacy}","received_events_url":"https://api.github.com/users/giftcardzen/received_events","type":"Organization","site_admin":false},"repo":{"id":23089940,"name":"la_gear","full_name":"giftcardzen/la_gear","owner":{"login":"giftcardzen","id":7176061,"avatar_url":"https://avatars.githubusercontent.com/u/7176061?v=3","gravatar_id":"","url":"https://api.github.com/users/giftcardzen","html_url":"https://github.com/giftcardzen","followers_url":"https://api.github.com/users/giftcardzen/followers","following_url":"https://api.github.com/users/giftcardzen/following{/other_user}","gists_url":"https://api.github.com/users/giftcardzen/gists{/gist_id}","starred_url":"https://api.github.com/users/giftcardzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giftcardzen/subscriptions","organizations_url":"https://api.github.com/users/giftcardzen/orgs","repos_url":"https://api.github.com/users/giftcardzen/repos","events_url":"https://api.github.com/users/giftcardzen/events{/privacy}","received_events_url":"https://api.github.com/users/giftcardzen/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/giftcardzen/la_gear","description":"What do you get when you glue sneakers and sidekiq together? la_gear! Pump it up!","fork":false,"url":"https://api.github.com/repos/giftcardzen/la_gear","forks_url":"https://api.github.com/repos/giftcardzen/la_gear/forks","keys_url":"https://api.github.com/repos/giftcardzen/la_gear/keys{/key_id}","collaborators_url":"https://api.github.com/repos/giftcardzen/la_gear/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/giftcardzen/la_gear/teams","hooks_url":"https://api.github.com/repos/giftcardzen/la_gear/hooks","issue_events_url":"https://api.github.com/repos/giftcardzen/la_gear/issues/events{/number}","events_url":"https://api.github.com/repos/giftcardzen/la_gear/events","assignees_url":"https://api.github.com/repos/giftcardzen/la_gear/assignees{/user}","branches_url":"https://api.github.com/repos/giftcardzen/la_gear/branches{/branch}","tags_url":"https://api.github.com/repos/giftcardzen/la_gear/tags","blobs_url":"https://api.github.com/repos/giftcardzen/la_gear/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/giftcardzen/la_gear/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/giftcardzen/la_gear/git/refs{/sha}","trees_url":"https://api.github.com/repos/giftcardzen/la_gear/git/trees{/sha}","statuses_url":"https://api.github.com/repos/giftcardzen/la_gear/statuses/{sha}","languages_url":"https://api.github.com/repos/giftcardzen/la_gear/languages","stargazers_url":"https://api.github.com/repos/giftcardzen/la_gear/stargazers","contributors_url":"https://api.github.com/repos/giftcardzen/la_gear/contributors","subscribers_url":"https://api.github.com/repos/giftcardzen/la_gear/subscribers","subscription_url":"https://api.github.com/repos/giftcardzen/la_gear/subscription","commits_url":"https://api.github.com/repos/giftcardzen/la_gear/commits{/sha}","git_commits_url":"https://api.github.com/repos/giftcardzen/la_gear/git/commits{/sha}","comments_url":"https://api.github.com/repos/giftcardzen/la_gear/comments{/number}","issue_comment_url":"https://api.github.com/repos/giftcardzen/la_gear/issues/comments{/number}","contents_url":"https://api.github.com/repos/giftcardzen/la_gear/contents/{+path}","compare_url":"https://api.github.com/repos/giftcardzen/la_gear/compare/{base}...{head}","merges_url":"https://api.github.com/repos/giftcardzen/la_gear/merges","archive_url":"https://api.github.com/repos/giftcardzen/la_gear/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/giftcardzen/la_gear/downloads","issues_url":"https://api.github.com/repos/giftcardzen/la_gear/issues{/number}","pulls_url":"https://api.github.com/repos/giftcardzen/la_gear/pulls{/number}","milestones_url":"https://api.github.com/repos/giftcardzen/la_gear/milestones{/number}","notifications_url":"https://api.github.com/repos/giftcardzen/la_gear/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/giftcardzen/la_gear/labels{/name}","releases_url":"https://api.github.com/repos/giftcardzen/la_gear/releases{/id}","created_at":"2014-08-18T23:29:18Z","updated_at":"2015-04-07T19:47:32Z","pushed_at":"2015-06-10T19:49:09Z","git_url":"git://github.com/giftcardzen/la_gear.git","ssh_url":"git@github.com:giftcardzen/la_gear.git","clone_url":"https://github.com/giftcardzen/la_gear.git","svn_url":"https://github.com/giftcardzen/la_gear","homepage":"","size":576,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/giftcardzen/la_gear/pulls/25"},"html":{"href":"https://github.com/giftcardzen/la_gear/pull/25"},"issue":{"href":"https://api.github.com/repos/giftcardzen/la_gear/issues/25"},"comments":{"href":"https://api.github.com/repos/giftcardzen/la_gear/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/giftcardzen/la_gear/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/giftcardzen/la_gear/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/giftcardzen/la_gear/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/giftcardzen/la_gear/statuses/7e163811e874f9d3a6e250711af5c2715ba78f0d"}}}}