<commit_before>require 'spec_helper'

describe Fars::BaseObjectSerializer do
  before { Book = Struct.new(:isbn, :title, :author, :price, :count) }
  let(:book) { Book.new('isbn1', 'title1', 'author1', 10, nil) }
  let(:book2) { Book.new('isbn2', 'title2', 'author2', 20.0, 4) }
  let(:book3) { Book.new('isbn3', 'title3', 'author3', 30.5, 7) }
  let(:books) { [book, book2, book3] }

  it 'serializes any object with appropriate serializer' do
    BookSerializer.new(book).as_json.should ==
      { book: { isbn: 'isbn1', title: 'title1', author: 'author1', price: '10.00', count: 0 } }
  end

  it 'includes only requested fields' do<commit_msg>Minor fix in tests, do not redefine constant Book<commit_after>require 'spec_helper'

describe Fars::BaseObjectSerializer do
  before(:all) { Book = Struct.new(:isbn, :title, :author, :price, :count) }
  let(:book) { Book.new('isbn1', 'title1', 'author1', 10, nil) }
  let(:book2) { Book.new('isbn2', 'title2', 'author2', 20.0, 4) }
  let(:book3) { Book.new('isbn3', 'title3', 'author3', 30.5, 7) }
  let(:books) { [book, book2, book3] }

  it 'serializes any object with appropriate serializer' do
    BookSerializer.new(book).as_json.should ==
      { book: { isbn: 'isbn1', title: 'title1', author: 'author1', price: '10.00', count: 0 } }
  end

  it 'includes only requested fields' do
{'fraction_non_alphanumeric': 0.18413173652694612, 'fraction_numerical': 0.04640718562874251, 'mean_word_length': 4.594142259414226, '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': '4998853', 'n_tokens_mistral': 517, 'n_tokens_neox': 488, 'n_words': 129}