new 0.1.1 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/bin/new +0 -2
- data/lib/new.rb +125 -52
- data/lib/new/cli.rb +514 -67
- data/lib/new/source.rb +110 -0
- data/lib/new/task.rb +67 -24
- data/lib/new/validation.rb +191 -0
- metadata +75 -132
- data/.gitignore +0 -6
- data/.new +0 -23
- data/.rspec +0 -2
- data/Gemfile +0 -16
- data/Gemfile.lock +0 -82
- data/Guardfile +0 -16
- data/LICENSE.txt +0 -22
- data/README.md +0 -128
- data/lib/new/core.rb +0 -7
- data/lib/new/dsl.rb +0 -42
- data/lib/new/interpolate.rb +0 -106
- data/lib/new/project.rb +0 -34
- data/lib/new/template.rb +0 -67
- data/lib/new/version.rb +0 -54
- data/spec/fixtures/custom/.new +0 -16
- data/spec/fixtures/custom/tasks/custom_bar_task/custom_bar_task.rb +0 -3
- data/spec/fixtures/custom/templates/custom_bar_template/.new +0 -3
- data/spec/fixtures/custom/templates/custom_bar_template/custom_bar.txt +0 -0
- data/spec/fixtures/project/.new +0 -4
- data/spec/fixtures/project/.new_cli_release_spec +0 -2
- data/spec/fixtures/tasks/custom_bar_task/custom_bar_task.rb +0 -1
- data/spec/fixtures/tasks/foo_task/Gemfile +0 -5
- data/spec/fixtures/tasks/foo_task/foo_task.rb +0 -7
- data/spec/fixtures/templates/custom_bar_template/.gitkeep +0 -0
- data/spec/fixtures/templates/foo_template/.new +0 -1
- data/spec/fixtures/templates/foo_template/[FOO.BAR].txt.erb +0 -1
- data/spec/fixtures/templates/foo_template/nested_[FOO.BAR]/foo.txt.erb +0 -1
- data/spec/lib/new/cli_spec.rb +0 -107
- data/spec/lib/new/interpolate_spec.rb +0 -43
- data/spec/lib/new/project_spec.rb +0 -33
- data/spec/lib/new/task_spec.rb +0 -39
- data/spec/lib/new/template_spec.rb +0 -59
- data/spec/lib/new/version_spec.rb +0 -26
- data/spec/lib/new_spec.rb +0 -19
- data/spec/spec_helper.rb +0 -46
- data/tasks/gem/.gemspec.erb +0 -4
- data/tasks/gem/README.md +0 -36
- data/tasks/gem/gem.rb +0 -170
- data/tasks/gem/gem_spec.rb +0 -138
- data/templates/js/.bowerrc +0 -3
- data/templates/js/.gitignore +0 -3
- data/templates/js/.new.erb +0 -11
- data/templates/js/CHANGELOG.md +0 -3
- data/templates/js/Gemfile +0 -2
- data/templates/js/Guardfile +0 -7
- data/templates/js/LICENSE-MIT.erb +0 -22
- data/templates/js/README.md.erb +0 -41
- data/templates/js/bower.json.erb +0 -11
- data/templates/js/demo/[PROJECT.FILENAME]_demo.coffee +0 -0
- data/templates/js/demo/[PROJECT.FILENAME]_demo.sass +0 -0
- data/templates/js/demo/index.html.erb +0 -12
- data/templates/js/lib/README.md +0 -2
- data/templates/js/package.json +0 -5
- data/templates/js/spec/[PROJECT.FILENAME]_spec.coffee.erb +0 -1
- data/templates/js/spec/[PROJECT.FILENAME]_spec.sass +0 -0
- data/templates/js/spec/index.html.erb +0 -35
- data/templates/js/src/[PROJECT.FILENAME].coffee.erb +0 -18
- data/templates/js/src/[PROJECT.FILENAME].sass +0 -0
- data/templates/js/testem.yml +0 -23
- data/templates/js/yuyi_menu +0 -7
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe New::Template do
|
4
|
-
subject(:template){ New::Template.new type, 'new_template' }
|
5
|
-
let(:type){ :foo_template }
|
6
|
-
|
7
|
-
before do
|
8
|
-
allow_any_instance_of(New::Template).to receive :interpolate
|
9
|
-
end
|
10
|
-
|
11
|
-
after do
|
12
|
-
allow_any_instance_of(New::Template).to receive :interpolate
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#template_dir' do
|
16
|
-
context 'with a default template' do
|
17
|
-
let(:type){ :foo_template }
|
18
|
-
|
19
|
-
it 'should return the default template path' do
|
20
|
-
expect(template.send(:template_dir)).to eq File.join(New::DEFAULT_DIR, New::TEMPLATES_DIR_NAME, type.to_s)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'with a custom template' do
|
25
|
-
let(:type){ :custom_bar_template }
|
26
|
-
|
27
|
-
it 'should return the custom template path' do
|
28
|
-
expect(template.send(:template_dir)).to eq File.join(New::CUSTOM_DIR, New::TEMPLATES_DIR_NAME, type.to_s)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should set the custom flag' do
|
32
|
-
expect(template.instance_variable_get('@custom')).to eq true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#options' do
|
38
|
-
before do
|
39
|
-
stub_const('New::Template::CUSTOM_CONFIG_TEMPLATE', { default: true })
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should build complete options' do
|
43
|
-
options = template.send(:options)
|
44
|
-
|
45
|
-
# check default template options
|
46
|
-
expect(options[:default]).to eq true
|
47
|
-
|
48
|
-
# check template options
|
49
|
-
expect(options[:template]).to eq true
|
50
|
-
|
51
|
-
# check custom config options
|
52
|
-
expect(options[:custom]).to eq true
|
53
|
-
|
54
|
-
# check project specific options
|
55
|
-
expect(options[:type]).to eq('foo_template')
|
56
|
-
expect(options[:project][:name]).to eq('new_template')
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class VersionSpec
|
4
|
-
include New::Version
|
5
|
-
end
|
6
|
-
|
7
|
-
describe New::Version do
|
8
|
-
let(:version){ VersionSpec.new }
|
9
|
-
|
10
|
-
describe '#bump_version' do
|
11
|
-
it 'should bump the major version' do
|
12
|
-
version.bump_version('1.2.3', :major)
|
13
|
-
expect(version.version.to_s).to eq '2.0.0'
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should bump the minor version' do
|
17
|
-
version.bump_version('1.2.3', :minor)
|
18
|
-
expect(version.version.to_s).to eq '1.3.0'
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should bump the patch version' do
|
22
|
-
version.bump_version('1.2.3', :patch)
|
23
|
-
expect(version.version.to_s).to eq '1.2.4'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/lib/new_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe New do
|
4
|
-
it 'should return a version' do
|
5
|
-
expect(New::VERSION).to match /[0-9]+.[0-9]+.[0-9]+/
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should return an array of available tasks' do
|
9
|
-
expect(New.tasks).to match_array [:foo_task, :custom_bar_task]
|
10
|
-
expect(New.default_tasks).to match_array [:foo_task, :custom_bar_task]
|
11
|
-
expect(New.custom_tasks).to match_array [:custom_bar_task]
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should return an array of available templates' do
|
15
|
-
expect(New.templates).to match_array [:foo_template, :custom_bar_template]
|
16
|
-
expect(New.default_templates).to match_array [:foo_template, :custom_bar_template]
|
17
|
-
expect(New.custom_templates).to match_array [:custom_bar_template]
|
18
|
-
end
|
19
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
$: << File.expand_path('../../lib', __FILE__)
|
2
|
-
$: << File.expand_path('../../tasks', __FILE__)
|
3
|
-
$: << File.expand_path('../fixtures', __FILE__)
|
4
|
-
require 'new'
|
5
|
-
$: << File.expand_path('tasks', New::CUSTOM_DIR)
|
6
|
-
|
7
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
8
|
-
RSpec.configure do |config|
|
9
|
-
config.run_all_when_everything_filtered = true
|
10
|
-
config.filter_run :focus
|
11
|
-
config.order = :random
|
12
|
-
|
13
|
-
config.before do
|
14
|
-
allow(New).to receive :say
|
15
|
-
stub_const 'New::DEFAULT_DIR', root('spec', 'fixtures')
|
16
|
-
stub_const 'New::CUSTOM_DIR', root('spec', 'fixtures', 'custom')
|
17
|
-
end
|
18
|
-
|
19
|
-
config.before :each do
|
20
|
-
# Force specs to always lookup new templates and tasks
|
21
|
-
New.instance_variables.each{ |v| New.instance_variable_set(v, nil) }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def root *paths
|
26
|
-
paths.unshift(File.expand_path('../../', __FILE__)).compact.join '/'
|
27
|
-
end
|
28
|
-
|
29
|
-
def require_task task
|
30
|
-
require "#{task}/#{task}"
|
31
|
-
end
|
32
|
-
|
33
|
-
def new_task task, options = {}
|
34
|
-
task_class = "New::Task::#{task.to_s.classify}".constantize
|
35
|
-
|
36
|
-
allow_any_instance_of(task_class).to receive(:get_part).and_return(:patch)
|
37
|
-
allow_any_instance_of(task_class).to receive(:run)
|
38
|
-
|
39
|
-
task_hash = {}
|
40
|
-
task_hash[task] = {}
|
41
|
-
task_options = {
|
42
|
-
tasks: task_hash
|
43
|
-
}.merge(options)
|
44
|
-
|
45
|
-
task_class.new task_options
|
46
|
-
end
|
data/tasks/gem/.gemspec.erb
DELETED
data/tasks/gem/README.md
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# GEM TASK
|
2
|
-
|
3
|
-
###### gemspec attributes
|
4
|
-
|
5
|
-
You can add any of the supported gemspec attributes to your project's `.new` configuration file.
|
6
|
-
|
7
|
-
```yaml
|
8
|
-
tasks:
|
9
|
-
gem:
|
10
|
-
summary: My gem summary
|
11
|
-
test_files: <%= Dir.glob('spec/*.rb') %> # use erb rules for inline ruby
|
12
|
-
```
|
13
|
-
|
14
|
-
A full list can be found here http://guides.rubygems.org/specification-reference
|
15
|
-
|
16
|
-
The following attributes expect arrays of unix glob patterns
|
17
|
-
|
18
|
-
* files
|
19
|
-
* test_files
|
20
|
-
* extra_rdoc_files
|
21
|
-
|
22
|
-
```yaml
|
23
|
-
tasks:
|
24
|
-
gem:
|
25
|
-
gemspec:
|
26
|
-
files:
|
27
|
-
- 'lib/**/*.rb'
|
28
|
-
test_files:
|
29
|
-
- 'spec/**/*.rb'
|
30
|
-
```
|
31
|
-
|
32
|
-
The following attributes are automatically set.
|
33
|
-
|
34
|
-
* name
|
35
|
-
* version
|
36
|
-
* date
|
data/tasks/gem/gem.rb
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
require 'rake'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
class New::Task::Gem < New::Task
|
6
|
-
include New::Interpolate
|
7
|
-
include New::Version
|
8
|
-
|
9
|
-
GLOB_ATTRIBUTES = [:files, :test_files, :extra_rdoc_files]
|
10
|
-
GEMFILE = File.expand_path(File.join(Dir.pwd, 'Gemfile'))
|
11
|
-
OPTIONS = {
|
12
|
-
gemspec: {
|
13
|
-
summary: "A short summary of this gem's description. Displayed in `gem list -d`",
|
14
|
-
files: ['**/*','**/.*']
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
def run
|
19
|
-
@gemspec = options[:gemspec]
|
20
|
-
|
21
|
-
set_version
|
22
|
-
validate_files
|
23
|
-
render_gemspec_options
|
24
|
-
write_gemspec
|
25
|
-
write_config
|
26
|
-
deploy
|
27
|
-
|
28
|
-
New.say "Version #{project_options[:version].green} of the #{project_options[:project][:name].green} gem successfully published."
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def set_version
|
34
|
-
# bump version
|
35
|
-
bump_version project_options[:version]
|
36
|
-
|
37
|
-
# set new version to config
|
38
|
-
project_options[:version] = version.to_s
|
39
|
-
end
|
40
|
-
|
41
|
-
# Check that any glob pattern attributes match existing files
|
42
|
-
#
|
43
|
-
def validate_files
|
44
|
-
GLOB_ATTRIBUTES.each do |file_attr|
|
45
|
-
next if @gemspec[file_attr].nil?
|
46
|
-
|
47
|
-
files = []
|
48
|
-
@gemspec[file_attr].each do |glob|
|
49
|
-
matching_files = FileList.new(glob).select{ |f| File.file? f }
|
50
|
-
matching_files.delete '.gemspec'
|
51
|
-
|
52
|
-
if matching_files.empty?
|
53
|
-
New.say "The pattern `#{glob}` in `tasks.gem.gemspec.#{file_attr}` did not match any files."
|
54
|
-
New.say 'Please check your configuration file.'
|
55
|
-
exit
|
56
|
-
else
|
57
|
-
files << matching_files
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
@gemspec[file_attr] = files.flatten
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def render_gemspec_options
|
66
|
-
array = []
|
67
|
-
|
68
|
-
# set defaults
|
69
|
-
@gemspec[:date] = Date.today.to_s
|
70
|
-
@gemspec[:name] = project_options[:project][:name]
|
71
|
-
@gemspec[:version] = project_options[:version]
|
72
|
-
@gemspec[:author] ||= project_options[:developer][:name]
|
73
|
-
@gemspec[:email] ||= project_options[:developer][:email]
|
74
|
-
@gemspec[:license] ||= project_options[:license]
|
75
|
-
|
76
|
-
# remove singular attributes if plural attribute is specified
|
77
|
-
if @gemspec[:authors]
|
78
|
-
@gemspec.delete(:author)
|
79
|
-
@gemspec[:authors] = @gemspec[:authors]
|
80
|
-
end
|
81
|
-
if @gemspec[:licenses]
|
82
|
-
@gemspec.delete(:license)
|
83
|
-
@gemspec[:licenses] = @gemspec[:licenses]
|
84
|
-
end
|
85
|
-
|
86
|
-
@gemspec.sort.each do |k,v|
|
87
|
-
val = case v
|
88
|
-
when String then "'#{v}'"
|
89
|
-
else v
|
90
|
-
end
|
91
|
-
|
92
|
-
array << " s.#{k} = #{val}"
|
93
|
-
end
|
94
|
-
|
95
|
-
array += extract_gem_dependencies
|
96
|
-
|
97
|
-
project_options[:gemspec_string] = array.join("\n")
|
98
|
-
end
|
99
|
-
|
100
|
-
# Extract dependencies based on the Gemfile to be used in the gemspec
|
101
|
-
#
|
102
|
-
def extract_gem_dependencies
|
103
|
-
b = Bundler::Dsl.new
|
104
|
-
b.eval_gemfile(GEMFILE)
|
105
|
-
|
106
|
-
array = []
|
107
|
-
runtime = []
|
108
|
-
development = []
|
109
|
-
|
110
|
-
# loop through the required gems and find default and development gems
|
111
|
-
b.dependencies.each do |g|
|
112
|
-
requirements = g.requirements_list.map{ |r| "'#{r}'" }.join(',')
|
113
|
-
data = {
|
114
|
-
name: g.name,
|
115
|
-
requirements: requirements
|
116
|
-
}
|
117
|
-
|
118
|
-
groups = g.groups
|
119
|
-
runtime << data if groups.include? :default
|
120
|
-
development << data if groups.include? :development
|
121
|
-
end
|
122
|
-
|
123
|
-
# create .gemspec friendly string of requirements
|
124
|
-
runtime.each do |r|
|
125
|
-
array << " s.add_runtime_dependency '#{r[:name]}', #{r[:requirements]}"
|
126
|
-
end
|
127
|
-
development.each do |r|
|
128
|
-
array << " s.add_development_dependency '#{r[:name]}', #{r[:requirements]}"
|
129
|
-
end
|
130
|
-
|
131
|
-
return array
|
132
|
-
end
|
133
|
-
|
134
|
-
def write_gemspec
|
135
|
-
New.say 'Updating `.gemspec` file...', type: :success
|
136
|
-
|
137
|
-
# process gemspec
|
138
|
-
interpolate File.join(File.dirname(__FILE__), '.gemspec.erb'), project_options
|
139
|
-
|
140
|
-
# copy it to the project
|
141
|
-
FileUtils.cp File.join(@dest_path, '.gemspec'), Dir.pwd
|
142
|
-
|
143
|
-
# cleanup the tmp
|
144
|
-
FileUtils.rm_rf @dest_path
|
145
|
-
end
|
146
|
-
|
147
|
-
def write_config
|
148
|
-
New.say 'Updating `.new` file...', type: :success
|
149
|
-
|
150
|
-
writeable_options = project_options.dup
|
151
|
-
writeable_options.delete(:gemspec_string)
|
152
|
-
GLOB_ATTRIBUTES.each{ |a| writeable_options.delete(a) }
|
153
|
-
|
154
|
-
File.open(New::CONFIG_FILE, 'w+') do |f|
|
155
|
-
f.write writeable_options.deep_stringify_keys.to_yaml
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def deploy
|
160
|
-
New.say 'Pushing new gem version to rubygems...', type: :success
|
161
|
-
New.say ' ...This may take a bit', type: :warn
|
162
|
-
|
163
|
-
`gem update --system`
|
164
|
-
`gem build .gemspec`
|
165
|
-
`gem push #{@gemspec[:name]}-#{@gemspec[:version]}.gem`
|
166
|
-
FileUtils.rm_rf "#{@gemspec[:name]}-#{@gemspec[:version]}.gem"
|
167
|
-
|
168
|
-
New.say "#{@gemspec[:name]}-#{@gemspec[:version]} released".green
|
169
|
-
end
|
170
|
-
end
|
data/tasks/gem/gem_spec.rb
DELETED
@@ -1,138 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_task :gem
|
3
|
-
|
4
|
-
describe New::Task::Gem do
|
5
|
-
before do
|
6
|
-
stub_const 'New::CONFIG_FILE', New::CONFIG_FILE
|
7
|
-
stub_const 'New::Task::Gem::GLOB_ATTRIBUTES', [:foo_files]
|
8
|
-
@gem = new_task :gem, { version: '1.2.3' }
|
9
|
-
@pwd = Dir.pwd
|
10
|
-
@tmp_dir = Dir.mktmpdir
|
11
|
-
|
12
|
-
Dir.chdir @tmp_dir
|
13
|
-
end
|
14
|
-
|
15
|
-
after do
|
16
|
-
Dir.chdir @pwd
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#set_version' do
|
20
|
-
before do
|
21
|
-
@gem.send(:set_version)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should set the version for project options' do
|
25
|
-
expect(@gem.project_options[:version]).to eq '1.2.4'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#validate_files' do
|
30
|
-
before do
|
31
|
-
# temporarily change the current directory to the gem task folder to test for valid files
|
32
|
-
Dir.chdir File.dirname(__FILE__)
|
33
|
-
|
34
|
-
@gem.instance_variable_set(:@gemspec, { foo_files: ['*.rb', '*.md'] })
|
35
|
-
@gem.send(:validate_files)
|
36
|
-
end
|
37
|
-
|
38
|
-
after do
|
39
|
-
# go back to the original root dir
|
40
|
-
Dir.chdir @tmp_dir
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should replace the file_attr array of globs with an array of files' do
|
44
|
-
files = @gem.instance_variable_get(:@gemspec)[:foo_files]
|
45
|
-
expect(files.all?{ |f| files.include? f }).to eq true
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#render_gemspec_options' do
|
50
|
-
before do
|
51
|
-
allow(@gem).to receive(:extract_gem_dependencies).and_return([' s.extract_gem_dependencies'])
|
52
|
-
@gem.instance_variable_set(:@gemspec, {})
|
53
|
-
@gem.send(:render_gemspec_options)
|
54
|
-
end
|
55
|
-
|
56
|
-
after do
|
57
|
-
allow(@gem).to receive(:extract_gem_dependencies).and_call_original
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'should create the gemspec_string option' do
|
61
|
-
gemspec_string = @gem.project_options[:gemspec_string]
|
62
|
-
expect(gemspec_string).to include "s.author = 'Foo Bar'"
|
63
|
-
expect(gemspec_string).to include "s.license = 'MIT'"
|
64
|
-
expect(gemspec_string).to include "s.extract_gem_dependencies"
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'when plurals are set' do
|
68
|
-
before do
|
69
|
-
@gem.instance_variable_set(:@gemspec, {
|
70
|
-
authors: ['Foo Author'],
|
71
|
-
licenses: ['Foo License'],
|
72
|
-
})
|
73
|
-
@gem.send(:render_gemspec_options)
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'should replace the singulars' do
|
77
|
-
expect(@gem.project_options[:gemspec_string]).to include 's.authors = ["Foo Author"]'
|
78
|
-
expect(@gem.project_options[:gemspec_string]).to_not include 's.author = '
|
79
|
-
expect(@gem.project_options[:gemspec_string]).to include 's.licenses = ["Foo License"]'
|
80
|
-
expect(@gem.project_options[:gemspec_string]).to_not include 's.license = '
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe '#extract_gem_dependencies' do
|
86
|
-
before do
|
87
|
-
stub_const 'New::Task::Gem::GEMFILE', root('spec', 'fixtures', 'tasks', 'foo_task', 'Gemfile')
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'should set dependencies' do
|
91
|
-
gem_dependencies = @gem.send(:extract_gem_dependencies)
|
92
|
-
expect(gem_dependencies).to include " s.add_runtime_dependency 'foo', '~> 1.2.3'"
|
93
|
-
expect(gem_dependencies).to include " s.add_development_dependency 'bar', '>= 0'"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#write_gemspec' do
|
98
|
-
before do
|
99
|
-
allow(@gem).to receive(:project_options).and_return({ gemspec_string: 'foo' })
|
100
|
-
@gem.send(:write_gemspec)
|
101
|
-
end
|
102
|
-
|
103
|
-
after do
|
104
|
-
allow(@gem).to receive(:project_options).and_call_original
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'should write a gemspec file' do
|
108
|
-
expect(File.exist?('.gemspec')).to eq true
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'should be a valid gemspec file' do
|
112
|
-
gemspec = File.read('.gemspec')
|
113
|
-
expect(gemspec).to include 'Gem::Specification.new'
|
114
|
-
expect(gemspec).to include 'foo'
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe '#write_config' do
|
119
|
-
before do
|
120
|
-
allow(@gem).to receive(:project_options).and_return({
|
121
|
-
gemspec_string: 'foo',
|
122
|
-
foo_files: 'foo',
|
123
|
-
bar: 'bar'
|
124
|
-
})
|
125
|
-
@gem.send(:write_config)
|
126
|
-
end
|
127
|
-
|
128
|
-
after do
|
129
|
-
allow(@gem).to receive(:project_options).and_call_original
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'should update the config file' do
|
133
|
-
config = File.read(New::CONFIG_FILE)
|
134
|
-
expect(config).to_not include 'foo'
|
135
|
-
expect(config).to include 'bar: bar'
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|