webspicy 0.2.3 → 0.3.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 664e519735fcd77f635cd462563320baba79481e
4
- data.tar.gz: c1f0002111073477a9503a2df78901f4f6f5cb5a
3
+ metadata.gz: 397c21900711f78462183be1dab9cba93caf6cdf
4
+ data.tar.gz: 12b2b0e27ee8171922e1d032fae95b0980d21ff2
5
5
  SHA512:
6
- metadata.gz: 707569be3cf76e783c82610c791f560bde7a849b742342e42f37e867f669966b05fbc44c52de49444a5cfac777480e98cf37d05620768e52e6d8edab6b3df4ac
7
- data.tar.gz: ba6f158b152a33d79ab220c08c66d0b1dd2b71fa11d288876d8c53f40cc20f67a74a7428e7eb02433048aee8dfed924281532c50424fed2a3c66ab6e65802497
6
+ metadata.gz: 2e68c059d88816ecdabf5737784aae341cd65f7891ce1db3264ac4dfbdaf6c75744b49645e94eb84597159ce241273808481d58d80e17bc0f41d42101ec838e8
7
+ data.tar.gz: 36477950cfb806330fff4ee261485960e87f696d575a2d55945a10b685090832be6b452eea0b25186a23d55288197c9837c18be20816ba19b8b75b346d3ed4fc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- webspicy (0.2.1)
4
+ webspicy (0.2.3)
5
5
  finitio (~> 0.5.2)
6
6
  http (~> 2)
7
7
  path (~> 1.3)
@@ -19,7 +19,7 @@ GEM
19
19
  unf (>= 0.0.5, < 1.0.0)
20
20
  finitio (0.5.2)
21
21
  citrus (>= 2.4, < 4.0)
22
- http (2.2.2)
22
+ http (2.2.1)
23
23
  addressable (~> 2.3)
24
24
  http-cookie (~> 1.0)
25
25
  http-form_data (~> 1.0.1)
@@ -4,17 +4,14 @@ require 'webspicy'
4
4
 
5
5
  desc "Checks all .yml definition files"
6
6
  task :check do
7
- config = Webspicy::Configuration.new do |c|
8
- c.add_folder Path.dir/"webspicy"
9
- end
7
+ config = Webspicy::Configuration.new(Path.dir/"webspicy")
10
8
  Webspicy::Checker.new(config).call
11
9
  end
12
10
 
13
11
  namespace :test do
14
12
  desc "Run all tests directly on Sinatra application using rack/test"
15
13
  task :rack do
16
- config = Webspicy::Configuration.new do |c|
17
- c.add_folder Path.dir/"webspicy"
14
+ config = Webspicy::Configuration.new(Path.dir/"webspicy") do |c|
18
15
  c.client = Webspicy::RackTestClient.for(::Sinatra::Application)
19
16
  c.before_each do |_,_,_,client|
20
17
  client.api.post "/reset"
@@ -25,9 +22,8 @@ namespace :test do
25
22
 
26
23
  desc "Runs all tests on the real web server (must be launched previously)"
27
24
  task :real do
28
- config = Webspicy::Configuration.new do |c|
25
+ config = Webspicy::Configuration.new(Path.dir/"webspicy") do |c|
29
26
  c.host = "http://127.0.0.1:4567"
30
- c.add_folder Path.dir/"webspicy"
31
27
  c.client = Webspicy::HttpClient
32
28
  c.before_each do |_,_,_,client|
33
29
  client.api.post "http://127.0.0.1:4567/reset"
@@ -1,8 +1,9 @@
1
1
  module Webspicy
2
2
  class Configuration
3
3
 
4
- def initialize
5
- @folders = []
4
+ def initialize(folder = Path.pwd)
5
+ @folder = folder
6
+ @children = []
6
7
  @before_listeners = []
7
8
  @rspec_options = default_rspec_options
8
9
  @run_counterexamples = default_run_counterexamples
@@ -11,16 +12,33 @@ module Webspicy
11
12
  @client = HttpClient
12
13
  yield(self) if block_given?
13
14
  end
15
+ attr_accessor :folder
16
+ protected :folder=
14
17
 
15
18
  # Adds a folder to the list of folders where test case definitions are
16
19
  # to be found.
17
- def add_folder(folder)
18
- folder = Path(folder)
19
- raise "Folder `#{folder}` does not exists" unless folder.exists? && folder.directory?
20
- @folders << folder
20
+ def folder(folder = nil, &bl)
21
+ if folder.nil?
22
+ @folder
23
+ else
24
+ folder = folder.is_a?(String) ? @folder/folder : Path(folder)
25
+ raise "Folder `#{folder}` does not exists" unless folder.exists? && folder.directory?
26
+ raise "Folder must be a descendant" unless folder.inside?(@folder)
27
+ child = dup do |c|
28
+ c.folder = folder
29
+ end
30
+ yield(child) if block_given?
31
+ @children << child
32
+ child
33
+ end
34
+ end
35
+ attr_accessor :children
36
+ protected :children=
37
+
38
+ # Returns whether this configuration has children configurations or not
39
+ def has_children?
40
+ !children.empty?
21
41
  end
22
- attr_accessor :folders
23
- protected :folders=
24
42
 
25
43
  # Sets whether counter examples have to be ran or not.
26
44
  def run_counterexamples=(run_counterexamples)
@@ -35,7 +53,7 @@ module Webspicy
35
53
 
36
54
  # Returns the defaut value for run_counterexamples
37
55
  def default_run_counterexamples
38
- ENV['ROBUST'].nil? || ENV['ROBUST'] != 'no'
56
+ ENV['ROBUST'].nil? || (ENV['ROBUST'] != 'no')
39
57
  end
40
58
  private :default_run_counterexamples
41
59
 
@@ -176,7 +194,7 @@ module Webspicy
176
194
  # original.
177
195
  def dup(&bl)
178
196
  super.tap do |d|
179
- d.folders = self.folders.dup
197
+ d.children = self.children.dup
180
198
  d.rspec_options = self.rspec_options.dup
181
199
  d.before_listeners = self.before_listeners.dup
182
200
  yield d if block_given?
@@ -13,14 +13,19 @@ module Webspicy
13
13
  # Yields each resource file in the current scope
14
14
  def each_resource_file(&bl)
15
15
  return enum_for(:each_resource_file) unless block_given?
16
- config.folders.each do |folder|
17
- _each_resource_file(folder, &bl)
16
+ if config.has_children?
17
+ config.children.each do |child|
18
+ _each_resource_file(child, &bl)
19
+ end
20
+ else
21
+ _each_resource_file(config, &bl)
18
22
  end
19
23
  end
20
24
 
21
25
  # Recursive implementation of `each_resource_file` for each
22
26
  # folder in the configuration.
23
- def _each_resource_file(folder)
27
+ def _each_resource_file(config)
28
+ folder = config.folder
24
29
  folder.glob("**/*.yml").select(&to_filter_proc(config.file_filter)).each do |file|
25
30
  yield file, folder
26
31
  end
@@ -61,8 +66,8 @@ module Webspicy
61
66
  # Returns the Data system to use for parsing schemas
62
67
  def data_system
63
68
  @data_system ||= begin
64
- root = config.folders.find{|f| (f/"schema.fio").file? }
65
- root ? Finitio::DEFAULT_SYSTEM.parse((root/"schema.fio").read) : Finitio::DEFAULT_SYSTEM
69
+ schema = config.folder/"schema.fio"
70
+ schema.file? ? Finitio::DEFAULT_SYSTEM.parse(schema.read) : Finitio::DEFAULT_SYSTEM
66
71
  end
67
72
  end
68
73
 
@@ -1,8 +1,8 @@
1
1
  module Webspicy
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 2
5
- TINY = 3
4
+ MINOR = 3
5
+ TINY = "0-rc1"
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -15,9 +15,7 @@ module Webspicy
15
15
  context 'without any filter' do
16
16
 
17
17
  let(:configuration) {
18
- Configuration.new{|c|
19
- c.add_folder restful_folder
20
- }
18
+ Configuration.new(restful_folder)
21
19
  }
22
20
 
23
21
  it 'returns all files' do
@@ -28,8 +26,7 @@ module Webspicy
28
26
  context 'with a file filter as a proc' do
29
27
 
30
28
  let(:configuration) {
31
- Configuration.new{|c|
32
- c.add_folder restful_folder
29
+ Configuration.new(restful_folder){|c|
33
30
  c.file_filter = ->(f) {
34
31
  f.basename.to_s == "getTodo.yml"
35
32
  }
@@ -44,8 +41,7 @@ module Webspicy
44
41
  context 'with a file filter as a Regex' do
45
42
 
46
43
  let(:configuration) {
47
- Configuration.new{|c|
48
- c.add_folder restful_folder
44
+ Configuration.new(restful_folder){|c|
49
45
  c.file_filter = /getTodo.yml/
50
46
  }
51
47
  }
@@ -55,5 +51,18 @@ module Webspicy
55
51
  end
56
52
  end
57
53
 
54
+ context 'when having children folders' do
55
+
56
+ let(:configuration) {
57
+ Configuration.new(restful_folder) do |c|
58
+ c.folder 'todo'
59
+ end
60
+ }
61
+
62
+ it 'returns all files' do
63
+ expect(subject.size).to eql(restful_folder.glob('**/*.yml').size)
64
+ end
65
+ end
66
+
58
67
  end
59
68
  end
@@ -19,8 +19,7 @@ module Webspicy
19
19
  context 'without any filter' do
20
20
 
21
21
  let(:configuration) {
22
- Configuration.new{|c|
23
- c.add_folder restful_folder
22
+ Configuration.new(restful_folder){|c|
24
23
  c.file_filter = /getTodo.yml/
25
24
  }
26
25
  }
@@ -33,8 +32,7 @@ module Webspicy
33
32
  context 'with a service filter as a proc' do
34
33
 
35
34
  let(:configuration) {
36
- Configuration.new{|c|
37
- c.add_folder restful_folder
35
+ Configuration.new(restful_folder){|c|
38
36
  c.file_filter = /getTodo.yml/
39
37
  c.service_filter = ->(s) {
40
38
  s.method == "POST"
@@ -3,8 +3,12 @@ require 'webspicy'
3
3
 
4
4
  module SpecHelper
5
5
 
6
+ def examples_folder
7
+ Webspicy::EXAMPLES_FOLDER
8
+ end
9
+
6
10
  def restful_folder
7
- Webspicy::EXAMPLES_FOLDER/'restful/webspicy'
11
+ examples_folder/'restful/webspicy'
8
12
  end
9
13
 
10
14
  end
@@ -10,6 +10,33 @@ module Webspicy
10
10
  expect(seen).to be_a(Configuration)
11
11
  end
12
12
 
13
+ describe 'folder' do
14
+
15
+ it 'returns the main folder without arg' do
16
+ config = Configuration.new(Path.dir)
17
+ expect(config.folder).to eql(Path.dir)
18
+ end
19
+
20
+ it 'creates a child when adding a folder' do
21
+ Configuration.new(Path.dir) do |c|
22
+ child = c.folder 'resource'
23
+ expect(child).to be_a(Configuration)
24
+ expect(child.folder).to eql(Path.dir/'resource')
25
+ end
26
+ end
27
+
28
+ it 'yield the child to the block if any given' do
29
+ Configuration.new(Path.dir) do |c|
30
+ seen = nil
31
+ c.folder 'resource' do |child|
32
+ seen = child
33
+ end
34
+ expect(seen).to be_a(Configuration)
35
+ expect(seen.folder).to eql(Path.dir/'resource')
36
+ end
37
+ end
38
+ end
39
+
13
40
  describe 'run_counterexamples' do
14
41
 
15
42
  it 'is true by default' do
@@ -83,8 +110,7 @@ module Webspicy
83
110
  describe 'dup' do
84
111
 
85
112
  let(:original) do
86
- Configuration.new do |c|
87
- c.add_folder Path.dir/'resource'
113
+ Configuration.new(Path.dir/'resource') do |c|
88
114
  c.host = "http://127.0.0.1"
89
115
  end
90
116
  end
@@ -93,19 +119,16 @@ module Webspicy
93
119
  duped = original.dup do |d|
94
120
  d.host = "http://127.0.0.1:4567"
95
121
  end
122
+ expect(duped.folder).to eql(Path.dir/'resource')
96
123
  expect(duped.host).to eql("http://127.0.0.1:4567")
97
124
  expect(original.host).to eql("http://127.0.0.1")
98
125
  end
99
126
 
100
127
  it 'duplicates the internal arrays to' do
101
128
  duped = original.dup do |d|
102
- d.add_folder Path.dir/'scope'
103
129
  d.rspec_options << "--hello"
104
130
  d.before_each do end
105
131
  end
106
- expect(duped.folders.size).to eql(2)
107
- expect(original.folders.size).to eql(1)
108
-
109
132
  expect(duped.rspec_options.last).to eq("--hello")
110
133
  expect(original.rspec_options.last).not_to eq("--hello")
111
134
 
data/tasks/test.rake CHANGED
@@ -16,7 +16,7 @@ namespace :test do
16
16
  desc "Runs the integration tests on the #{file.basename} example"
17
17
  task(test_name) do
18
18
  Bundler.with_original_env do
19
- system("cd #{file} && rake")
19
+ system("cd #{file} && bundle exec rake")
20
20
  end
21
21
  end
22
22
  tests << test_name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webspicy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
@@ -169,9 +169,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  requirements:
172
- - - ">="
172
+ - - ">"
173
173
  - !ruby/object:Gem::Version
174
- version: '0'
174
+ version: 1.3.1
175
175
  requirements: []
176
176
  rubyforge_project:
177
177
  rubygems_version: 2.5.1