learn-co-curriculum / sinatra-mvc-file-structure Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
I usually flag issues with labs and lessons, but I just wanted to say this lab was really well done and the information in it is extremely helpful and easy to digest. Thank you!
The spec that tests Dog.all.count
returns different output each time rspec is run. See example below.
Failures:
1) ApplicationController Dog class can create a dog with attributes on initialization
Failure/Error: expect(Dog.all.count).to eq (1)
expected: 1
got: 3
(compared using ==)
# ./spec/controllers/application_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
Finished in 0.05782 seconds (files took 0.35458 seconds to load)
7 examples, 1 failure
Failed examples:
rspec ./spec/controllers/application_controller_spec.rb:5 # ApplicationController Dog class can create a dog with attributes on initialization
And once I run rspec again
Failures:
1) ApplicationController Dog class can create a dog with attributes on initialization
Failure/Error: expect(Dog.all.count).to eq (1)
expected: 1
got: 5
(compared using ==)
# ./spec/controllers/application_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
Finished in 0.0462 seconds (files took 0.34495 seconds to load)
7 examples, 1 failure
Failed examples:
rspec ./spec/controllers/application_controller_spec.rb:5 # ApplicationController Dog class can create a dog with attributes on initialization
The lesson text offers this explanation for the Gemfile.lock file: "The lock word is actually because it makes sure that only one thing is running bundle install at a time." This comes across as incorrect/misleading given that the purpose of the lock file is to document and enforce a specific working gem versions configuration.
The defined tests fail if the first defined test (it 'can create a dog with attributes on initialization') does not run first. If other tests run before this one there are leftover dogs in the DOGS array.
The easiest way to avoid the problem is to add the following line to the .rspec file:
--order defined
This makes sure the tests run in the order they have been defined in the spec and that the test suite passes (when the task has been solved correctly).
so let me disclaim this by saying that most people finished with lab without a problem but some were really hung up. there are no instructions, is purely test-driven which is fine but they've only see the whole "set an instance variable in the controller and render it in a view" thing once or twice and i don't think it was every discussed explicitly (i could be wrong!). So would be good to provide some basic instructions/a reminder about that instance variable -> view set-up.
Under subhead: "views directory":
"We've filled in the views for you to display the dog Ralph we just created in our controller action. Feel free to take a look."
Nothing of the sort has been filled out that I could find, and this is the first mention of Ralph. I Googled around and eventually figured out how to pass the last test on my own, but wasted a lot of time checking other lessons and trying to find these examples. Hadn't actually written any erb or incorporated MVCs at all to this point. Seems like the lesson's out of order or the order was changed at some point without the readme being updated to reflect that.
very slow loading.
Not sure what the point of this DOG
constant is –– it doesn't ever seem to be invoked. Perhaps a relic from a past version of the lab?
I honestly don't know if this is my fault but this works when I require 'rake' in my gemfile. I did run bundle install before issuing these commands. Is this a problem with my ruby environment setup?
12:38:31 activerecord-associations-intro
♥ rspec --fail-fast
/Users/yonk/Development/code/foo/activerecord-associations-intro/config/environment.rb:5:in require': cannot load such file -- rake (LoadError) from /Users/yonk/Development/code/foo/activerecord-associations-intro/config/environment.rb:5:in
<top (required)>'
from /Users/yonk/Development/code/foo/activerecord-associations-intro/spec/spec_helper.rb:3:in require_relative' from /Users/yonk/Development/code/foo/activerecord-associations-intro/spec/spec_helper.rb:3:in
<top (required)>'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in require' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in
block in requires='
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in each' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in
requires='
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:109:in block in process_options_into' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:108:in
each'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:108:in process_options_into' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:21:in
configure'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:101:in setup' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:88:in
run'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:73:in run' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:41:in
invoke'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/exe/rspec:4:in <top (required)>' from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/rspec:23:in
load'
from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/rspec:23:in <main>' from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in
eval'
from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `
♥ bundle exec rspec --fail-fast
/Users/yonk/Development/code/foo/activerecord-associations-intro/config/environment.rb:5:in require': cannot load such file -- rake (LoadError) from /Users/yonk/Development/code/foo/activerecord-associations-intro/config/environment.rb:5:in
<top (required)>'
from /Users/yonk/Development/code/foo/activerecord-associations-intro/spec/spec_helper.rb:3:in require_relative' from /Users/yonk/Development/code/foo/activerecord-associations-intro/spec/spec_helper.rb:3:in
<top (required)>'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in require' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in
block in requires='
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in each' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in
requires='
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:109:in block in process_options_into' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:108:in
each'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:108:in process_options_into' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:21:in
configure'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:101:in setup' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:88:in
run'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:73:in run' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:41:in
invoke'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/exe/rspec:4:in <top (required)>' from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/rspec:23:in
load'
from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/rspec:23:in <main>' from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in
eval'
from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `
/Users/yonk/Development/code/foo/activerecord-associations-intro/config/environment.rb:5:in require': cannot load such file -- rake (LoadError) from /Users/yonk/Development/code/foo/activerecord-associations-intro/config/environment.rb:5:in
<top (required)>'
from /Users/yonk/Development/code/foo/activerecord-associations-intro/spec/spec_helper.rb:3:in require_relative' from /Users/yonk/Development/code/foo/activerecord-associations-intro/spec/spec_helper.rb:3:in
<top (required)>'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in require' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in
block in requires='
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in each' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in
requires='
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:109:in block in process_options_into' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:108:in
each'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:108:in process_options_into' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:21:in
configure'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:101:in setup' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:88:in
run'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:73:in run' from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:41:in
invoke'
from /Users/yonk/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.3.0/exe/rspec:4:in <top (required)>' from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/rspec:23:in
load'
from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/rspec:23:in <main>' from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in
eval'
from /Users/yonk/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `
♥ rvm -v
rvm 1.26.11 (latest) by Wayne E. Seguin [email protected], Michal Papis [email protected] [https://rvm.io/]
12:39:51 activerecord-associations-intro
♥ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
12:39:56 activerecord-associations-intro
♥
Hi. This lesson is really good, but I noticed that there was a test missing. There should be a test that checks for whether you can change the dog's breed. Something like this:
describe ApplicationController do
describe 'Dog class' do
...
# Maybe put this between the tests that check for changing the dog's name and age:
it 'can change dog breed' do
@dog = Dog.new("rudolph", "mastiff", 2)
@dog.breed = "beagle"
expect(@dog.breed).to eq("beagle")
end
...
end
end
Thanks as always for looking into this!
Sdcrouse
This repo includes code for a very basic sample app.
The README works entirely without that code. However, in theory, it'd be nice if this README included a working sample app and referenced it's source code within the README. We'd have to instruct the student to clone the lab and play and explore the local files as they go through the README.
Refer to Readme for content to be included
due 9/17/2015 - using content from other repos here
application_controller_spec.rb
should read something like
it 'can change dog age' do
@dog = Dog.new("rudolph", "mastiff", 2)
@dog.age = 3
expect(@dog.age).to eq(3)
end
currently reads
it 'can change dog age' do
@dog = Dog.new("rudolph", "mastiff", 2)
@dog. name = "bessie"
expect(@dog.name).to eq("bessie")
end
Last test in spec requires 'breed' to be 'dalmation' (it is hard-coded this way) so students will always have to instantiate a Dog class with the breed set to 'dalmation.' Otherwise test will fail.
View file extension should be index.html.erb and not index.erb
So this lab is really quite confusing. I created a Dog class as a model that inherited from model.rb
... assuming that's what they were looking for... anyway I got the tests to pass, and when I looked at the solution code after submitting I saw that they created an @dog
instance var to pass to the erb file from ApplicationController
... but this is a poorly designed lesson. I have a little background in rails and MVC pattern so I figured they were looking for a model (though there is no test nor hint that they want to create an instance to pass to the view here)... some better wording is needed to explain this random request for a simple Dog class... at least a hint that it should be a model or something. I can imagine a lot of students being totally lost on this, or creating code that passes but doesn't necessarily serve the purpose of introducing the idea of passing data from a model to controller to view...
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.