Sha256: 6636a1237bf45db823fed69cc0f5cd5749df1e880f59368fc3e632b6eecbd0a3

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

module Cellect::Server
  describe API do
    include_context 'API'
    
    { 'Ungrouped' => nil, 'Grouped' => 'grouped' }.each_pair do |grouping_type, grouping|
      SET_TYPES.shuffle.each do |set_type|
        context "#{ grouping_type } #{ set_type }" do
          let(:workflow_type){ [grouping, set_type].compact.join '_' }
          let(:workflow){ Workflow[workflow_type] }
          let(:user){ workflow.user 123 }
          before(:each){ pass_until workflow, is: :ready }
          
          it 'should sample without a user, limit, or group' do
            expect(workflow).to receive(:sample).with(limit: 5, user_id: nil, group_id: nil).and_call_original
            get "/workflows/#{ workflow_type }"
            expect(last_response.status).to eq 200
            expect(json).to be_a Array
          end
          
          shoulda = grouping ? 'limit, group, and user' : 'limit and user'
          it "should sample with a #{ shoulda }" do
            group_id = grouping ? 1 : nil
            expect(workflow).to receive(:sample).with(limit: 3, user_id: 123, group_id: group_id).and_call_original
            get "/workflows/#{ workflow_type }?limit=3&user_id=123#{ grouping ? '&group_id=1' : '' }"
            expect(last_response.status).to eq 200
            expect(json).to be_a Array
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cellect-server-0.1.3 spec/server/api/sample_spec.rb
cellect-server-0.1.2.pre.jruby spec/server/api/sample_spec.rb
cellect-server-0.1.2 spec/server/api/sample_spec.rb
cellect-server-0.1.1 spec/server/api/sample_spec.rb
cellect-server-0.1.0 spec/server/api/sample_spec.rb
cellect-server-0.0.9 spec/server/api/sample_spec.rb
cellect-server-0.0.8 spec/server/api/sample_spec.rb