<commit_before>require 'spec_helper'

describe TrainStationsController do

  use_vcr_cassette :record => :new_episodes  

  before :each do
    # We want to seed all the train stations...
    TrainStation.create :name => 'Kenwick'
    TrainStation.create :name => 'Perth'
  end

  let(:content_body) { response.decoded_body.response }

  describe 'listing train stations' do

    before :each do
      get :index, :version => 1
    end

    it 'should have the correct status code' do
      response.should be_successful
    end

    it 'should include the station url' do
      content_body.each do |item|
        item.url.should be_present
      end
    end

    it 'should be the correct object types' do
      response.should be_collection_resource
    end

    it 'should return compact stations' do
      content_body.should be_all { |r| r.compact }
    end

    it 'should be ordered by name' do
      names = content_body.map { |r| r.name }
      names.should == names.sort
    end

    it 'should not include train times' do
      content_body.should be_all { |r| r.times.nil? }
    end

    it 'should be json' do
      response.content_type.should == 'application/json'
    end
<commit_msg>Tweaks to the train stations controller spec<commit_after>require 'spec_helper'

describe TrainStationsController do

  use_vcr_cassette :record => :new_episodes  

  before :each do
    # We want to seed all the train stations...
    TrainStation.create :name => 'Kenwick', :lat => 10, :lng => 10
    TrainStation.create :name => 'Perth',   :lat => 20, :lng => 20
  end

  let(:content_body) { response.decoded_body.response }

  describe 'listing train stations' do

    context 'basic listings' do

      before :each do
        get :index, :version => 1
      end

      it 'should have the correct status code' do
        response.should be_successful
      end

      it 'should include the station url' do
        content_body.each do |item|
          item.url.should be_present
        end
      end

      it 'should be the correct object types' do
        response.should be_collection_resource
      end

      it 'should return compact stations' do
        content_body.should be_all { |r| r.compact }
      end

      it 'should be ordered by name' do
        names = content_body.map { |r| r.name }
        names.should == names.sort
      end

      it 'should not include train times' do
        content_body.should be_all { |r| r.times.nil? }
      end

      it 'should be json' do
        response.content_type.should == 'application/json'
      end

    end

    it 'should let you filter to items near a location' do
      get :index, :version => 1, :near => '10,10'
      content_body.should have(1).station
      content_body.first.name.should == 'Kenwick'
    end

{'fraction_non_alphanumeric': 0.08282538544281104, 'fraction_numerical': 0.005736823234134099, 'mean_word_length': 2.4487021013597032, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '6714111', 'n_tokens_mistral': 867, 'n_tokens_neox': 817, 'n_words': 285}