This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "cat" | |
| Rspec.describe("Cat"){ #examples } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'cat' | |
| describe Cat do | |
| it "is initialized with a name" do | |
| cat = Cat.new("Wednesday") | |
| expect(cat.name).to eq("Wednesday") | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #We expect a thing that we set to match an outcome | |
| expect(something).to matcher(outcome) | |
| #We expect a thing that we set not to match an outcome | |
| expect(something).not_to matcher(outcome) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| expect(1<2).to be true | |
| #what is really happening here is this: | |
| expect(1<2).to(be(true)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Car | |
| attr_accessor :color, :year, :make, :model | |
| def initialize(color, year, make, model) | |
| # our instance variables are defined using a single @ | |
| @color = color | |
| @year = year | |
| @make = make | |
| @model = model | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Car | |
| attr_accessor :color, :year, :make, :model | |
| def initialize(color, year, make, model) | |
| @color = color | |
| @year = year | |
| @make = make | |
| @model = model | |
| end | |
| def get_vin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Car | |
| attr_accessor :color, :year, :make, :model | |
| @@all = [] | |
| def initialize(color, year, make, model) | |
| @color = color | |
| @year = year | |
| @make = make | |
| @model = model | |
| @@all << self | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a comment. Comments start with the '#' | |
| # Function one (for demonstration purposes) | |
| def function_name(parameter): | |
| #This is the functions body | |
| #The body is defined by the indention at the begining of the line | |
| print(parameter) | |
| # Function two | |
| def function_two(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "0.2.0", | |
| "configurations": [ | |
| { | |
| "name": "Python: Current File", | |
| "type": "python", | |
| "request": "launch", | |
| "program": "${file}", | |
| "console": "internalConsole" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def square(num): | |
| answer = num * num | |
| print(answer) | |
| square(2) | |
| square(4) | |
| square(6) |
OlderNewer