require 'spec_helper' require 'xiv_lodestone/lodestone_character_disciple' describe XIVLodestone::DiscipleList do let (:valid) { XIVLodestone::DiscipleList.new(Nokogiri::HTML(open(LOCAL_FILE)).xpath("//table[@class='class_list']/tr/td")) } let (:invalid) { XIVLodestone::DiscipleList.new(Nokogiri::HTML(open(INVALID_FILE)).xpath("//table[@class='class_list']/tr/td")) } it 'Dump json of disciples' do expect(valid.to_json).to eq("{\"gladiator\":\"#\",\"pugilist\":\"#\",\"marauder\":\"#\",\"lancer\":\"#\",\"archer\":\"#\",\"rogue\":\"#\",\"conjurer\":\"#\",\"thaumaturge\":\"#\",\"arcanist\":\"#\",\"dark_knight\":\"#\",\"machinist\":\"#\",\"astrologian\":\"#\",\"carpenter\":\"#\",\"blacksmith\":\"#\",\"armorer\":\"#\",\"goldsmith\":\"#\",\"leatherworker\":\"#\",\"weaver\":\"#\",\"alchemist\":\"#\",\"culinarian\":\"#\",\"miner\":\"#\",\"botanist\":\"#\",\"fisher\":\"#\"}") expect(invalid.to_json).to eq("{}") expect(valid.to_json.is_a?(String)).to eq(true) end it 'method missing check' do expect(valid.method_missing(:rogue).is_a?(XIVLodestone::DiscipleList::Disciple)).to eql(true) expect(valid.method_missing(:goldsmith).is_a?(XIVLodestone::DiscipleList::Disciple)).to eql(true) expect(valid.method_missing(:arcanist).is_a?(XIVLodestone::DiscipleList::Disciple)).to eql(true) end it 'Build a disciple' do d = XIVLodestone::DiscipleList::Disciple.new("Rogue", 1, 0, 300, "http") expect(d.name).to eq("Rogue") expect(d.level).to eq(1) expect(d.current_exp).to eq(0) expect(d.total_exp).to eq(300) expect(d.icon_url).to eq("http") expect(d.next_level).to eq(300) end end