<commit_before>require 'spec_helper'
require 'nasdaq_scraper/result'

describe NasdaqScraper::Result do
	let(:result) { NasdaqScraper::Result.new(4351.03,73.73) }
	it 'have accessor to index' do
		result.index.should eq 4351.03
	end
	it 'have accessor to change' do
		result.change.should eq 73.73
	end
	it 'can be converted to string' do
		result.to_str.should eq "NASDAQ: Index(4351.03), Change(73.73)"
	end
	it 'can be converted to json' do
		result.to_json.should eq '{"index":4351.03,"change":73.73}'
	end
	it 'can be converted to empty json when invalid' do
		NasdaqScraper::Result.new.to_json.should eq "{}"
	end
	it 'can validate itself' do
		result.should be_valid
		NasdaqScraper::Result.new(nil,nil).should_not be_valid
	end
end<commit_msg>Group invalid result into a variable<commit_after>require 'spec_helper'
require 'nasdaq_scraper/result'

describe NasdaqScraper::Result do
	let(:result) { NasdaqScraper::Result.new(4351.03,73.73) }
	let(:invalid_result) { NasdaqScraper::Result.new }
	it 'have accessor to index' do
		result.index.should eq 4351.03
	end
	it 'have accessor to change' do
		result.change.should eq 73.73
	end
	it 'can be converted to string' do
		result.to_str.should eq "NASDAQ: Index(4351.03), Change(73.73)"
	end
	it 'can be converted to json' do
		result.to_json.should eq '{"index":4351.03,"change":73.73}'
	end
	it 'can be converted to empty json when invalid' do
		invalid_result.to_json.should eq "{}"
	end
	it 'can validate itself' do
		result.should be_valid
		invalid_result.should_not be_valid
	end
end
{'fraction_non_alphanumeric': 0.1093143596377749, 'fraction_numerical': 0.0517464424320828, 'mean_word_length': 4.6875, 'pattern_counts': {'":': 4, '<': 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': '3499341', 'n_tokens_mistral': 638, 'n_tokens_neox': 573, 'n_words': 160}