This file contains 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 method | |
end |
This file contains 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 render_order(bar) | |
render partial: “order”, locals: { foo: bar } | |
end |
This file contains 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
# Set current application time zone to user's one | |
def set_time_zone | |
Time.zone = current_user.time_zone if user_signed_in? | |
end | |
# Somewhere in code | |
Time.zone.now # obtain current time in current user's time zone |
This file contains 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 "csv" | |
class Client | |
def import | |
importer = CsvProductImporter.new(params[:file_path]) | |
inventory = Inventory.new(importer) | |
inventory.import_products | |
end | |
end |
This file contains 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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
This file contains 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 Vertice | |
attr_accessor :predecessor, :d, :name | |
def initialize(n) | |
@name = n | |
end | |
end | |
class Edge | |
attr_accessor :source, :destination, :w | |
def initialize(s,d,w) |
This file contains 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" | |
feature "Authentication" do | |
before do | |
Traver.create(user: { email: "walter@white.com", password: "walter" }) | |
end | |
scenario "User logs in successfully by entering email and password" do | |
visit login_path |
This file contains 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
RSpec::Matchers.define :login_successfully do | |
match do |login_page| | |
expect(login_page.page).to have_content "Successfully logged in." | |
end | |
end |
This file contains 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 OrderCalulator | |
attr_reader :order | |
attr_reader :total, :fee | |
def initialize(order) | |
@order = order | |
end | |
def calculate | |
@total = calculate_total |
This file contains 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 OrderReport do | |
subject { | |
Traver.create(order_report: { | |
order: { items: [{ price: 1.0 }, { price: 2.0 }] } | |
}) | |
} | |
describe "#update_order_report" do |
OlderNewer