genomer 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,262 @@
1
+ require 'spec_helper'
2
+
3
+ describe Genomer::Runtime do
4
+ include FakeFS::SpecHelpers
5
+
6
+ subject do
7
+ Genomer::Runtime.new MockSettings.new arguments, flags
8
+ end
9
+
10
+ let(:flags){ {} }
11
+ let(:arguments){ [] }
12
+
13
+ describe "with the command" do
14
+
15
+ describe "none" do
16
+
17
+ it "should print the short help description" do
18
+ msg = <<-EOF
19
+ genomer COMMAND [options]
20
+ run `genomer help` for a list of available commands
21
+ EOF
22
+ subject.execute!.should == msg.unindent
23
+ end
24
+
25
+ end
26
+
27
+ describe "unknown" do
28
+
29
+ let(:arguments){ %w|unknown| }
30
+
31
+ it "should print an error message" do
32
+ error = <<-EOF
33
+ Unknown command or plugin 'unknown.'
34
+ run `genomer help` for a list of available commands
35
+ EOF
36
+ lambda{ subject.execute! }.should raise_error(Genomer::Error,error.unindent)
37
+ end
38
+
39
+ end
40
+
41
+ describe "init" do
42
+
43
+ let(:arguments){ %w|init project_name| }
44
+
45
+ after do
46
+ FileUtils.rm_rf('project_name') if File.exists?('project_name')
47
+ end
48
+
49
+ describe "with project name argument" do
50
+
51
+ before do
52
+ subject.execute!
53
+ end
54
+
55
+ it "should create a directory from the named argument" do
56
+ File.exists?('project_name').should be_true
57
+ end
58
+
59
+ it "should create an 'assembly' directory" do
60
+ File.exists?(File.join('project_name','assembly')).should be_true
61
+ end
62
+
63
+ end
64
+
65
+ describe "when project already exists" do
66
+
67
+ before do
68
+ Dir.mkdir('project_name')
69
+ end
70
+
71
+ it "should raise an error" do
72
+ lambda{ subject.execute! }.should raise_error(Genomer::Error,
73
+ "Directory 'project_name' already exists.")
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+
80
+ describe "help" do
81
+
82
+ let(:arguments){ %w|help| }
83
+
84
+ before do
85
+ mock(Genomer::Plugin).plugins{ gems }
86
+ end
87
+
88
+ describe "with no available plugins" do
89
+
90
+ let(:gems) do
91
+ []
92
+ end
93
+
94
+ it "should print the header description" do
95
+ msg = <<-EOF
96
+ genomer COMMAND [options]
97
+
98
+ Available commands:
99
+ EOF
100
+ subject.execute!.should include msg.unindent.strip
101
+ end
102
+
103
+ it "should show the init command" do
104
+ subject.execute!.should include "init Create a new genomer project"
105
+ end
106
+
107
+ it "should show the man command" do
108
+ subject.execute!.should include "man View man page for the specified plugin"
109
+ end
110
+ end
111
+
112
+ describe "with available genomer plugins" do
113
+
114
+ let(:gems) do
115
+ [Gem::Specification.new do |s|
116
+ s.name = 'genomer-plugin-simple'
117
+ s.summary = 'A simple scaffolder command'
118
+ end]
119
+ end
120
+
121
+ it "should print the plugin command description" do
122
+ subject.execute!.should include "simple A simple scaffolder command"
123
+ end
124
+
125
+ end
126
+
127
+ end
128
+
129
+ describe "man" do
130
+
131
+ before do
132
+ stub(Genomer::Plugin).plugins{ gems }
133
+ end
134
+
135
+ describe "with no command specified" do
136
+
137
+ let(:arguments){ %w|man| }
138
+
139
+ it "should print the man help description" do
140
+ msg = <<-EOF
141
+ genomer man COMMAND
142
+ run `genomer help` for a list of available commands
143
+ EOF
144
+ subject.execute!.should include msg.unindent.strip
145
+ end
146
+
147
+ end
148
+
149
+ describe "with a command specified" do
150
+
151
+ let(:arguments){ %w|man simple| }
152
+ let(:man_file){ 'a' }
153
+ let(:groffed_man_file){ mock!.path{ 'b' } }
154
+
155
+ before do
156
+ mock(subject).man_file(['simple']){ man_file }
157
+ mock(subject).groffed_man_file(man_file){ groffed_man_file }
158
+ mock(File).exists?(man_file){true}
159
+ end
160
+
161
+ it "should call man for the groffed path" do
162
+ mock(Kernel).exec("man b")
163
+ subject.execute!
164
+ end
165
+
166
+ end
167
+
168
+ describe "with a subcommand specified" do
169
+
170
+ let(:arguments){ %w|man simple subcommand| }
171
+ let(:man_file){ 'a' }
172
+ let(:groffed_man_file){ mock!.path{ 'b' } }
173
+
174
+ before do
175
+ mock(subject).man_file(['simple','subcommand']){ man_file }
176
+ mock(subject).groffed_man_file(man_file){ groffed_man_file }
177
+ mock(File).exists?(man_file){true}
178
+ end
179
+
180
+ it "should call man for the groffed path" do
181
+ mock(Kernel).exec("man b")
182
+ subject.execute!
183
+ end
184
+
185
+ end
186
+
187
+ describe "with an unknown subcommand specified" do
188
+
189
+ let(:arguments){ %w|man simple subcommand| }
190
+ let(:man_file){ 'a' }
191
+
192
+ before do
193
+ mock(subject).man_file(['simple','subcommand']){ man_file }
194
+ mock(File).exists?(man_file){false}
195
+ end
196
+
197
+ it "should call man for the groffed path" do
198
+ lambda{ subject.execute! }.
199
+ should raise_error(Genomer::Error,"No manual entry for command 'simple subcommand'")
200
+ end
201
+
202
+ end
203
+
204
+ end
205
+
206
+ end
207
+
208
+ describe "#initialize" do
209
+
210
+ describe "with arguments and flags" do
211
+
212
+ let(:arguments){ %w|init project_name| }
213
+ let(:flags){ {:flag => 'something'} }
214
+
215
+ it "should set the runtime variables" do
216
+ subject.command.should == 'init'
217
+ subject.arguments.should == ['project_name']
218
+ subject.flags[:flag] == flags[:flag]
219
+ end
220
+
221
+ end
222
+
223
+ end
224
+
225
+ describe "#man_file" do
226
+
227
+ before do
228
+ mock(Genomer::Plugin).fetch('simple') do
229
+ mock!.full_gem_path{ '/tmp' }
230
+ end
231
+ end
232
+
233
+ it "should return the path to the man page for a command" do
234
+ subject.man_file(['simple']).should == '/tmp/man/genomer-simple.ronn'
235
+ end
236
+
237
+ it "should return the path to the man page for a subcommand" do
238
+ subject.man_file(['simple','subcommand']).should == '/tmp/man/genomer-simple-subcommand.ronn'
239
+ end
240
+
241
+ end
242
+
243
+ describe "#run_plugin" do
244
+
245
+ before do
246
+ mock(Genomer::Plugin).[]('plugin') do
247
+ mock!.new(anything,anything) do
248
+ mock!.run
249
+ end
250
+ end
251
+ end
252
+
253
+ let(:arguments){ %w|plugin arg1 arg2| }
254
+ let(:flags){ {:flag => 'arg3'} }
255
+
256
+ it "should fetch, initialize and run the required plugin" do
257
+ subject.run_plugin
258
+ end
259
+
260
+ end
261
+
262
+ end
@@ -0,0 +1,45 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'rspec'
4
+ require 'fakefs/spec_helpers'
5
+ require 'scaffolder/test/helpers'
6
+
7
+ require 'genomer'
8
+
9
+ # Requires supporting files with custom matchers and macros, etc,
10
+ # in ./support/ and its subdirectories.
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each do |f|
12
+ require File.expand_path(f)
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ config.mock_with :rr
17
+
18
+ include Scaffolder::Test
19
+ include Scaffolder::Test::Helpers
20
+
21
+ class MockSettings
22
+
23
+ attr :rest
24
+
25
+ def initialize(rest = [], command_args = {})
26
+ @rest = rest
27
+ @args = command_args
28
+ end
29
+
30
+ def [](arg)
31
+ @args[arg]
32
+ end
33
+
34
+ def flags
35
+ @args
36
+ end
37
+
38
+ end
39
+
40
+ config.after(:each) do
41
+ instance_variables.each do |ivar|
42
+ instance_variable_set(ivar, nil)
43
+ end
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,290 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: genomer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Barton
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.1.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.1.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: configliere
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.4.8
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.8
62
+ - !ruby/object:Gem::Dependency
63
+ name: scaffolder
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 0.4.0
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.4.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: scaffolder-annotation-locator
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 0.1.2
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 0.1.2
94
+ - !ruby/object:Gem::Dependency
95
+ name: unindent
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.0.0
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.0.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: ronn
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.7.3
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.7.3
126
+ - !ruby/object:Gem::Dependency
127
+ name: rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 2.7.0
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 2.7.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: fakefs
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 0.4.0
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 0.4.0
158
+ - !ruby/object:Gem::Dependency
159
+ name: rr
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: 1.0.4
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 1.0.4
174
+ - !ruby/object:Gem::Dependency
175
+ name: scaffolder-test-helpers
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ version: 0.4.0
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ~>
188
+ - !ruby/object:Gem::Version
189
+ version: 0.4.0
190
+ - !ruby/object:Gem::Dependency
191
+ name: cucumber
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ~>
196
+ - !ruby/object:Gem::Version
197
+ version: 1.1.4
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: 1.1.4
206
+ - !ruby/object:Gem::Dependency
207
+ name: aruba
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ~>
212
+ - !ruby/object:Gem::Version
213
+ version: 0.4.11
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ~>
220
+ - !ruby/object:Gem::Version
221
+ version: 0.4.11
222
+ description: Turns scaffolded contigs and annotations into a genome.
223
+ email:
224
+ - mail@michaelbarton.me.uk
225
+ executables:
226
+ - genomer
227
+ extensions: []
228
+ extra_rdoc_files: []
229
+ files:
230
+ - .document
231
+ - .gitignore
232
+ - Gemfile
233
+ - LICENSE.txt
234
+ - README.rdoc
235
+ - Rakefile
236
+ - bin/genomer
237
+ - cucumber.yml
238
+ - features/api/annotation_ids.feature
239
+ - features/api/annotation_location.feature
240
+ - features/api/scaffold.feature
241
+ - features/cli/create.feature
242
+ - features/cli/error.feature
243
+ - features/cli/help.feature
244
+ - features/cli/man.feature
245
+ - features/cli/plugins.feature
246
+ - features/step_definitions/genomer_steps.rb
247
+ - features/support/env.rb
248
+ - genomer-plugin-simple/genomer-plugin-simple.gemspec
249
+ - genomer-plugin-simple/lib/genomer-plugin-simple.rb
250
+ - genomer-plugin-simple/man/genomer-simple-subcommand.ronn
251
+ - genomer-plugin-simple/man/genomer-simple.ronn
252
+ - genomer.gemspec
253
+ - lib/genomer.rb
254
+ - lib/genomer/error.rb
255
+ - lib/genomer/plugin.rb
256
+ - lib/genomer/runtime.rb
257
+ - lib/genomer/version.rb
258
+ - man/genomer-init.1.ronn
259
+ - spec/genomer/plugin_spec.rb
260
+ - spec/genomer/runtime_spec.rb
261
+ - spec/spec_helper.rb
262
+ homepage: http://github.com/michaelbarton/genomer
263
+ licenses:
264
+ - MIT
265
+ post_install_message:
266
+ rdoc_options: []
267
+ require_paths:
268
+ - lib
269
+ required_ruby_version: !ruby/object:Gem::Requirement
270
+ none: false
271
+ requirements:
272
+ - - ! '>='
273
+ - !ruby/object:Gem::Version
274
+ version: '0'
275
+ segments:
276
+ - 0
277
+ hash: 4331820328226072819
278
+ required_rubygems_version: !ruby/object:Gem::Requirement
279
+ none: false
280
+ requirements:
281
+ - - ! '>='
282
+ - !ruby/object:Gem::Version
283
+ version: 1.8.0
284
+ requirements: []
285
+ rubyforge_project: genomer
286
+ rubygems_version: 1.8.23
287
+ signing_key:
288
+ specification_version: 3
289
+ summary: Build genome output files
290
+ test_files: []