Giter VIP home page Giter VIP logo

rack-responses-lab's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rack-responses-lab's Issues

Time.new (Fails) vs Time.now (Passes)

This seems to still be a slight issue several years later. Since this lab provides no instructions on the implementation of Time and the SEI courses never really discuss it until now, I'm therefore googling the correct implementation. I find out that Time.now is an alias for Time.new. If I pick the wrong one, when they both should be equal, I get a failure in the tests that is confusing and contrary to the documentation.

I'd suggest an addition to the readme that explains you need to use Time.now to pass the tests. It appears that using Time.new fails because the test ends up getting the system's current time.

I do not see an issue with a readme addition because this lab is about the use of the #write method and nothing is lost by explaining the small quirk in this test.

Passes:

class Application
    def call(env)
        resp = Rack::Response.new
        if Time.now.hour < 12
            resp.write "Good Morning!"
        else
            resp.write "Good Afternoon"
        end
        resp.finish
    end 
end

Fails:

class Application
    def call(env)
        resp = Rack::Response.new
        if Time.new.hour < 12
            resp.write "Good Morning!"
        else
            resp.write "Good Afternoon"
        end
        resp.finish
    end 
end

Test fails with Time.new

The tests only work if the app gets the time using Time.now (allowing the test to use the time from the spec instead of the current time). It fails if using Time.new because the test will use the system's current time. System time can only be morning or afternoon—so one of the tests will fail.

Clarify that they should work with military time?

The solution says that if the number is greater than 12, then the response should be "Good Afternoon!"

Should we clarify that they should be working with military time? Should we also say that for any time after 12 is afternoon, and any time before 12 is morning.

Possible Rspec bug, Using Time.new.hour vs Time.now.hour

The code below works in this lab to pass all test cases. However, when initially setting up my instance variable current_time, i used current_time = Time.new.hour . This code did not pass the good afternon rspec. To my knowledge, .now is an alias of .new so both should work? If not what should i take into consideration to distinguish why .now is to be used.

Thank you

class Application

def call(env)
resp = Rack::Response.new
current_time = Time.now.hour #initially i used .new, however, if i used .now, the code works
if current_time > 12
resp.write "Afternoon\n"
else
resp.write "Morning\n"
end
resp.finish
end
end

Case sensitive

Spent way too long attempting to refactor my code before I realized the tests were looking for capital Morning and Afternoon. Seems like this could be built into the tests.

Tests would not pass

I had to make a change to the tests to set the time, the tests were always using the current time:

    allow(Time).to receive(:now).and_return(Time.utc(*[26, 10, 10, 2, 1, 2018, 1, 154, false, "MST"]))
  #  allow(Time).to receive(:now){
  #    Time.new(2015,11,27,9,30)
  #  }

.rspec file

I noticed that the Rack labs are missing the .rspec files, I added it manually but wasn't sure if it was omitted on purpose so I thought I should submit an issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.