ruby-aws 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.gemtest +0 -0
  3. data/History.txt +75 -0
  4. data/LICENSE.txt +202 -0
  5. data/Manifest.txt +72 -0
  6. data/NOTICE.txt +4 -0
  7. data/README.txt +105 -0
  8. data/Rakefile +33 -0
  9. data/bin/ruby-aws +9 -0
  10. data/lib/amazon/util.rb +10 -0
  11. data/lib/amazon/util/binder.rb +48 -0
  12. data/lib/amazon/util/data_reader.rb +169 -0
  13. data/lib/amazon/util/filter_chain.rb +79 -0
  14. data/lib/amazon/util/hash_nesting.rb +93 -0
  15. data/lib/amazon/util/lazy_results.rb +59 -0
  16. data/lib/amazon/util/logging.rb +23 -0
  17. data/lib/amazon/util/paginated_iterator.rb +70 -0
  18. data/lib/amazon/util/proactive_results.rb +116 -0
  19. data/lib/amazon/util/threadpool.rb +129 -0
  20. data/lib/amazon/util/user_data_store.rb +100 -0
  21. data/lib/amazon/webservices/mechanical_turk.rb +123 -0
  22. data/lib/amazon/webservices/mechanical_turk_requester.rb +274 -0
  23. data/lib/amazon/webservices/mturk/mechanical_turk_error_handler.rb +150 -0
  24. data/lib/amazon/webservices/mturk/question_generator.rb +58 -0
  25. data/lib/amazon/webservices/util/amazon_authentication_relay.rb +72 -0
  26. data/lib/amazon/webservices/util/command_line.rb +157 -0
  27. data/lib/amazon/webservices/util/convenience_wrapper.rb +90 -0
  28. data/lib/amazon/webservices/util/filter_proxy.rb +45 -0
  29. data/lib/amazon/webservices/util/mock_transport.rb +70 -0
  30. data/lib/amazon/webservices/util/request_signer.rb +42 -0
  31. data/lib/amazon/webservices/util/rest_transport.rb +120 -0
  32. data/lib/amazon/webservices/util/soap_simplifier.rb +48 -0
  33. data/lib/amazon/webservices/util/soap_transport.rb +20 -0
  34. data/lib/amazon/webservices/util/soap_transport_header_handler.rb +27 -0
  35. data/lib/amazon/webservices/util/unknown_result_exception.rb +27 -0
  36. data/lib/amazon/webservices/util/validation_exception.rb +55 -0
  37. data/lib/amazon/webservices/util/xml_simplifier.rb +61 -0
  38. data/lib/ruby-aws.rb +19 -0
  39. data/lib/ruby-aws/version.rb +6 -0
  40. data/run_rcov.sh +1 -0
  41. data/samples/mturk/best_image/BestImage.rb +61 -0
  42. data/samples/mturk/best_image/best_image.properties +39 -0
  43. data/samples/mturk/best_image/best_image.question +82 -0
  44. data/samples/mturk/blank_slate/BlankSlate.rb +63 -0
  45. data/samples/mturk/blank_slate/BlankSlate_multithreaded.rb +67 -0
  46. data/samples/mturk/helloworld/MTurkHelloWorld.rb +56 -0
  47. data/samples/mturk/helloworld/mturk.yml +8 -0
  48. data/samples/mturk/review_policy/ReviewPolicy.rb +139 -0
  49. data/samples/mturk/review_policy/review_policy.question +30 -0
  50. data/samples/mturk/reviewer/Reviewer.rb +103 -0
  51. data/samples/mturk/reviewer/mturk.yml +8 -0
  52. data/samples/mturk/simple_survey/SimpleSurvey.rb +90 -0
  53. data/samples/mturk/simple_survey/simple_survey.question +30 -0
  54. data/samples/mturk/site_category/SiteCategory.rb +87 -0
  55. data/samples/mturk/site_category/externalpage.htm +71 -0
  56. data/samples/mturk/site_category/site_category.input +6 -0
  57. data/samples/mturk/site_category/site_category.properties +45 -0
  58. data/samples/mturk/site_category/site_category.question +9 -0
  59. data/test/mturk/test_changehittypeofhit.rb +130 -0
  60. data/test/mturk/test_error_handler.rb +137 -0
  61. data/test/mturk/test_mechanical_turk_requester.rb +178 -0
  62. data/test/mturk/test_mock_mechanical_turk_requester.rb +205 -0
  63. data/test/test_ruby-aws.rb +24 -0
  64. data/test/unit/test_binder.rb +89 -0
  65. data/test/unit/test_data_reader.rb +135 -0
  66. data/test/unit/test_exceptions.rb +32 -0
  67. data/test/unit/test_hash_nesting.rb +99 -0
  68. data/test/unit/test_lazy_results.rb +89 -0
  69. data/test/unit/test_mock_transport.rb +132 -0
  70. data/test/unit/test_paginated_iterator.rb +58 -0
  71. data/test/unit/test_proactive_results.rb +108 -0
  72. data/test/unit/test_question_generator.rb +55 -0
  73. data/test/unit/test_threadpool.rb +50 -0
  74. data/test/unit/test_user_data_store.rb +80 -0
  75. metadata +238 -0
  76. metadata.gz.sig +0 -0
@@ -0,0 +1,32 @@
1
+ # Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
2
+ # License:: Apache License, Version 2.0
3
+
4
+ require 'test/unit/testcase'
5
+ require 'amazon/webservices/util/unknown_result_exception'
6
+ require 'amazon/webservices/util/validation_exception'
7
+
8
+ class TestExceptions < Test::Unit::TestCase
9
+ include Amazon::WebServices::Util
10
+
11
+ def testUnknownString
12
+ @methodName = :Method17
13
+ ex = UnknownResultException.new( RuntimeError.new('superRuntimeError'), @methodName, nil )
14
+
15
+ assert_equal "UnknownResultException: got superRuntimeError calling Method17", ex.to_s
16
+ end
17
+
18
+ def testValidationString
19
+ @result = { :OperationRequest => {:RequestId=>"aa718afb-a1f2-4812-9962-4058c20d75a8"},
20
+ :HIT => { :Request => { :IsValid=>"False",
21
+ :Errors => { :Error => { :Message => "your xml broke",
22
+ :Code => "AWS.MechanicalTurk.XMLParseError"}
23
+ }
24
+ }
25
+ }
26
+ }
27
+ ex = ValidationException.new( @result )
28
+
29
+ assert_equal "ValidationException: AWS.MechanicalTurk.XMLParseError", ex.to_s
30
+ end
31
+
32
+ end
@@ -0,0 +1,99 @@
1
+ # Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
2
+ # License:: Apache License, Version 2.0
3
+
4
+ require 'test/unit/testcase'
5
+ require 'amazon/util/hash_nesting'
6
+
7
+ class TestHashNesting < Test::Unit::TestCase
8
+ include Amazon::Util
9
+
10
+ def setup
11
+ @hash = {}.extend HashNesting
12
+ @nested = { 'a' => 'b', 'c.d' => 'e', 'c.f' => 'g', 'h.1.i' => 'j', 'h.2.k' => 'l' }.extend HashNesting
13
+ @unnested = { :a => 'b', :c => { :d => 'e', :f => 'g' }, :h => [ {:i => 'j'}, {:k => 'l'} ] }.extend HashNesting
14
+ end
15
+
16
+ def testSimpleNest
17
+ @hash[:a] = 'b'
18
+ @hash[:p] = { :q => 'r', :s => 't' }
19
+ @hash[:x] = [{:y => 'z'}, {:y => 'w'}]
20
+ nest = @hash.nest
21
+ assert_equal 'b', nest['a']
22
+ assert_equal 'r', nest['p.q']
23
+ assert_equal 't', nest['p.s']
24
+ assert_equal 'z', nest['x.1.y']
25
+ assert_equal 'w', nest['x.2.y']
26
+ assert_equal [], %w( a p.q p.s x.1.y x.2.y) - nest.keys
27
+ assert_equal [], nest.keys - %w( a p.q p.s x.1.y x.2.y)
28
+ end
29
+
30
+ def testSimpleUnnest
31
+ @hash['a'] = 'b'
32
+ @hash['p.q'] = 'r'
33
+ @hash['x.1.w'] = 'q'
34
+ @hash['x.2.w'] = 'z'
35
+ unnest = @hash.unnest
36
+ assert_equal 'b', unnest[:a]
37
+ assert_equal 'r', unnest[:p][:q]
38
+ assert_equal 'q', unnest[:x][0][:w]
39
+ assert_equal 'z', unnest[:x][1][:w]
40
+ end
41
+
42
+ def testMutability
43
+ cpy = @unnested.dup
44
+
45
+ unnest = @unnested.unnest
46
+ assert_equal cpy, @unnested
47
+ assert_not_nil unnest
48
+ unnest[:q] = 'p'
49
+ assert_equal cpy, @unnested
50
+
51
+ nest = @unnested.nest
52
+ assert_equal cpy, @unnested
53
+ assert_not_nil nest
54
+ nest['q'] = 'p'
55
+ assert_equal cpy, @unnested
56
+
57
+ @unnested.nest!
58
+ assert_equal @nested, @unnested
59
+ @unnested.unnest!
60
+ assert_equal cpy, @unnested
61
+
62
+ @unnested.nest!.unnest!
63
+ assert_equal cpy, @unnested
64
+
65
+ assert_equal cpy, @unnested.unnest!
66
+
67
+ cpy = @nested.dup
68
+
69
+ @nested.unnest!.nest!
70
+ assert_equal cpy, @nested
71
+
72
+ assert_equal cpy, @nested.nest!
73
+ end
74
+
75
+ def testChaining
76
+ assert_equal @unnested, @nested.unnest.unnest!.unnest
77
+ assert_equal @nested, @unnested.nest.nest!.nest
78
+ assert_equal @nested, @nested.unnest.unnest!.nest!.nest
79
+ assert_equal @unnested, @unnested.nest.nest!.unnest!.unnest
80
+ end
81
+
82
+ def testPrecedence
83
+ @hash['a'] = 'b'
84
+ @hash[:a] = 'c'
85
+ @hash[:z] = 'x'
86
+ @hash['z'] = 'y'
87
+
88
+ assert_equal 'c', @hash.nest['a']
89
+ assert_equal 'c', @hash.unnest[:a]
90
+ assert_equal 'x', @hash.nest['z']
91
+ assert_equal 'x', @hash.unnest[:z]
92
+
93
+ @hash['a'] = 'd'
94
+
95
+ assert_equal 'c', @hash.nest['a']
96
+ assert_equal 'c', @hash.unnest[:a]
97
+ end
98
+
99
+ end
@@ -0,0 +1,89 @@
1
+ # Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
2
+ # License:: Apache License, Version 2.0
3
+
4
+ require 'test/unit/testcase'
5
+ require 'amazon/util/lazy_results'
6
+
7
+ class TestLazyResults < Test::Unit::TestCase
8
+ include Amazon::Util
9
+
10
+ def setup
11
+ @call_count = 0
12
+ @simple_pagesize = 2
13
+ @simple_data_size = 6
14
+ @simple_data = [ [1,2],[3,4],[5,6] ]
15
+ @simple_lazy = LazyResults.new {|page| @call_count += 1 ; @simple_data[ page-1 ] }
16
+ end
17
+
18
+ def testBasic
19
+ assert_equal 0, @call_count
20
+ assert_equal @simple_data.flatten, @simple_lazy.to_a
21
+ assert_equal 4, @call_count
22
+ assert_equal @simple_data.flatten, @simple_lazy.to_a
23
+ assert_equal 4, @call_count
24
+ assert_equal Array, @simple_lazy.to_a.class
25
+ end
26
+
27
+ def testEnumerable
28
+ result = @simple_lazy.collect
29
+ assert_equal @simple_data.flatten, result.to_a
30
+ assert_equal 4, @call_count
31
+ result = @simple_lazy.collect
32
+ assert_equal @simple_data.flatten, result.to_a
33
+ assert_equal 4, @call_count
34
+ minus1 = @simple_lazy.collect {|i| i-1}
35
+ minus1.each_with_index {|i,n| assert_equal i, n }
36
+ evenodd = @simple_lazy.inject({:even => [],:odd => []}) {|a,num| a[ num % 2 == 0 ? :even : :odd ] << num ; a }
37
+ expected = {:even => [2,4,6], :odd => [1,3,5] }
38
+ assert_equal expected, evenodd
39
+ end
40
+
41
+ def testIncremental
42
+ count = 0
43
+ @simple_lazy.each { |value|
44
+ assert_equal count+1, value
45
+ assert_equal( (count / @simple_pagesize)+1, @call_count )
46
+ count += 1
47
+ }
48
+ assert_equal 4, @call_count
49
+ end
50
+
51
+ def testRandomAccess
52
+ assert_equal 4, @simple_lazy[3]
53
+ assert_equal 2, @call_count
54
+ assert_nil @simple_lazy[@simple_data_size]
55
+ assert_equal 4, @call_count
56
+ 10.times do
57
+ index = rand(@simple_data_size+@simple_pagesize)
58
+ assert_equal( ( index >= @simple_data_size ? nil : index+1 ), @simple_lazy[index] )
59
+ end
60
+ assert_equal 4, @call_count
61
+ assert_equal @simple_data.flatten, @simple_lazy.to_a
62
+ end
63
+
64
+ def testFlush
65
+ @simple_lazy.to_a
66
+ @simple_lazy.to_a
67
+ assert_equal 4, @call_count
68
+ @simple_lazy.flush
69
+ @simple_lazy.to_a
70
+ assert_equal 8, @call_count
71
+ end
72
+
73
+ def testError
74
+ @picky_message = "picky picky picky"
75
+ @picky_lazy = LazyResults.new {|page| @call_count += 1 ; if page < 3 ; @simple_data[ page-1 ] ; else ; raise @picky_message ; end }
76
+ assert_equal 4, @picky_lazy[3]
77
+ e = assert_raises( RuntimeError ) { @picky_lazy[4] }
78
+ assert_equal @picky_message, e.message
79
+ end
80
+
81
+ def testImmutability
82
+ assert_equal 3, @simple_lazy[2]
83
+ a = @simple_lazy.to_a
84
+ assert_equal 3, a[2]
85
+ a[2] = 7
86
+ assert_equal 3, @simple_lazy[2]
87
+ end
88
+
89
+ end
@@ -0,0 +1,132 @@
1
+ # Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
2
+ # License:: Apache License, Version 2.0
3
+
4
+ require 'test/unit/testcase'
5
+ require 'amazon/webservices/util/mock_transport'
6
+
7
+ class TestMockTransport < Test::Unit::TestCase
8
+ include Amazon::WebServices::Util
9
+
10
+ SAMPLE_REQUEST = { :speed => :slow }
11
+ SAMPLE_ARGS = { :Auth => :fake, :Request => [SAMPLE_REQUEST] }
12
+
13
+ def setup
14
+ @mock = MockTransport.new
15
+ end
16
+
17
+ def testBasic
18
+ result = @mock.dance SAMPLE_ARGS
19
+
20
+ assert result[:OperationRequest]
21
+ assert result[:MockResult]
22
+ assert_equal SAMPLE_REQUEST, result[:MockResult][:Request]
23
+
24
+ request = @mock.call_buffer[0]
25
+ assert request
26
+ assert request.args
27
+ assert request.request
28
+ assert_equal :dance, request.name
29
+ assert_equal SAMPLE_ARGS, request.args
30
+ assert_equal SAMPLE_REQUEST, request.request
31
+ end
32
+
33
+ def testListener
34
+ @a = []
35
+ log_listener = proc { |call| @a << call }
36
+
37
+ mock = MockTransport.new :MockListener => log_listener
38
+ mock.dance SAMPLE_ARGS
39
+
40
+ assert_equal 1, @a.size
41
+ assert_equal SAMPLE_REQUEST, @a.first.request
42
+ end
43
+
44
+ def testListenerInjection
45
+ injection_listener = proc {|call| {:Param => :Injected } }
46
+
47
+ mock = MockTransport.new :MockListener => injection_listener
48
+ result = mock.dance SAMPLE_ARGS
49
+
50
+ assert_equal :Injected, result[:Param], "Should have injected our parameter"
51
+ assert result[:MockResult], "Injection should not have precluded MockResult"
52
+ end
53
+
54
+ def testMockReply
55
+ result = @mock.dance SAMPLE_ARGS
56
+ @mock.mock_reply = {:Bogus => :Fun}
57
+ result2 = @mock.dance SAMPLE_ARGS
58
+
59
+ assert result[:MockResult]
60
+ assert_nil result2[:MockResult]
61
+
62
+ assert_nil result[:Bogus]
63
+ assert result2[:Bogus]
64
+ end
65
+
66
+ def testEnumerable
67
+
68
+ # should start out with empty buffer
69
+ calls = @mock.collect { |call| call.name }
70
+ assert_equal [], calls
71
+
72
+ # now generate 3 calls
73
+ @mock.dance SAMPLE_ARGS
74
+ @mock.fall SAMPLE_ARGS
75
+ @mock.sing SAMPLE_ARGS
76
+
77
+ # ensure we got all 3 args in proper order
78
+ calls = @mock.collect { |call| call.name }
79
+ assert_equal [:dance,:fall,:sing], calls
80
+
81
+ # should be repeatable
82
+ calls = @mock.collect { |call| call.name }
83
+ assert_equal [:dance,:fall,:sing], calls
84
+
85
+ # now flush the buffer and ensure it's empty again
86
+ @mock.flush
87
+ calls = @mock.collect { |call| call.name }
88
+ assert_equal [], calls
89
+ end
90
+
91
+ def testNext
92
+
93
+ # should start out with empty buffer
94
+ assert_nil @mock.next
95
+
96
+ # make a call
97
+ @mock.dance SAMPLE_ARGS
98
+
99
+ # call shows up with #next
100
+ n = @mock.next
101
+ assert_equal :dance, n.name
102
+
103
+ # should only have been one call in the buffer
104
+ assert_nil @mock.next
105
+
106
+ # two more calls
107
+ @mock.fall SAMPLE_ARGS
108
+ @mock.sing SAMPLE_ARGS
109
+
110
+ # ensure we get them in proper order
111
+ assert_equal :fall, @mock.next.name
112
+ assert_equal :sing, @mock.next.name
113
+
114
+ # and we should have no more
115
+ assert_nil @mock.next
116
+
117
+ # after flushing, we should still have none
118
+ @mock.flush
119
+ assert_nil @mock.next
120
+
121
+ # add one more call
122
+ @mock.smile SAMPLE_ARGS
123
+
124
+ # we should have just one queued up now
125
+ assert_equal :smile, @mock.next.name
126
+ assert_nil @mock.next
127
+
128
+ end
129
+
130
+ end
131
+
132
+
@@ -0,0 +1,58 @@
1
+ # Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
2
+ # License:: Apache License, Version 2.0
3
+
4
+ require 'test/unit/testcase'
5
+ require 'amazon/util/paginated_iterator'
6
+
7
+ class TestPaginatedIterator < Test::Unit::TestCase
8
+ include Amazon::Util
9
+
10
+ def setup
11
+ @call_count = 0
12
+ @simple_pagesize = 2
13
+ @simple_data_size = 6
14
+ @simple_data = [ [1,2],[3,4],[5,6] ]
15
+ @simple_iter = PaginatedIterator.new {|page| @call_count += 1 ; @simple_data[ page-1 ] }
16
+ end
17
+
18
+ def testNext
19
+ assert_equal 0, @call_count
20
+ @simple_data.flatten.each do |i|
21
+ assert_equal i, @simple_iter.next
22
+ end
23
+ assert_equal 3, @call_count
24
+ assert !@simple_iter.done
25
+ assert_nil @simple_iter.next
26
+ assert_equal 4, @call_count
27
+ assert @simple_iter.done
28
+ end
29
+
30
+ def testRestart
31
+ assert_equal 0, @call_count
32
+ @simple_iter.next until @simple_iter.done
33
+ assert_equal 4, @call_count
34
+ @simple_iter.restart
35
+ assert !@simple_iter.done
36
+ @simple_iter.next until @simple_iter.done
37
+ assert_equal 8, @call_count
38
+ end
39
+
40
+ def testEach
41
+ res = []
42
+ @simple_iter.each {|i| res << i }
43
+ assert_equal @simple_data.flatten, res
44
+ assert_equal 4, @call_count
45
+ assert @simple_iter.done
46
+ @simple_iter.each {|i| fail }
47
+ end
48
+
49
+ def testError
50
+ @picky_message = "picky picky picky"
51
+ @picky_iter = PaginatedIterator.new {|page| @call_count += 1 ; if page < 3 ; @simple_data[ page-1 ] ; else ; raise @picky_message ; end }
52
+ 3.times { @picky_iter.next }
53
+ assert_equal 4, @picky_iter.next
54
+ e = assert_raises( RuntimeError ) { @picky_iter.next }
55
+ assert_equal @picky_message, e.message
56
+ end
57
+
58
+ end
@@ -0,0 +1,108 @@
1
+ # Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
2
+ # License:: Apache License, Version 2.0
3
+
4
+ require 'test/unit/testcase'
5
+ require 'amazon/util/proactive_results'
6
+
7
+ class TestProactiveResults < Test::Unit::TestCase
8
+ include Amazon::Util
9
+
10
+ def setup
11
+ @call_count = 0
12
+ @exception_count = 0
13
+ @simple_pagesize = 2
14
+ @simple_data_size = 6
15
+ @simple_data = [ [1,2],[3,4],[5,6] ]
16
+ @simple_proactive = ProactiveResults.new {|page| @call_count += 1 ; @simple_data[ page-1 ] }
17
+ end
18
+
19
+ def testBasic
20
+ assert @call_count >= 0
21
+ assert_equal @simple_data.flatten, @simple_proactive.to_a
22
+ assert_equal 6, @call_count
23
+ assert_equal @simple_data.flatten, @simple_proactive.to_a
24
+ assert_equal 6, @call_count
25
+ assert_equal Array, @simple_proactive.to_a.class
26
+ end
27
+
28
+ def testEnumerable
29
+ result = @simple_proactive.collect
30
+ assert_equal @simple_data.flatten, result.to_a
31
+ assert_equal 6, @call_count
32
+ result = @simple_proactive.collect
33
+ assert_equal @simple_data.flatten, result.to_a
34
+ assert_equal 6, @call_count
35
+ minus1 = @simple_proactive.collect {|i| i-1}
36
+ minus1.each_with_index {|i,n| assert_equal i, n }
37
+ evenodd = @simple_proactive.inject({:even => [],:odd => []}) {|a,num| a[ num % 2 == 0 ? :even : :odd ] << num ; a }
38
+ expected = {:even => [2,4,6], :odd => [1,3,5] }
39
+ assert_equal expected, evenodd
40
+ end
41
+
42
+ def testIncremental
43
+ count = 0
44
+ remaining = @simple_data.flatten
45
+ @simple_proactive.each { |value|
46
+ assert_not_nil value
47
+ assert_not_nil remaining.delete( value )
48
+ assert @call_count >= (count / @simple_pagesize)+1
49
+ count += 1
50
+ }
51
+ assert_equal 6, count
52
+ assert_equal 6, @call_count
53
+ end
54
+
55
+ def testRandomAccess
56
+ assert [2,4,6].member?( @simple_proactive[3] )
57
+ assert @call_count >= 2
58
+ assert_nil @simple_proactive[@simple_data_size]
59
+ assert_equal 6, @call_count
60
+ 10.times do
61
+ index = rand(@simple_data_size+@simple_pagesize)
62
+ if index >= @simple_data_size
63
+ assert_nil @simple_proactive[index]
64
+ else
65
+ if index % 2 == 0
66
+ assert [1,3,5].member?( @simple_proactive[index] )
67
+ else
68
+ assert [2,4,6].member?( @simple_proactive[index] )
69
+ end
70
+ end
71
+ end
72
+ assert_equal 6, @call_count
73
+ assert_equal @simple_data.flatten, @simple_proactive.to_a.sort
74
+ end
75
+
76
+ def testFlush
77
+ @simple_proactive.to_a
78
+ @simple_proactive.to_a
79
+ assert_equal 6, @call_count
80
+ @simple_proactive.flush
81
+ @simple_proactive.to_a
82
+ assert_equal 12, @call_count
83
+ end
84
+
85
+ def testError
86
+ @picky_message = "picky picky picky"
87
+ exception_count = 0
88
+ @picky_proactive = ProactiveResults.new(Proc.new {|i| exception_count += 1 }) do |page|
89
+ @call_count += 1
90
+ if page < 3
91
+ @simple_data[ page-1 ]
92
+ else
93
+ raise @picky_message
94
+ end
95
+ end
96
+ assert_equal @simple_data.flatten[0..3], @picky_proactive.to_a
97
+ assert_equal 3, exception_count
98
+ end
99
+
100
+ def testImmutability
101
+ assert_equal 3, @simple_proactive[2]
102
+ a = @simple_proactive.to_a
103
+ assert_equal 3, a[2]
104
+ a[2] = 7
105
+ assert_equal 3, @simple_proactive[2]
106
+ end
107
+
108
+ end