skellington 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +0 -70
- data/config/config.yaml +8 -6
- data/lib/skellington/version.rb +1 -1
- data/lib/templates/.gitignore.eruby +1 -0
- data/lib/templates/Guardfile.eruby +28 -0
- data/spec/cli/app_spec.rb +3 -3
- data/spec/cli/bootstrap_spec.rb +3 -3
- data/spec/cli/config_ru_spec.rb +1 -1
- data/spec/cli/cukes_spec.rb +3 -3
- data/spec/cli/gemfile_spec.rb +8 -8
- data/spec/cli/git_spec.rb +7 -1
- data/spec/cli/guardfile_spec.rb +43 -0
- data/spec/cli/javascript_spec.rb +2 -2
- data/spec/cli/non_local_path_spec.rb +2 -2
- data/spec/cli/procfile_spec.rb +1 -1
- data/spec/cli/rakefile_spec.rb +1 -1
- data/spec/cli/rbenv_spec.rb +2 -2
- data/spec/cli/spec_spec.rb +3 -3
- data/spec/matcher/have_content_spec.rb +137 -0
- data/spec/spec_helper.rb +9 -20
- data/spec/support/matchers/have_content.rb +47 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4200cea11887c45594dd4eb6ef40e24f0d68131d
|
4
|
+
data.tar.gz: c392b90548b4f2c635c8e3cf0566d49f689a23c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcf0cd22bb591abfe073886523d1956334210b47e0e46237a518e663e2787e4dc4d05d1dcb22b1ae26af839fbc7b06c086c668a07f2c2c61c505d2f67599a894
|
7
|
+
data.tar.gz: 5db49c880a4657a7e08a0b3431ace03adce16dea3e480d5299ae34b74c7547f589b319d600e901f82094c895f2da80a6f990aa1462a4b24e36598a4749f90a61
|
data/Guardfile
CHANGED
@@ -1,37 +1,3 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
## Uncomment and set this to only include directories you want to watch
|
5
|
-
# directories %w(app lib config test spec feature)
|
6
|
-
|
7
|
-
## Uncomment to clear the screen before every task
|
8
|
-
# clearing :on
|
9
|
-
|
10
|
-
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
-
## If you want Guard to automatically start up again, run guard in a
|
12
|
-
## shell loop, e.g.:
|
13
|
-
##
|
14
|
-
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
-
##
|
16
|
-
## Note: if you are using the `directories` clause above and you are not
|
17
|
-
## watching the project directory ('.'), the you will want to move the Guardfile
|
18
|
-
## to a watched dir and symlink it back, e.g.
|
19
|
-
#
|
20
|
-
# $ mkdir config
|
21
|
-
# $ mv Guardfile config/
|
22
|
-
# $ ln -s config/Guardfile .
|
23
|
-
#
|
24
|
-
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
-
|
26
|
-
# Note: The cmd option is now required due to the increasing number of ways
|
27
|
-
# rspec may be run, below are examples of the most common uses.
|
28
|
-
# * bundler: 'bundle exec rspec'
|
29
|
-
# * bundler binstubs: 'bin/rspec'
|
30
|
-
# * spring: 'bin/rspec' (This will use spring if running and you have
|
31
|
-
# installed the spring binstubs per the docs)
|
32
|
-
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
33
|
-
# * 'just' rspec: 'rspec'
|
34
|
-
|
35
1
|
guard :rspec, cmd: "bundle exec rspec" do
|
36
2
|
require "guard/rspec/dsl"
|
37
3
|
dsl = Guard::RSpec::Dsl.new(self)
|
@@ -47,40 +13,4 @@ guard :rspec, cmd: "bundle exec rspec" do
|
|
47
13
|
# Ruby files
|
48
14
|
ruby = dsl.ruby
|
49
15
|
dsl.watch_spec_files_for(ruby.lib_files)
|
50
|
-
|
51
|
-
# Rails files
|
52
|
-
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
53
|
-
dsl.watch_spec_files_for(rails.app_files)
|
54
|
-
dsl.watch_spec_files_for(rails.views)
|
55
|
-
|
56
|
-
watch(rails.controllers) do |m|
|
57
|
-
[
|
58
|
-
rspec.spec.("routing/#{m[1]}_routing"),
|
59
|
-
rspec.spec.("controllers/#{m[1]}_controller"),
|
60
|
-
rspec.spec.("acceptance/#{m[1]}")
|
61
|
-
]
|
62
|
-
end
|
63
|
-
|
64
|
-
# Rails config changes
|
65
|
-
watch(rails.spec_helper) { rspec.spec_dir }
|
66
|
-
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
67
|
-
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
68
|
-
|
69
|
-
# Capybara features specs
|
70
|
-
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
71
|
-
|
72
|
-
# Turnip features and steps
|
73
|
-
watch(%r{^spec/acceptance/(.+)\.feature$})
|
74
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
75
|
-
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
guard "cucumber" do
|
80
|
-
watch(%r{^features/.+\.feature$})
|
81
|
-
watch(%r{^features/support/.+$}) { "features" }
|
82
|
-
|
83
|
-
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
|
84
|
-
"features"
|
85
|
-
end
|
86
16
|
end
|
data/config/config.yaml
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
gems:
|
2
2
|
production:
|
3
3
|
- sinatra
|
4
|
-
- puma
|
5
|
-
- rake
|
6
4
|
- rack-conneg
|
5
|
+
- rake
|
6
|
+
- puma
|
7
7
|
|
8
8
|
test:
|
9
9
|
- cucumber
|
10
|
-
- capybara
|
11
|
-
- coveralls
|
12
|
-
- jasmine
|
13
10
|
- rspec
|
11
|
+
- guard
|
14
12
|
- guard-rspec
|
15
13
|
- guard-jasmine
|
16
|
-
- guard
|
17
14
|
- guard-cucumber
|
15
|
+
- capybara
|
16
|
+
- coveralls
|
17
|
+
- jasmine
|
18
18
|
- pry
|
19
19
|
- actionpack
|
20
20
|
|
@@ -23,10 +23,12 @@ gems:
|
|
23
23
|
|
24
24
|
files:
|
25
25
|
Gemfile:
|
26
|
+
Guardfile:
|
26
27
|
Rakefile:
|
27
28
|
Procfile:
|
28
29
|
.ruby-version:
|
29
30
|
.rspec:
|
31
|
+
.gitignore:
|
30
32
|
config.ru:
|
31
33
|
# the template has this name
|
32
34
|
features/first.feature:
|
data/lib/skellington/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
coverage/
|
@@ -0,0 +1,28 @@
|
|
1
|
+
guard :cucumber do
|
2
|
+
watch %r{^features/.+\.feature$}
|
3
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
4
|
+
|
5
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
|
6
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || 'features'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
guard :jasmine do
|
11
|
+
watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { 'spec/javascripts' }
|
12
|
+
watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$})
|
13
|
+
watch(%r{spec/javascripts/fixtures/.+$})
|
14
|
+
watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{ m[1] }_spec.#{ m[2] }" }
|
15
|
+
end
|
16
|
+
|
17
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
18
|
+
require 'guard/rspec/dsl'
|
19
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
20
|
+
|
21
|
+
rspec = dsl.rspec
|
22
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
23
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
24
|
+
watch(rspec.spec_files)
|
25
|
+
|
26
|
+
ruby = dsl.ruby
|
27
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
28
|
+
end
|
data/spec/cli/app_spec.rb
CHANGED
@@ -6,7 +6,7 @@ module Skellington
|
|
6
6
|
|
7
7
|
it 'generates an app file' do
|
8
8
|
subject.generate 'dummy_app'
|
9
|
-
expect('dummy_app/lib/dummy_app.rb').to
|
9
|
+
expect('dummy_app/lib/dummy_app.rb').to have_content (
|
10
10
|
"""
|
11
11
|
require 'sinatra/base'
|
12
12
|
require 'tilt/erubis'
|
@@ -43,7 +43,7 @@ module Skellington
|
|
43
43
|
"""
|
44
44
|
)
|
45
45
|
|
46
|
-
expect('dummy_app/lib/dummy_app/racks.rb').to
|
46
|
+
expect('dummy_app/lib/dummy_app/racks.rb').to have_content (
|
47
47
|
"""
|
48
48
|
require 'rack/conneg'
|
49
49
|
|
@@ -72,7 +72,7 @@ module Skellington
|
|
72
72
|
"""
|
73
73
|
)
|
74
74
|
|
75
|
-
expect('dummy_app/lib/dummy_app/helpers.rb').to
|
75
|
+
expect('dummy_app/lib/dummy_app/helpers.rb').to have_content (
|
76
76
|
"""
|
77
77
|
module DummyApp
|
78
78
|
module Helpers
|
data/spec/cli/bootstrap_spec.rb
CHANGED
@@ -6,7 +6,7 @@ module Skellington
|
|
6
6
|
|
7
7
|
it 'generates a bootstrap template' do
|
8
8
|
subject.generate 'dummy_app'
|
9
|
-
expect('dummy_app/views/default.erb').to
|
9
|
+
expect('dummy_app/views/default.erb').to have_content (
|
10
10
|
"""
|
11
11
|
<!DOCTYPE html>
|
12
12
|
<html lang='en'>
|
@@ -26,7 +26,7 @@ module Skellington
|
|
26
26
|
"""
|
27
27
|
)
|
28
28
|
|
29
|
-
expect('dummy_app/views/includes/header.erb').to
|
29
|
+
expect('dummy_app/views/includes/header.erb').to have_content (
|
30
30
|
"""
|
31
31
|
<head>
|
32
32
|
<meta charset='utf-8' />
|
@@ -52,7 +52,7 @@ module Skellington
|
|
52
52
|
</head>
|
53
53
|
"""
|
54
54
|
)
|
55
|
-
expect('dummy_app/views/index.erb').to
|
55
|
+
expect('dummy_app/views/index.erb').to have_content (
|
56
56
|
"""
|
57
57
|
<%= @content %>
|
58
58
|
"""
|
data/spec/cli/config_ru_spec.rb
CHANGED
data/spec/cli/cukes_spec.rb
CHANGED
@@ -6,7 +6,7 @@ module Skellington
|
|
6
6
|
|
7
7
|
it 'generates some cucumber file' do
|
8
8
|
subject.generate 'dummy_app'
|
9
|
-
expect('dummy_app/features/dummy_app.feature').to
|
9
|
+
expect('dummy_app/features/dummy_app.feature').to have_content (
|
10
10
|
"""
|
11
11
|
Feature: Make sure DummyApp is plumbed in correctly
|
12
12
|
|
@@ -16,7 +16,7 @@ module Skellington
|
|
16
16
|
"""
|
17
17
|
)
|
18
18
|
|
19
|
-
expect('dummy_app/features/json.feature').to
|
19
|
+
expect('dummy_app/features/json.feature').to have_content (
|
20
20
|
"""
|
21
21
|
Feature: Get JSON
|
22
22
|
|
@@ -30,7 +30,7 @@ module Skellington
|
|
30
30
|
"""
|
31
31
|
)
|
32
32
|
|
33
|
-
expect('dummy_app/features/support/env.rb').to
|
33
|
+
expect('dummy_app/features/support/env.rb').to have_content (
|
34
34
|
"""
|
35
35
|
ENV['RACK_ENV'] = 'test'
|
36
36
|
|
data/spec/cli/gemfile_spec.rb
CHANGED
@@ -6,27 +6,27 @@ module Skellington
|
|
6
6
|
|
7
7
|
it 'generates a Gemfile' do
|
8
8
|
subject.generate 'dummy_app'
|
9
|
-
expect('dummy_app/Gemfile').to
|
9
|
+
expect('dummy_app/Gemfile').to have_content (
|
10
10
|
"""
|
11
11
|
source 'https://rubygems.org'
|
12
12
|
|
13
|
-
/ruby [0-9]
|
13
|
+
/ruby '[0-9]*\\.[0-9]*\\.[0-9]*'/
|
14
14
|
|
15
15
|
gem 'sinatra'
|
16
|
-
gem 'puma'
|
17
|
-
gem 'rake'
|
18
16
|
gem 'rack-conneg'
|
17
|
+
gem 'rake'
|
18
|
+
gem 'puma'
|
19
19
|
|
20
20
|
group :test do
|
21
21
|
gem 'cucumber'
|
22
|
-
gem 'capybara'
|
23
|
-
gem 'coveralls'
|
24
|
-
gem 'jasmine'
|
25
22
|
gem 'rspec'
|
23
|
+
gem 'guard'
|
26
24
|
gem 'guard-rspec'
|
27
25
|
gem 'guard-jasmine'
|
28
|
-
gem 'guard'
|
29
26
|
gem 'guard-cucumber'
|
27
|
+
gem 'capybara'
|
28
|
+
gem 'coveralls'
|
29
|
+
gem 'jasmine'
|
30
30
|
gem 'pry'
|
31
31
|
gem 'actionpack'
|
32
32
|
gem 'cucumber-api-steps', require: false
|
data/spec/cli/git_spec.rb
CHANGED
@@ -4,9 +4,15 @@ module Skellington
|
|
4
4
|
described_class.new
|
5
5
|
end
|
6
6
|
|
7
|
-
it '
|
7
|
+
it 'initialises a git repo' do
|
8
8
|
subject.generate 'dummy_app'
|
9
9
|
expect(Dir).to exist 'dummy_app/.git'
|
10
|
+
|
11
|
+
expect('dummy_app/.gitignore').to have_content (
|
12
|
+
"""
|
13
|
+
coverage/
|
14
|
+
"""
|
15
|
+
)
|
10
16
|
end
|
11
17
|
end
|
12
18
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Skellington
|
2
|
+
describe CLI do
|
3
|
+
let :subject do
|
4
|
+
described_class.new
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'generates a Guardfile' do
|
8
|
+
subject.generate 'dummy_app'
|
9
|
+
expect('dummy_app/Guardfile').to have_content (
|
10
|
+
"""
|
11
|
+
guard :cucumber do
|
12
|
+
/watch/
|
13
|
+
/watch/
|
14
|
+
|
15
|
+
/watch/
|
16
|
+
/Dir/
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
guard :jasmine do
|
21
|
+
/watch/
|
22
|
+
/watch/
|
23
|
+
/watch/
|
24
|
+
/watch/
|
25
|
+
end
|
26
|
+
|
27
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
28
|
+
require 'guard/rspec/dsl'
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
rspec = dsl.rspec
|
32
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
33
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
34
|
+
watch(rspec.spec_files)
|
35
|
+
|
36
|
+
ruby = dsl.ruby
|
37
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
38
|
+
end
|
39
|
+
"""
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/cli/javascript_spec.rb
CHANGED
@@ -6,7 +6,7 @@ module Skellington
|
|
6
6
|
|
7
7
|
it 'generates javascript files' do
|
8
8
|
subject.generate 'dummy_app'
|
9
|
-
expect('dummy_app/spec/javascripts/support/jasmine.yml').to
|
9
|
+
expect('dummy_app/spec/javascripts/support/jasmine.yml').to have_content (
|
10
10
|
"""
|
11
11
|
src_files:
|
12
12
|
- public/js/**/*.js
|
@@ -28,7 +28,7 @@ module Skellington
|
|
28
28
|
|
29
29
|
expect(File).to exist 'dummy_app/spec/javascripts/support/jasmine_helper.rb'
|
30
30
|
|
31
|
-
expect('dummy_app/spec/javascripts/dummy_appSpec.js').to
|
31
|
+
expect('dummy_app/spec/javascripts/dummy_appSpec.js').to have_content (
|
32
32
|
"""
|
33
33
|
describe('DummyApp', function() {
|
34
34
|
it('knows the truth', function() {
|
@@ -6,7 +6,7 @@ module Skellington
|
|
6
6
|
|
7
7
|
it 'generates an app at a non-local path' do
|
8
8
|
subject.generate 'subdir/some_app'
|
9
|
-
expect('subdir/some_app/lib/some_app.rb').to
|
9
|
+
expect('subdir/some_app/lib/some_app.rb').to have_content (
|
10
10
|
"""
|
11
11
|
require 'sinatra/base'
|
12
12
|
require 'tilt/erubis'
|
@@ -43,7 +43,7 @@ module Skellington
|
|
43
43
|
"""
|
44
44
|
)
|
45
45
|
|
46
|
-
expect('subdir/some_app/config.ru').to
|
46
|
+
expect('subdir/some_app/config.ru').to have_content (
|
47
47
|
"""
|
48
48
|
require File.join(File.dirname(__FILE__), 'lib/some_app.rb')
|
49
49
|
|
data/spec/cli/procfile_spec.rb
CHANGED
data/spec/cli/rakefile_spec.rb
CHANGED
data/spec/cli/rbenv_spec.rb
CHANGED
@@ -7,9 +7,9 @@ module Skellington
|
|
7
7
|
it 'generates a .ruby-version' do
|
8
8
|
subject.generate 'dummy_app'
|
9
9
|
expect(File).to exist 'dummy_app/.ruby-version'
|
10
|
-
expect('dummy_app/.ruby-version').to
|
10
|
+
expect('dummy_app/.ruby-version').to have_content (
|
11
11
|
"""
|
12
|
-
/[0-9]
|
12
|
+
/[0-9]*\\.[0-9]*\\.[0-9]*/
|
13
13
|
"""
|
14
14
|
)
|
15
15
|
end
|
data/spec/cli/spec_spec.rb
CHANGED
@@ -6,7 +6,7 @@ module Skellington
|
|
6
6
|
|
7
7
|
it 'generates rspec files' do
|
8
8
|
subject.generate 'dummy_app'
|
9
|
-
expect('dummy_app/spec/spec_helper.rb').to
|
9
|
+
expect('dummy_app/spec/spec_helper.rb').to have_content (
|
10
10
|
"""
|
11
11
|
require 'coveralls'
|
12
12
|
Coveralls.wear_merged!
|
@@ -27,7 +27,7 @@ module Skellington
|
|
27
27
|
"""
|
28
28
|
)
|
29
29
|
|
30
|
-
expect('dummy_app/spec/dummy_app/dummy_app_spec.rb').to
|
30
|
+
expect('dummy_app/spec/dummy_app/dummy_app_spec.rb').to have_content (
|
31
31
|
"""
|
32
32
|
module DummyApp
|
33
33
|
describe App do
|
@@ -39,7 +39,7 @@ module Skellington
|
|
39
39
|
"""
|
40
40
|
)
|
41
41
|
|
42
|
-
expect('dummy_app/.rspec').to
|
42
|
+
expect('dummy_app/.rspec').to have_content (
|
43
43
|
"""
|
44
44
|
--color
|
45
45
|
--require spec_helper
|
@@ -0,0 +1,137 @@
|
|
1
|
+
describe 'Matcher' do
|
2
|
+
context 'simple matches' do
|
3
|
+
it 'matches a file and a string' do
|
4
|
+
dump 'A string'
|
5
|
+
expect('matcher').to have_content 'A string'
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'matches two strings ignoring extra whitespace' do
|
9
|
+
dump ' Leading space'
|
10
|
+
expect('matcher').to have_content 'Leading space'
|
11
|
+
|
12
|
+
dump 'Trailing space '
|
13
|
+
expect('matcher').to have_content 'Trailing space'
|
14
|
+
|
15
|
+
dump ' Space at both ends '
|
16
|
+
expect('matcher').to have_content 'Space at both ends'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'does not match wrong strings' do
|
20
|
+
dump 'A string'
|
21
|
+
expect('matcher').to_not have_content 'A different string'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'multi-line matches' do
|
26
|
+
it 'matches on multi-line files' do
|
27
|
+
dump """
|
28
|
+
foo
|
29
|
+
bar
|
30
|
+
baz
|
31
|
+
"""
|
32
|
+
expect('matcher').to have_content (
|
33
|
+
"""
|
34
|
+
foo
|
35
|
+
bar
|
36
|
+
baz
|
37
|
+
"""
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'matches multi-line, ignoring extraneous whitespace' do
|
42
|
+
dump """
|
43
|
+
odd
|
44
|
+
spacing
|
45
|
+
here
|
46
|
+
"""
|
47
|
+
expect('matcher').to have_content (
|
48
|
+
"""
|
49
|
+
odd
|
50
|
+
spacing
|
51
|
+
here
|
52
|
+
"""
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'ignores blank lines' do
|
57
|
+
dump """
|
58
|
+
|
59
|
+
this
|
60
|
+
has
|
61
|
+
a blank
|
62
|
+
"""
|
63
|
+
expect('matcher').to have_content (
|
64
|
+
"""
|
65
|
+
this
|
66
|
+
has
|
67
|
+
a blank
|
68
|
+
"""
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'even blank lines in the middle of the file' do
|
73
|
+
dump """
|
74
|
+
this
|
75
|
+
is
|
76
|
+
|
77
|
+
a
|
78
|
+
file
|
79
|
+
"""
|
80
|
+
expect('matcher').to have_content (
|
81
|
+
"""
|
82
|
+
this
|
83
|
+
is
|
84
|
+
a
|
85
|
+
file
|
86
|
+
"""
|
87
|
+
)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'regular expressions' do
|
92
|
+
it 'matches on a regex' do
|
93
|
+
dump 'partial match'
|
94
|
+
expect('matcher').to have_content '/partial/'
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'matches on a regex somewhere in a file' do
|
98
|
+
dump """
|
99
|
+
source 'https://rubygems.org'
|
100
|
+
|
101
|
+
ruby '2.3.0'
|
102
|
+
|
103
|
+
gem 'skellington'
|
104
|
+
"""
|
105
|
+
expect('matcher').to have_content (
|
106
|
+
"""
|
107
|
+
source 'https://rubygems.org'
|
108
|
+
|
109
|
+
/ruby '[0-9]*\.[0-9]*\.[0-9]*'/
|
110
|
+
|
111
|
+
gem 'skellington'
|
112
|
+
"""
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'fails on a non-match' do
|
117
|
+
dump """
|
118
|
+
foo
|
119
|
+
ruby '2.3.0'
|
120
|
+
bar
|
121
|
+
"""
|
122
|
+
expect('matcher').to_not have_content (
|
123
|
+
"""
|
124
|
+
foo
|
125
|
+
ruby 2.3.0
|
126
|
+
bar
|
127
|
+
"""
|
128
|
+
)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def dump content
|
134
|
+
File.open 'matcher', 'w' do |f|
|
135
|
+
f.write content
|
136
|
+
end
|
137
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,12 +16,19 @@ RSpec.configure do |config|
|
|
16
16
|
config.run_all_when_everything_filtered = true
|
17
17
|
config.order = :random
|
18
18
|
|
19
|
+
# Use tmp/ to write skellington
|
20
|
+
$pwd = FileUtils.pwd
|
19
21
|
config.before(:each) do
|
20
22
|
FileUtils.rm_rf 'tmp'
|
21
23
|
FileUtils.mkdir_p 'tmp'
|
22
24
|
FileUtils.cd 'tmp'
|
23
25
|
end
|
24
26
|
|
27
|
+
config.after(:each) do
|
28
|
+
FileUtils.cd $pwd
|
29
|
+
end
|
30
|
+
|
31
|
+
# Suppress CLI output. This *will* fuck with Pry
|
25
32
|
original_stderr = $stderr
|
26
33
|
original_stdout = $stdout
|
27
34
|
config.before(:all) do
|
@@ -29,29 +36,11 @@ RSpec.configure do |config|
|
|
29
36
|
$stderr = File.new '/dev/null', 'w'
|
30
37
|
$stdout = File.new '/dev/null', 'w'
|
31
38
|
end
|
39
|
+
|
32
40
|
config.after(:all) do
|
33
41
|
$stderr = original_stderr
|
34
42
|
$stdout = original_stdout
|
35
43
|
end
|
36
44
|
end
|
37
45
|
|
38
|
-
|
39
|
-
match do |actual|
|
40
|
-
x = expected.split("\n").map { |l| l.strip }.reject { |m| m == '' }
|
41
|
-
a = File.readlines(actual).map { |l| l.strip }.reject { |m| m == '' }
|
42
|
-
|
43
|
-
pass = true
|
44
|
-
x.each_with_index do |e, i|
|
45
|
-
if /^\/.*\/$/.match e.strip
|
46
|
-
unless Regexp.new(e.strip[1..-2]).match a[i].strip
|
47
|
-
pass = false
|
48
|
-
end
|
49
|
-
else
|
50
|
-
unless e.strip == a[i].strip
|
51
|
-
pass = false
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
pass
|
56
|
-
end
|
57
|
-
end
|
46
|
+
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
RSpec::Matchers.define :have_content do |expected|
|
2
|
+
match do |actual|
|
3
|
+
actual = File.read actual
|
4
|
+
|
5
|
+
pass = true
|
6
|
+
expected.contentise.each_with_index do |line, index|
|
7
|
+
unless line.matches actual.contentise[index]
|
8
|
+
pass = false
|
9
|
+
end
|
10
|
+
end
|
11
|
+
pass
|
12
|
+
end
|
13
|
+
|
14
|
+
failure_message do |actual|
|
15
|
+
"expected #{expected} to match #{File.read actual}"
|
16
|
+
end
|
17
|
+
|
18
|
+
failure_message_when_negated do |actual|
|
19
|
+
"expected #{expected} to not match #{File.read actual}"
|
20
|
+
end
|
21
|
+
|
22
|
+
description do
|
23
|
+
'matches file content against expectation'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class String
|
28
|
+
def contentise
|
29
|
+
# split into lines, strip spaces from ends, ding blank lines
|
30
|
+
self.strip.split("\n").map { |l| l.strip }.reject { |l| l == '' }
|
31
|
+
end
|
32
|
+
|
33
|
+
def matches other
|
34
|
+
if self.is_regex
|
35
|
+
return self.to_regex.match other
|
36
|
+
end
|
37
|
+
self == other
|
38
|
+
end
|
39
|
+
|
40
|
+
def is_regex
|
41
|
+
/^\/.*\/$/.match self.strip
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_regex
|
45
|
+
Regexp.new self[1..-2]
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skellington
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pikesley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -147,9 +147,11 @@ files:
|
|
147
147
|
- lib/skellington/helpers.rb
|
148
148
|
- lib/skellington/template.rb
|
149
149
|
- lib/skellington/version.rb
|
150
|
+
- lib/templates/.gitignore.eruby
|
150
151
|
- lib/templates/.rspec.eruby
|
151
152
|
- lib/templates/.ruby-version.eruby
|
152
153
|
- lib/templates/Gemfile.eruby
|
154
|
+
- lib/templates/Guardfile.eruby
|
153
155
|
- lib/templates/Procfile.eruby
|
154
156
|
- lib/templates/Rakefile.eruby
|
155
157
|
- lib/templates/config.ru.eruby
|
@@ -179,6 +181,7 @@ files:
|
|
179
181
|
- spec/cli/cukes_spec.rb
|
180
182
|
- spec/cli/gemfile_spec.rb
|
181
183
|
- spec/cli/git_spec.rb
|
184
|
+
- spec/cli/guardfile_spec.rb
|
182
185
|
- spec/cli/javascript_spec.rb
|
183
186
|
- spec/cli/non_local_path_spec.rb
|
184
187
|
- spec/cli/procfile_spec.rb
|
@@ -188,8 +191,10 @@ files:
|
|
188
191
|
- spec/cli/spec_spec.rb
|
189
192
|
- spec/cli_spec.rb
|
190
193
|
- spec/hyphens_spec.rb
|
194
|
+
- spec/matcher/have_content_spec.rb
|
191
195
|
- spec/skellington_spec.rb
|
192
196
|
- spec/spec_helper.rb
|
197
|
+
- spec/support/matchers/have_content.rb
|
193
198
|
homepage: http://sam.pikesley.org/projects/skellington/
|
194
199
|
licenses:
|
195
200
|
- MIT
|
@@ -221,6 +226,7 @@ test_files:
|
|
221
226
|
- spec/cli/cukes_spec.rb
|
222
227
|
- spec/cli/gemfile_spec.rb
|
223
228
|
- spec/cli/git_spec.rb
|
229
|
+
- spec/cli/guardfile_spec.rb
|
224
230
|
- spec/cli/javascript_spec.rb
|
225
231
|
- spec/cli/non_local_path_spec.rb
|
226
232
|
- spec/cli/procfile_spec.rb
|
@@ -230,5 +236,7 @@ test_files:
|
|
230
236
|
- spec/cli/spec_spec.rb
|
231
237
|
- spec/cli_spec.rb
|
232
238
|
- spec/hyphens_spec.rb
|
239
|
+
- spec/matcher/have_content_spec.rb
|
233
240
|
- spec/skellington_spec.rb
|
234
241
|
- spec/spec_helper.rb
|
242
|
+
- spec/support/matchers/have_content.rb
|