<commit_before>require 'spec_helper'

describe Pivotal::Story do

  before(:each) do
    @story = Pivotal::Story.new :resource => pivotal_api.resource["projects"][1]["stories"][1]
  end
  
  it "should be connected to the story resource" do
    @story.resource.url.should == "https://www.pivotaltracker.com/services/v3/projects/1/stories/1"
  end
  
  [:id, :story_type, :url, :estimate, :current_state,
     :description, :name, :requested_by, :owned_by,
     :created_at, :accepted_at, :labels].map(&:to_s).each do |method|
    it "should have an accessor method for #{method}" do
      @story.methods.should include(method)
    end
    
    it "should include #{method} in the list of valid attributes" do
      @story.class.attributes.should include(method)
    end
  it "should specify whether the story is a feature" do
    @story.xml = story_type "feature"

    @story.should be_a_feature
    @story.should_not be_a_bug
    @story.should_not be_a_chore
    @story.should_not be_a_release
  end
  
  it "should specify whether the story is a bug" do
    @story.xml = story_type "bug"

    @story.should_not be_a_feature
    @story.should be_a_bug
    @story.should_not be_a_chore
    @story.should_not be_a_release
  end
  
  it "should specify whether the story is a chore" do
    @story.xml = story_type "chore"

    @story.should_not be_a_feature
    @story.should_not be_a_bug
    @story.should be_a_chore
    @story.should_not be_a_release<commit_msg>Helper method in story_spec, adding checks on attribute methods<commit_after>require 'spec_helper'

describe Pivotal::Story do

  def story_type(type = "feature")
    Factory(:story, :story_type => type)
  end
  
  before(:each) do
    @story = Pivotal::Story.new :resource => pivotal_api.resource["projects"][1]["stories"][1]
  end
  
  it "should be connected to the story resource" do
    @story.resource.url.should == "https://www.pivotaltracker.com/services/v3/projects/1/stories/1"
  end
  
  [:id, :story_type, :url, :estimate, :current_state,
     :description, :name, :requested_by, :owned_by,
     :created_at, :accepted_at, :labels].map(&:to_s).each do |method|
    it "should have an accessor method for #{method}" do
      @story.methods.should include(method)
    end
    
    it "should include #{method} in the list of valid attributes" do
      @story.class.attributes.should include(method)
    end
    
    it "should return the proper value when #{method} is called" do
      @story.xml = Factory(:story, method.to_sym => "Test Result")
      @story.send(method).should == "Test Result"
    end
  end
  
  it "should specify whether the story is a feature" do
    @story.xml = story_type "feature"

    @story.should be_a_feature
    @story.should_not be_a_bug
    @story.should_not be_a_chore
    @story.should_not be_a_release
  end
  
  it "should specify whether the story is a bug" do
    @story.xml = story_type "bug"

    @story.should_not be_a_feature
    @story.should be_a_bug
    @story.should_not be_a_chore
    @story.should_not be_a_release
  end
  
  it "should specify whether the story is a chore" do
    @story.xml = story_type "chore"

    @story.should_not be_a_feature
    @story.should_not be_a_bug
    @story.should be_a_chore
    @story.should_not be_a_release
{'fraction_non_alphanumeric': 0.10440906307409675, 'fraction_numerical': 0.003061849357011635, 'mean_word_length': 3.506206896551724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 7}, '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': '7430553', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1112, 'n_words': 293}