<commit_before>require 'minitest/spec'
require 'minitest/autorun'
require 'unirest'
require 'awesome_print'
require 'ostruct'

describe 'Speakers API' do
  SPEAKERS_ALL_URI = 'http://localhost:5000/speakers'
  res = nil 
  
  before do
    res = Unirest.get SPEAKERS_ALL_URI, 
                      headers:{ 'Accept' => "application/json" }

  end
  
  it 'should return a 200 response' do
    res.code.must_be :==, 200
    res.headers[:content_type].must_be :==, 'application/json; charset=utf-8'
  end
  
  it 'should return all speakers' do
    speakers = res.body
    speakers.wont_be_nil
    speakers.wont_be_empty    
    speakers.length.must_be :==, 3
    ap speakers
    
    speaker3 = OpenStruct.new(speakers[2])
    speaker3.company.must_be :==, 'Talkola'
    speaker3.firstName.must_be :==, 'Christensen'
    speaker3.lastName.must_be :==, 'Fisher'
    speaker3.tags.must_be :==, ['Java', 'Spring',
      'Maven', 'REST']

    ap speaker3
  end
end<commit_msg>Used expect-style matchers and objects.<commit_after>require 'minitest/spec'
require 'minitest/autorun'
require 'unirest'
require 'awesome_print'
require 'ostruct'

describe 'Speakers API' do
  SPEAKERS_ALL_URI = 'http://localhost:5000/speakers'
  
  before do
    @res = Unirest.get SPEAKERS_ALL_URI, 
                      headers:{ 'Accept' => "application/json" }

  end
  
  it 'should return a 200 response' do
    expect(@res.code).must_equal 200
    expect(@res.headers[:content_type]).must_equal 'application/json; charset=utf-8'
  end
  
  it 'should return all speakers' do
    speakers = @res.body
    speakers.wont_be_nil
    speakers.wont_be_empty    
    expect(speakers.length).must_equal 3
    ap speakers
    
    speaker3 = OpenStruct.new(speakers[2])
    expect(speaker3.company).must_equal 'Talkola'
    expect(speaker3.firstName).must_equal 'Christensen'
    expect(speaker3.lastName).must_equal 'Fisher'
    expect(speaker3.tags).must_equal ['Java', 'Spring', 'Maven', 'REST']

    ap speaker3
  end
end
{'fraction_non_alphanumeric': 0.11855927963981991, 'fraction_numerical': 0.01900950475237619, 'mean_word_length': 3.3859649122807016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5405999', 'n_tokens_mistral': 722, 'n_tokens_neox': 697, 'n_words': 143}