learn-co-students / diy-json-serializer-lab-v-000 Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Hi, I had a weird bug where I had everything exactly as the solution did, but when I clicked the Next Product link, the next product info would flicker for a sec and revert back to the previous item.
I have no idea how it worked, but I was able to solve this by copying and pasting a Gemfile.lock file from the readme of the previous lab.
https://github.com/kevinYCKim33/diy-json-serializer-ruby-v-000
Even though it was working correctly in the browser, a student was getting this error:
1) Products requires javascript to go next Failure/Error: expect(page).to have_content p2.name expected to find text "Test Product 2" in "Flatiron Widgets Store Next Product Test Product 0 2 This is a test description with more text than should be there." # ./spec/features/product_feature_spec.rb:15:in `block (2 levels) in <top (required)>'
Adding js:true here got it to pass:
it 'requires javascript to go next' , js:true do ....
I worked with two tech coaches on these issues. None of us could figure out why these errors were occurring.
Solution: commented out lines 12 - 15 and 22 - 27 of product_feature_spec.rb
One thing that helped the code was adding 'event' in the third line of the <script>:
$(".js-next").on("click", function (event) {
and finish with 'event.preventDefault();
like so:
$(".js-next").attr("data-id", data["id"]);
});
event.preventDefault();
Using example from prior README doesn't update page correctly with next product (the same issue occurring in the README as well).
I bumped into an error in the product_feature_spec.rb file, specifically under the 'loads next product without page refresh' test. Upon checking, the AJAX feature is functional and works well in the browser, without any errors in the console.
Here is a snippet of the error message:
1) Products loads next product without page refresh
Failure/Error: expect(page).to have_content p2.name
Capybara::Poltergeist::JavascriptError:
One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).
SyntaxError: Expected an identifier but found 'nextId' instead
SyntaxError: Expected an identifier but found 'nextId' instead
Upon following the error message to set js_errors: false, I added the following lines of code:
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {js_errors: false})
end
into rails_helper.rb after the Capybara.javascript_driver = :poltergeist
line.
In terms of overall development practice, I'm not sure if it's advisable to ignore JS errors this way, but there didn't seem to be any errors that I could detect, so I went forward with this.
expected integer in JSON return body.
in spec/controllers/products_controller.rb line 45
expect(body["inventory"]).to eq product.inventory
body["inventory'] should equate to a stringified version of product.inventory
expect(body["inventory"]).to eq product.inventory.to_s
resolves this issue
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.