cloudfactory 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +7 -0
- data/lib/cf.rb +4 -1
- data/lib/cf/badge.rb +59 -0
- data/lib/cf/cli.rb +6 -0
- data/lib/cf/cli/line.rb +185 -132
- data/lib/cf/cli/line_yaml_validator.rb +7 -30
- data/lib/cf/cli/production.rb +63 -9
- data/lib/cf/gold_standard.rb +74 -0
- data/lib/cf/help.txt +67 -0
- data/lib/cf/human_worker.rb +45 -49
- data/lib/cf/line.rb +51 -1
- data/lib/cf/run.rb +10 -10
- data/lib/cf/station.rb +111 -29
- data/lib/cf/test_run.rb +66 -0
- data/lib/cf/version.rb +1 -1
- data/spec/account_spec.rb +1 -1
- data/spec/badges/station_1.html +135 -0
- data/spec/badges_spec.rb +288 -0
- data/spec/gold_standard_spec.rb +179 -0
- data/spec/gold_standards.csv +2 -0
- data/spec/google_translate_robot_spec.rb +1 -1
- data/spec/human_worker_spec.rb +1 -65
- data/spec/line_spec.rb +6 -39
- data/spec/robot_worker_spec.rb +1 -1
- data/spec/run_spec.rb +9 -7
- data/spec/stat_badge_spec.rb +45 -0
- data/spec/test_run_spec.rb +105 -0
- metadata +264 -218
- data/spec/badge_spec.rb +0 -88
| @@ -0,0 +1,135 @@ | |
| 1 | 
            +
            <!DOCTYPE html>
         | 
| 2 | 
            +
            <html lang="en">
         | 
| 3 | 
            +
            <meta charset="UTF-8">
         | 
| 4 | 
            +
            <head>
         | 
| 5 | 
            +
              <style>
         | 
| 6 | 
            +
              body {
         | 
| 7 | 
            +
                margin: 0 auto;
         | 
| 8 | 
            +
                padding: 0;
         | 
| 9 | 
            +
                color: #000;
         | 
| 10 | 
            +
                width: 960px;
         | 
| 11 | 
            +
                background: #302D2F;
         | 
| 12 | 
            +
                font-family: georgia;
         | 
| 13 | 
            +
              }
         | 
| 14 | 
            +
              #wrapper {
         | 
| 15 | 
            +
                background: #FFF;
         | 
| 16 | 
            +
                position: relative;
         | 
| 17 | 
            +
                padding:0 10px;
         | 
| 18 | 
            +
              }
         | 
| 19 | 
            +
              #header {
         | 
| 20 | 
            +
                border-bottom: solid 1px grey;
         | 
| 21 | 
            +
                padding: 10px;
         | 
| 22 | 
            +
                height: 50px;
         | 
| 23 | 
            +
                text-align: center;
         | 
| 24 | 
            +
                font-size: 36px;
         | 
| 25 | 
            +
                font-weight: bold;
         | 
| 26 | 
            +
                color: #666666;
         | 
| 27 | 
            +
              }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              ul{
         | 
| 30 | 
            +
                list-style: decimal;
         | 
| 31 | 
            +
              }
         | 
| 32 | 
            +
              input[type=text] {
         | 
| 33 | 
            +
                width:660px;
         | 
| 34 | 
            +
                margin:4px;
         | 
| 35 | 
            +
                font-size: 12px;
         | 
| 36 | 
            +
                height:40px;
         | 
| 37 | 
            +
              }
         | 
| 38 | 
            +
              input[type=submit]{
         | 
| 39 | 
            +
                width: 160px;
         | 
| 40 | 
            +
                height: 40px;
         | 
| 41 | 
            +
                border: solid 1px black;
         | 
| 42 | 
            +
              }
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              #gender, #age, #location {
         | 
| 45 | 
            +
                font-weight: bold;
         | 
| 46 | 
            +
                color: #A9BED4;
         | 
| 47 | 
            +
              }
         | 
| 48 | 
            +
              a{
         | 
| 49 | 
            +
                color: #007EB9;
         | 
| 50 | 
            +
              }
         | 
| 51 | 
            +
              #footer{
         | 
| 52 | 
            +
                border-top: solid 1px grey;
         | 
| 53 | 
            +
                padding: 10px;
         | 
| 54 | 
            +
                text-align: center;
         | 
| 55 | 
            +
              }
         | 
| 56 | 
            +
              </style>
         | 
| 57 | 
            +
            </head>
         | 
| 58 | 
            +
            <body>
         | 
| 59 | 
            +
            <div id="wrapper">
         | 
| 60 | 
            +
              <div id="header">
         | 
| 61 | 
            +
                Be a Match Maker
         | 
| 62 | 
            +
              </div>
         | 
| 63 | 
            +
              <div id="instructions">
         | 
| 64 | 
            +
                <h2>Instructions:</h2>
         | 
| 65 | 
            +
                <ul>
         | 
| 66 | 
            +
                  <li><img src="{{image_url}}" /></li>
         | 
| 67 | 
            +
                  <li>Then enter the url of hottest date found</li>
         | 
| 68 | 
            +
                </ul>
         | 
| 69 | 
            +
              </div>
         | 
| 70 | 
            +
             | 
| 71 | 
            +
              <div id="station_2_form">
         | 
| 72 | 
            +
                <div id = "field-panel">
         | 
| 73 | 
            +
                  <p>
         | 
| 74 | 
            +
                    <form>
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                      <label>Gender</label><br />
         | 
| 77 | 
            +
                      <select id="gender_option" name="output[gender]">
         | 
| 78 | 
            +
                        <option value="Male">Male</option>
         | 
| 79 | 
            +
                        <option value="Female">Female</option>
         | 
| 80 | 
            +
                      </select>
         | 
| 81 | 
            +
                      <br />
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                      <label>How rich?</label><br />
         | 
| 84 | 
            +
                      <select id="rich_option" name="output[rich]">
         | 
| 85 | 
            +
                        <option value="1">1</option>
         | 
| 86 | 
            +
                        <option value="2">2</option>
         | 
| 87 | 
            +
                        <option value="3">3</option>
         | 
| 88 | 
            +
                      </select>
         | 
| 89 | 
            +
                      <br />
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                      <label>How Kind?</label><br />
         | 
| 92 | 
            +
                      <select id="kind_option" name="output[kind]">
         | 
| 93 | 
            +
                        <option value="1">1</option>
         | 
| 94 | 
            +
                        <option value="2">2</option>
         | 
| 95 | 
            +
                        <option value="3">3</option>
         | 
| 96 | 
            +
                      </select>
         | 
| 97 | 
            +
                      <br />
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                      <label>How Attractive?</label><br />
         | 
| 100 | 
            +
                      <select id="attractive_option" name="output[attractive]">
         | 
| 101 | 
            +
                        <option value="1">1</option>
         | 
| 102 | 
            +
                        <option value="2">2</option>
         | 
| 103 | 
            +
                        <option value="3">3</option>
         | 
| 104 | 
            +
                      </select>
         | 
| 105 | 
            +
                      <br />
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                      <input type="submit" value="submit" />
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                    </form>
         | 
| 110 | 
            +
                  </p>
         | 
| 111 | 
            +
                </div>
         | 
| 112 | 
            +
              </div>
         | 
| 113 | 
            +
              <div id="footer">
         | 
| 114 | 
            +
                Copyright(c)
         | 
| 115 | 
            +
              </div>
         | 
| 116 | 
            +
            </div>
         | 
| 117 | 
            +
            </body>
         | 
| 118 | 
            +
            </html>
         | 
| 119 | 
            +
             | 
| 120 | 
            +
            <!-- scripts -->
         | 
| 121 | 
            +
            <script>
         | 
| 122 | 
            +
            $(document).ready(function() {
         | 
| 123 | 
            +
                var url = $("#instructions a").attr('href');
         | 
| 124 | 
            +
                var splitted_url = url.split("/");
         | 
| 125 | 
            +
                var gender = splitted_url[splitted_url.length - 3];
         | 
| 126 | 
            +
                var new_gender = gender.toLowerCase() == "male" ? "female" : "male";
         | 
| 127 | 
            +
                splitted_url[splitted_url.length - 3] = new_gender;
         | 
| 128 | 
            +
                var age = splitted_url[splitted_url.length - 1];
         | 
| 129 | 
            +
                age = decodeURI(age).split(" ")[0];
         | 
| 130 | 
            +
                splitted_url[splitted_url.length - 1] = age;
         | 
| 131 | 
            +
                var new_url = splitted_url.join("/");
         | 
| 132 | 
            +
                $("#instructions a").attr('href',new_url);
         | 
| 133 | 
            +
            });
         | 
| 134 | 
            +
             | 
| 135 | 
            +
            </script>
         | 
    
        data/spec/badges_spec.rb
    ADDED
    
    | @@ -0,0 +1,288 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe CF::Badge do
         | 
| 4 | 
            +
              context "add a badge" do
         | 
| 5 | 
            +
                it "should add a badge to the station in DSL way" do
         | 
| 6 | 
            +
                  WebMock.allow_net_connect!
         | 
| 7 | 
            +
                  title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 8 | 
            +
                  sleep 1
         | 
| 9 | 
            +
                  line = CF::Line.create(title,"Digitization") do |l|
         | 
| 10 | 
            +
                    CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 11 | 
            +
                    CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                  station = CF::Station.create({:line => line, :type => "work"}) do |s|
         | 
| 14 | 
            +
                    CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 15 | 
            +
                    CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 16 | 
            +
                      CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 17 | 
            +
                      CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 18 | 
            +
                      CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                    @gold_standard = CF::GoldStandard.new({ :line => line,
         | 
| 21 | 
            +
                      :station => s,
         | 
| 22 | 
            +
                      :name => "easy_#{Time.now}",
         | 
| 23 | 
            +
                      :input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
         | 
| 24 | 
            +
                      :expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
         | 
| 25 | 
            +
                      })
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                      @badge = CF::Badge.create({
         | 
| 28 | 
            +
                        :line => line,
         | 
| 29 | 
            +
                        :station => s,
         | 
| 30 | 
            +
                        :name           => "Tomb Digitizer",
         | 
| 31 | 
            +
                        :description    => "This badge qualifies you to work on tomb digitization tasks.",
         | 
| 32 | 
            +
                        :max_badges     => 100,
         | 
| 33 | 
            +
                        :gold_standards => ["#{@gold_standard.settings[:name]}"],
         | 
| 34 | 
            +
                        :test_attributes =>
         | 
| 35 | 
            +
                        {
         | 
| 36 | 
            +
                          :type => "default",
         | 
| 37 | 
            +
                          :retries => 10,
         | 
| 38 | 
            +
                          :pass_percentage => 100,
         | 
| 39 | 
            +
                          :check_manually => true
         | 
| 40 | 
            +
                        }
         | 
| 41 | 
            +
                        })
         | 
| 42 | 
            +
                      end
         | 
| 43 | 
            +
                    end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                    it "should add a badge to the station in plain ruby way" do
         | 
| 46 | 
            +
                      WebMock.allow_net_connect!
         | 
| 47 | 
            +
                      title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 48 | 
            +
                      sleep 1
         | 
| 49 | 
            +
                      @line = CF::Line.create(title,"Digitization") do |l|
         | 
| 50 | 
            +
                        CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 51 | 
            +
                        CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 52 | 
            +
                      end
         | 
| 53 | 
            +
                      station = CF::Station.create({:line => @line, :type => "work"}) do |s|
         | 
| 54 | 
            +
                        CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 55 | 
            +
                        CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 56 | 
            +
                          CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 57 | 
            +
                          CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 58 | 
            +
                          CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 59 | 
            +
                        end
         | 
| 60 | 
            +
                        @gold_standard = CF::GoldStandard.new({ :line => @line,
         | 
| 61 | 
            +
                          :station => s,
         | 
| 62 | 
            +
                          :name => "easy",
         | 
| 63 | 
            +
                          :input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
         | 
| 64 | 
            +
                          :expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
         | 
| 65 | 
            +
                          })
         | 
| 66 | 
            +
                        end
         | 
| 67 | 
            +
                        badge = CF::Badge.new({
         | 
| 68 | 
            +
                          :name           => "Tomb Digitizer",
         | 
| 69 | 
            +
                          :description    => "This badge qualifies you to work on tomb digitization tasks.",
         | 
| 70 | 
            +
                          :max_badges     => 100,
         | 
| 71 | 
            +
                          :gold_standards => ["#{@gold_standard.settings[:name]}"],
         | 
| 72 | 
            +
                          :test_attributes =>
         | 
| 73 | 
            +
                          {
         | 
| 74 | 
            +
                            :type => "default",
         | 
| 75 | 
            +
                            :retries => 10,
         | 
| 76 | 
            +
                            :pass_percentage => 100,
         | 
| 77 | 
            +
                            :check_manually => false
         | 
| 78 | 
            +
                          }
         | 
| 79 | 
            +
                          })
         | 
| 80 | 
            +
                          @line.stations.first.badges badge
         | 
| 81 | 
            +
                          @line.stations.first.badges.first.settings["name"].should eq(badge.settings[:name])
         | 
| 82 | 
            +
                          @line.stations.first.badges.first.settings['test']["form"].should eql({"_type"=>"TaskForm", "form_fields"=>[{"label"=>"First Name", "field_type"=>"short_answer", "required"=>true, "position"=>1}, {"label"=>"Middle Name", "field_type"=>"short_answer", "position"=>2}, {"label"=>"Last Name", "field_type"=>"short_answer", "required"=>true, "position"=>3}], "instruction"=>"Describe", "title"=>"Enter text from a business card image"})
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                        end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
             | 
| 87 | 
            +
                        it "should add a badge to the station with test form defined in DSL way" do
         | 
| 88 | 
            +
                          WebMock.allow_net_connect!
         | 
| 89 | 
            +
                          title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 90 | 
            +
                          sleep 1
         | 
| 91 | 
            +
                          line = CF::Line.create(title,"Digitization") do |l|
         | 
| 92 | 
            +
                            CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 93 | 
            +
                            CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 94 | 
            +
                          end
         | 
| 95 | 
            +
                          station = CF::Station.create({:line => line, :type => "work"}) do |s|
         | 
| 96 | 
            +
                            CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 97 | 
            +
                            CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 98 | 
            +
                              CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 99 | 
            +
                              CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 100 | 
            +
                              CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 101 | 
            +
                            end
         | 
| 102 | 
            +
                            @gold_standard = CF::GoldStandard.new({ :line => line,
         | 
| 103 | 
            +
                              :station => s,
         | 
| 104 | 
            +
                              :name => "easy_#{Time.now}",
         | 
| 105 | 
            +
                              :input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
         | 
| 106 | 
            +
                              :expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
         | 
| 107 | 
            +
                              })
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                              @badge = CF::Badge.new({
         | 
| 110 | 
            +
                                :line => line,
         | 
| 111 | 
            +
                                :station => s,
         | 
| 112 | 
            +
                                :name           => "Tomb Digitizer",
         | 
| 113 | 
            +
                                :description    => "This badge qualifies you to work on tomb digitization tasks.",
         | 
| 114 | 
            +
                                :max_badges     => 100,
         | 
| 115 | 
            +
                                :gold_standards => ["#{@gold_standard.settings[:name]}"],
         | 
| 116 | 
            +
                                :test_attributes =>
         | 
| 117 | 
            +
                                {
         | 
| 118 | 
            +
                                  :type => "default",
         | 
| 119 | 
            +
                                  :retries => 10,
         | 
| 120 | 
            +
                                  :pass_percentage => 100,
         | 
| 121 | 
            +
                                  :check_manually => true,
         | 
| 122 | 
            +
                                  :form_attributes => {
         | 
| 123 | 
            +
                                    :title => "Tombfinder Test",
         | 
| 124 | 
            +
                                    :instruction => "Look at the image of the tomb in the url given and answer the asked questions.",
         | 
| 125 | 
            +
                                    :type => "TaskForm",
         | 
| 126 | 
            +
                                    :form_fields_attributes =>
         | 
| 127 | 
            +
                                    [
         | 
| 128 | 
            +
                                      { "label" => "Last Name", "field_type" => "radio_button", 'option_values' => ["LEIGH", "IRVING", "GERTRUDE"] },
         | 
| 129 | 
            +
                                      { "label" => "Lizzie Year of Birth", "field_type" => "radio_button", 'option_values' => ["1873", "1933", "1896"] }
         | 
| 130 | 
            +
                                    ]
         | 
| 131 | 
            +
                                  }
         | 
| 132 | 
            +
                                }
         | 
| 133 | 
            +
                                })
         | 
| 134 | 
            +
                              end
         | 
| 135 | 
            +
                              line.stations.first.badges.first.settings[:test_attributes][:form_attributes][:type].should eql("TaskForm")
         | 
| 136 | 
            +
                              line.stations.first.badges.first.settings[:test_attributes][:form_attributes][:form_fields_attributes].should eql([{"label"=>"Last Name", "field_type"=>"radio_button", "option_values"=>["LEIGH", "IRVING", "GERTRUDE"]}, {"label"=>"Lizzie Year of Birth", "field_type"=>"radio_button", "option_values"=>["1873", "1933", "1896"]}])
         | 
| 137 | 
            +
                            end
         | 
| 138 | 
            +
             | 
| 139 | 
            +
             | 
| 140 | 
            +
             | 
| 141 | 
            +
                            it "should add a badge to the station with customtaskform as a badge testform form defined in DSL way" do
         | 
| 142 | 
            +
                              WebMock.allow_net_connect!
         | 
| 143 | 
            +
                              title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 144 | 
            +
                              sleep 1
         | 
| 145 | 
            +
                              line = CF::Line.create(title,"Digitization") do |l|
         | 
| 146 | 
            +
                                CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 147 | 
            +
                                CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 148 | 
            +
                              end
         | 
| 149 | 
            +
                              station = CF::Station.create({:line => line, :type => "work"}) do |s|
         | 
| 150 | 
            +
                                CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 151 | 
            +
                                CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 152 | 
            +
                                  CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 153 | 
            +
                                  CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 154 | 
            +
                                  CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 155 | 
            +
                                end
         | 
| 156 | 
            +
                                @gold_standard = CF::GoldStandard.new({ :line => line,
         | 
| 157 | 
            +
                                  :station => s,
         | 
| 158 | 
            +
                                  :name => "easy_#{Time.now}",
         | 
| 159 | 
            +
                                  :input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
         | 
| 160 | 
            +
                                  :expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
         | 
| 161 | 
            +
                                  })
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                                  @badge = CF::Badge.new({
         | 
| 164 | 
            +
                                    :line => line,
         | 
| 165 | 
            +
                                    :station => s,
         | 
| 166 | 
            +
                                    :name           => "Tomb Digitizer",
         | 
| 167 | 
            +
                                    :description    => "This badge qualifies you to work on tomb digitization tasks.",
         | 
| 168 | 
            +
                                    :max_badges     => 100,
         | 
| 169 | 
            +
                                    :gold_standards => ["#{@gold_standard.settings[:name]}"],
         | 
| 170 | 
            +
                                    :test_attributes =>
         | 
| 171 | 
            +
                                    {
         | 
| 172 | 
            +
                                      :type => "default",
         | 
| 173 | 
            +
                                      :retries => 10,
         | 
| 174 | 
            +
                                      :pass_percentage => 100,
         | 
| 175 | 
            +
                                      :check_manually => true,
         | 
| 176 | 
            +
                                      :form_attributes => {
         | 
| 177 | 
            +
                                        :title => "Custom TestForm",
         | 
| 178 | 
            +
                                        :instruction => "Look at the image of the tomb in the url given and answer the asked questions.",
         | 
| 179 | 
            +
                                        :type => "CustomTaskForm",
         | 
| 180 | 
            +
                                        :file =>"./spec/badges/station_1.html"
         | 
| 181 | 
            +
                                      }
         | 
| 182 | 
            +
                                    }
         | 
| 183 | 
            +
                                    })
         | 
| 184 | 
            +
                                  end
         | 
| 185 | 
            +
                                  line.stations.first.badges.first.settings[:test_attributes][:form_attributes][:type].should eql("CustomTaskForm")
         | 
| 186 | 
            +
                                end
         | 
| 187 | 
            +
             | 
| 188 | 
            +
             | 
| 189 | 
            +
                                it "should add a badge with defined custom_task_form as a badge test form in plain ruby way " do
         | 
| 190 | 
            +
                                  WebMock.allow_net_connect!
         | 
| 191 | 
            +
                                  title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 192 | 
            +
                                  sleep 1
         | 
| 193 | 
            +
                                  @line = CF::Line.create(title,"Digitization") do |l|
         | 
| 194 | 
            +
                                    CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 195 | 
            +
                                    CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 196 | 
            +
                                  end
         | 
| 197 | 
            +
                                  station = CF::Station.create({:line => @line, :type => "work"}) do |s|
         | 
| 198 | 
            +
                                    CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 199 | 
            +
                                    CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 200 | 
            +
                                      CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 201 | 
            +
                                      CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 202 | 
            +
                                      CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 203 | 
            +
                                    end
         | 
| 204 | 
            +
                                    @gold_standard = CF::GoldStandard.new({ :line => @line,
         | 
| 205 | 
            +
                                      :station => s,
         | 
| 206 | 
            +
                                      :name => "easy",
         | 
| 207 | 
            +
                                      :input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
         | 
| 208 | 
            +
                                      :expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
         | 
| 209 | 
            +
                                      })
         | 
| 210 | 
            +
                                    end
         | 
| 211 | 
            +
                                    badge = CF::Badge.new({
         | 
| 212 | 
            +
                                      :name           => "Tomb Digitizer",
         | 
| 213 | 
            +
                                      :description    => "This badge qualifies you to work on tomb digitization tasks.",
         | 
| 214 | 
            +
                                      :max_badges     => 100,
         | 
| 215 | 
            +
                                      :gold_standards => ["#{@gold_standard.settings[:name]}"],
         | 
| 216 | 
            +
                                      :test_attributes =>
         | 
| 217 | 
            +
                                      {
         | 
| 218 | 
            +
                                        :type => "default",
         | 
| 219 | 
            +
                                        :retries => 10,
         | 
| 220 | 
            +
                                        :pass_percentage => 100,
         | 
| 221 | 
            +
                                        :check_manually => false,
         | 
| 222 | 
            +
                                        :form_attributes => {
         | 
| 223 | 
            +
                                          :title => "Custom TestForm in plain ruby way",
         | 
| 224 | 
            +
                                          :instruction => "Look at the image of the tomb in the url given and answer the asked questions.",
         | 
| 225 | 
            +
                                          :type => "CustomTaskForm",
         | 
| 226 | 
            +
                                          :file =>"./spec/badges/station_1.html"
         | 
| 227 | 
            +
                                        }
         | 
| 228 | 
            +
                                      }
         | 
| 229 | 
            +
                                      })
         | 
| 230 | 
            +
                                      @line.stations.first.badges badge
         | 
| 231 | 
            +
                                      @line.stations.first.badges.first.settings["test"]["form"]["_type"].should eql("CustomTaskForm")
         | 
| 232 | 
            +
                                      @line.stations.first.badges.first.settings["test"]["form"]["raw_html"].present?.should eql(true)
         | 
| 233 | 
            +
                                    end
         | 
| 234 | 
            +
             | 
| 235 | 
            +
             | 
| 236 | 
            +
                                    it "should add a badge with defined task_form as a badge test form in plain ruby way " do
         | 
| 237 | 
            +
                                      WebMock.allow_net_connect!
         | 
| 238 | 
            +
                                      title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 239 | 
            +
                                      sleep 1
         | 
| 240 | 
            +
                                      @line = CF::Line.create(title,"Digitization") do |l|
         | 
| 241 | 
            +
                                        CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 242 | 
            +
                                        CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 243 | 
            +
                                      end
         | 
| 244 | 
            +
                                      station = CF::Station.create({:line => @line, :type => "work"}) do |s|
         | 
| 245 | 
            +
                                        CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 246 | 
            +
                                        CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 247 | 
            +
                                          CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 248 | 
            +
                                          CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 249 | 
            +
                                          CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 250 | 
            +
                                        end
         | 
| 251 | 
            +
                                        @gold_standard = CF::GoldStandard.new({ :line => @line,
         | 
| 252 | 
            +
                                          :station => s,
         | 
| 253 | 
            +
                                          :name => "easy",
         | 
| 254 | 
            +
                                          :input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
         | 
| 255 | 
            +
                                          :expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
         | 
| 256 | 
            +
                                          })
         | 
| 257 | 
            +
                                        end
         | 
| 258 | 
            +
                                        badge = CF::Badge.new({
         | 
| 259 | 
            +
                                          :name           => "Tomb Digitizer",
         | 
| 260 | 
            +
                                          :description    => "This badge qualifies you to work on tomb digitization tasks.",
         | 
| 261 | 
            +
                                          :max_badges     => 100,
         | 
| 262 | 
            +
                                          :gold_standards => ["#{@gold_standard.settings[:name]}"],
         | 
| 263 | 
            +
                                          :test_attributes =>
         | 
| 264 | 
            +
                                          {
         | 
| 265 | 
            +
                                            :type => "default",
         | 
| 266 | 
            +
                                            :retries => 10,
         | 
| 267 | 
            +
                                            :pass_percentage => 100,
         | 
| 268 | 
            +
                                            :check_manually => false,
         | 
| 269 | 
            +
                                            :form_attributes => {
         | 
| 270 | 
            +
                                              :title => "Tombfinder Test plain ruby way",
         | 
| 271 | 
            +
                                              :instruction => "Look at the image of the tomb in the url given and answer the asked questions.",
         | 
| 272 | 
            +
                                              :type => "TaskForm",
         | 
| 273 | 
            +
                                              :form_fields_attributes =>
         | 
| 274 | 
            +
                                              [
         | 
| 275 | 
            +
                                                { "label" => "Last Name", "field_type" => "radio_button", 'option_values' => ["LEIGH", "IRVING", "GERTRUDE"] },
         | 
| 276 | 
            +
                                                { "label" => "Lizzie Year of Birth", "field_type" => "radio_button", 'option_values' => ["1873", "1933", "1896"] }
         | 
| 277 | 
            +
                                              ]
         | 
| 278 | 
            +
                                            }
         | 
| 279 | 
            +
                                          }
         | 
| 280 | 
            +
                                          })
         | 
| 281 | 
            +
                                          @line.stations.first.badges badge
         | 
| 282 | 
            +
                                          @line.stations.first.badges.first.settings["test"]["form"]["_type"].should eql("TaskForm")
         | 
| 283 | 
            +
                                          @line.stations.first.badges.first.settings["test"]["form"]["form_fields"].should eql([{"label"=>"Last Name", "field_type"=>"radio_button", "option_values"=>["LEIGH", "IRVING", "GERTRUDE"]}, {"label"=>"Lizzie Year of Birth", "field_type"=>"radio_button", "option_values"=>["1873", "1933", "1896"]}])
         | 
| 284 | 
            +
             | 
| 285 | 
            +
                                        end
         | 
| 286 | 
            +
             | 
| 287 | 
            +
                                      end
         | 
| 288 | 
            +
                                    end
         | 
| @@ -0,0 +1,179 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe CF::GoldStandard do
         | 
| 4 | 
            +
              context "add a glodstandard to a line" do
         | 
| 5 | 
            +
                it "should add gold standard to a line in plain ruby way way" do
         | 
| 6 | 
            +
                  WebMock.allow_net_connect!
         | 
| 7 | 
            +
                  title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 8 | 
            +
                  sleep 1
         | 
| 9 | 
            +
                  line = CF::Line.create(title,"Digitization") do |l|
         | 
| 10 | 
            +
                    CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 11 | 
            +
                    CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 12 | 
            +
                    CF::Station.create({:line => l, :type => "work"}) do |s|
         | 
| 13 | 
            +
                      CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 14 | 
            +
                      CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 15 | 
            +
                        CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 16 | 
            +
                        CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 17 | 
            +
                        CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 18 | 
            +
                      end
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                  gold_standard = CF::GoldStandard.new({:name => "easy", :input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},:expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}})
         | 
| 22 | 
            +
                  line.gold_standards gold_standard
         | 
| 23 | 
            +
                  line.gold_standards.first.settings[:name].should eql("easy")
         | 
| 24 | 
            +
                  line.gold_standards.first.settings[:input].should eql({"image_url"=>"http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"})
         | 
| 25 | 
            +
                  line.gold_standards.first.settings[:expected_output].should eql({"first_name"=>{"value"=>"John"}, "last_name"=>{"value"=>"Lennon"}, "company"=>{"value"=>"Sprout"}})
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                it "should add gold standard to a line in Block DSL way" do
         | 
| 29 | 
            +
                  WebMock.allow_net_connect!
         | 
| 30 | 
            +
                  title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 31 | 
            +
                  sleep 1
         | 
| 32 | 
            +
                  line = CF::Line.create(title,"Digitization") do |l|
         | 
| 33 | 
            +
                    CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 34 | 
            +
                    CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 35 | 
            +
                    CF::Station.create({:line => l, :type => "work"}) do |s|
         | 
| 36 | 
            +
                      CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 37 | 
            +
                      CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 38 | 
            +
                        CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 39 | 
            +
                        CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 40 | 
            +
                        CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 41 | 
            +
                      end
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                  gold_standard = CF::GoldStandard.new({ :line => line,
         | 
| 45 | 
            +
                    :name => "gold_standard_#{Time.new.strftime('%Y%b%d-%H%M%S')}",
         | 
| 46 | 
            +
                    :input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
         | 
| 47 | 
            +
                    :expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
         | 
| 48 | 
            +
                    })
         | 
| 49 | 
            +
                    line.gold_standards.should include(gold_standard)
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  it "should add gold standard to a line from a file in Block DSL way" do
         | 
| 53 | 
            +
                    WebMock.allow_net_connect!
         | 
| 54 | 
            +
                    title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 55 | 
            +
                    sleep 1
         | 
| 56 | 
            +
                    line = CF::Line.create(title,"Digitization") do |l|
         | 
| 57 | 
            +
                      CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 58 | 
            +
                      CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 59 | 
            +
                      CF::Station.create({:line => l, :type => "work"}) do |s|
         | 
| 60 | 
            +
                        CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 61 | 
            +
                        CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 62 | 
            +
                          CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 63 | 
            +
                          CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 64 | 
            +
                          CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 65 | 
            +
                        end
         | 
| 66 | 
            +
                      end
         | 
| 67 | 
            +
                    end
         | 
| 68 | 
            +
                    gold_standard = CF::GoldStandard.new({:line => line,:file =>"./spec/gold_standards.csv" })
         | 
| 69 | 
            +
                    line.gold_standards.should include(gold_standard)
         | 
| 70 | 
            +
                  end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                  it "should add gold standard to a line from a file in plain ruby way" do
         | 
| 73 | 
            +
                    WebMock.allow_net_connect!
         | 
| 74 | 
            +
                    title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 75 | 
            +
                    sleep 1
         | 
| 76 | 
            +
                    line = CF::Line.create(title,"Digitization") do |l|
         | 
| 77 | 
            +
                      CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 78 | 
            +
                      CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 79 | 
            +
                    end
         | 
| 80 | 
            +
                    station = CF::Station.new({:type => "work"})
         | 
| 81 | 
            +
                    line.stations station
         | 
| 82 | 
            +
                    gold_standard = CF::GoldStandard.new({:file =>"./spec/gold_standards.csv" })
         | 
| 83 | 
            +
                    line.gold_standards gold_standard
         | 
| 84 | 
            +
                    line.gold_standards.first.settings["name"].should eql("gold_standard_1")
         | 
| 85 | 
            +
                    line.gold_standards.first.settings["input"].should eql({"Website"=>"aaple.com"})
         | 
| 86 | 
            +
                    line.gold_standards.first.settings["expected_output"].present?.should eql(true)
         | 
| 87 | 
            +
                  end
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                context "should add goldstandard to a station" do
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  it "should add gold standard to the station in block DSL way" do
         | 
| 93 | 
            +
                    WebMock.allow_net_connect!
         | 
| 94 | 
            +
                    title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 95 | 
            +
                    sleep 1
         | 
| 96 | 
            +
                    line = CF::Line.create(title,"Digitization") do |l|
         | 
| 97 | 
            +
                      CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 98 | 
            +
                      CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 99 | 
            +
                    end
         | 
| 100 | 
            +
                    station = CF::Station.create({:line => line, :type => "work"}) do |s|
         | 
| 101 | 
            +
                      CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 102 | 
            +
                      CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 103 | 
            +
                        CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 104 | 
            +
                        CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 105 | 
            +
                        CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 106 | 
            +
                      end
         | 
| 107 | 
            +
                      @gold_standard = CF::GoldStandard.new({ :line => line,
         | 
| 108 | 
            +
                        :station => s,
         | 
| 109 | 
            +
                        :name => "easy",
         | 
| 110 | 
            +
                        :input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
         | 
| 111 | 
            +
                        :expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
         | 
| 112 | 
            +
                        })
         | 
| 113 | 
            +
                      end
         | 
| 114 | 
            +
                      line.stations.first.gold_standards.should include(@gold_standard)
         | 
| 115 | 
            +
                    end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
             | 
| 118 | 
            +
                    it "should add gold standard to the station in plain ruby way" do
         | 
| 119 | 
            +
                      WebMock.allow_net_connect!
         | 
| 120 | 
            +
                      title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 121 | 
            +
                      sleep 1
         | 
| 122 | 
            +
                      line = CF::Line.create(title,"Digitization") do |l|
         | 
| 123 | 
            +
                        CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 124 | 
            +
                        CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 125 | 
            +
                      end
         | 
| 126 | 
            +
                      station = CF::Station.new({:type => "work"})
         | 
| 127 | 
            +
                      line.stations station
         | 
| 128 | 
            +
                      gold_standard = CF::GoldStandard.new({
         | 
| 129 | 
            +
                        :name => "easy",
         | 
| 130 | 
            +
                        :input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
         | 
| 131 | 
            +
                        :expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
         | 
| 132 | 
            +
                        })
         | 
| 133 | 
            +
                        line.stations.first.gold_standards gold_standard
         | 
| 134 | 
            +
                        line.stations.first.gold_standards.first.settings[:name].should eql("easy")
         | 
| 135 | 
            +
                        line.stations.first.gold_standards.first.settings[:input].should eql({"image_url"=>"http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"})
         | 
| 136 | 
            +
                        line.stations.first.gold_standards.first.settings[:expected_output].should eql({"first_name"=>{"value"=>"John"}, "last_name"=>{"value"=>"Lennon"}, "company"=>{"value"=>"Sprout"}})
         | 
| 137 | 
            +
                      end
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                      it "should add gold standard to the station from a file in block DSL way" do
         | 
| 140 | 
            +
                        WebMock.allow_net_connect!
         | 
| 141 | 
            +
                        title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 142 | 
            +
                        sleep 1
         | 
| 143 | 
            +
                        line = CF::Line.create(title,"Digitization") do |l|
         | 
| 144 | 
            +
                          CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 145 | 
            +
                          CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 146 | 
            +
                        end
         | 
| 147 | 
            +
                        station = CF::Station.create({:line => line, :type => "work"}) do |s|
         | 
| 148 | 
            +
                          CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
         | 
| 149 | 
            +
                          CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
         | 
| 150 | 
            +
                            CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
         | 
| 151 | 
            +
                            CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
         | 
| 152 | 
            +
                            CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
         | 
| 153 | 
            +
                          end
         | 
| 154 | 
            +
                          @gold_standard = CF::GoldStandard.create({ :line => line,
         | 
| 155 | 
            +
                            :station => s,
         | 
| 156 | 
            +
                            :file =>"./spec/gold_standards.csv"
         | 
| 157 | 
            +
                            })
         | 
| 158 | 
            +
                          end
         | 
| 159 | 
            +
                          line.stations.first.gold_standards.should include(@gold_standard)
         | 
| 160 | 
            +
                        end
         | 
| 161 | 
            +
             | 
| 162 | 
            +
                        it "should add gold standard to a station from a file in plain ruby way" do
         | 
| 163 | 
            +
                          WebMock.allow_net_connect!
         | 
| 164 | 
            +
                          title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
         | 
| 165 | 
            +
                          sleep 1
         | 
| 166 | 
            +
                          line = CF::Line.create(title,"Digitization") do |l|
         | 
| 167 | 
            +
                            CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
         | 
| 168 | 
            +
                            CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
         | 
| 169 | 
            +
                          end
         | 
| 170 | 
            +
                          station = CF::Station.new({:type => "work"})
         | 
| 171 | 
            +
                          line.stations station
         | 
| 172 | 
            +
                          gold_standard = CF::GoldStandard.new({:file =>"./spec/gold_standards.csv" })
         | 
| 173 | 
            +
                          line.stations.first.gold_standards gold_standard
         | 
| 174 | 
            +
                          line.stations.first.gold_standards.first.settings["name"].should eql("gold_standard_1")
         | 
| 175 | 
            +
                          line.stations.first.gold_standards.first.settings["input"].should eql({"Website"=>"aaple.com"})
         | 
| 176 | 
            +
                          line.stations.first.gold_standards.first.settings["expected_output"].present?.should eql(true)
         | 
| 177 | 
            +
                        end
         | 
| 178 | 
            +
                      end
         | 
| 179 | 
            +
                    end
         |