<commit_before>require 'spec_helper'

describe Verso::Occupation do
  before do
    @raw_occupation = { "id" => 2966,
                        "title" => "Agricultural Commodity Broker",
                        "pathway" => { "title" => "Agriculture" } }
    @occupation = Verso::Occupation.new(@raw_occupation)
  end

  it 'should respond to #title' do
    @occupation.title.should eq("Agricultural Commodity Broker")
  end

  it 'should respond to #id' do
    @occupation.id.should eq(2966)
  end

  it 'should respond to #pathway' do
    @occupation.pathway.title.should eq("Agriculture")
  end

  it 'should respond to #related_courses' do
    Net::HTTP.
      should_receive(:get).
      with('api.cteresource.org', "/occupations/2966", 80).
      and_return(
        JSON.pretty_generate(
          :occupation => {
            :id => 2966,
            :title => "Agricultural Commodity Broker",
            :related_courses => [
              { :code => "8050",
                :title => "Agricultural Education--Preparation" }
            ]
          }
        )
      )
      @occupation.related_courses.first.code.should eq("8050")
  end
end<commit_msg>Add Verso::Occupation examples<commit_after>require 'spec_helper'

describe Verso::Occupation do
  use_vcr_cassette :record => :new_episodes

  before(:each) do
    @occ = Verso::OccupationList.new(:text => "golf").first.occupations.first
  end

  describe '#description' do
    it 'responds' do
      @occ.should respond_to(:description)
    end

    it 'is a String' do
      @occ.description.should be_a(String)
    end

    it 'is HTML' do
      @occ.description.should match(/<\/.+>/)
    end
  end

  describe '#id' do
    it 'responds' do
      @occ.should respond_to(:id)
    end

    it 'is a Fixnum' do
      @occ.id.should be_a(Fixnum)
    end

    it 'is not the same as #object_id' do
      @occ.id.should_not == @occ.object_id
    end
  end

  describe '#pathway' do
    it 'responds' do
      @occ.should respond_to(:pathway)
    end

    it 'is a Verso::Pathway' do
      @occ.pathway.should be_a(Verso::Pathway)
    end
  end

  describe '#preparations' do
    it 'responds' do
      @occ.should respond_to(:preparations)
    end

    it 'is an Array' do
      @occ.preparations.should be_a(Array)
    end

    it 'is an Array of Strings' do
      @occ.preparations.first.should be_a(String)
    end
  end

  describe '#related_courses' do
    it 'responds' do
      @occ.should respond_to(:related_courses)
    end

    it 'is an Array' do
      @occ.related_courses.should be_a(Array)
    end

    it 'is an Array of Verso::Course objects' do
      @occ.related_courses.first.should be_a(Verso::Course)
    end
  end

  describe '#title' do
    it 'responds' do
      @occ.should respond_to(:title)
    end

    it 'is a String' do
      @occ.title.should be_a(String)
    end
  end
end
{'fraction_non_alphanumeric': 0.11370770840599931, 'fraction_numerical': 0.009068712940355772, 'mean_word_length': 2.386068476977568, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 16, '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': '6504172', 'n_tokens_mistral': 1021, 'n_tokens_neox': 964, 'n_words': 242}