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 'spec_helper' | |
| describe "Apple" do | |
| let (:apple) { Fruit::Apple.new } | |
| describe "#initialize" do | |
| context "when given no parameters" do | |
| it "variety is 'Granny Smith'" do | |
| expect(apple.variety).to eq "Granny Smith" | |
| 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
| module Fruit | |
| class Apple | |
| require 'time' | |
| attr_accessor :variety | |
| def initialize(variety = "Granny Smith") | |
| @variety = variety | |
| @remaining_slices = apple_size | |
| @created_at = Time.now |
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 Encryptor | |
| def cypher(letter, rotation) | |
| (letter.ord + rotation).chr | |
| end | |
| def encrypt(message, rotation) | |
| letters = message.split("") | |
| letters.collect { |letter| cypher(letter, rotation) }.join | |
| 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
| --- | |
| LongMethod: | |
| max_statements: 8 | |
| FeatureEnvy: | |
| enabled: false | |
| IrresponsibleModule: | |
| enabled: false | |
| UncommunicativeVariableName: | |
| enabled: false |
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
| slugs = ["menu", "index", "food"] | |
| contents = ["menu contents", "index contents", "food contents"] | |
| pages = [] | |
| pages = slugs.each_with_index do |slug, index| | |
| {slug: slug, content: contents[index]} | |
| end | |
| # [{slug: "menu", content: "menu contents"}, {slug: "index", content: "index contents"}] |
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 Seeder | |
| def create_data | |
| 100.times do | |
| create_user | |
| create_event | |
| end | |
| end | |
| private |
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 Item < ActiveRecord::Base | |
| has_many :order_items | |
| has_many :orders, through: :order_items | |
| validates :name, presence: true, uniqueness: true | |
| validates :description, presence: true, uniqueness: true | |
| 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
| require 'forwardable' | |
| class BeerSong | |
| def verse(number) | |
| fragments = build_fragments(number) | |
| Verse.new(fragments).to_s | |
| end | |
| def verses(start, ending = 0) | |
| song = "" |
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 User < ActiveRecord::Base | |
| has_many :orders | |
| validates :name, presence: true | |
| validates :email, presence: true, uniqueness: true | |
| 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
| require 'spec_helper' | |
| describe Item do | |
| it "should exist" do | |
| item = Item.new | |
| expect item | |
| end | |
| it "should have a name" do | |
| item = Item.new(name: "hammer") |
OlderNewer