turkee 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turkee (2.0.0)
4
+ turkee (2.0.1)
5
5
  lockfile
6
6
  rails (>= 3.1.1)
7
7
  rturk (>= 2.4.0)
@@ -6,21 +6,21 @@ module Turkee
6
6
 
7
7
  options.merge!({:url => mturk_url})
8
8
 
9
- buffer = ''
10
- form_for record, options do |f|
11
- params.each do |k,v|
12
- unless ['action','controller'].include?(k) || !v.is_a?(String)
13
- buffer << hidden_field_tag(k, v)
14
- cookies[k] = v
9
+ capture do
10
+ form_for record, options do |f|
11
+ params.each do |k,v|
12
+ unless ['action','controller'].include?(k) || !v.is_a?(String)
13
+ concat hidden_field_tag(k, v)
14
+ cookies[k] = v
15
+ end
15
16
  end
16
- end
17
17
 
18
- ['assignmentId', 'workerId', 'hitId'].each do |k|
19
- buffer << hidden_field_tag(k, cookies[k]) if !params.has_key?(k) && cookies.has_key?(k)
20
- end
18
+ ['assignmentId', 'workerId', 'hitId'].each do |k|
19
+ concat hidden_field_tag(k, cookies[k]) if !params.has_key?(k) && cookies.has_key?(k)
20
+ end
21
21
 
22
- buffer << yield(f)
23
- buffer.html_safe
22
+ concat(yield(f))
23
+ end
24
24
  end
25
25
  end
26
26
 
@@ -33,21 +33,24 @@ module Turkee
33
33
  style = "position: fixed; top: 120px; right: 30px; color: #FFF;"
34
34
  style << "width: 400px; height: 375px; z-index: 100; padding: 10px;"
35
35
  style << "background-color: rgba(0,0,0, 0.5); border: 1px solid #000;"
36
+
36
37
  div_for(task, :style => style) do
37
- content = content_tag(:h3, "DIRECTIONS", :style => 'text-align: right; color:#FF0000;')
38
- content << task.hit_description.html_safe
39
- content << '<hr/>'.html_safe
40
- content << turkee_form_for(study, params) do |f|
41
- buffer = f.label(:feedback, "Feedback?:")
42
- buffer << f.text_area(:feedback, :rows => 3, :disabled => disabled)
43
- buffer << f.label(:gold_response, "Enter the fourth word from your above feedback :")
44
- buffer << f.text_field(:gold_response, :disabled => disabled)
45
- buffer << f.hidden_field(:turkee_task_id, :value => task.id)
46
- buffer << '<br/>'.html_safe
47
- buffer << f.submit('Submit', :disabled => disabled)
48
- buffer
49
- end.html_safe
50
- content
38
+ capture do
39
+ concat content_tag(:h3, "DIRECTIONS", :style => 'text-align: right; color:#FF0000;')
40
+ concat task.hit_description.html_safe
41
+ concat '<hr/>'.html_safe
42
+ concat(turkee_form_for(study, params) do |f|
43
+ capture do
44
+ concat f.label(:feedback, "Feedback?:")
45
+ concat f.text_area(:feedback, :rows => 3, :disabled => disabled)
46
+ concat f.label(:gold_response, "Enter the fourth word from your above feedback :")
47
+ concat f.text_field(:gold_response, :disabled => disabled)
48
+ concat f.hidden_field(:turkee_task_id, :value => task.id)
49
+ concat '<br/>'.html_safe
50
+ concat f.submit('Submit', :disabled => disabled)
51
+ end
52
+ end)
53
+ end
51
54
  end
52
55
  end
53
56
  end
@@ -0,0 +1,7 @@
1
+ class SurveysController < ApplicationController
2
+
3
+ def new
4
+
5
+ end
6
+
7
+ end
@@ -0,0 +1,3 @@
1
+ class Survey < ActiveRecord::Base
2
+ attr_accessible :answer
3
+ end
@@ -1,6 +1,5 @@
1
1
  Dummy::Application.routes.draw do
2
- resources :companies, :only => %w(new create)
3
- resources :projects, :only => %w(new create)
2
+ resources :surveys, :only => %w(new)
4
3
  get '/:controller/:action'
5
4
 
6
5
  # The priority is based upon order of creation:
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :survey do |s|
3
+ s.answer "The answer"
4
+ s.created_at Time.now
5
+ s.updated_at Time.now
6
+ end
7
+ end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Turkee::TurkeeFormHelper, :type => :helper do
4
- #include RSpec::Rails::HelperExampleGroup
5
4
  describe "mturk_url" do
6
5
  it "should return sandbox" do
7
6
  RTurk.stub(:sandbox?).and_return true
@@ -17,28 +16,60 @@ describe Turkee::TurkeeFormHelper, :type => :helper do
17
16
  before do
18
17
  @task = Factory(:turkee_task)
19
18
  RTurk.stub(:sandbox?).and_return true
19
+
20
+ helper.stub(:params).and_return({:assignmentId => '123456', :workerId => '987654'})
21
+ @study_form = helper.turkee_study
20
22
  end
21
23
 
22
- it "includes the description" do
23
- helper.stub(:params).and_return {}
24
- study_form = turkee_study
25
- study_form.should =~ /Test Desc/
26
- study_form.should =~ /feedback/
27
- study_form.should match /workersandbox.mturk.com/
24
+ it "includes the description, textarea" do
25
+ @study_form.should match(/Test Desc/)
26
+ @study_form.should match(/feedback/)
27
+ @study_form.should match(/textarea/)
28
+ @study_form.should match(/workersandbox.mturk.com/)
28
29
  end
29
30
 
30
- it "saves the assignmentId to a cookie for later retrieval" do
31
- helper.stub(:params).and_return({'assignmentId' => '123456'})
31
+ it "the form points to the sandbox" do
32
+ @study_form = turkee_study
33
+ @study_form.should match(/workersandbox.mturk.com/)
34
+ end
32
35
 
33
- helper.turkee_study
36
+ it "still includes the necessary assignmentId and workerId" do
37
+ @study_form.should match(/assignmentId/)
38
+ @study_form.should match(/workerId/)
39
+ end
34
40
 
41
+ end
42
+
43
+ describe "turkee_form_for" do
44
+ before do
45
+ @survey = Factory(:survey)
46
+ RTurk.stub(:sandbox?).and_return true
47
+
48
+ params = {:assignmentId => '123456', :workerId => '987654'}
49
+ @survey_form = helper.turkee_form_for(@survey, params) do |f|
50
+ f.text_field :answer
51
+ end
52
+ end
53
+
54
+ it "displays the passed in assignmentId and workerId " do
55
+ @survey_form.should match(/answer/)
56
+ @survey_form.should match(/type=\"text\"/)
57
+ @survey_form.should match(/assignmentId/)
58
+ @survey_form.should match(/workerId/)
59
+ end
60
+
61
+ it "the intial turkee_form_for saved the assignmentId and workerId to a cookie for later retrieval" do
35
62
  helper.cookies['assignmentId'].should == '123456'
63
+ helper.cookies['workerId'].should == '987654'
36
64
 
37
65
  # Subsequent requests should still return form fields for assignmentId
38
- helper.stub(:params).and_return({})
39
- study_form = helper.turkee_study
40
-
41
- study_form.should =~ /123456/
66
+ survey_form = helper.turkee_form_for(@survey, {}) do |f|
67
+ f.text_field :answer
68
+ end
69
+ survey_form.should match(/123456/)
70
+ survey_form.should match(/987654/)
71
+ survey_form.should match(/assignmentId/)
72
+ survey_form.should match(/workerId/)
42
73
  end
43
74
  end
44
75
  end
@@ -39,6 +39,8 @@ ActiveRecord::Schema.define(:version => 1) do
39
39
 
40
40
  create_table :surveys do |t|
41
41
  t.string :answer
42
+ t.datetime :created_at, :null => false
43
+ t.datetime :updated_at, :null => false
42
44
  end
43
45
 
44
46
  create_table :turkee_studies do |t|
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = %q{turkee}
6
- s.version = "2.0.0"
6
+ s.version = "2.0.1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = [%q{Jim Jones}]
10
- s.date = %q{2013-04-27}
10
+ s.date = %q{2013-05-14}
11
11
  s.description = %q{Turkee will help you to easily create usability studies, post HITs, and retrieve the user entered values from Mechanical Turk.}
12
12
  s.email = %q{jjones@aantix.com}
13
13
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turkee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-27 00:00:00.000000000 Z
12
+ date: 2013-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lockfile
@@ -176,9 +176,11 @@ files:
176
176
  - spec/dummy/app/assets/javascripts/application.js
177
177
  - spec/dummy/app/assets/stylesheets/application.css
178
178
  - spec/dummy/app/controllers/application_controller.rb
179
+ - spec/dummy/app/controllers/surveys_controller.rb
179
180
  - spec/dummy/app/helpers/application_helper.rb
180
181
  - spec/dummy/app/mailers/.gitkeep
181
182
  - spec/dummy/app/models/.gitkeep
183
+ - spec/dummy/app/models/survey.rb
182
184
  - spec/dummy/app/views/layouts/application.html.erb
183
185
  - spec/dummy/config.ru
184
186
  - spec/dummy/config/application.rb
@@ -206,6 +208,7 @@ files:
206
208
  - spec/dummy/public/favicon.ico
207
209
  - spec/dummy/script/rails
208
210
  - spec/dummy/tmp/cache/.gitkeep
211
+ - spec/factories/survey_factory.rb
209
212
  - spec/factories/turkee_task_factory.rb
210
213
  - spec/helpers/turkee_forms_helper_spec.rb
211
214
  - spec/models/turkee_study_spec.rb
@@ -233,7 +236,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
236
  version: '0'
234
237
  segments:
235
238
  - 0
236
- hash: 2965433502609428037
239
+ hash: 509377053887078608
237
240
  required_rubygems_version: !ruby/object:Gem::Requirement
238
241
  none: false
239
242
  requirements: