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 OrderReport < ActiveRecord::Base | |
belongs_to :order | |
def update_order_report | |
this.total = calculator.total | |
this.fee = calculator.fee | |
save! | |
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
require "spec_helper" | |
describe OrderCalculator do | |
let(:order) { | |
Traver.create(order: { | |
items: [{ price: 1.0 }, { price: 2.0 }] | |
}) | |
} | |
subject { OrderCalculator.new(order) } |
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) } | |
describe "#update_order_report" do | |
before do | |
calculator = instance_double("OrderCalculator", total: 1.0, fee: 0.01) | |
expect(subject).to recieve(:calculator).and_return(calculator) | |
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
require "spec_helper" | |
describe OrderReport do | |
subject { | |
Traver.create(order_report: { | |
order: { items: [{ price: 1.0 }, { price: 2.0 }] } | |
}) | |
} | |
describe "#update_order_report" do |
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
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
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
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
=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
require "csv" | |
class Client | |
def import | |
importer = CsvProductImporter.new(params[:file_path]) | |
inventory = Inventory.new(importer) | |
inventory.import_products | |
end | |
end |