Skip to content

Commit

Permalink
added spec files
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosuke Tanabe committed Jan 5, 2012
1 parent 6eec539 commit a1ad32f
Show file tree
Hide file tree
Showing 66 changed files with 1,732 additions and 14 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Expand Up @@ -3,4 +3,9 @@ log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/
test/dummy/tmp/
spec/dummy/db/*.sqlite3
spec/dummy/log/*.log
spec/dummy/solr/
spec/dummy/tmp/
spec/cassette_library/
1 change: 1 addition & 0 deletions .rspec
@@ -0,0 +1 @@
--colour
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -9,6 +9,7 @@ gemspec
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
gem 'factory_girl_rails', '~> 1.4'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
12 changes: 9 additions & 3 deletions Rakefile
Expand Up @@ -14,13 +14,13 @@ end

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'EnjuBarcode'
rdoc.title = 'EnjuPurchaseRequest'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'


Expand All @@ -35,5 +35,11 @@ Rake::TestTask.new(:test) do |t|
t.verbose = false
end

require 'rspec/core'
require 'rspec/core/rake_task'

task :default => :test
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end

task :default => :spec
6 changes: 0 additions & 6 deletions app/controllers/barcodes_controller.rb
Expand Up @@ -22,8 +22,6 @@ def index
# GET /barcodes/1
# GET /barcodes/1.json
def show
@barcode = Barcode.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render :json => @barcode }
Expand All @@ -44,7 +42,6 @@ def new

# GET /barcodes/1/edit
def edit
@barcode = Barcode.find(params[:id])
end

# POST /barcodes
Expand All @@ -67,8 +64,6 @@ def create
# PUT /barcodes/1
# PUT /barcodes/1.json
def update
@barcode = Barcode.find(params[:id])

respond_to do |format|
if @barcode.update_attributes(params[:barcode])
flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.barcode'))
Expand All @@ -84,7 +79,6 @@ def update
# DELETE /barcodes/1
# DELETE /barcodes/1.json
def destroy
@barcode = Barcode.find(params[:id])
@barcode.destroy

respond_to do |format|
Expand Down
6 changes: 5 additions & 1 deletion app/models/barcode.rb
@@ -1,3 +1,7 @@
# TODO: Codarbar support
require 'barby/barcode/code_39'
require 'barby/outputter/svg_outputter'

class Barcode < ActiveRecord::Base
belongs_to :barcodable, :polymorphic => true

Expand All @@ -11,7 +15,7 @@ def self.per_page
end

def generate_barcode
self.data = Barby::Code128B.new(self.code_word).to_svg(:width => 150, :height => 70)
self.data = Barby::Code39.new(code_word).to_svg(:width => 150, :height => 70)
end

def is_readable_by(user, parent = nil)
Expand Down
9 changes: 9 additions & 0 deletions config/locales/translation_en.yml
@@ -0,0 +1,9 @@
ja:
activerecord:
models:
barcode: "Barcode"

attributes:
barcode:
code_word: "Code word"
data: "Data"
9 changes: 9 additions & 0 deletions config/locales/translation_ja.yml
@@ -0,0 +1,9 @@
ja:
activerecord:
models:
barcode: バーコード

attributes:
barcode:
code_word: コードワード
data: データ
14 changes: 14 additions & 0 deletions db/migrate/20081108112016_create_barcodes.rb
@@ -0,0 +1,14 @@
class CreateBarcodes < ActiveRecord::Migration
def self.up
create_table :barcodes do |t|
t.string :code_word
t.binary :data

t.timestamps
end
end

def self.down
drop_table :barcodes
end
end
7 changes: 5 additions & 2 deletions enju_barcode.gemspec
Expand Up @@ -14,11 +14,14 @@ Gem::Specification.new do |s|
s.description = "barcode generator for Next-L Enju"

s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
s.test_files = Dir["spec/**/*"]

s.add_dependency "rails", "~> 3"
s.add_dependency "rails", "~> 3.0"
s.add_dependency "barby", "~> 0.5"
s.add_dependency "rqrcode"
s.add_dependency "devise"
s.add_dependency "cancan"
s.add_dependency "will_paginate"

s.add_development_dependency "sqlite3"
s.add_development_dependency "rspec-rails"
Expand Down
4 changes: 4 additions & 0 deletions lib/enju_barcode/engine.rb
@@ -1,3 +1,7 @@
require 'devise'
require 'cancan'
require 'will_paginate'

module EnjuBarcode
class Engine < Rails::Engine
end
Expand Down
2 changes: 1 addition & 1 deletion script/rails
Expand Up @@ -3,4 +3,4 @@
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

ENGINE_PATH = File.expand_path('../..', __FILE__)
load File.expand_path('../../test/dummy/script/rails', __FILE__)
load File.expand_path('../../spec/dummy/script/rails', __FILE__)

0 comments on commit a1ad32f

Please sign in to comment.