learn-co-students / pokemon-scraper-v-000 Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Student reported that there was a conflict between nokogiri 1.6.8 and a common library installed on mac called xz. Solution was to update to Nokogiri v. 1.8.2
I am helping a student with a failing test, and the best I could have come up with was I found that file pokemon_spec.rb
was updated on Solutions branch but wasn't merged?
Would someone mind merging that code in please and thank you.
require_relative "spec_helper"
describe "Pokemon" do
before do
@db = SQLite3::Database.new(':memory:')
@sql_runner = SQLRunner.new(@db)
@sql_runner.execute_schema_migration_sql
scraper = Scraper.new(@db)
scraper.scrape
end
let(:pokemon) {Pokemon.new(1, "Pikachu", "fire", @db)}
describe ".initialize" do
it 'is initialized with a name, type and db' do
expect(pokemon).to respond_to(:id)
expect(pokemon).to respond_to(:name)
expect(pokemon).to respond_to(:type)
expect(pokemon).to respond_to(:db)
end
end
describe ".save" do
it 'saves an instance of a pokemon with the correct id' do
charmander_from_db = @db.execute("SELECT * FROM pokemon WHERE name = 'Charmander'")
expect(charmander_from_db).to eq([[4, "Charmander", "Fire"]])
end
end
describe ".find" do
it 'finds a pokemon from the database' do
charmander_from_db = Pokemon.find(4, @db)
expect(charmander_from_db).to eq([[4, "Charmander", "Fire"]])
end
end
describe "BONUS" do
# The find method creates a new Pokemon after selecting their row from the database by their id number.
let(:pikachu){Pokemon.find(25, @db)}
let(:magikarp){Pokemon.find(129, @db)}
before do
@sql_runner.execute_create_hp_column
end
it "knows that a pokemon have a default hp of 60" do
expect(@db.execute("SELECT hp FROM pokemon WHERE id = 1").flatten.first).to eq(60)
end
# So Ian and you have decided to battle. He chose Magikarp (rookie mistake), and you chose Pikachu.
# He used splash. It wasn't very effective. It did one damage.
it "alters Pikachu's hp to 59" do
Pokemon.alter_hp(59,25,@db)
expect(@db.execute("SELECT hp FROM pokemon WHERE id = 25").flatten.first).to eq(59)
end
# Now we alter Magikarp's hp
it "alters Magikarp's hp" do
Pokemon.alter_hp(0,129,@db)
expect(@db.execute("SELECT hp FROM pokemon WHERE id = 129").flatten.first).to eq(0)
end
end
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.