clintegracon 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +158 -0
- data/Rakefile +60 -0
- data/clintegracon.gemspec +34 -0
- data/lib/CLIntegracon.rb +9 -0
- data/lib/CLIntegracon/adapter/bacon.rb +208 -0
- data/lib/CLIntegracon/configuration.rb +67 -0
- data/lib/CLIntegracon/diff.rb +81 -0
- data/lib/CLIntegracon/file_tree_spec.rb +213 -0
- data/lib/CLIntegracon/file_tree_spec_context.rb +180 -0
- data/lib/CLIntegracon/formatter.rb +77 -0
- data/lib/CLIntegracon/subject.rb +128 -0
- data/lib/CLIntegracon/version.rb +3 -0
- data/spec/bacon/execution_output.txt +72 -0
- data/spec/bacon/spec_helper.rb +60 -0
- data/spec/fixtures/bin/coffeemaker.rb +58 -0
- data/spec/integration/coffeemaker_help/after/execution_output.txt +23 -0
- data/spec/integration/coffeemaker_help/before/.gitkeep +0 -0
- data/spec/integration/coffeemaker_no_milk/after/BlackEye.brewed-coffee +1 -0
- data/spec/integration/coffeemaker_no_milk/after/CaPheSuaDa.brewed-coffee +1 -0
- data/spec/integration/coffeemaker_no_milk/after/Coffeemakerfile.yml +5 -0
- data/spec/integration/coffeemaker_no_milk/after/RedTux.brewed-coffee +1 -0
- data/spec/integration/coffeemaker_no_milk/after/execution_output.txt +6 -0
- data/spec/integration/coffeemaker_no_milk/before/Coffeemakerfile.yml +5 -0
- data/spec/integration/coffeemaker_sweetner_honey/after/Affogato.brewed-coffee +2 -0
- data/spec/integration/coffeemaker_sweetner_honey/after/BlackEye.brewed-coffee +2 -0
- data/spec/integration/coffeemaker_sweetner_honey/after/Coffeemakerfile.yml +3 -0
- data/spec/integration/coffeemaker_sweetner_honey/after/RedTux.brewed-coffee +2 -0
- data/spec/integration/coffeemaker_sweetner_honey/after/execution_output.txt +4 -0
- data/spec/integration/coffeemaker_sweetner_honey/before/Coffeemakerfile.yml +3 -0
- data/spec/unit/adapter/bacon_spec.rb +187 -0
- data/spec/unit/configuration_spec.rb +72 -0
- metadata +176 -0
@@ -0,0 +1,187 @@
|
|
1
|
+
require 'CLIntegracon'
|
2
|
+
require 'mocha-on-bacon'
|
3
|
+
|
4
|
+
describe 'CLIntegracon::Adapter::Bacon' do
|
5
|
+
|
6
|
+
CLIntegracon.configure do
|
7
|
+
hook_into :bacon
|
8
|
+
end
|
9
|
+
|
10
|
+
# Mutes specs from output
|
11
|
+
def defines_specs
|
12
|
+
Bacon.expects(:handle_specification).yields
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#describe_cli' do
|
16
|
+
|
17
|
+
it 'is globally available' do
|
18
|
+
defines_specs.once
|
19
|
+
describe_cli('test') {}.should.be.an.instance_of? Bacon::Context
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'is available for Bacon::Context' do
|
23
|
+
defines_specs.twice
|
24
|
+
describe('test') do
|
25
|
+
describe_cli('test') {}.should.be.an.instance_of? Bacon::Context
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
shared 'extended context' do
|
30
|
+
it 'can access #describe_cli' do
|
31
|
+
@context.should.respond_to? :describe_cli
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'can access to methods defined in CLIntegracon::Adapter::Bacon::Context' do
|
35
|
+
@context.should.respond_to? :subject
|
36
|
+
@context.should.respond_to? :context
|
37
|
+
@context.should.respond_to? :cli_spec
|
38
|
+
@context.should.respond_to? :file_spec
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'extends context with methods' do
|
43
|
+
before do
|
44
|
+
defines_specs.once
|
45
|
+
@context = describe_cli('test') {}
|
46
|
+
end
|
47
|
+
|
48
|
+
behaves_like 'extended context'
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'extends inner context with methods' do
|
52
|
+
before do
|
53
|
+
defines_specs.twice
|
54
|
+
parent_context = self
|
55
|
+
describe_cli('test') do
|
56
|
+
@context = describe('inner') {}
|
57
|
+
parent_context.instance_variable_set '@context', @context
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
behaves_like 'extended context'
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'Context' do
|
67
|
+
|
68
|
+
MockContext = Class.new do
|
69
|
+
include CLIntegracon::Adapter::Bacon::Context
|
70
|
+
end
|
71
|
+
|
72
|
+
before do
|
73
|
+
@context = MockContext.new
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
shared 'mutating accessor' do
|
78
|
+
|
79
|
+
before do
|
80
|
+
def call_accessor(&block)
|
81
|
+
@context.send(@method, &block)
|
82
|
+
end
|
83
|
+
|
84
|
+
def set_ivar(value)
|
85
|
+
@context.instance_variable_set("@#{@method.to_s}", value)
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_ivar
|
89
|
+
@context.instance_variable_get("@#{@method.to_s}")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'with block argument' do
|
94
|
+
it 'should call the given block' do
|
95
|
+
proc = Proc.new {}
|
96
|
+
proc.expects(:call).once
|
97
|
+
call_accessor { proc.call() }
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should pass it as parameter to the given block' do
|
101
|
+
mock = mock()
|
102
|
+
set_ivar(mock)
|
103
|
+
call_accessor do |arg|
|
104
|
+
arg.should.be.equal? mock
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should get and keep a new if ivar is empty' do
|
109
|
+
set_ivar(nil)
|
110
|
+
call_accessor {}
|
111
|
+
get_ivar.should.be.an.instance_of? @type
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should get a new by duplicating from shared context' do
|
115
|
+
CLIntegracon.shared_config.expects(@method).returns mock(:dup)
|
116
|
+
call_accessor
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should keep the existing if there is one' do
|
120
|
+
mock = mock()
|
121
|
+
set_ivar(mock)
|
122
|
+
call_accessor {}
|
123
|
+
get_ivar.should.be.equal? mock
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe 'with block argument' do
|
128
|
+
it 'should instantiate and keep a new if ivar is empty' do
|
129
|
+
set_ivar(nil)
|
130
|
+
call_accessor.should.be.an.instance_of? @type
|
131
|
+
get_ivar.should.be.an.instance_of? @type
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should return the existing if there is one' do
|
135
|
+
mock = mock()
|
136
|
+
set_ivar(mock)
|
137
|
+
call_accessor.should.be.equal? mock
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
describe '#subject' do
|
144
|
+
before do
|
145
|
+
@method = :subject
|
146
|
+
@type = CLIntegracon::Subject
|
147
|
+
end
|
148
|
+
|
149
|
+
behaves_like 'mutating accessor'
|
150
|
+
end
|
151
|
+
|
152
|
+
describe '#context' do
|
153
|
+
before do
|
154
|
+
@method = :context
|
155
|
+
@type = CLIntegracon::FileTreeSpecContext
|
156
|
+
end
|
157
|
+
|
158
|
+
behaves_like 'mutating accessor'
|
159
|
+
end
|
160
|
+
|
161
|
+
describe '#file_spec' do
|
162
|
+
|
163
|
+
before do
|
164
|
+
defines_specs.once
|
165
|
+
CLIntegracon::FileTreeSpec.any_instance.stubs(:run)
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'knows the on-the-fly defined shared behavior' do
|
169
|
+
describe_cli 'git' do
|
170
|
+
lambda {
|
171
|
+
behaves_like file_spec('any_dir')
|
172
|
+
}.should.not.raise?(NameError)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'executes the FileTreeSpecContext' do
|
177
|
+
describe_cli 'git' do
|
178
|
+
context.expects(:spec).once.returns mock(:run => true)
|
179
|
+
behaves_like file_spec('git')
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'CLIntegracon'
|
2
|
+
require 'mocha-on-bacon'
|
3
|
+
|
4
|
+
describe CLIntegracon do
|
5
|
+
|
6
|
+
def subject
|
7
|
+
CLIntegracon
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#self.configure' do
|
11
|
+
|
12
|
+
after do
|
13
|
+
subject.shared_config = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should call the given block' do
|
17
|
+
proc = Proc.new {}
|
18
|
+
proc.expects(:call).once
|
19
|
+
subject.configure { proc.call() }
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should pass the shared_config as parameter to the given block' do
|
23
|
+
shared_config = mock()
|
24
|
+
subject.stubs(:shared_config).returns(shared_config)
|
25
|
+
subject.configure do |c|
|
26
|
+
c.should.be.equal? shared_config
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should instantiate and keep a new shared config if no was given' do
|
31
|
+
subject.shared_config = nil
|
32
|
+
subject.configure {}
|
33
|
+
subject.shared_config.should.be.an.instance_of? CLIntegracon::Configuration
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should keep the existing config if there is one' do
|
37
|
+
shared_config = mock()
|
38
|
+
subject.shared_config = shared_config
|
39
|
+
subject.configure {}
|
40
|
+
subject.shared_config.should.be.equal? shared_config
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe CLIntegracon::Configuration do
|
46
|
+
|
47
|
+
def subject
|
48
|
+
CLIntegracon::Configuration
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#self.adapters' do
|
52
|
+
|
53
|
+
it 'should include :bacon' do
|
54
|
+
subject.adapters.should.include? :bacon
|
55
|
+
File.exists?(subject.adapters[:bacon]).should.be.true?
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#hook_into' do
|
61
|
+
|
62
|
+
it 'should include the corresponding implementation file' do
|
63
|
+
config = subject.new
|
64
|
+
config.expects(:require).with(subject.adapters[:bacon])
|
65
|
+
config.hook_into :bacon
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: clintegracon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marius Rackwitz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2014-08-04 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
prerelease: false
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: "1.3"
|
22
|
+
version_requirements: *id001
|
23
|
+
type: :development
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: rake
|
26
|
+
prerelease: false
|
27
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ~>
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 10.1.0
|
32
|
+
version_requirements: *id002
|
33
|
+
type: :development
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: bacon
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- &id005
|
40
|
+
- ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: "0"
|
43
|
+
version_requirements: *id003
|
44
|
+
type: :development
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: mocha
|
47
|
+
prerelease: false
|
48
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ~>
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.0.0
|
53
|
+
version_requirements: *id004
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha-on-bacon
|
57
|
+
prerelease: false
|
58
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- *id005
|
61
|
+
version_requirements: *id006
|
62
|
+
type: :development
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: claide
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- *id005
|
69
|
+
version_requirements: *id007
|
70
|
+
type: :development
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: colored
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "1.2"
|
79
|
+
version_requirements: *id008
|
80
|
+
type: :runtime
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: diffy
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- *id005
|
87
|
+
version_requirements: *id009
|
88
|
+
type: :runtime
|
89
|
+
description: CLIntegracon allows you to build Integration specs for your CLI,independent if they are based on Ruby or another technology.It is especially useful if your command modifies the file system.It provides an integration for Bacon.
|
90
|
+
email:
|
91
|
+
- git@mariusrackwitz.de
|
92
|
+
executables: []
|
93
|
+
|
94
|
+
extensions: []
|
95
|
+
|
96
|
+
extra_rdoc_files: []
|
97
|
+
|
98
|
+
files:
|
99
|
+
- .gitignore
|
100
|
+
- .travis.yml
|
101
|
+
- Gemfile
|
102
|
+
- LICENSE.txt
|
103
|
+
- README.md
|
104
|
+
- Rakefile
|
105
|
+
- clintegracon.gemspec
|
106
|
+
- lib/CLIntegracon.rb
|
107
|
+
- lib/CLIntegracon/adapter/bacon.rb
|
108
|
+
- lib/CLIntegracon/configuration.rb
|
109
|
+
- lib/CLIntegracon/diff.rb
|
110
|
+
- lib/CLIntegracon/file_tree_spec.rb
|
111
|
+
- lib/CLIntegracon/file_tree_spec_context.rb
|
112
|
+
- lib/CLIntegracon/formatter.rb
|
113
|
+
- lib/CLIntegracon/subject.rb
|
114
|
+
- lib/CLIntegracon/version.rb
|
115
|
+
- spec/bacon/execution_output.txt
|
116
|
+
- spec/bacon/spec_helper.rb
|
117
|
+
- spec/fixtures/bin/coffeemaker.rb
|
118
|
+
- spec/integration/coffeemaker_help/after/execution_output.txt
|
119
|
+
- spec/integration/coffeemaker_help/before/.gitkeep
|
120
|
+
- spec/integration/coffeemaker_no_milk/after/BlackEye.brewed-coffee
|
121
|
+
- spec/integration/coffeemaker_no_milk/after/CaPheSuaDa.brewed-coffee
|
122
|
+
- spec/integration/coffeemaker_no_milk/after/Coffeemakerfile.yml
|
123
|
+
- spec/integration/coffeemaker_no_milk/after/RedTux.brewed-coffee
|
124
|
+
- spec/integration/coffeemaker_no_milk/after/execution_output.txt
|
125
|
+
- spec/integration/coffeemaker_no_milk/before/Coffeemakerfile.yml
|
126
|
+
- spec/integration/coffeemaker_sweetner_honey/after/Affogato.brewed-coffee
|
127
|
+
- spec/integration/coffeemaker_sweetner_honey/after/BlackEye.brewed-coffee
|
128
|
+
- spec/integration/coffeemaker_sweetner_honey/after/Coffeemakerfile.yml
|
129
|
+
- spec/integration/coffeemaker_sweetner_honey/after/RedTux.brewed-coffee
|
130
|
+
- spec/integration/coffeemaker_sweetner_honey/after/execution_output.txt
|
131
|
+
- spec/integration/coffeemaker_sweetner_honey/before/Coffeemakerfile.yml
|
132
|
+
- spec/unit/adapter/bacon_spec.rb
|
133
|
+
- spec/unit/configuration_spec.rb
|
134
|
+
homepage: https://github.com/mrackwitz/CLIntegracon
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata: {}
|
138
|
+
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- *id005
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- *id005
|
150
|
+
requirements: []
|
151
|
+
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.0.14
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: Integration specs for your CLI
|
157
|
+
test_files:
|
158
|
+
- spec/bacon/execution_output.txt
|
159
|
+
- spec/bacon/spec_helper.rb
|
160
|
+
- spec/fixtures/bin/coffeemaker.rb
|
161
|
+
- spec/integration/coffeemaker_help/after/execution_output.txt
|
162
|
+
- spec/integration/coffeemaker_help/before/.gitkeep
|
163
|
+
- spec/integration/coffeemaker_no_milk/after/BlackEye.brewed-coffee
|
164
|
+
- spec/integration/coffeemaker_no_milk/after/CaPheSuaDa.brewed-coffee
|
165
|
+
- spec/integration/coffeemaker_no_milk/after/Coffeemakerfile.yml
|
166
|
+
- spec/integration/coffeemaker_no_milk/after/RedTux.brewed-coffee
|
167
|
+
- spec/integration/coffeemaker_no_milk/after/execution_output.txt
|
168
|
+
- spec/integration/coffeemaker_no_milk/before/Coffeemakerfile.yml
|
169
|
+
- spec/integration/coffeemaker_sweetner_honey/after/Affogato.brewed-coffee
|
170
|
+
- spec/integration/coffeemaker_sweetner_honey/after/BlackEye.brewed-coffee
|
171
|
+
- spec/integration/coffeemaker_sweetner_honey/after/Coffeemakerfile.yml
|
172
|
+
- spec/integration/coffeemaker_sweetner_honey/after/RedTux.brewed-coffee
|
173
|
+
- spec/integration/coffeemaker_sweetner_honey/after/execution_output.txt
|
174
|
+
- spec/integration/coffeemaker_sweetner_honey/before/Coffeemakerfile.yml
|
175
|
+
- spec/unit/adapter/bacon_spec.rb
|
176
|
+
- spec/unit/configuration_spec.rb
|