Commit af3612665b408d0eb5bc60a5ae493927c06dfce9
Committed by
Paulo Meireles
1 parent
c9b39d89
Exists in
master
and in
29 other branches
[Mezuro] Refactoring Repository
Showing
3 changed files
with
26 additions
and
21 deletions
Show diff stats
plugins/mezuro/test/fixtures/repository_fixtures.rb
| 1 | 1 | class RepositoryFixtures |
| 2 | 2 | |
| 3 | 3 | def self.qt_calculator |
| 4 | - repository = Kalibro::Entities::Repository.new | |
| 4 | + repository = Kalibro::Repository.new | |
| 5 | 5 | repository.type = 'SUBVERSION' |
| 6 | 6 | repository.address = 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator' |
| 7 | 7 | repository | ... | ... |
plugins/mezuro/test/unit/kalibro/entities/repository_test.rb
| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | -require "test_helper" | |
| 2 | - | |
| 3 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" | |
| 4 | - | |
| 5 | -class RepositoryTest < ActiveSupport::TestCase | |
| 6 | - | |
| 7 | - def setup | |
| 8 | - @hash = RepositoryFixtures.qt_calculator_hash | |
| 9 | - @repository = RepositoryFixtures.qt_calculator | |
| 10 | - end | |
| 11 | - | |
| 12 | - should 'create repository from hash' do | |
| 13 | - assert_equal @repository, Kalibro::Entities::Repository.from_hash(@hash) | |
| 14 | - end | |
| 15 | - | |
| 16 | - should 'convert repository to hash' do | |
| 17 | - assert_equal @hash, @repository.to_hash | |
| 18 | - end | |
| 19 | - | |
| 20 | -end | |
| 21 | 0 | \ No newline at end of file |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +require "test_helper" | |
| 2 | + | |
| 3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" | |
| 4 | + | |
| 5 | +class RepositoryTest < ActiveSupport::TestCase | |
| 6 | + | |
| 7 | + def setup | |
| 8 | + @hash = RepositoryFixtures.qt_calculator_hash | |
| 9 | + @repository = RepositoryFixtures.qt_calculator | |
| 10 | + end | |
| 11 | + | |
| 12 | + #TODO como pegar o nome de TODAS as variáveis, mesmo as não setadas??? | |
| 13 | + should 'create repository from hash' do | |
| 14 | + repository = Kalibro::Repository.new(@hash) | |
| 15 | + attributes = repository.instance_variable_names.map { |variable| variable.to_s.sub(/@/, '') } | |
| 16 | + attributes.each { |field| assert_equal(@repository.send("#{field}"), repository.send("#{field}")) } | |
| 17 | + attributes = @repository.instance_variable_names.map { |variable| variable.to_s.sub(/@/, '') } | |
| 18 | + attributes.each { |field| assert_equal(@repository.send("#{field}"), repository.send("#{field}")) } | |
| 19 | + end | |
| 20 | + | |
| 21 | + should 'convert repository to hash' do | |
| 22 | + assert_equal @hash, @repository.to_hash | |
| 23 | + end | |
| 24 | + | |
| 25 | +end | ... | ... |