sourcerer_ 0.0.2.pre → 0.0.6.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -2
- data/lib/sourcerer/metadata.rb +1 -1
- metadata +28 -98
- data/spec/fixtures/i18n.yml +0 -5
- data/spec/fixtures/source.dir/bar/file.bar +0 -0
- data/spec/fixtures/source.dir/foo/file.foo +0 -0
- data/spec/fixtures/source.git/COMMIT_EDITMSG +0 -1
- data/spec/fixtures/source.git/HEAD +0 -1
- data/spec/fixtures/source.git/config +0 -7
- data/spec/fixtures/source.git/description +0 -1
- data/spec/fixtures/source.git/hooks/applypatch-msg.sample +0 -15
- data/spec/fixtures/source.git/hooks/commit-msg.sample +0 -24
- data/spec/fixtures/source.git/hooks/post-update.sample +0 -8
- data/spec/fixtures/source.git/hooks/pre-applypatch.sample +0 -14
- data/spec/fixtures/source.git/hooks/pre-commit.sample +0 -49
- data/spec/fixtures/source.git/hooks/pre-push.sample +0 -54
- data/spec/fixtures/source.git/hooks/pre-rebase.sample +0 -169
- data/spec/fixtures/source.git/hooks/prepare-commit-msg.sample +0 -36
- data/spec/fixtures/source.git/hooks/update.sample +0 -128
- data/spec/fixtures/source.git/index +0 -0
- data/spec/fixtures/source.git/info/exclude +0 -6
- data/spec/fixtures/source.git/logs/HEAD +0 -1
- data/spec/fixtures/source.git/logs/refs/heads/master +0 -1
- data/spec/fixtures/source.git/objects/35/d778d19cdf4fea30f1f8090d3167723b3421ec +0 -0
- data/spec/fixtures/source.git/objects/65/5cd0061e2c5fba07b5e38fbc6a8a752f0d8a8e +0 -0
- data/spec/fixtures/source.git/objects/92/469c6ba0e1585b36e474ef8e5dc069daa28842 +0 -0
- data/spec/fixtures/source.git/objects/c7/e09aa454d4e5b551131ed168bc5ba5d6169753 +0 -3
- data/spec/fixtures/source.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/spec/fixtures/source.git/refs/heads/master +0 -1
- data/spec/fixtures/source.zip +0 -0
- data/spec/lib/sourcerer/core_spec.rb +0 -118
- data/spec/lib/sourcerer/error_spec.rb +0 -15
- data/spec/lib/sourcerer/source_type_spec.rb +0 -139
- data/spec/lib/sourcerer/source_types/dir_spec.rb +0 -2
- data/spec/lib/sourcerer/source_types/git_spec.rb +0 -26
- data/spec/lib/sourcerer/source_types/zip_spec.rb +0 -2
- data/spec/lib/sourcerer_spec.rb +0 -15
- data/spec/spec_helper.rb +0 -74
@@ -1,15 +0,0 @@
|
|
1
|
-
describe Sourcerer::Error do
|
2
|
-
before do
|
3
|
-
@error_instance = Sourcerer::Error.allocate
|
4
|
-
end
|
5
|
-
|
6
|
-
describe '#initialize' do
|
7
|
-
before do
|
8
|
-
@error = @error_instance.send :initialize, 'foo.bar', foo: 'FOO', bar: 'BAR'
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should look up i18n values' do
|
12
|
-
expect(@error).to eq 'This FOO is a BAR'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,139 +0,0 @@
|
|
1
|
-
describe Sourcerer::SourceType do
|
2
|
-
before do
|
3
|
-
class Sourcerer::SourceType::Foo < Sourcerer::SourceType
|
4
|
-
def move source, destination, options
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
@foo_source_type = Sourcerer::SourceType::Foo.allocate
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#initialize' do
|
12
|
-
it 'should call the move method on the source type instance' do
|
13
|
-
allow(@foo_source_type).to receive(:move)
|
14
|
-
|
15
|
-
@foo_source_type.send :initialize, 'source', 'destination', foo: 'foo'
|
16
|
-
|
17
|
-
expect(@foo_source_type).to have_received(:move).with 'source', 'destination', foo: 'foo'
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'when destination directory already exists' do
|
21
|
-
it 'should raise an error' do
|
22
|
-
allow(Dir).to receive(:exist?).and_return true
|
23
|
-
|
24
|
-
expect{ @foo_source_type.send(:initialize, 'source', 'destination', foo: 'foo') }.to raise_error Sourcerer::Error
|
25
|
-
|
26
|
-
allow(Dir).to receive(:exist?).and_call_original
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#files' do
|
32
|
-
before do
|
33
|
-
@foo_source_type.instance_variable_set :@destination, File.expand_path('spec/fixtures/source.dir')
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'when relative is set to false' do
|
37
|
-
context 'when :all' do
|
38
|
-
it 'should return all files' do
|
39
|
-
expect(@foo_source_type.files(:all, false)).to contain_exactly(
|
40
|
-
File.expand_path('spec/fixtures/source.dir/bar/file.bar'),
|
41
|
-
File.expand_path('spec/fixtures/source.dir/foo/file.foo'),
|
42
|
-
File.expand_path('spec/fixtures/source.dir/.hidden_foo')
|
43
|
-
)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'when :hidden' do
|
48
|
-
it 'should return only hidden files' do
|
49
|
-
expect(@foo_source_type.files(:hidden, false)).to contain_exactly(
|
50
|
-
File.expand_path('spec/fixtures/source.dir/.hidden_foo')
|
51
|
-
)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'when custom glob' do
|
56
|
-
it 'should return matching files' do
|
57
|
-
expect(@foo_source_type.files('**/file*', false)).to contain_exactly(
|
58
|
-
File.expand_path('spec/fixtures/source.dir/bar/file.bar'),
|
59
|
-
File.expand_path('spec/fixtures/source.dir/foo/file.foo')
|
60
|
-
)
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should return matching files' do
|
64
|
-
expect(@foo_source_type.files('**/*foo', false)).to contain_exactly(
|
65
|
-
File.expand_path('spec/fixtures/source.dir/foo/file.foo'),
|
66
|
-
File.expand_path('spec/fixtures/source.dir/.hidden_foo')
|
67
|
-
)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'when relative is set to true' do
|
73
|
-
context 'when :all' do
|
74
|
-
it 'should return all files' do
|
75
|
-
expect(@foo_source_type.files(:all, true)).to contain_exactly(
|
76
|
-
'bar/file.bar',
|
77
|
-
'foo/file.foo',
|
78
|
-
'.hidden_foo'
|
79
|
-
)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'when :hidden' do
|
84
|
-
it 'should return only hidden files' do
|
85
|
-
expect(@foo_source_type.files(:hidden, true)).to contain_exactly(
|
86
|
-
'.hidden_foo'
|
87
|
-
)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'when custom glob' do
|
92
|
-
it 'should return matching files' do
|
93
|
-
expect(@foo_source_type.files('**/file*', true)).to contain_exactly(
|
94
|
-
'bar/file.bar',
|
95
|
-
'foo/file.foo'
|
96
|
-
)
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should return matching files' do
|
100
|
-
expect(@foo_source_type.files('**/*foo', true)).to contain_exactly(
|
101
|
-
'foo/file.foo',
|
102
|
-
'.hidden_foo'
|
103
|
-
)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# Test supported local source types
|
110
|
-
# All sources must have the following structure
|
111
|
-
# |_ bar
|
112
|
-
# | |_ file.bar
|
113
|
-
# |_ foo
|
114
|
-
# | |_ file.foo
|
115
|
-
# |_ .hidden_foo
|
116
|
-
#
|
117
|
-
describe 'supported local source types' do
|
118
|
-
source_types = {
|
119
|
-
dir: 'spec/fixtures/source.dir',
|
120
|
-
git: 'spec/fixtures/source.git',
|
121
|
-
zip: 'spec/fixtures/source.zip'
|
122
|
-
}
|
123
|
-
|
124
|
-
source_types.each do |type, source|
|
125
|
-
describe "#{type} source from #{source}" do
|
126
|
-
before do
|
127
|
-
@tmp_dir = File.join Dir.mktmpdir, type.to_s
|
128
|
-
@source_type = "Sourcerer::SourceType::#{type.to_s.classify}".constantize.new source, @tmp_dir, {}
|
129
|
-
end
|
130
|
-
|
131
|
-
it 'should copy files to the destination' do
|
132
|
-
expect(File.exist?(File.join(@tmp_dir, 'bar', 'file.bar'))).to be true
|
133
|
-
expect(File.exist?(File.join(@tmp_dir, 'foo', 'file.foo'))).to be true
|
134
|
-
expect(File.exist?(File.join(@tmp_dir, '.hidden_foo'))).to be true
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
describe Sourcerer::SourceType::Git do
|
2
|
-
@repo_formats = [
|
3
|
-
'https://github.com/brewster1134/sourcerer.git',
|
4
|
-
'https://github.com/brewster1134/sourcerer',
|
5
|
-
'git@github.com:brewster1134/sourcerer.git',
|
6
|
-
'brewster1134/sourcerer'
|
7
|
-
]
|
8
|
-
|
9
|
-
before do
|
10
|
-
@source_type = Sourcerer::SourceType::Git.allocate
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
allow(Git).to receive(:clone).and_call_original
|
15
|
-
end
|
16
|
-
|
17
|
-
@repo_formats.each do |repo|
|
18
|
-
it 'should handle different remote repo formats' do
|
19
|
-
allow(Git).to receive(:clone)
|
20
|
-
|
21
|
-
@source_type.move repo, 'destination', {}
|
22
|
-
|
23
|
-
expect(Git).to have_received(:clone).with('https://github.com/brewster1134/sourcerer.git', 'destination')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/lib/sourcerer_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
describe Sourcerer do
|
2
|
-
before do
|
3
|
-
allow(Sourcerer::Core).to receive(:new)
|
4
|
-
|
5
|
-
@sourcerer = Sourcerer.new 'source', 'destination', foo: 'foo'
|
6
|
-
end
|
7
|
-
|
8
|
-
after do
|
9
|
-
allow(Sourcerer::Core).to receive(:new).and_call_original
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should allow .new on namespace' do
|
13
|
-
expect(Sourcerer::Core).to have_received(:new).with 'source', 'destination', foo: 'foo'
|
14
|
-
end
|
15
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'coveralls'
|
2
|
-
Coveralls.wear!
|
3
|
-
require 'sourcerer'
|
4
|
-
|
5
|
-
I18n.load_path << File.expand_path(File.join('spec', 'fixtures', 'i18n.yml'))
|
6
|
-
I18n.locale = 'spec'
|
7
|
-
I18n.reload!
|
8
|
-
|
9
|
-
def root *paths
|
10
|
-
paths.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..'))).compact.join '/'
|
11
|
-
end
|
12
|
-
|
13
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
14
|
-
RSpec.configure do |config|
|
15
|
-
# The settings below are suggested to provide a good initial experience
|
16
|
-
# with RSpec, but feel free to customize to your heart's content.
|
17
|
-
|
18
|
-
# These two settings work together to allow you to limit a spec run
|
19
|
-
# to individual examples or groups you care about by tagging them with
|
20
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
21
|
-
# get run.
|
22
|
-
config.filter_run :focus
|
23
|
-
config.run_all_when_everything_filtered = true
|
24
|
-
|
25
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
26
|
-
# file, and it's useful to allow more verbose output when running an
|
27
|
-
# individual spec file.
|
28
|
-
if config.files_to_run.one?
|
29
|
-
# Use the documentation formatter for detailed output,
|
30
|
-
# unless a formatter has already been configured
|
31
|
-
# (e.g. via a command-line flag).
|
32
|
-
config.default_formatter = 'doc'
|
33
|
-
end
|
34
|
-
|
35
|
-
# Print the 10 slowest examples and example groups at the
|
36
|
-
# end of the spec run, to help surface which specs are running
|
37
|
-
# particularly slow.
|
38
|
-
config.profile_examples = 5
|
39
|
-
|
40
|
-
# Run specs in random order to surface order dependencies. If you find an
|
41
|
-
# order dependency and want to debug it, you can fix the order by providing
|
42
|
-
# the seed, which is printed after each run.
|
43
|
-
# --seed 1234
|
44
|
-
config.order = :random
|
45
|
-
|
46
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
47
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
48
|
-
# test failures related to randomization by passing the same `--seed` value
|
49
|
-
# as the one that triggered the failure.
|
50
|
-
Kernel.srand config.seed
|
51
|
-
|
52
|
-
# rspec-expectations config goes here. You can use an alternate
|
53
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
54
|
-
# assertions if you prefer.
|
55
|
-
config.expect_with :rspec do |expectations|
|
56
|
-
# Enable only the newer, non-monkey-patching expect syntax.
|
57
|
-
# For more details, see:
|
58
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
59
|
-
expectations.syntax = :expect
|
60
|
-
end
|
61
|
-
|
62
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
63
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
64
|
-
config.mock_with :rspec do |mocks|
|
65
|
-
# Enable only the newer, non-monkey-patching expect syntax.
|
66
|
-
# For more details, see:
|
67
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
68
|
-
mocks.syntax = :expect
|
69
|
-
|
70
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
71
|
-
# a real object. This is generally recommended.
|
72
|
-
mocks.verify_partial_doubles = true
|
73
|
-
end
|
74
|
-
end
|