Sha256: bca24ea5b461ca5fd0e7d164ccfd16a9f4645c5aecced09be494496c973a97df

Contents?: true

Size: 1.23 KB

Versions: 27

Compression:

Stored size: 1.23 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))


describe RTurk::AnswerParser do
  
  before(:all) do
    @answer =  <<-XML
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;QuestionFormAnswers xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd"&gt;
&lt;Answer&gt;
&lt;QuestionIdentifier&gt;tweet&#91;content&#93;&lt;/QuestionIdentifier&gt;
&lt;FreeText&gt;This is my tweet!&lt;/FreeText&gt;
&lt;/Answer&gt;
&lt;Answer&gt;
&lt;QuestionIdentifier&gt;tweet&#91;time&#93;&lt;/QuestionIdentifier&gt;
&lt;FreeText&gt;12345678&lt;/FreeText&gt;
&lt;/Answer&gt;
&lt;Answer&gt;
&lt;QuestionIdentifier&gt;Submit&lt;/QuestionIdentifier&gt;
&lt;FreeText&gt;Submit&lt;/FreeText&gt;
&lt;/Answer&gt;
&lt;/QuestionFormAnswers&gt;
XML
  end
  
  it "should parse a answer" do
    RTurk::AnswerParser.parse(@answer).to_hash.should == {"Submit"=>"Submit", "tweet[content]"=>"This is my tweet!", "tweet[time]" => "12345678"}
  end

	it "should parse an answer into a param hash" do
		hash = RTurk::AnswerParser.parse(@answer).to_hash
		RTurk::Parser.new.normalize_nested_params(hash).should == {"Submit"=>"Submit", "tweet"=> {"content" => "This is my tweet!", "time" => "12345678"}}
	end

  
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
rturk-2.12.1 spec/parsers/answer_parser_spec.rb
rturk-2.12.0 spec/parsers/answer_parser_spec.rb
rturk-2.11.3 spec/parsers/answer_parser_spec.rb
rturk-2.11.2 spec/parsers/answer_parser_spec.rb
rturk-2.11.1 spec/parsers/answer_parser_spec.rb
rturk-2.11.0 spec/parsers/answer_parser_spec.rb
rturk-2.10.3 spec/parsers/answer_parser_spec.rb
rturk-2.10.2 spec/parsers/answer_parser_spec.rb
rturk-2.10.1 spec/parsers/answer_parser_spec.rb
rturk-2.10.0 spec/parsers/answer_parser_spec.rb
rturk-2.9.0 spec/parsers/answer_parser_spec.rb
rturk-2.8.0 spec/parsers/answer_parser_spec.rb
rturk-2.7.0 spec/parsers/answer_parser_spec.rb
rturk-2.6.0 spec/parsers/answer_parser_spec.rb
rturk-2.5.2 spec/parsers/answer_parser_spec.rb
rturk-2.5.0 spec/parsers/answer_parser_spec.rb
rturk-2.4.1 spec/parsers/answer_parser_spec.rb
rturk-2.4.0 spec/parsers/answer_parser_spec.rb
rturk-2.3.6 spec/parsers/answer_parser_spec.rb
rturk-2.3.5 spec/parsers/answer_parser_spec.rb