Skip to content

Commit

Permalink
Add an example spec
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Apr 26, 2015
1 parent 4ea4fbf commit 9b7e6ea
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
require "bundler/gem_tasks"
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new('spec')

# If you want to make this the default task
task :default => :spec
task :test => :spec

task :console do
exec "irb -r receipts -I ./lib"
end
9 changes: 7 additions & 2 deletions lib/receipts/receipt.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'prawn'
require 'prawn-table'
require 'prawn/table'

module Receipts
class Receipt < Prawn::Document
Expand Down Expand Up @@ -42,7 +42,12 @@ def generate

def header
move_down 60
image company.fetch(:logo), height: 32

if company.has_key? :logo
image company.fetch(:logo), height: 32
else
move_down 32
end

move_down 8
text "<color rgb='a6a6a6'>RECEIPT FOR CHARGE ##{id}</color>", inline_format: true
Expand Down
2 changes: 2 additions & 0 deletions receipts.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec"
spec.add_development_dependency "pry"

spec.add_dependency 'prawn', '~> 1.3.0'
spec.add_dependency 'prawn-table', '~> 0.2.1'
Expand Down
18 changes: 18 additions & 0 deletions spec/receipts_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'spec_helper'

describe Receipts do
it "lets you create a new receipt" do
expect(Receipts::Receipt.new(
id: 1,
product: "GoRails",
company: {
name: "One Month, Inc.",
address: "37 Great Jones\nFloor 2\nNew York City, NY 10012",
email: "[email protected]"
},
line_items: [
["Product", "GoRails"],
],
).class.name).to eq("Receipts::Receipt")
end
end
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
begin
require 'pry'
rescue LoadError
end

require 'receipts'

RSpec.configure do |config|
end

0 comments on commit 9b7e6ea

Please sign in to comment.