Sha256: 268718dc008a3e838ef3b297fb21512061056b1360bde0e6ebebb00cce64fd69

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

begin
  require 'v8'
rescue LoadError
  begin
    require 'rhino'
  rescue LoadError
    STDERR.puts "You need to install therubyracer (or therhinoracer on jruby) to use matchers"
  end
end

module CouchPotato
  module RSpec
    module RunJS
      private

      def run_js(js)
        if defined?(V8)
          V8::Context.new.eval(js)
        else
          Rhino::Context.open{|cxt| cxt.eval(js)}
        end
      end
    end
  end
end


require 'couch_potato/rspec/matchers/map_to_matcher'
require 'couch_potato/rspec/matchers/reduce_to_matcher'
require 'couch_potato/rspec/matchers/map_reduce_to_matcher'
require 'couch_potato/rspec/matchers/list_as_matcher'

module RSpec
  module Matchers
    def map(document)
      CouchPotato::RSpec::MapToProxy.new(document)
    end

    def reduce(keys, values)
      CouchPotato::RSpec::ReduceToProxy.new(keys, values)
    end

    def rereduce(keys, values)
      CouchPotato::RSpec::ReduceToProxy.new(keys, values, true)
    end

    def list(results)
      CouchPotato::RSpec::ListAsProxy.new(results)
    end

    def map_reduce(*docs)
      CouchPotato::RSpec::MapReduceToProxy.new(docs)
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
couch_potato-rspec-3.4.0 lib/couch_potato/rspec/matchers.rb
couch_potato-1.4.0 lib/couch_potato/rspec/matchers.rb
couch_potato-1.3.0 lib/couch_potato/rspec/matchers.rb
couch_potato-1.2.0 lib/couch_potato/rspec/matchers.rb
couch_potato-1.1.4 lib/couch_potato/rspec/matchers.rb
couch_potato-1.1.2 lib/couch_potato/rspec/matchers.rb
couch_potato-1.1.1 lib/couch_potato/rspec/matchers.rb
couch_potato-1.1.0 lib/couch_potato/rspec/matchers.rb
couch_potato-1.0.1 lib/couch_potato/rspec/matchers.rb
couch_potato-1.0.0 lib/couch_potato/rspec/matchers.rb