summaryrefslogtreecommitdiff
path: root/spec/bundler/gem_specification_spec.rb
blob: 3389196efc583afd5b0fd9a580279dacadb255dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Gem::Specification" do

  it "is able to store the source URI of the gem as a URI" do
    spec = Gem::Specification.new do |s|
      s.name    = 'greeter'
      s.version = '1.0'
      s.source  = 'http://gems.rubyforge.org'
    end

    spec.source.should == Bundler::Source.new("http://gems.rubyforge.org")
  end

  it "does not consider two gem specs with different sources to be the same" do
    spec1 = Gem::Specification.new do |s|
      s.name    = 'greeter'
      s.version = '1.0'
      s.source  = 'http://gems.rubyforge.org'
    end

    spec2 = spec1.dup
    spec2.source = Bundler::Source.new("http://gems.github.com")

    spec1.should_not == spec2
  end

  it "can set a source that is already a Source" do
    source = Bundler::Source.new("http://foo")
    spec   = Gem::Specification.new
    spec.source = source
    spec.source.should == source
  end

  it "requires a valid URI for the source" do
    spec = Gem::Specification.new
    lambda { spec.source = "fail" }.should raise_error(ArgumentError)
  end

end