summaryrefslogtreecommitdiff
path: root/test/integration/couch_db/source_test.rb
blob: 9e319f410a2e41d7d8664959fc594a685be15c37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'test_helper'
require 'file_content'
require 'nickserver/couch_db/source'

module Nickserver::CouchDB
  class SourceTest < Minitest::Test
  include FileContent

    class TestAdapter
      def initialize(status, content)
        @status = status
        @content = content
      end

      def get(url, opts)
        yield @status, @content
      end
    end

    def test_couch_query_and_response
      adapter = TestAdapter.new 200, file_content(:blue_couchdb_result)
      source = Source.new adapter
      source.query 'blue@example.org' do |response|
        assert_equal 200, response.status
        assert_equal file_content(:blue_nickserver_result), response.content
      end
    end
  end
end