spectifly 0.0.10 → 0.0.11

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjRjMmEzZWVjMjgwZmI5ZGYxNzZhZWZjMzljOGViZWIxMDY0ZmE0Yg==
5
+ data.tar.gz: !binary |-
6
+ NWI0OTcxMGVkZjM4N2UxMzE1MTdjMDc3NzhlZWY2ZGI1MDAwNmYwMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NGQ4MWFjZTUwNzkxYzlmYjhhZGE1N2Q5ZGZjNTI2MjEwMzdjZDBjYjE0N2I0
10
+ NDhiMThjYjZmOThhYzg0Mzc1MGRmMzAwZmJmMWVlZWQxNTg2MTEyYTUzY2M1
11
+ ZWI4ZjQ5ZDM3OWFhNmJmNjk4ZjY2YTEzNGQ2ZmFiMGZmN2Y3NmI=
12
+ data.tar.gz: !binary |-
13
+ NWY5OGI1OWUzOWJmODZlZTUzYzQ3MTYxOWU4NjkzNWUxNGE0Y2JlZTA4MmMy
14
+ OGM1NmViNGE4OTA5MzA4OGQwZTA4Y2ViMmYxNzYxMWI1MTJkMDRjZTRmY2U5
15
+ YmI4OWQ0YzU0MTQ2MGJhYzczMDY2YzE4M2VhNGU0YjBkYzE2ODI=
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require 'spec_helper'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 1.9.3-p392
1
+ 1.9.3-p484
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ rvm:
2
+ - "1.9.3"
@@ -1,17 +1,22 @@
1
1
  module Spectifly
2
2
  class Configuration
3
- attr_accessor :entity_path
3
+ class InvalidPresenterPath < StandardError; end
4
+ attr_accessor :entity_path, :presenter_path
5
+
4
6
  def initialize(config = {})
5
7
  @entity_path = config.fetch('entity_path')
6
- @presenter_path = config['presenter_path']
8
+ set_presenter_path(config['presenter_path'])
7
9
  end
8
10
 
9
- def presenter_path
10
- @presenter_path ||= begin
11
- proposed_path = File.join(@entity_path, 'presenters')
12
- if Dir.exists?(proposed_path)
13
- @presenter_path = proposed_path
14
- end
11
+ private
12
+
13
+ def set_presenter_path(path = nil)
14
+ path = 'presenters' if path.nil?
15
+ proposed_path = File.join(@entity_path, path)
16
+ if Dir.exists?(proposed_path)
17
+ @presenter_path = proposed_path
18
+ else
19
+ raise InvalidPresenterPath, "#{proposed_path} does not exist"
15
20
  end
16
21
  end
17
22
  end
@@ -7,21 +7,26 @@ module Spectifly
7
7
  class Task < ::Rake::TaskLib
8
8
  attr_accessor :configuration
9
9
 
10
- def configure!
11
- config_path = File.join(Rake.original_dir, 'config', 'spectifly.yml')
12
- config_hash = File.exist?(config_path) ? YAML.load_file(config_path) : {}
13
- @configuration = Spectifly::Configuration.new(config_hash)
14
- end
15
-
16
10
  def initialize(task_name, *args, &block)
17
- configure!
18
11
  task task_name, *args do |task_name, task_args|
12
+ configure!(task_args)
19
13
  block.call(configuration, task_args) if block
20
14
  end
21
15
  end
16
+
17
+ private
18
+
19
+ def configure!(options = {})
20
+ config_path = File.join(Rake.original_dir, 'config', 'spectifly.yml')
21
+ config_hash = File.exist?(config_path) ? YAML.load_file(config_path) : {}
22
+
23
+ # Stringify the options hash and merge it in to the config_hash
24
+ config_hash.merge!(Hash[options.map{ |k, v| [k.to_s, v] }])
25
+ @configuration = Spectifly::Configuration.new(config_hash)
26
+ end
22
27
  end
23
28
  end
24
29
 
25
30
  Dir[File.join(File.dirname(__FILE__), '..', 'tasks', '*.rake')].each do |path|
26
31
  load path
27
- end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Spectifly
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -8,9 +8,8 @@ namespace :spectifly do
8
8
  end
9
9
  end
10
10
 
11
- Spectifly::Task.new('generate_from_entities', [:destination_path]) do |spectifly, args|
11
+ Spectifly::Task.new('generate_from_entities', [:destination_path, :presenter_path]) do |spectifly, args|
12
12
  options = File.exist?(spectifly.presenter_path) ? { :presenter_path => spectifly.presenter_path } : {}
13
-
14
13
  Spectifly::Entity.from_directory(spectifly.entity_path, options).each do |name, entity|
15
14
  if entity.is_a? Spectifly::Entity
16
15
  write_entity(entity, args[:destination_path])
@@ -24,7 +23,7 @@ namespace :spectifly do
24
23
  end
25
24
  end
26
25
 
27
- Spectifly::Task.new('generate_extended_types', [:destination_path]) do |spectifly, args|
26
+ Spectifly::Task.new('generate_extended_types', [:destination_path, :presenter_path]) do |spectifly, args|
28
27
  extended = File.join(args[:destination_path], 'extended.xsd')
29
28
  File.open(extended, 'w') do |f|
30
29
  f.write Spectifly::Xsd::Types.build_extended
@@ -36,6 +35,6 @@ namespace :spectifly do
36
35
  end
37
36
 
38
37
  desc 'Generate all XSDs for the configured entity directory, including extended type definitions'
39
- task :generate_all, [:destination_path] => [:generate_from_entities, :generate_extended_types]
38
+ task :generate_all, [:destination_path, :presenter_path] => [:generate_from_entities, :generate_extended_types]
40
39
  end
41
40
  end
@@ -1,11 +1,10 @@
1
- require 'spec_helper'
2
1
  require 'json'
3
2
 
4
3
  describe Spectifly::Base::Builder do
5
4
  describe '.from_path' do
6
5
  it 'generates builder from entity at given path' do
7
6
  path_builder = described_class.from_path(fixture_path('individual'))
8
- path_builder.root.should == 'Individual'
7
+ expect(path_builder.root).to eq('Individual')
9
8
  end
10
9
  end
11
10
 
@@ -21,9 +20,7 @@ describe Spectifly::Base::Builder do
21
20
  describe '#custom_types' do
22
21
  it 'return an array of all non-built-in types in result' do
23
22
  entity = Spectifly::Entity.parse(fixture_path('group'))
24
- described_class.new(entity).custom_types.should =~ [
25
- 'individual'
26
- ]
23
+ expect(described_class.new(entity).custom_types).to match_array(['individual'])
27
24
  end
28
25
  end
29
- end
26
+ end
@@ -1,29 +1,27 @@
1
- require 'spec_helper'
2
-
3
1
  describe Spectifly::Base::EntityNode do
4
2
  describe 'uniqueness restriction' do
5
3
  it 'unique should be false by default and there should be no unique restriction' do
6
4
  field = described_class.new("Mini me")
7
- field.should_not be_unique
8
- field.restrictions.keys.should_not be_include('unique')
5
+ expect(field).to_not be_unique
6
+ expect(field.restrictions.keys.include?('unique')).to be_falsey
9
7
  end
10
8
 
11
9
  it 'adds a restriction and returns true for unique? if there is a uniqueness validation' do
12
10
  field = described_class.new("Little Snowflake", {"Validations" => "must be unique"})
13
- field.should be_unique
14
- field.restrictions.keys.include?('unique').should be_true
11
+ expect(field).to be_unique
12
+ expect(field.restrictions.keys.include?('unique')).to be_truthy
15
13
  end
16
14
 
17
15
  it 'adds a restriction and returns true for unique? if there is an attribute Unique set to true' do
18
16
  field = described_class.new("Little Snowflake", {"Unique" => "true"})
19
- field.should be_unique
20
- field.restrictions.keys.include?('unique').should be_true
17
+ expect(field).to be_unique
18
+ expect(field.restrictions.keys.include?('unique')).to be_truthy
21
19
  end
22
20
 
23
21
  it 'throws an error if the two ways of setting uniqueness contradict each other' do
24
- lambda {
22
+ expect{
25
23
  field = described_class.new("Little Snowflake?", {"Validations" => "must be unique", "Unique" => false})
26
- }.should raise_error
24
+ }.to raise_error
27
25
  end
28
26
  end
29
- end
27
+ end
@@ -1,10 +1,8 @@
1
- require 'spec_helper'
2
-
3
1
  describe Spectifly::Base::Field do
4
2
  describe '#name' do
5
3
  it 'returns tokenized version of field name' do
6
4
  field = described_class.new('A really cool hat')
7
- field.name.should == 'a_really_cool_hat'
5
+ expect(field.name).to eq('a_really_cool_hat')
8
6
  end
9
7
  end
10
8
 
@@ -19,17 +17,17 @@ describe Spectifly::Base::Field do
19
17
  describe '#type' do
20
18
  it 'defaults to string if no type specified' do
21
19
  field = described_class.new('A really cool hat')
22
- field.type.should == 'string'
20
+ expect(field.type).to eq('string')
23
21
  end
24
22
 
25
23
  it 'returns boolean if field name has "?" token' do
26
24
  field = described_class.new('A really cool hat?')
27
- field.type.should == 'boolean'
25
+ expect(field.type).to eq('boolean')
28
26
  end
29
27
 
30
28
  it 'returns type if specified' do
31
29
  field = described_class.new('some field', 'Type' => 'Rhubarb')
32
- field.type.should == 'rhubarb'
30
+ expect(field.type).to eq('rhubarb')
33
31
  end
34
32
  end
35
33
 
@@ -38,63 +36,63 @@ describe Spectifly::Base::Field do
38
36
  field = described_class.new('some field', {
39
37
  'Minimum Value' => 3, 'Maximum Value' => 145
40
38
  })
41
- field.restrictions.should == {
39
+ expect(field.restrictions).to eq({
42
40
  'minimum_value' => 3,
43
41
  'maximum_value' => 145
44
- }
42
+ })
45
43
  end
46
44
 
47
45
  it 'sets up enumerations' do
48
46
  field = described_class.new('some field', {
49
47
  'Valid Values' => [34, 52, 100, 4]
50
48
  })
51
- field.restrictions.should == {
49
+ expect(field.restrictions).to eq({
52
50
  'valid_values' => [34, 52, 100, 4]
53
- }
51
+ })
54
52
  end
55
53
 
56
54
  it 'pulls regex restriction from validations' do
57
55
  field = described_class.new('some field', {
58
56
  'Validations' => 'Must match regex "^[0-9]{4}"'
59
57
  })
60
- field.validations.should be_empty
61
- field.restrictions.should == {
58
+ expect(field.validations).to be_empty
59
+ expect(field.restrictions).to eq({
62
60
  'regex' => /^[0-9]{4}/
63
- }
61
+ })
64
62
  end
65
63
 
66
64
  it 'sets restrictions to empty hash if none exist' do
67
65
  field = described_class.new('some field')
68
- field.restrictions.should be_empty
66
+ expect(field.restrictions).to be_empty
69
67
  end
70
68
  end
71
69
 
72
70
  describe '#multiple?' do
73
71
  it 'returns true if multiple set to true' do
74
72
  field = described_class.new('some field', 'Multiple' => true)
75
- field.should be_multiple
73
+ expect(field).to be_multiple
76
74
  end
77
75
 
78
76
  it 'returns false if multiple set to anything but true' do
79
77
  field = described_class.new('some field', 'Multiple' => 'Whatever')
80
- field.should_not be_multiple
78
+ expect(field).not_to be_multiple
81
79
  end
82
80
 
83
81
  it 'returns false if multiple not set' do
84
82
  field = described_class.new('some field')
85
- field.should_not be_multiple
83
+ expect(field).not_to be_multiple
86
84
  end
87
85
  end
88
86
 
89
87
  describe '#required?' do
90
88
  it 'returns true if field name has "*" token' do
91
89
  field = described_class.new('some field*')
92
- field.should be_required
90
+ expect(field).to be_required
93
91
  end
94
92
 
95
93
  it 'returns false if field name does not have "*" token' do
96
94
  field = described_class.new('some field')
97
- field.should_not be_required
95
+ expect(field).not_to be_required
98
96
  end
99
97
  end
100
- end
98
+ end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Spectifly::Configuration do
4
2
  let(:configuration_args) {
5
3
  {
@@ -18,25 +16,30 @@ describe Spectifly::Configuration do
18
16
  end
19
17
 
20
18
  describe '#presenter_path' do
21
- it 'returns configured value if set' do
22
- configuration = described_class.new(
19
+ it 'raises an exception if configured value is set but does not exist' do
20
+ expect{described_class.new(
23
21
  configuration_args.merge('presenter_path' => 'goose')
24
- )
25
- configuration.presenter_path.should == 'goose'
22
+ )}.to raise_error(Spectifly::Configuration::InvalidPresenterPath)
26
23
  end
27
24
 
28
- it 'returns nil if no presenter path exists at entity path' do
29
- configuration = described_class.new(
25
+ it 'raises an exception if no default presenter path exists' do
26
+ expect{described_class.new(
30
27
  configuration_args.merge('entity_path' => spec_path)
28
+ )}.to raise_error(Spectifly::Configuration::InvalidPresenterPath)
29
+ end
30
+
31
+ it 'returns presenter path when passed in' do
32
+ configuration = described_class.new(
33
+ configuration_args.merge('presenter_path' => 'presenters/masterless_group')
31
34
  )
32
- configuration.presenter_path.should be_nil
35
+ expect(configuration.presenter_path).to eq(base_presenter_path + "/masterless_group")
33
36
  end
34
37
 
35
38
  it 'returns {entity_path}/presenters if exists' do
36
39
  configuration = described_class.new(
37
40
  configuration_args
38
41
  )
39
- configuration.presenter_path.should == base_presenter_path
42
+ expect(configuration.presenter_path).to eq(base_presenter_path)
40
43
  end
41
44
  end
42
45
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Spectifly::Entity do
4
2
  before :each do
5
3
  @entity = Spectifly::Entity.parse(fixture_path('individual'))
@@ -8,9 +6,9 @@ describe Spectifly::Entity do
8
6
  describe '.from_directory' do
9
7
  it 'returns entities generated from files at given path' do
10
8
  entities = Spectifly::Entity.from_directory(fixture_path)
11
- entities.keys.should =~ ['individual', 'group']
12
- entities.values.map(&:class).uniq.should == [Spectifly::Entity]
13
- entities.values.map(&:name).should =~ ['individual', 'group']
9
+ expect(entities.keys).to match_array(['individual', 'group'])
10
+ expect(entities.values.map(&:class).uniq).to eq([Spectifly::Entity])
11
+ expect(entities.values.map(&:name)).to match_array(['individual', 'group'])
14
12
  end
15
13
 
16
14
  it 'includes presenters if option passed' do
@@ -18,20 +16,20 @@ describe Spectifly::Entity do
18
16
  fixture_path, :presenter_path => base_presenter_path
19
17
  )
20
18
 
21
- entities.keys.should =~ ['individual', 'group', 'positionless_individual', 'masterless_group']
22
- entities['positionless_individual'].keys.should == ['individual']
23
- entities['positionless_individual'].values.map(&:name).should == ['individual']
24
- entities['masterless_group'].keys.should == ['group']
25
- entities['masterless_group'].values.map(&:name).should == ['group']
19
+ expect(entities.keys).to match_array(['individual', 'group', 'positionless_individual', 'masterless_group'])
20
+ expect(entities['positionless_individual'].keys).to eq(['individual'])
21
+ expect(entities['positionless_individual'].values.map(&:name)).to eq(['individual'])
22
+ expect(entities['masterless_group'].keys).to eq(['group'])
23
+ expect(entities['masterless_group'].values.map(&:name)).to eq(['group'])
26
24
  ['positionless_individual', 'masterless_group'].each do |presenter|
27
- entities[presenter].values.map(&:class).uniq.should == [Spectifly::Entity]
25
+ expect(entities[presenter].values.map(&:class).uniq).to eq([Spectifly::Entity])
28
26
  end
29
27
  end
30
28
  end
31
29
 
32
30
  describe '.parse' do
33
31
  it 'delegates to initializer' do
34
- Spectifly::Entity.should_receive(:new).with(:arguments)
32
+ expect(Spectifly::Entity).to receive(:new).with(:arguments)
35
33
  Spectifly::Entity.parse(:arguments)
36
34
  end
37
35
  end
@@ -58,7 +56,7 @@ describe Spectifly::Entity do
58
56
 
59
57
  describe '#root' do
60
58
  it 'returns root element of parsed yaml' do
61
- @entity.root.should == 'Individual'
59
+ expect(@entity.root).to eq('Individual')
62
60
  end
63
61
  end
64
62
 
@@ -70,39 +68,39 @@ describe Spectifly::Entity do
70
68
  end
71
69
 
72
70
  it 'returns name from entity file' do
73
- @entity.name.should == 'individual'
74
- @presenter_entity.name.should == 'individual'
71
+ expect(@entity.name).to eq('individual')
72
+ expect(@presenter_entity.name).to eq('individual')
75
73
  end
76
74
 
77
75
  it 'returns presenter name when presented' do
78
- @entity.present_as(@presenter_entity).name.should == 'individual'
76
+ expect(@entity.present_as(@presenter_entity).name).to eq('individual')
79
77
  end
80
78
  end
81
79
 
82
80
  describe '#presented_as' do
83
81
  it 'returns nil if not presented' do
84
- @entity.presented_as.should be_nil
82
+ expect(@entity.presented_as).to be_nil
85
83
  end
86
84
 
87
85
  it 'returns presenter if presented' do
88
86
  @presenter_entity = Spectifly::Entity.parse(
89
87
  fixture_path('presenters/positionless_individual/individual.entity')
90
88
  )
91
- @entity.present_as(@presenter_entity).presented_as.should == @presenter_entity
89
+ expect(@entity.present_as(@presenter_entity).presented_as).to eq(@presenter_entity)
92
90
  end
93
91
  end
94
92
 
95
93
  describe '#metadata' do
96
94
  it 'returns metadata from parsed yaml' do
97
- @entity.metadata.should == {
95
+ expect(@entity.metadata).to eq({
98
96
  "Description" => "An Individual"
99
- }
97
+ })
100
98
  end
101
99
  end
102
100
 
103
101
  describe '#fields' do
104
102
  it 'returns fields from parsed yaml' do
105
- @entity.fields.should == {
103
+ expect(@entity.fields).to eq({
106
104
  "Name*" => {
107
105
  "Description" => "The individual's name",
108
106
  "Example" => "Randy McTougherson",
@@ -129,7 +127,7 @@ describe Spectifly::Entity do
129
127
  "Pickled?*" => {
130
128
  "Description" => "Whether or not this individual is pickled"
131
129
  }
132
- }
130
+ })
133
131
  end
134
132
  end
135
133
 
@@ -147,7 +145,7 @@ describe Spectifly::Entity do
147
145
 
148
146
  it 'uses presenter fields only, but merges metadata and field attributes' do
149
147
  @merged_entity = @entity.present_as(@presenter_entity)
150
- @merged_entity.fields.should == {
148
+ expect(@merged_entity.fields).to eq({
151
149
  "Name*" => {
152
150
  "Description" => "The individual's name",
153
151
  "Example" => "Wussy O'Weakling",
@@ -166,17 +164,17 @@ describe Spectifly::Entity do
166
164
  "Pickled?" => {
167
165
  "Description" => "Whether or not this individual is pickled"
168
166
  }
169
- }
170
- @merged_entity.metadata.should == {
167
+ })
168
+ expect(@merged_entity.metadata).to eq({
171
169
  "Description" => "A Positionless Individual"
172
- }
170
+ })
173
171
  end
174
172
  end
175
173
 
176
174
  describe '#relationships' do
177
175
  it 'returns relationships from parsed yaml' do
178
176
  @group_entity = Spectifly::Entity.parse(fixture_path('group'))
179
- @group_entity.relationships.should == {
177
+ expect(@group_entity.relationships).to eq({
180
178
  "Has Many" => {
181
179
  "Peeps" => {
182
180
  "Description" => "Who is in the group",
@@ -189,7 +187,7 @@ describe Spectifly::Entity do
189
187
  "Type" => "Individual"
190
188
  }
191
189
  }
192
- }
190
+ })
193
191
  end
194
192
  end
195
193
  end
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'json'
3
2
 
4
3
  describe Spectifly::Json::Builder do
@@ -7,14 +6,14 @@ describe Spectifly::Json::Builder do
7
6
  entity = Spectifly::Entity.parse(fixture_path('individual'))
8
7
  json_path = expectation_path('individual', 'json')
9
8
  hash = described_class.new(entity).build
10
- JSON.pretty_generate(hash).strip.should == File.read(json_path).strip
9
+ expect(JSON.pretty_generate(hash).strip).to eq(File.read(json_path).strip)
11
10
  end
12
11
 
13
12
  it 'works with containing relationships' do
14
13
  entity = Spectifly::Entity.parse(fixture_path('group'))
15
14
  json_path = expectation_path('group', 'json')
16
15
  hash = described_class.new(entity).build
17
- JSON.pretty_generate(hash).should == File.read(json_path)
16
+ expect(JSON.pretty_generate(hash)).to eq(File.read(json_path))
18
17
  end
19
18
  end
20
19
 
@@ -24,9 +23,9 @@ describe Spectifly::Json::Builder do
24
23
  presenter_entity = Spectifly::Entity.parse(fixture_path('presenters/positionless_individual/individual'))
25
24
  json_path = expectation_path('presented/positionless_individual', 'json')
26
25
  builder = described_class.new(entity)
27
- builder.present_as(presenter_entity).should == builder
26
+ expect(builder.present_as(presenter_entity)).to eq(builder)
28
27
  hash = builder.build
29
- JSON.pretty_generate(hash).strip.should == File.read(json_path).strip
28
+ expect(JSON.pretty_generate(hash).strip).to eq(File.read(json_path).strip)
30
29
  end
31
30
 
32
31
  it 'works with overriding relationships' do
@@ -34,9 +33,9 @@ describe Spectifly::Json::Builder do
34
33
  presenter_entity = Spectifly::Entity.parse(fixture_path('presenters/masterless_group/group'))
35
34
  json_path = expectation_path('presented/masterless_group', 'json')
36
35
  builder = described_class.new(entity)
37
- builder.present_as(presenter_entity).should == builder
36
+ expect(builder.present_as(presenter_entity)).to eq(builder)
38
37
  hash = builder.build
39
- JSON.pretty_generate(hash).should == File.read(json_path)
38
+ expect(JSON.pretty_generate(hash)).to eq(File.read(json_path))
40
39
  end
41
40
  end
42
41
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Spectifly::Json::Field do
4
2
  describe '#to_h' do
5
3
  it 'returns hash format of field' do
@@ -20,7 +18,7 @@ describe Spectifly::Json::Field do
20
18
  'Example' => 'children',
21
19
  'Validations' => ['Must be young', 'Must love eating mud']
22
20
  })
23
- field.to_h.should == expected
21
+ expect(field.to_h).to eq(expected)
24
22
  end
25
23
  end
26
- end
24
+ end
@@ -1,53 +1,51 @@
1
- require 'spec_helper'
2
-
3
1
  describe Spectifly::Support do
4
2
 
5
3
  describe '.camelize' do
6
4
  it 'removes underscores and spaces and capitalizes the first' do
7
- Spectifly::Support.camelize('foo_bar One two 3').should == 'FooBarOneTwo3'
5
+ expect(Spectifly::Support.camelize('foo_bar One two 3')).to eq('FooBarOneTwo3')
8
6
  end
9
7
 
10
8
  it 'deals with nested classes' do
11
- Spectifly::Support.camelize('foo_bar/bar_foo').should == 'FooBar::BarFoo'
9
+ expect(Spectifly::Support.camelize('foo_bar/bar_foo')).to eq('FooBar::BarFoo')
12
10
  end
13
11
  end
14
12
 
15
13
  describe '.lower_camelize' do
16
14
  it 'camelizes but with lowercase first character' do
17
- Spectifly::Support.lower_camelize('we Are the_toasty').should == 'weAreTheToasty'
18
- Spectifly::Support.lower_camelize('PleaseChange me').should == 'pleaseChangeMe'
15
+ expect(Spectifly::Support.lower_camelize('we Are the_toasty')).to eq('weAreTheToasty')
16
+ expect(Spectifly::Support.lower_camelize('PleaseChange me')).to eq('pleaseChangeMe')
19
17
  end
20
18
  end
21
19
 
22
20
  describe '.tokenize' do
23
21
  it 'creates snake_case version of string' do
24
- Spectifly::Support.tokenize('Albus Dumbledore & his_friend').should == 'albus_dumbledore_and_his_friend'
22
+ expect(Spectifly::Support.tokenize('Albus Dumbledore & his_friend')).to eq('albus_dumbledore_and_his_friend')
25
23
  end
26
24
 
27
25
  it 'uncamelizes' do
28
- Spectifly::Support.tokenize('thisStrangeJavalikeWord').should == 'this_strange_javalike_word'
26
+ expect(Spectifly::Support.tokenize('thisStrangeJavalikeWord')).to eq('this_strange_javalike_word')
29
27
  end
30
28
 
31
29
  it 'returns nil if given nil' do
32
- Spectifly::Support.tokenize(nil).should be_nil
30
+ expect(Spectifly::Support.tokenize(nil)).to be_nil
33
31
  end
34
32
  end
35
33
 
36
34
  describe '.get_module' do
37
35
  it 'returns module from constant' do
38
- Spectifly::Support.get_module(Spectifly::Support).should == 'Spectifly'
36
+ expect(Spectifly::Support.get_module(Spectifly::Support)).to eq('Spectifly')
39
37
  end
40
38
 
41
39
  it 'works with strings' do
42
- Spectifly::Support.get_module('Spectifly::Support').should == 'Spectifly'
40
+ expect(Spectifly::Support.get_module('Spectifly::Support')).to eq('Spectifly')
43
41
  end
44
42
 
45
43
  it 'works with multiple parent modules' do
46
- Spectifly::Support.get_module('The::Way::It::Is').should == 'The::Way::It'
44
+ expect(Spectifly::Support.get_module('The::Way::It::Is')).to eq('The::Way::It')
47
45
  end
48
46
 
49
47
  it 'returns nil if no module' do
50
- Spectifly::Support.get_module('LonelyConstant').should be_nil
48
+ expect(Spectifly::Support.get_module('LonelyConstant')).to be_nil
51
49
  end
52
50
  end
53
- end
51
+ end
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'json'
3
2
 
4
3
  describe Spectifly::Xsd::Builder do
@@ -7,7 +6,7 @@ describe Spectifly::Xsd::Builder do
7
6
  path_builder = Spectifly::Xsd::Builder.from_path(fixture_path('individual'))
8
7
  xsd_path = expectation_path('individual', 'xsd')
9
8
  xsd = path_builder.build
10
- xsd.should == File.read(xsd_path)
9
+ expect(xsd).to eq(File.read(xsd_path))
11
10
  end
12
11
  end
13
12
 
@@ -16,14 +15,14 @@ describe Spectifly::Xsd::Builder do
16
15
  entity = Spectifly::Entity.parse(fixture_path('individual'))
17
16
  xsd_path = expectation_path('individual', 'xsd')
18
17
  xsd = Spectifly::Xsd::Builder.new(entity).build
19
- xsd.should == File.read(xsd_path)
18
+ expect(xsd).to eq(File.read(xsd_path))
20
19
  end
21
20
 
22
21
  it 'includes import directives for custom field types' do
23
22
  entity = Spectifly::Entity.parse(fixture_path('group'))
24
23
  xsd_path = expectation_path('group', 'xsd')
25
24
  xsd = Spectifly::Xsd::Builder.new(entity).build
26
- xsd.should == File.read(xsd_path)
25
+ expect(xsd).to eq(File.read(xsd_path))
27
26
  end
28
27
  end
29
28
 
@@ -33,9 +32,9 @@ describe Spectifly::Xsd::Builder do
33
32
  presenter_entity = Spectifly::Entity.parse(fixture_path('presenters/positionless_individual/individual'))
34
33
  xsd_path = expectation_path('presented/positionless_individual', 'xsd')
35
34
  builder = Spectifly::Xsd::Builder.new(entity)
36
- builder.present_as(presenter_entity).should == builder
35
+ expect(builder.present_as(presenter_entity)).to eq(builder)
37
36
  xsd = builder.build
38
- xsd.should == File.read(xsd_path)
37
+ expect(xsd).to eq(File.read(xsd_path))
39
38
  end
40
39
 
41
40
  it 'works with presented relationship-having entities' do
@@ -43,9 +42,9 @@ describe Spectifly::Xsd::Builder do
43
42
  presenter_entity = Spectifly::Entity.parse(fixture_path('presenters/masterless_group/group'))
44
43
  xsd_path = expectation_path('presented/masterless_group', 'xsd')
45
44
  builder = Spectifly::Xsd::Builder.new(entity)
46
- builder.present_as(presenter_entity).should == builder
45
+ expect(builder.present_as(presenter_entity)).to eq(builder)
47
46
  xsd = builder.build
48
- xsd.should == File.read(xsd_path)
47
+ expect(xsd).to eq(File.read(xsd_path))
49
48
  end
50
49
  end
51
50
  end
@@ -1,12 +1,10 @@
1
- require 'spec_helper'
2
-
3
1
  describe Spectifly::Xsd::Field do
4
2
  describe '#regex' do
5
3
  it 'formats regex to xsd-compatible pattern restriction' do
6
4
  field = Spectifly::Xsd::Field.new('some field', {
7
5
  'Validations' => 'Must match regex "^[0-9]{4}"'
8
6
  })
9
- field.regex.should == '[0-9]{4}[\s\S]*'
7
+ expect(field.regex).to eq('[0-9]{4}[\s\S]*')
10
8
  end
11
9
  end
12
- end
10
+ end
@@ -1,11 +1,9 @@
1
- require 'spec_helper'
2
-
3
1
  describe Spectifly::Xsd::Types do
4
2
  describe '.build_extended' do
5
3
  it 'builds xsd for extended types' do
6
4
  expected_path = expectation_path('extended', 'xsd')
7
5
  expected = File.read(expected_path)
8
- Spectifly::Xsd::Types.build_extended.should == expected
6
+ expect(Spectifly::Xsd::Types.build_extended).to eq(expected)
9
7
  end
10
8
  end
11
- end
9
+ end
data/spectifly.gemspec CHANGED
@@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "rake"
27
27
 
28
28
  spec.add_development_dependency "bundler", "~> 1.3"
29
- spec.add_development_dependency "rake"
30
29
  spec.add_development_dependency "rspec"
31
30
  spec.add_development_dependency "simplecov"
32
31
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectifly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
5
- prerelease:
4
+ version: 0.0.11
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ravi Gadad
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-27 00:00:00.000000000 Z
11
+ date: 2014-11-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: builder
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: bundler
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,31 +62,13 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
77
68
  version: '1.3'
78
- - !ruby/object:Gem::Dependency
79
- name: rake
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
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'
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: rspec
96
71
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
72
  requirements:
99
73
  - - ! '>='
100
74
  - !ruby/object:Gem::Version
@@ -102,7 +76,6 @@ dependencies:
102
76
  type: :development
103
77
  prerelease: false
104
78
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
79
  requirements:
107
80
  - - ! '>='
108
81
  - !ruby/object:Gem::Version
@@ -110,7 +83,6 @@ dependencies:
110
83
  - !ruby/object:Gem::Dependency
111
84
  name: simplecov
112
85
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
86
  requirements:
115
87
  - - ! '>='
116
88
  - !ruby/object:Gem::Version
@@ -118,7 +90,6 @@ dependencies:
118
90
  type: :development
119
91
  prerelease: false
120
92
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
93
  requirements:
123
94
  - - ! '>='
124
95
  - !ruby/object:Gem::Version
@@ -132,7 +103,9 @@ extensions: []
132
103
  extra_rdoc_files: []
133
104
  files:
134
105
  - .gitignore
106
+ - .rspec
135
107
  - .ruby-version
108
+ - .travis.yml
136
109
  - Gemfile
137
110
  - LICENSE.txt
138
111
  - README.md
@@ -197,33 +170,26 @@ files:
197
170
  homepage: ''
198
171
  licenses:
199
172
  - MIT
173
+ metadata: {}
200
174
  post_install_message:
201
175
  rdoc_options: []
202
176
  require_paths:
203
177
  - lib
204
178
  required_ruby_version: !ruby/object:Gem::Requirement
205
- none: false
206
179
  requirements:
207
180
  - - ! '>='
208
181
  - !ruby/object:Gem::Version
209
182
  version: '0'
210
- segments:
211
- - 0
212
- hash: -190850164299161101
213
183
  required_rubygems_version: !ruby/object:Gem::Requirement
214
- none: false
215
184
  requirements:
216
185
  - - ! '>='
217
186
  - !ruby/object:Gem::Version
218
187
  version: '0'
219
- segments:
220
- - 0
221
- hash: -190850164299161101
222
188
  requirements: []
223
189
  rubyforge_project:
224
- rubygems_version: 1.8.23
190
+ rubygems_version: 2.2.2
225
191
  signing_key:
226
- specification_version: 3
192
+ specification_version: 4
227
193
  summary: Generate schema files from business entity YAML specs.
228
194
  test_files:
229
195
  - spec/expectations/extended.xsd