-
Notifications
You must be signed in to change notification settings - Fork 74
/
gemfile_generator_test.rb
72 lines (54 loc) · 2.22 KB
/
gemfile_generator_test.rb
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require 'test_helper'
require 'gemfile_generator'
# Stub out methods on upgrader class
module Rails
module Upgrading
class GemfileGenerator
attr_writer :environment_code
def has_environment?
true
end
def environment_code
@environment_code
end
end
end
end
class GemfileGeneratorTest < ActiveSupport::TestCase
PREAMBLE = <<STR
# Edit this Gemfile to bundle your application's dependencies.
# This preamble is the current preamble for Rails 3 apps; edit as needed.
source 'http://rubygems.org'
gem 'rails', '3.0.0.beta3'
STR
def test_generates_with_no_gems
generator = Rails::Upgrading::GemfileGenerator.new
generator.environment_code = ""
assert_equal PREAMBLE, generator.generate_gemfile
end
def test_generates_with_gem
generator = Rails::Upgrading::GemfileGenerator.new
generator.environment_code = "config.gem 'camping'"
assert_equal PREAMBLE + "gem 'camping'", generator.generate_gemfile
end
def test_generates_with_version
generator = Rails::Upgrading::GemfileGenerator.new
generator.environment_code = "config.gem 'camping', :version => '2.1.1'"
assert_equal PREAMBLE + "gem 'camping', '2.1.1'", generator.generate_gemfile
end
def test_can_add_sources
generator = Rails::Upgrading::GemfileGenerator.new
generator.environment_code = "config.gem 'camping', :source => 'http://code.whytheluckystiff.net'"
assert_equal PREAMBLE + "source 'http://code.whytheluckystiff.net'\ngem 'camping'", generator.generate_gemfile
end
def test_changes_lib_to_new_key
generator = Rails::Upgrading::GemfileGenerator.new
generator.environment_code = "config.gem 'camping', :lib => 'kamping'"
assert_equal PREAMBLE + "gem 'camping', :require => 'kamping'", generator.generate_gemfile
end
def test_generates_with_all_options
generator = Rails::Upgrading::GemfileGenerator.new
generator.environment_code = "config.gem 'camping', :lib => 'kamping', :source => 'http://code.whytheluckystiff.net', :version => '2.1.1'"
assert_equal PREAMBLE + "source 'http://code.whytheluckystiff.net'\ngem 'camping', '2.1.1', :require => 'kamping'", generator.generate_gemfile
end
end