[Rubygems-developers] Overhaul of specification.rb
gsinclair at soyabean.com.au
Tue Aug 17 04:27:33 EDT 2004
On Sunday, August 15, 2004, 4:43:00 AM, Chad wrote:
> Looks like there's one more problem that I noticed while trying to
> implement some other things: Your alias for #test_suite_file works
> when you're building a gem, but it doesn't work when you want to run
> tests on pre-existing gem files. I suppose this is because YAML
> doesn't touch your attributes, but instead just populates the instance
> variables of the Gem::Specification object. So, for example, you can
> load the YAML and get a Gem::Specification object that has
> "@test_suite_file" set properly, but calling "spec.test_suite_file"
> doesn't work because "@test_files" is nil. I'll try to get to this
> later, but if anyone wants to take a crack at it before then, be my
> guess. I have my regular busy Saturday lined up unfortunately.
OK, I've fixed this:
overwrite_accessor :test_files do
# Handle the possibility that we have @test_suite_file but not @test_files. This will
# happen when an old gem is loaded via YAML.
@test_files = [@test_suite_file].flatten
@test_suite_file = nil
In English: when a spec is deserialized from YAML, it _may_ have
@test_suite_file and not @test_files. The custom #test_files now
checks for this and all is well, hopefully.
Incidentally, I've implemented Specification.from_yaml(input), and
that is the proper way to load a YAML spec now. It:
- throws Gem::Exception if it can't load a spec
- sets the @specification_version instance variable appropriately
- provides a mechanism (not used atm) to call a spec conversion
I've changed all places in the code that call 'YAML.load(yaml_spec)'.
There's one place I can't change:
remote_installer.rb:92: spec = YAML.load(yaml_spec)
That's because it's loading an array of specs, not a single one.
Probably nothing can be done about it at the moment. I'll look into
it later. Gotta go to Sydney Ruby User Group now.
BTW, Chad, unit testing of installed gems still doesn't work, due to
the test file not (necessarily) being in the LOAD_PATH. But that's a
P.S. Two test cases are not working as a result of this change, one in
test_package.rb and one in test_specification.rb. However, I've
tested manually by building and installing gems, so it's not hopefully
More information about the Rubygems-developers