Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Load ROXML::VERSION from the VERSION file so it's never out of date

  • Loading branch information...
commit 9716129a81f00c4a304cb123fdef72a5c86a918c 1 parent 3ba1225
@Empact authored
Showing with 31 additions and 27 deletions.
  1. +1 −5 Rakefile
  2. +1 −1  lib/roxml.rb
  3. +29 −21 spec/roxml_spec.rb
View
6 Rakefile
@@ -34,11 +34,7 @@ task :nokogiri => ['test:nokogiri', 'spec:nokogiri']
require 'rdoc/task'
RDoc::Task.new do |rdoc|
- if File.exist?('VERSION')
- version = File.read('VERSION')
- else
- version = ""
- end
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "roxml #{version}"
View
2  lib/roxml.rb
@@ -14,7 +14,7 @@
require 'roxml/xml'
module ROXML # :nodoc:
- VERSION = '3.2.1'
+ VERSION = File.read('VERSION')
def self.included(base) # :nodoc:
base.class_eval do
View
50 spec/roxml_spec.rb
@@ -1,34 +1,42 @@
require_relative './spec_helper'
-describe ROXML, "#from_xml" do
- shared_examples_for "from_xml call" do
- it "should fetch values" do
- book = BookWithContributors.from_xml(@path)
- book.title.should == "Programming Ruby - 2nd Edition"
- book.contributors.map(&:name).should == ["David Thomas","Andrew Hunt","Chad Fowler"]
+describe ROXML do
+ describe "::VERSION" do
+ it "should be equal to the VERSION file contents" do
+ ROXML::VERSION.should == File.read('VERSION')
end
end
- context "called with PathName" do
- before do
- @path = Pathname.new(fixture_path(:book_with_contributors))
+ describe "#from_xml" do
+ shared_examples_for "from_xml call" do
+ it "should fetch values" do
+ book = BookWithContributors.from_xml(@path)
+ book.title.should == "Programming Ruby - 2nd Edition"
+ book.contributors.map(&:name).should == ["David Thomas","Andrew Hunt","Chad Fowler"]
+ end
end
- it_should_behave_like "from_xml call"
- end
- context "called with File" do
- before do
- @path = File.new(fixture_path(:book_with_contributors))
+ context "called with PathName" do
+ before do
+ @path = Pathname.new(fixture_path(:book_with_contributors))
+ end
+ it_should_behave_like "from_xml call"
end
- it_should_behave_like "from_xml call"
- end
- context "called with URI" do
- before do
- require 'uri'
- @path = URI.parse("file://#{File.expand_path(File.expand_path(fixture_path(:book_with_contributors)))}")
+ context "called with File" do
+ before do
+ @path = File.new(fixture_path(:book_with_contributors))
+ end
+ it_should_behave_like "from_xml call"
+ end
+
+ context "called with URI" do
+ before do
+ require 'uri'
+ @path = URI.parse("file://#{File.expand_path(File.expand_path(fixture_path(:book_with_contributors)))}")
+ end
+ it_should_behave_like "from_xml call"
end
- it_should_behave_like "from_xml call"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.