Sha256: f9214a29762789bcd28967a58a325ff99ac08f1301c26b8667e00fbab49c77a0

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

class WordCountTest < Test::Unit::TestCase
  
  context "the word_count action" do
    
    setup do
      @asset_store = AssetStore.new
      @browser = Rack::Test::Session.new(Rack::MockSession.new(CloudCrowd::Server))
      @browser.put('/worker', :name => 'test_worker', :thread_status => 'sleeping')
      post_job_to_count_words_in_this_file
      @job_id = JSON.parse(@browser.last_response.body)['id']
    end
    
    teardown do
      CloudCrowd::Job.destroy_all
    end

    should "be able to create a word_count job" do
      assert @browser.last_response.ok? 
      info = JSON.parse(@browser.last_response.body)
      assert info['status'] == 'processing'
      assert info['work_units'] == 1
    end
    
    should "be able to perform the processing stage of a word_count" do
      action = CloudCrowd.actions['word_count'].new(1, "file://#{File.expand_path(__FILE__)}", {}, @asset_store)
      count = action.process
      assert count == 104
    end
    
  end
  
  def post_job_to_count_words_in_this_file
    @browser.post '/jobs', :job => {
      'action'  => 'word_count',
      'inputs'  => ["file://#{File.expand_path(__FILE__)}"],
      'options' => {}
    }.to_json
  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
documentcloud-cloud-crowd-0.1.1 test/acceptance/test_word_count.rb
documentcloud-cloud-crowd-0.2.0 test/acceptance/test_word_count.rb
cloud-crowd-0.2.0 test/acceptance/test_word_count.rb