Sha256: b2ebc5eb6c9df5ab811a38dac901c500ddbefc066f6a1d104ccbb895053b14e4

Contents?: true

Size: 1005 Bytes

Versions: 2

Compression:

Stored size: 1005 Bytes

Contents

require File.expand_path('../test_helper', __FILE__)

module Loquor
  class InteractorTest < Minitest::Test
    class FoobarInteractor
      extend Interactor::ClassMethods
      include Interactor::InstanceMethods

      def self.path
        "/foobar"
      end
    end

    def test_find_should_get_correct_path_with_simple_path
      id = 8
      Loquor.expects(:get).with("/foobar/#{id}")
      FoobarInteractor.find(id)
    end

    def test_find_each_should_get_correct_path
      Loquor.expects(:get).with("/foobar?&page=1&per=200").returns([])
      FoobarInteractor.find_each
    end

    def test_find_each_should_yield_block
      Loquor.expects(:get).returns([{id: 1}])
      ids = []
      FoobarInteractor.find_each do |json|
        ids << json['id']
      end
    end

    def test_where_should_get_correct_path_with_simple_path
      email = "foobar"
      Loquor.expects(:get).with("/foobar?email=#{email}").returns([])
      FoobarInteractor.where(email: email).to_a
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loquor-0.2.0 test/interactor_test.rb
loquor-0.1.2 test/interactor_test.rb