rturk 1.0.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/.gitmodules +3 -0
  2. data/.yardoc +0 -0
  3. data/README.markdown +49 -29
  4. data/Rakefile +53 -0
  5. data/TODO.markdown +3 -0
  6. data/VERSION +1 -1
  7. data/examples/blank_slate.rb +21 -4
  8. data/examples/create_hit.rb +19 -0
  9. data/examples/newtweet.html +0 -1
  10. data/examples/review_answer.rb +18 -5
  11. data/lib/rturk.rb +33 -6
  12. data/lib/rturk/adapters/answers.rb +38 -0
  13. data/lib/rturk/adapters/assignment.rb +75 -0
  14. data/lib/rturk/adapters/hit.rb +97 -0
  15. data/lib/rturk/builders/qualification_builder.rb +68 -0
  16. data/lib/rturk/builders/qualifications_builder.rb +43 -0
  17. data/lib/rturk/builders/question_builder.rb +51 -0
  18. data/lib/rturk/errors.rb +5 -0
  19. data/lib/rturk/logger.rb +20 -0
  20. data/lib/rturk/macros.rb +35 -0
  21. data/lib/rturk/operation.rb +86 -0
  22. data/lib/rturk/operations/approve_assignment.rb +28 -0
  23. data/lib/rturk/operations/create_hit.rb +77 -0
  24. data/lib/rturk/operations/disable_hit.rb +19 -0
  25. data/lib/rturk/operations/dispose_hit.rb +19 -0
  26. data/lib/rturk/operations/force_expire_hit.rb +18 -0
  27. data/lib/rturk/operations/get_account_balance.rb +15 -0
  28. data/lib/rturk/operations/get_assignments_for_hit.rb +24 -0
  29. data/lib/rturk/operations/get_hit.rb +21 -0
  30. data/lib/rturk/operations/get_reviewable_hits.rb +23 -0
  31. data/lib/rturk/operations/grant_bonus.rb +26 -0
  32. data/lib/rturk/operations/reject_assignment.rb +23 -0
  33. data/lib/rturk/requester.rb +58 -76
  34. data/lib/rturk/response.rb +58 -0
  35. data/lib/rturk/responses/create_hit_response.rb +33 -0
  36. data/lib/rturk/responses/get_account_balance_response.rb +11 -0
  37. data/lib/rturk/responses/get_assignments_for_hit_response.rb +43 -0
  38. data/lib/rturk/responses/get_hit_response.rb +80 -0
  39. data/lib/rturk/responses/get_reviewable_hits_response.rb +33 -0
  40. data/lib/rturk/utilities.rb +19 -1
  41. data/lib/rturk/xml_utilities.rb +23 -0
  42. data/rturk.gemspec +143 -0
  43. data/spec/adapters/answers_spec.rb +27 -0
  44. data/spec/adapters/assignment_spec.rb +0 -0
  45. data/spec/adapters/hit_spec.rb +46 -0
  46. data/spec/builders/qualification_spec.rb +53 -0
  47. data/spec/builders/qualifications_spec.rb +30 -0
  48. data/spec/builders/question_spec.rb +46 -0
  49. data/spec/fake_responses/approve_assignment.xml +5 -0
  50. data/spec/fake_responses/create_hit.xml +12 -0
  51. data/spec/fake_responses/disable_hit.xml +5 -0
  52. data/spec/fake_responses/dispose_hit.xml +5 -0
  53. data/spec/fake_responses/force_expire_hit.xml +5 -0
  54. data/spec/fake_responses/get_account_balance.xml +10 -0
  55. data/spec/fake_responses/get_assignments.xml +35 -0
  56. data/spec/fake_responses/get_hit.xml +41 -0
  57. data/spec/fake_responses/get_reviewable_hits.xml +17 -0
  58. data/spec/fake_responses/grant_bonus.xml +5 -0
  59. data/spec/fake_responses/invalid_credentials.xml +12 -0
  60. data/spec/fake_responses/reject_assignment.xml +5 -0
  61. data/spec/operations/approve_assignment_spec.rb +27 -0
  62. data/spec/operations/create_hit_spec.rb +66 -0
  63. data/spec/operations/disable_hit_spec.rb +26 -0
  64. data/spec/operations/dispose_hit_spec.rb +26 -0
  65. data/spec/operations/force_expire_hit_spec.rb +26 -0
  66. data/spec/operations/get_account_balance_spec.rb +15 -0
  67. data/spec/operations/get_assignments_spec.rb +26 -0
  68. data/spec/operations/get_hit_spec.rb +18 -0
  69. data/spec/operations/get_reviewable_hits_spec.rb +0 -0
  70. data/spec/operations/grant_bonus_spec.rb +32 -0
  71. data/spec/operations/reject_assignment_spec.rb +26 -0
  72. data/spec/requester_spec.rb +7 -18
  73. data/spec/response_spec.rb +48 -0
  74. data/spec/rturk_spec.rb +27 -0
  75. data/spec/spec_helper.rb +28 -3
  76. data/spec/tmp +2 -0
  77. data/spec/xml_parse_spec.rb +32 -0
  78. metadata +94 -34
  79. data/examples/external_page.rb +0 -33
  80. data/lib/rturk/answer.rb +0 -20
  81. data/lib/rturk/custom_operations.rb +0 -80
  82. data/lib/rturk/external_question_builder.rb +0 -22
  83. data/spec/answer_spec.rb +0 -24
  84. data/spec/external_question_spec.rb +0 -27
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+
4
+ describe RTurk::Qualifications do
5
+
6
+ before(:each) do
7
+ @qualifications = RTurk::Qualifications.new
8
+ end
9
+
10
+ it "should build a qualification set with multiple qualifications" do
11
+ @qualifications.add :approval_rate, {:gt => 80}
12
+ @qualifications.approval_rate(:lt => 90)
13
+ @qualifications.to_params['QualificationRequirement.1.Comparator'].should == 'GreaterThan'
14
+ @qualifications.to_params['QualificationRequirement.2.IntegerValue'].should == 90
15
+ end
16
+
17
+ it "should build a qualification set with booleans" do
18
+ @qualifications.add :adult, true
19
+ @qualifications.to_params['QualificationRequirement.1.Comparator'].should == 'EqualTo'
20
+ @qualifications.to_params['QualificationRequirement.1.IntegerValue'].should == 1
21
+ end
22
+
23
+ it "should build a qualification set with a country condition" do
24
+ @qualifications.add :adult, true
25
+ @qualifications.country :eql => 'US'
26
+ @qualifications.to_params['QualificationRequirement.2.Comparator'].should == 'EqualTo'
27
+ @qualifications.to_params['QualificationRequirement.2.LocaleValue.Country'].should == 'US'
28
+ end
29
+
30
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+ require 'cgi'
3
+
4
+ describe RTurk::Question do
5
+
6
+ before(:all) do
7
+ end
8
+
9
+ it "should build a question" do
10
+ question = RTurk::Question.new('http://mpercival.com')
11
+ question.url.should == 'http://mpercival.com'
12
+ question.frame_height.should == 400
13
+ end
14
+
15
+ it "should build a question " do
16
+ question = RTurk::Question.new('http://mpercival.com', :frame_height => 500, :chapter => 1)
17
+ question.params[:chapter] = 2
18
+ question.url.should == 'http://mpercival.com?chapter=2'
19
+ question.frame_height.should == 500
20
+ end
21
+
22
+ it "should build a question with params" do
23
+ params = RTurk::Question.new('http://google.com/', :id => 'foo').to_params
24
+ CGI.unescape(params).should ==
25
+ <<-XML
26
+ <ExternalQuestion xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd">
27
+ <ExternalURL>http://google.com/?id=foo</ExternalURL>
28
+ <FrameHeight>400</FrameHeight>
29
+ </ExternalQuestion>
30
+ XML
31
+ end
32
+
33
+ it "should build a question without params" do
34
+ params = RTurk::Question.new('http://google.com/').to_params
35
+ CGI.unescape(params).should ==
36
+ <<-XML
37
+ <ExternalQuestion xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd">
38
+ <ExternalURL>http://google.com/</ExternalURL>
39
+ <FrameHeight>400</FrameHeight>
40
+ </ExternalQuestion>
41
+ XML
42
+ end
43
+
44
+
45
+
46
+ end
@@ -0,0 +1,5 @@
1
+ <ApproveAssignmentResult>
2
+ <Request>
3
+ <IsValid>True</IsValid>
4
+ </Request>
5
+ </ApproveAssignmentResult>
@@ -0,0 +1,12 @@
1
+ <CreateHITResponse>
2
+ <OperationRequest>
3
+ <RequestId>ece2785b-6292-4b12-a60e-4c34847a7916</RequestId>
4
+ </OperationRequest>
5
+ <HIT>
6
+ <Request>
7
+ <IsValid>True</IsValid>
8
+ </Request>
9
+ <HITId>GBHZVQX3EHXZ2AYDY2T0</HITId>
10
+ <HITTypeId>NYVZTQ1QVKJZXCYZCZVZ</HITTypeId>
11
+ </HIT>
12
+ </CreateHITResponse>
@@ -0,0 +1,5 @@
1
+ <DisposeHITResult>
2
+ <Request>
3
+ <IsValid>True</IsValid>
4
+ </Request>
5
+ </DisposeHITResult>
@@ -0,0 +1,5 @@
1
+ <DisposeHITResult>
2
+ <Request>
3
+ <IsValid>True</IsValid>
4
+ </Request>
5
+ </DisposeHITResult>
@@ -0,0 +1,5 @@
1
+ <ForceExpireHITResult>
2
+ <Request>
3
+ <IsValid>True</IsValid>
4
+ </Request>
5
+ </ForceExpireHITResult>
@@ -0,0 +1,10 @@
1
+ <GetAccountBalanceResult>
2
+ <Request>
3
+ <IsValid>True</IsValid>
4
+ </Request>
5
+ <AvailableBalance>
6
+ <Amount>15555.55</Amount>
7
+ <CurrencyCode>USD</CurrencyCode>
8
+ <FormattedPrice>$15,555.55</FormattedPrice>
9
+ </AvailableBalance>
10
+ </GetAccountBalanceResult>
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0"?>
2
+ <GetAssignmentsForHITResponse>
3
+ <OperationRequest>
4
+ <RequestId>a964d1f8-d315-4bbb-9ab6-692625d662ff</RequestId>
5
+ </OperationRequest>
6
+ <GetAssignmentsForHITResult>
7
+ <Request>
8
+ <IsValid>True</IsValid>
9
+ </Request>
10
+ <NumResults>1</NumResults>
11
+ <TotalNumResults>1</TotalNumResults>
12
+ <PageNumber>1</PageNumber>
13
+ <Assignment>
14
+ <AssignmentId>32A8TDZQEZYRV84XKZ4ZBT6JT05DKJRZ1BC42YSZ</AssignmentId>
15
+ <WorkerId>ADOJP7RNRYAFG</WorkerId>
16
+ <HITId>32A8TDZQEZYRV84XKZ4Z</HITId>
17
+ <AssignmentStatus>Submitted</AssignmentStatus>
18
+ <AutoApprovalTime>2009-11-25T05:17:32Z</AutoApprovalTime>
19
+ <AcceptTime>2009-10-26T05:17:18Z</AcceptTime>
20
+ <SubmitTime>2009-10-26T05:17:32Z</SubmitTime>
21
+ <Answer>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
22
+ &lt;QuestionFormAnswers xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd"&gt;
23
+ &lt;Answer&gt;
24
+ &lt;QuestionIdentifier&gt;tweet&lt;/QuestionIdentifier&gt;
25
+ &lt;FreeText&gt;This is my tweet!&lt;/FreeText&gt;
26
+ &lt;/Answer&gt;
27
+ &lt;Answer&gt;
28
+ &lt;QuestionIdentifier&gt;Submit&lt;/QuestionIdentifier&gt;
29
+ &lt;FreeText&gt;Submit&lt;/FreeText&gt;
30
+ &lt;/Answer&gt;
31
+ &lt;/QuestionFormAnswers&gt;
32
+ </Answer>
33
+ </Assignment>
34
+ </GetAssignmentsForHITResult>
35
+ </GetAssignmentsForHITResponse>
@@ -0,0 +1,41 @@
1
+ <?xml version="1.0"?>
2
+ <GetHITResponse>
3
+ <OperationRequest>
4
+ <RequestId>49341251-fcbd-45c3-ab98-8fbe2e4d8060</RequestId>
5
+ </OperationRequest>
6
+ <HIT>
7
+ <Request>
8
+ <IsValid>True</IsValid>
9
+ </Request>
10
+ <HITId>GR4R3HY3YGBZXDCAPJWZ</HITId>
11
+ <HITTypeId>YGKZ2W5X6YFZ08ZRXXZZ</HITTypeId>
12
+ <CreationTime>2009-06-25T04:21:17Z</CreationTime>
13
+ <Title>Write a twitter update</Title>
14
+ <Description>Simply write a twitter update for me</Description>
15
+ <Question>&lt;ExternalQuestion xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd"&gt;
16
+ &lt;ExternalURL&gt;http://s3.amazonaws.com/mpercival.com/newtweet.html?id=foo&lt;/ExternalURL&gt;
17
+ &lt;FrameHeight&gt;400&lt;/FrameHeight&gt;
18
+ &lt;/ExternalQuestion&gt;
19
+ </Question>
20
+ <Keywords>twitter, blogging, writing, english</Keywords>
21
+ <HITStatus>Reviewable</HITStatus>
22
+ <MaxAssignments>1</MaxAssignments>
23
+ <Reward>
24
+ <Amount>0.10</Amount>
25
+ <CurrencyCode>USD</CurrencyCode>
26
+ <FormattedPrice>$0.10</FormattedPrice>
27
+ </Reward>
28
+ <AutoApprovalDelayInSeconds>3600</AutoApprovalDelayInSeconds>
29
+ <Expiration>2009-06-25T05:21:17Z</Expiration>
30
+ <AssignmentDurationInSeconds>3600</AssignmentDurationInSeconds>
31
+ <NumberOfSimilarHITs>0</NumberOfSimilarHITs>
32
+ <RequesterAnnotation>OptionalNote</RequesterAnnotation>
33
+ <QualificationRequirement>
34
+ <QualificationTypeId>000000000000000000L0</QualificationTypeId>
35
+ <Comparator>GreaterThan</Comparator>
36
+ <IntegerValue>90</IntegerValue>
37
+ <RequiredToPreview>0</RequiredToPreview>
38
+ </QualificationRequirement>
39
+ <HITReviewStatus>NotReviewed</HITReviewStatus>
40
+ </HIT>
41
+ </GetHITResponse>
@@ -0,0 +1,17 @@
1
+ <GetReviewableHITsResult>
2
+ <Request>
3
+ <IsValid>True</IsValid>
4
+ </Request>
5
+ <NumResults>3</NumResults>
6
+ <TotalNumResults>3</TotalNumResults>
7
+ <PageNumber>1</PageNumber>
8
+ <HIT>
9
+ <HITId>GBHZVQX3EHXZ2AYDY2T0</HITId>
10
+ </HIT>
11
+ <HIT>
12
+ <HITId>GBHZVQX3EHXZ2AYDY2T1</HITId>
13
+ </HIT>
14
+ <HIT>
15
+ <HITId>GBHZVQX3EHXZ2AYDY2T2</HITId>
16
+ </HIT>
17
+ </GetReviewableHITsResult>
@@ -0,0 +1,5 @@
1
+ <GrantBonusResult>
2
+ <Request>
3
+ <IsValid>True</IsValid>
4
+ </Request>
5
+ </GrantBonusResult>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0"?>
2
+ <GetResponse>
3
+ <OperationRequest>
4
+ <RequestId>1306b1ca-0169-49fb-a196-83f6a762738c</RequestId>
5
+ <Errors>
6
+ <Error>
7
+ <Code>AWS.NotAuthorized</Code>
8
+ <Message>The identity contained in the request is not authorized to use this AWSAccessKeyId</Message>
9
+ </Error>
10
+ </Errors>
11
+ </OperationRequest>
12
+ </GetResponse>
@@ -0,0 +1,5 @@
1
+ <RejectAssignmentResult>
2
+ <Request>
3
+ <IsValid>True</IsValid>
4
+ </Request>
5
+ </RejectAssignmentResult>
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe RTurk::ApproveAssignment do
4
+
5
+ before(:all) do
6
+ aws = YAML.load(File.open(File.join(SPEC_ROOT, 'mturk.yml')))
7
+ RTurk.setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
8
+ faker('approve_assignment', :operation => 'ApproveAssignment')
9
+ end
10
+
11
+ it "should ensure required params" do
12
+ lambda{RTurk::ApproveAssignment()}.should raise_error RTurk::MissingParameters
13
+ end
14
+
15
+ it "should successfully request the operation" do
16
+ RTurk::Requester.should_receive(:request).once.with(
17
+ hash_including('Operation' => 'ApproveAssignment'))
18
+ RTurk::ApproveAssignment(:assignment_id => "123456789") rescue RTurk::InvalidRequest
19
+ end
20
+
21
+ it "should parse and return the result" do
22
+ RTurk::ApproveAssignment(:assignment_id => "123456789").elements.should eql(
23
+ {"ApproveAssignmentResult"=>{"Request"=>{"IsValid"=>"True"}}}
24
+ )
25
+ end
26
+
27
+ end
@@ -0,0 +1,66 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe "using mechanical turk with RTurk" do
4
+
5
+ before(:all) do
6
+ aws = YAML.load(File.open(File.join(SPEC_ROOT, 'mturk.yml')))
7
+ RTurk.setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
8
+ FakeWeb.clean_registry
9
+ faker('create_hit', :operation => "CreateHIT")
10
+ faker('get_hit', :operation => "GetHIT")
11
+ end
12
+
13
+ it "should let me build and send a hit" do
14
+ hit = RTurk::CreateHIT.new(:title => "Look at some pictures from 4Chan") do |hit|
15
+ hit.assignments = 5
16
+ hit.description = 'blah'
17
+ hit.question("http://mpercival.com", :frame_height => 600)
18
+ hit.reward = 0.05
19
+ hit.qualifications.add :approval_rate, {:gt => 80}
20
+ end
21
+ hit.assignments.should eql(5)
22
+ response = hit.request
23
+ response.hit_id.should_not be_nil
24
+ end
25
+
26
+ it "should let me create a hit" do
27
+ response = RTurk::CreateHIT(:title => "Look at some pictures from 4Chan") do |hit|
28
+ hit.assignments = 5
29
+ hit.description = 'blah'
30
+ hit.question("http://mpercival.com", :test => 'b')
31
+ hit.reward = 0.05
32
+ hit.qualifications.add(:adult, true)
33
+ end
34
+ response.hit.url.should eql('http://workersandbox.mturk.com/mturk/preview?groupId=YGKZ2W5X6YFZ08ZRXXZZ')
35
+ end
36
+
37
+ it "should let me create a hit with just option arguments" do
38
+ hit = RTurk::CreateHIT.new(:title => "Look at some pictures from 4Chan",
39
+ :description => "Pics from the b-tards",
40
+ :assignments => 5,
41
+ :reward => nil,
42
+ :question => 'http://mpercival.com?picture=1',
43
+ :qualifications => [
44
+ [:approval_rate, {:gt => 80}],
45
+ [:adult, true]
46
+ ]
47
+ )
48
+ hit.assignments.should eql(5)
49
+ hit.qualifications.qualifications.size.should eql(2)
50
+ lambda{hit.request}.should raise_error RTurk::MissingParameters
51
+ end
52
+
53
+ it "should rerturn a CreateHITResponse after the request" do
54
+ response = RTurk::CreateHIT(:title => "Look at some pictures from 4Chan") do |hit|
55
+ hit.assignments = 5
56
+ hit.description = "foo"
57
+ hit.question("http://mpercival.com", :test => 'b')
58
+ hit.reward = 0.05
59
+ hit.qualifications.add(:adult, true)
60
+ end
61
+ response.is_a?(RTurk::CreateHITResponse).should be_true
62
+ response.hit_id.should == 'GBHZVQX3EHXZ2AYDY2T0'
63
+ response.hit_type_id.should == 'NYVZTQ1QVKJZXCYZCZVZ'
64
+ end
65
+
66
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe RTurk::DisableHIT do
4
+
5
+ before(:all) do
6
+ aws = YAML.load(File.open(File.join(SPEC_ROOT, 'mturk.yml')))
7
+ RTurk.setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
8
+ faker('disable_hit', :operation => 'DisableHIT')
9
+ end
10
+
11
+ it "should ensure required params" do
12
+ lambda{RTurk::DisableHIT()}.should raise_error RTurk::MissingParameters
13
+ end
14
+
15
+ it "should successfully request the operation" do
16
+ RTurk::Requester.should_receive(:request).once.with(
17
+ hash_including('Operation' => 'DisableHIT'))
18
+ RTurk::DisableHIT(:hit_id => "123456789") rescue RTurk::InvalidRequest
19
+ end
20
+
21
+ it "should parse and return the result" do
22
+ RTurk::DisableHIT(:hit_id => "123456789").should
23
+ be_a_kind_of RTurk::Response
24
+ end
25
+
26
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe RTurk::DisposeHIT do
4
+
5
+ before(:all) do
6
+ aws = YAML.load(File.open(File.join(SPEC_ROOT, 'mturk.yml')))
7
+ RTurk.setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
8
+ faker('dispose_hit', :operation => 'DisposeHIT')
9
+ end
10
+
11
+ it "should ensure required params" do
12
+ lambda{RTurk::DisposeHIT()}.should raise_error RTurk::MissingParameters
13
+ end
14
+
15
+ it "should successfully request the operation" do
16
+ RTurk::Requester.should_receive(:request).once.with(
17
+ hash_including('Operation' => 'DisposeHIT'))
18
+ RTurk::DisposeHIT(:hit_id => "123456789") rescue RTurk::InvalidRequest
19
+ end
20
+
21
+ it "should parse and return the result" do
22
+ RTurk::DisposeHIT(:hit_id => "123456789").should
23
+ be_a_kind_of RTurk::Response
24
+ end
25
+
26
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe RTurk::ForceExpireHIT do
4
+
5
+ before(:all) do
6
+ aws = YAML.load(File.open(File.join(SPEC_ROOT, 'mturk.yml')))
7
+ RTurk.setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
8
+ faker('force_expire_hit', :operation => 'ForceExpireHIT')
9
+ end
10
+
11
+ it "should ensure required params" do
12
+ lambda{RTurk::ForceExpireHIT()}.should raise_error RTurk::MissingParameters
13
+ end
14
+
15
+ it "should successfully request the operation" do
16
+ RTurk::Requester.should_receive(:request).once.with(
17
+ hash_including('Operation' => 'ForceExpireHIT'))
18
+ RTurk::ForceExpireHIT(:hit_id => "123456789") rescue RTurk::InvalidRequest
19
+ end
20
+
21
+ it "should parse and return the result" do
22
+ RTurk::ForceExpireHIT(:hit_id => "123456789").should
23
+ be_a_kind_of RTurk::Response
24
+ end
25
+
26
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+
4
+ describe RTurk::GetAccountBalance do
5
+
6
+ before(:all) do
7
+ faker('get_account_balance', :operation => 'GetAccountBalance')
8
+ end
9
+
10
+ it "should give me my account balance" do
11
+ RTurk.GetAccountBalance.amount.should eql(15555.55)
12
+ end
13
+
14
+
15
+ end