<commit_before># coding: utf-8
require "ld/form/item"
require "ld/form/option"
require "uri"

describe "LD::Form::Option", "#label" do

  before :all do
    @label = "a label of an option"
    @option = LD::Form::Option.new(@label)
  end

  it "ラベルを返す" do
    expect(@option.label).to eq @label
  end

end

describe "LD::Form::Option", "#url" do

  before :each do
    @label = "a label of an option"
    @url = "http://example.com/a/b/1"
    @new_url= "http://example.com/a/b/2"
    
    @option = LD::Form::Option.new(@label, @url)
  end

  it "URIオブジェクトを返す" do
    expect(@option.url.is_a?(URI)).to be true
  end

  it "コンストラクタで指定したURLを返す" do
    expect(@option.url.to_s).to eq @url
  end

  it "引数にURLを指定することで、URLを変更できる" do
    @option.url(@new_url)
    expect(@option.url.to_s).to eq @new_url
  end

end<commit_msg>LD::Form::Option の仕様に #parents / #add_parents を追加<commit_after># coding: utf-8
require "ld/form"
require "ld/form/item"
require "ld/form/option"
require "uri"

describe "LD::Form::Option", "#label" do

  before :all do
    @label = "a label of an option"
    @option = LD::Form::Option.new(@label)
  end

  it "ラベルを返す" do
    expect(@option.label).to eq @label
  end

end

describe "LD::Form::Option", "#url" do

  before :each do
    @label = "a label of an option"
    @url = "http://example.com/a/b/1"
    @new_url= "http://example.com/a/b/2"
    
    @option = LD::Form::Option.new(@label, @url)
  end

  it "URIオブジェクトを返す" do
    expect(@option.url.is_a?(URI)).to be true
  end

  it "コンストラクタで指定したURLを返す" do
    expect(@option.url.to_s).to eq @url
  end

  it "引数にURLを指定することで、URLを変更できる" do
    @option.url(@new_url)
    expect(@option.url.to_s).to eq @new_url
  end

end

describe LD::Form::Option, "#add_parent" do

  before :each do
    @form = LD::Form.new("new form")
    @item_a = LD::Form::Item.new(@form, "A")
    @item_b = LD::Form::Item.new(@form, "B")    
    @option = LD::Form::Option.new("option a")
  end

  it "その選択肢を持つ設問を追加できる" do
    expect(@option.parents.length).to eq 0
    @option.add_parent(@item_a)
    expect(@option.parents.length).to eq 1
    @option.add_parent(@item_b)
    expect(@option.parents.length).to eq 2
  end

  it "重複した設問は追加できない" do
    expect(@option.parents.length).to eq 0
    @option.add_parent(@item_a)
    expect(@option.parents.length).to eq 1
    @option.add_parent(@item_a)
    expect(@option.parents.length).to eq 1
  end  
  
end

describe LD::Form::Option, "#parents" do
  before :each do
    @form = LD::Form.new("new form")
    @item_a = LD::Form::Item.new(@form, "A")
    @item_b = LD::Form::Item.new(@form, "B")    
    @option = LD::Form::Option.new("option a")
  end

  it "その選択肢をもつ設問のリストを返す" do
    expect(@option.parents.length).to eq 0
    @option.add_parent(@item_a)
    expect(@option.parents.length).to eq 1
  end

  it "返り値の方はArrayのサブクラス" do
    expect(@option.parents.is_a?(Array)).to be true
  end
end
{'fraction_non_alphanumeric': 0.16470588235294117, 'fraction_numerical': 0.004844290657439446, 'mean_word_length': 3.3149253731343284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7015976', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1204, 'n_words': 249}