Sha256: d6a96c76fd7c1e6f8e40f1a1ceb4c84ef52906e6d4c28a784c02cdd4eeb617af

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

# Author:: Mike Evans <mike@urlgonomics.com>
# Copyright:: 2013 Urlgonomics LLC.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require File.join(File.dirname(__FILE__), 'setup')

class TestDesignDocs < MiniTest::Test

  def setup
    @mock = start_mock
    @cb = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
  end

  def teardown
    stop_mock(@mock)
    @cb.disconnect
  end

  def test_save_design_doc
    assert @cb.save_design_doc(design_doc)
  end

  def test_save_design_doc_with_bad_data
    assert_raises ArgumentError do
      @cb.save_design_doc(123)
    end
  end

  def test_delete_design_doc
    @cb.save_design_doc(design_doc)
    assert @cb.delete_design_doc('blog')
  end

  def test_design_doc_access
    @cb.save_design_doc(design_doc)
    assert @cb.design_docs['blog']
  end

  def test_design_doc_missing_access
    refute @cb.design_docs['missing']
  end

  def design_doc
    {
      '_id'      => '_design/blog',
      'language' => 'javascript',
      'views' => {
        'recent_posts' => {
          'map' => <<-JS
            function (doc, meta) {
              emit(doc.name);
            }
          JS
        }
      }
    }
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
couchbase-jruby-client-0.1.2 test/test_design_docs.rb
couchbase-jruby-client-0.1.1 test/test_design_docs.rb