genomer-plugin-validate 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +9 -0
  4. data/VERSION +1 -0
  5. data/features/annotations/bad-product-field.feature +91 -0
  6. data/features/annotations/command-line-interface.feature +19 -0
  7. data/features/annotations/duplicate_id.feature +144 -0
  8. data/features/annotations/identical_locations.feature +74 -0
  9. data/features/annotations/incorrect-attributes.feature +135 -0
  10. data/features/annotations/missing_attributes.feature +75 -0
  11. data/features/annotations/name.feature +40 -0
  12. data/features/command-line-interface.feature +36 -0
  13. data/features/support/env.rb +13 -0
  14. data/genomer-plugin-validate.gemspec +28 -0
  15. data/lib/extensions/string.rb +12 -0
  16. data/lib/genomer-plugin-validate.rb +33 -0
  17. data/lib/genomer-plugin-validate/group.rb +17 -0
  18. data/lib/genomer-plugin-validate/group/annotations.rb +20 -0
  19. data/lib/genomer-plugin-validate/validator.rb +27 -0
  20. data/lib/genomer-plugin-validate/validator/bad_product_field.rb +45 -0
  21. data/lib/genomer-plugin-validate/validator/duplicate_coordinates.rb +12 -0
  22. data/lib/genomer-plugin-validate/validator/duplicate_id.rb +11 -0
  23. data/lib/genomer-plugin-validate/validator/gff3_attributes.rb +16 -0
  24. data/lib/genomer-plugin-validate/validator/missing_id.rb +13 -0
  25. data/lib/genomer-plugin-validate/validator/no_name_or_product.rb +13 -0
  26. data/lib/genomer-plugin-validate/validator/uppercase_name.rb +13 -0
  27. data/lib/genomer-plugin-validate/validator/view_attributes.rb +16 -0
  28. data/man/genomer-validate.ronn +100 -0
  29. data/spec/genomer-plugin-validate/group/annotations_spec.rb +18 -0
  30. data/spec/genomer-plugin-validate/group_spec.rb +24 -0
  31. data/spec/genomer-plugin-validate/validator/bad_product_field_spec.rb +93 -0
  32. data/spec/genomer-plugin-validate/validator/duplicate_coordinates_spec.rb +24 -0
  33. data/spec/genomer-plugin-validate/validator/duplicate_id_spec.rb +34 -0
  34. data/spec/genomer-plugin-validate/validator/gff_attributes_spec.rb +32 -0
  35. data/spec/genomer-plugin-validate/validator/missing_id_spec.rb +27 -0
  36. data/spec/genomer-plugin-validate/validator/no_name_or_product_spec.rb +28 -0
  37. data/spec/genomer-plugin-validate/validator/uppercase_name_spec.rb +22 -0
  38. data/spec/genomer-plugin-validate/validator/view_attributes_spec.rb +31 -0
  39. data/spec/genomer-plugin-validate/validator_spec.rb +107 -0
  40. data/spec/genomer-plugin-validate_spec.rb +92 -0
  41. data/spec/spec_helper.rb +35 -0
  42. data/spec/validator_run_matcher.rb +25 -0
  43. metadata +244 -0
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+
3
+ describe GenomerPluginValidate::Validator do
4
+
5
+ before do
6
+ @example = GenomerPluginValidate::Validator::ExampleValidator = Class.new
7
+ stub(described_class).require(anything)
8
+ end
9
+
10
+ after do
11
+ GenomerPluginValidate::Validator.send(:remove_const,'ExampleValidator')
12
+ end
13
+
14
+ describe "#validators" do
15
+
16
+ subject do
17
+ described_class.validators
18
+ end
19
+
20
+ its([:example_validator]){should == @example}
21
+
22
+ end
23
+
24
+ describe "#annotations_by_attribute" do
25
+
26
+ subject do
27
+ dummy_class = Class.new
28
+ dummy_class.send(:include, described_class)
29
+
30
+ dummy = dummy_class.new
31
+ stub(dummy).annotations{annotations}
32
+ dummy.annotations_by_attribute(attribute)
33
+ end
34
+
35
+ let(:attribute) do
36
+ 'ID'
37
+ end
38
+
39
+ context "where there are no annotations" do
40
+
41
+ let(:annotations) do
42
+ []
43
+ end
44
+
45
+ it{ should == {}}
46
+
47
+ end
48
+
49
+ context "where there is one annotation using the ID attribute" do
50
+
51
+ let(:annotations) do
52
+ [annotation_with_id(1)]
53
+ end
54
+
55
+ its(['1']){ should == annotations }
56
+
57
+ end
58
+
59
+ context "where there is one annotation using the product attribute" do
60
+
61
+ let(:attribute) do
62
+ 'product'
63
+ end
64
+
65
+ let(:annotations) do
66
+ [annotation(:attributes => {:product => '1'})]
67
+ end
68
+
69
+ its(['1']){ should == annotations }
70
+
71
+ end
72
+
73
+ context "where there is one annotation and one annotions with a missing ID" do
74
+
75
+ let(:annotations) do
76
+ [annotation_with_id(1), Annotation.new.to_gff3_record]
77
+ end
78
+
79
+ its(['1']){ should == annotations[0..0] }
80
+ its([nil]){ should == annotations[1..1] }
81
+
82
+ end
83
+
84
+ context "where there is two annotations with different attributes" do
85
+
86
+ let(:annotations) do
87
+ [annotation_with_id(1), annotation_with_id(2)]
88
+ end
89
+
90
+ its(['1']){ should == annotations[0..0] }
91
+ its(['2']){ should == annotations[1..1] }
92
+
93
+ end
94
+
95
+ context "where there is two annotations the same attribute" do
96
+
97
+ let(:annotations) do
98
+ [annotation_with_id(1), annotation_with_id(1)]
99
+ end
100
+
101
+ its(['1']){ should == annotations }
102
+
103
+ end
104
+
105
+ end
106
+
107
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ describe GenomerPluginValidate do
4
+
5
+ describe "#run" do
6
+
7
+ after do
8
+ GenomerPluginValidate::Group.send(:remove_const,'Example')
9
+ end
10
+
11
+ before do
12
+ @example = GenomerPluginValidate::Group::Example = Class.new
13
+ end
14
+
15
+ subject do
16
+ described_class.new([arg].compact,{}).run
17
+ end
18
+
19
+ context "passed no arguments" do
20
+
21
+ let(:arg) do
22
+ nil
23
+ end
24
+
25
+ before do
26
+ def @example.description
27
+ "Some description"
28
+ end
29
+ end
30
+
31
+ it "should return the help message" do
32
+ msg = <<-EOS
33
+ USAGE: genomer validate <GROUP>
34
+
35
+ Available validation groups:
36
+ EOS
37
+ subject.should include msg.unindent
38
+ end
39
+
40
+ it "should include the descriptions annotation groups" do
41
+ msg = ' example Some description'
42
+ subject.should include msg
43
+ end
44
+
45
+ end
46
+
47
+ context "passed an unknown validation group name" do
48
+
49
+ let(:arg) do
50
+ "unknown"
51
+ end
52
+
53
+ it "should raise and Genomer::Error" do
54
+ lambda{subject.to_s}.should raise_error Genomer::Error,
55
+ "Unknown validation group 'unknown'"
56
+ end
57
+
58
+ end
59
+
60
+ context "passed a known validation group name" do
61
+
62
+ let(:validator) do
63
+ c = Class.new(Genomer::Plugin)
64
+ any_instance_of(c) do |instance|
65
+ mock(instance).run{ [['some_error_1', 'some_error_2'],['another_error_1']]}
66
+ end
67
+ c
68
+ end
69
+
70
+ before do
71
+ mock(GenomerPluginValidate::Group).groups{{'example' => @example}}
72
+ mock(@example).validators{ ['example'] }
73
+ mock(GenomerPluginValidate::Validator).validators{{'example' => validator}}
74
+ end
75
+
76
+ let(:arg) do
77
+ "example"
78
+ end
79
+
80
+ it "should return a string output of validation error array" do
81
+ subject.should ==<<-EOS.unindent.strip
82
+ some_error_1
83
+ some_error_2
84
+ another_error_1
85
+ EOS
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+
92
+ end
@@ -0,0 +1,35 @@
1
+ current = File.dirname(__FILE__)
2
+ $LOAD_PATH.unshift(File.join(current, '..', 'lib'), current)
3
+
4
+ require 'rspec'
5
+ require 'scaffolder/test/helpers'
6
+ require 'heredoc_unindent'
7
+ require 'genomer-plugin-validate'
8
+ require 'validator_run_matcher'
9
+
10
+ RSpec.configure do |config|
11
+ config.mock_with :rr
12
+
13
+ include Scaffolder::Test
14
+
15
+ def annotation(options = {})
16
+ attrs = options[:attributes] || {}
17
+ attrs[:ID].to_s ||= '1'
18
+
19
+ opts = {:start => options[:start] || 1,
20
+ :end => options[:end] || 3,
21
+ :attributes => Hash[attrs.map{|(k,v)| [k.to_s,v]}]}
22
+
23
+ Annotation.new(opts).to_gff3_record
24
+ end
25
+
26
+ def annotation_with_id(id)
27
+ annotation(:attributes => {:ID => id})
28
+ end
29
+
30
+ def annotation_with_product(product)
31
+ annotation(:attributes => {'product' => product, 'ID' => 1})
32
+ end
33
+
34
+
35
+ end
@@ -0,0 +1,25 @@
1
+ def errors_for(validator,annotations)
2
+ c = validator.new([],{})
3
+ stub(c).annotations{ annotations }
4
+ c.run
5
+ end
6
+
7
+ RSpec::Matchers.define :return_no_errors_for do |annotations|
8
+ match do
9
+ @actual = errors_for(actual,annotations)
10
+ @expected = []
11
+ actual == expected
12
+ end
13
+
14
+ diffable
15
+ end
16
+
17
+ RSpec::Matchers.define :return_errors_for do |annotations,errors|
18
+ match do
19
+ @actual = errors_for(actual,annotations)
20
+ @expected = errors
21
+ actual == expected
22
+ end
23
+
24
+ diffable
25
+ end
metadata ADDED
@@ -0,0 +1,244 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: genomer-plugin-validate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
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: genomer
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.4
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.0.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: heredoc_unindent
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: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.8.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.8.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: scaffolder-test-helpers
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.4.1
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.4.1
94
+ - !ruby/object:Gem::Dependency
95
+ name: cucumber
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.1.4
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.1.4
110
+ - !ruby/object:Gem::Dependency
111
+ name: aruba
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.4.11
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.4.11
126
+ - !ruby/object:Gem::Dependency
127
+ name: rr
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 1.0.4
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: 1.0.4
142
+ description: Test assembly files for common errors which may lead to incorrect assembly
143
+ email:
144
+ - mail@michaelbarton.me.uk
145
+ executables: []
146
+ extensions: []
147
+ extra_rdoc_files: []
148
+ files:
149
+ - .gitignore
150
+ - Gemfile
151
+ - Rakefile
152
+ - VERSION
153
+ - features/annotations/bad-product-field.feature
154
+ - features/annotations/command-line-interface.feature
155
+ - features/annotations/duplicate_id.feature
156
+ - features/annotations/identical_locations.feature
157
+ - features/annotations/incorrect-attributes.feature
158
+ - features/annotations/missing_attributes.feature
159
+ - features/annotations/name.feature
160
+ - features/command-line-interface.feature
161
+ - features/support/env.rb
162
+ - genomer-plugin-validate.gemspec
163
+ - lib/extensions/string.rb
164
+ - lib/genomer-plugin-validate.rb
165
+ - lib/genomer-plugin-validate/group.rb
166
+ - lib/genomer-plugin-validate/group/annotations.rb
167
+ - lib/genomer-plugin-validate/validator.rb
168
+ - lib/genomer-plugin-validate/validator/bad_product_field.rb
169
+ - lib/genomer-plugin-validate/validator/duplicate_coordinates.rb
170
+ - lib/genomer-plugin-validate/validator/duplicate_id.rb
171
+ - lib/genomer-plugin-validate/validator/gff3_attributes.rb
172
+ - lib/genomer-plugin-validate/validator/missing_id.rb
173
+ - lib/genomer-plugin-validate/validator/no_name_or_product.rb
174
+ - lib/genomer-plugin-validate/validator/uppercase_name.rb
175
+ - lib/genomer-plugin-validate/validator/view_attributes.rb
176
+ - man/genomer-validate.ronn
177
+ - spec/genomer-plugin-validate/group/annotations_spec.rb
178
+ - spec/genomer-plugin-validate/group_spec.rb
179
+ - spec/genomer-plugin-validate/validator/bad_product_field_spec.rb
180
+ - spec/genomer-plugin-validate/validator/duplicate_coordinates_spec.rb
181
+ - spec/genomer-plugin-validate/validator/duplicate_id_spec.rb
182
+ - spec/genomer-plugin-validate/validator/gff_attributes_spec.rb
183
+ - spec/genomer-plugin-validate/validator/missing_id_spec.rb
184
+ - spec/genomer-plugin-validate/validator/no_name_or_product_spec.rb
185
+ - spec/genomer-plugin-validate/validator/uppercase_name_spec.rb
186
+ - spec/genomer-plugin-validate/validator/view_attributes_spec.rb
187
+ - spec/genomer-plugin-validate/validator_spec.rb
188
+ - spec/genomer-plugin-validate_spec.rb
189
+ - spec/spec_helper.rb
190
+ - spec/validator_run_matcher.rb
191
+ homepage: ''
192
+ licenses: []
193
+ post_install_message:
194
+ rdoc_options: []
195
+ require_paths:
196
+ - lib
197
+ required_ruby_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ segments:
204
+ - 0
205
+ hash: -1125290684225056222
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
+ none: false
208
+ requirements:
209
+ - - ! '>='
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ segments:
213
+ - 0
214
+ hash: -1125290684225056222
215
+ requirements: []
216
+ rubyforge_project: genomer-plugin-validate
217
+ rubygems_version: 1.8.23
218
+ signing_key:
219
+ specification_version: 3
220
+ summary: Validate assembly files for errors
221
+ test_files:
222
+ - features/annotations/bad-product-field.feature
223
+ - features/annotations/command-line-interface.feature
224
+ - features/annotations/duplicate_id.feature
225
+ - features/annotations/identical_locations.feature
226
+ - features/annotations/incorrect-attributes.feature
227
+ - features/annotations/missing_attributes.feature
228
+ - features/annotations/name.feature
229
+ - features/command-line-interface.feature
230
+ - features/support/env.rb
231
+ - spec/genomer-plugin-validate/group/annotations_spec.rb
232
+ - spec/genomer-plugin-validate/group_spec.rb
233
+ - spec/genomer-plugin-validate/validator/bad_product_field_spec.rb
234
+ - spec/genomer-plugin-validate/validator/duplicate_coordinates_spec.rb
235
+ - spec/genomer-plugin-validate/validator/duplicate_id_spec.rb
236
+ - spec/genomer-plugin-validate/validator/gff_attributes_spec.rb
237
+ - spec/genomer-plugin-validate/validator/missing_id_spec.rb
238
+ - spec/genomer-plugin-validate/validator/no_name_or_product_spec.rb
239
+ - spec/genomer-plugin-validate/validator/uppercase_name_spec.rb
240
+ - spec/genomer-plugin-validate/validator/view_attributes_spec.rb
241
+ - spec/genomer-plugin-validate/validator_spec.rb
242
+ - spec/genomer-plugin-validate_spec.rb
243
+ - spec/spec_helper.rb
244
+ - spec/validator_run_matcher.rb