Skip to content

Commit

Permalink
test: migrate resource unit test to rspec test
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Gaychuk <[email protected]>
  • Loading branch information
AlexeyShepelev authored and sergeygaychuk committed Dec 14, 2011
1 parent 870a0ab commit b0293d5
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ log/*.log
tmp/**/*
.idea
.rspec
vendor/bundle
17 changes: 17 additions & 0 deletions app/models/asset.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2011 Sergey Yanovich <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Please see ./COPYING for details

class Asset < ActiveRecord::Base
validates_presence_of :tag
validates_uniqueness_of :tag
has_many :deal_gives, :class_name => "Deal", :as => :give
has_many :deal_takes, :class_name => "Deal", :as => :take
end

# vim: ts=2 sts=2 sw=2 et:
7 changes: 0 additions & 7 deletions app/models/resource.rb → app/models/money.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
#
# Please see ./COPYING for details

class Asset < ActiveRecord::Base
validates_presence_of :tag
validates_uniqueness_of :tag
has_many :deal_gives, :class_name => "Deal", :as => :give
has_many :deal_takes, :class_name => "Deal", :as => :take
end

class Money < ActiveRecord::Base
validates_presence_of :num_code
validates_presence_of :alpha_code
Expand Down
20 changes: 20 additions & 0 deletions spec/models/asset_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2011 Sergey Yanovich <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Please see ./COPYING for details

require 'spec_helper'

describe Asset do
it "should have next behaviour" do
Factory(:asset)
should validate_presence_of :tag
should validate_uniqueness_of :tag
should have_many :deal_gives
should have_many :deal_takes
end
end
23 changes: 23 additions & 0 deletions spec/models/money_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2011 Sergey Yanovich <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Please see ./COPYING for details

require 'spec_helper'

describe Money do
it "should have next behaviour" do
Factory(:money)
should validate_presence_of :num_code
should validate_presence_of :alpha_code
should validate_uniqueness_of :num_code
should validate_uniqueness_of :alpha_code
should have_many :deal_gives
should have_many :deal_takes
should have_many :quotes
end
end
9 changes: 9 additions & 0 deletions spec/support/factories/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@
factory :entity do |e|
e.sequence(:tag) { |n| "entity#{n}" }
end

factory :asset do |a|
a.sequence(:tag) { |n| "asset#{n}" }
end

factory :money do |m|
m.sequence(:alpha_code) { |n| "MN#{n}" }
m.sequence(:num_code) { |n| n }
end
end
40 changes: 0 additions & 40 deletions test/unit/resource_test.rb

This file was deleted.

0 comments on commit b0293d5

Please sign in to comment.