<commit_before>require 'spec_helper'

describe CucumberFM::Feature do
  it "should store path for file" do
    path = "some_path_to_my.feature"
    feature = CucumberFM::Feature.new(path)
    feature.path.should == path
  end

  it "should load file content" do
    feature = CucumberFM::Feature.new('spec/data/cucumber_f_m/feature/first.feature')
    feature.raw.should == %q{Feature: Edit feature content
  To update requirement for project
  product owner
  should be able to change feature content

  Scenario: Inserting Background

  Scenario: Inserting Scenario when cursor on text field
}
  end

  describe "PARSING" do
    before(:each) do
      subject { CucumberFM::Feature.new('some_path') }
      subject.stub(:raw).and_return(FEATURE_CONTENT)
      cfm = mock(:cfm)
      filter = CucumberFM::TagFilter.new('')
      cfm.stub(:filter).and_return(filter)
      subject.stub(:cfm).and_return(cfm)
    end
    it "should parse feature info" do
      CucumberFM::FeatureElement::Info.should_receive(:new).with(subject, INFO_CONTENT)
      subject.info
    end
    it "should parse background" do
      CucumberFM::FeatureElement::Background.should_receive(:new).with(subject, BACKGROUND_CONTENT)
      subject.background
    end
# SKIP bug in rspec
#    it "should parse scenarios" do
#      CucumberFM::FeatureElement::Scenario.should_receive(:new).with(subject, SCENARIO_CONTENT)
#      subject.scenarios
#    end
#    it "should parse scenario outlines" do
#      CucumberFM::FeatureElement::ScenarioOutline.should_receive(:new).with(subject, SCENARIO_OUTLINE)
#      subject.scenarios
#    end
    
    it "should parse two scenarios" do
      subject.should have(2).scenarios
    end
    context "TAGS" do
      specify { should have(2).tags }
      specify { subject.tags.should == %w(@tag @mc) }
    end
  end

  describe "WRITING" do
    # TODO
    #    it "should compact file content"
    it "should write content to file" do
      @feature = CucumberFM::Feature.new('tmp/some.feature')
      @feature.stub!(:raw).and_return("Some Content")
      @feature.save
      File.open('tmp/some.feature', 'r') { |stream| stream.read.should == "Some Content" }
<commit_msg>formattin<commit_after>require 'spec_helper'

describe CucumberFM::Feature do
  it "should store path for file" do
    path = "some_path_to_my.feature"
    feature = CucumberFM::Feature.new(path)
    feature.path.should == path
  end

  it "should load file content" do
    feature = CucumberFM::Feature.new('spec/data/cucumber_f_m/feature/first.feature')
    feature.raw.should == %q{Feature: Edit feature content
  To update requirement for project
  product owner
  should be able to change feature content

  Scenario: Inserting Background

  Scenario: Inserting Scenario when cursor on text field
}
  end

  describe "PARSING" do
    before(:each) do
      subject { CucumberFM::Feature.new('some_path') }
      subject.stub(:raw).and_return(FEATURE_CONTENT)
      cfm = mock(:cfm)
      filter = CucumberFM::TagFilter.new('')
      cfm.stub(:filter).and_return(filter)
      subject.stub(:cfm).and_return(cfm)
    end
    it "should parse feature info" do
      CucumberFM::FeatureElement::Info.should_receive(:new).with(subject, INFO_CONTENT)
      subject.info
    end
    it "should parse background" do
      CucumberFM::FeatureElement::Background.should_receive(:new).with(subject, BACKGROUND_CONTENT)
      subject.background
    end
    
# SKIP bug in rspec
#    it "should parse scenarios" do
#      CucumberFM::FeatureElement::Scenario.should_receive(:new).with(subject, SCENARIO_CONTENT)
#      subject.scenarios
#    end
#    it "should parse scenario outlines" do
#      CucumberFM::FeatureElement::ScenarioOutline.should_receive(:new).with(subject, SCENARIO_OUTLINE)
#      subject.scenarios
#    end
    
    it "should parse two scenarios" do
      subject.should have(2).scenarios
    end
    context "TAGS" do
      specify { should have(2).tags }
      specify { subject.tags.should == %w(@tag @mc) }
    end
  end

  describe "WRITING" do
    # TODO
    #    it "should compact file content"
    it "should write content to file" do
      @feature = CucumberFM::Feature.new('tmp/some.feature')
      @feature.stub!(:raw).and_return("Some Content")
      @feature.save
      File.open('tmp/some.feature', 'r') { |stream| stream.read.should == "Some Content" }

{'fraction_non_alphanumeric': 0.10991527364323334, 'fraction_numerical': 0.0009159606136936112, 'mean_word_length': 3.4754098360655736, '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': '6698794', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1372, 'n_words': 326}