restflow 0.0.2
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.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +31 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +124 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/bin/restflow +11 -0
- data/lib/restflow.rb +6 -0
- data/lib/restflow/report.rb +49 -0
- data/lib/restflow/sequence.rb +94 -0
- data/restflow.gemspec +67 -0
- data/samples/github_calls.rb +16 -0
- data/samples/local_server.rb +36 -0
- data/samples/local_sinatra_calls.rb +72 -0
- data/samples/new_user.json +1 -0
- data/spec/restflow_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +134 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec"
|
10
|
+
gem "rdoc"
|
11
|
+
gem "bundler"
|
12
|
+
gem "jeweler", "~> 1.8.4"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.8.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rdoc
|
11
|
+
json (1.7.7)
|
12
|
+
rake (10.0.3)
|
13
|
+
rdoc (3.12.1)
|
14
|
+
json (~> 1.4)
|
15
|
+
rspec (2.12.0)
|
16
|
+
rspec-core (~> 2.12.0)
|
17
|
+
rspec-expectations (~> 2.12.0)
|
18
|
+
rspec-mocks (~> 2.12.0)
|
19
|
+
rspec-core (2.12.2)
|
20
|
+
rspec-expectations (2.12.1)
|
21
|
+
diff-lcs (~> 1.1.3)
|
22
|
+
rspec-mocks (2.12.2)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
bundler
|
29
|
+
jeweler (~> 1.8.4)
|
30
|
+
rdoc
|
31
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 simcap
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
= Restflow
|
2
|
+
|
3
|
+
Simple DSL to assert REST services
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
$ gem install restflow
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
Create a file that contains the sequences of REST calls and
|
12
|
+
add assertions to test the payloads you get back.
|
13
|
+
|
14
|
+
Example with a file name sequence.rb:
|
15
|
+
|
16
|
+
base_url 'https://api.github.com'
|
17
|
+
|
18
|
+
sequence 'Retrieve info of a Github user' do
|
19
|
+
get 'users/simcap'
|
20
|
+
json['login'].should == "simcap"
|
21
|
+
status.should == 200
|
22
|
+
end
|
23
|
+
|
24
|
+
sequence 'Retrieve info of a Github repo' do
|
25
|
+
get 'users/simcap/repos'
|
26
|
+
json[0]['full_name'].should == "simcap/anagram-kata"
|
27
|
+
status.should == 200
|
28
|
+
|
29
|
+
get 'repos/simcap/anagram-kata'
|
30
|
+
json['name'].should == "anagram-kata"
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
Then run on the file
|
35
|
+
|
36
|
+
$ restflow sequence.rb
|
37
|
+
|
38
|
+
A report file sequences-report.html will be generated in the current directory.
|
39
|
+
|
40
|
+
=== Examples
|
41
|
+
|
42
|
+
GET asserting response code
|
43
|
+
|
44
|
+
sequence 'List all users' do
|
45
|
+
get 'users'
|
46
|
+
status.should == 200
|
47
|
+
end
|
48
|
+
|
49
|
+
sequence 'Cannot find user' do
|
50
|
+
get 'users/3'
|
51
|
+
status.should == 404
|
52
|
+
end
|
53
|
+
|
54
|
+
GET asserting json content
|
55
|
+
|
56
|
+
sequence 'List one users' do
|
57
|
+
get 'users/1'
|
58
|
+
json['firstname'].should == "John"
|
59
|
+
json['lastname'].should == "Doe"
|
60
|
+
|
61
|
+
get 'users/2'
|
62
|
+
json['firstname'].should == "Sue"
|
63
|
+
json['lastname'].should == "Helen"
|
64
|
+
end
|
65
|
+
|
66
|
+
POST inline post data
|
67
|
+
|
68
|
+
sequence 'Create new user' do
|
69
|
+
post 'users', <<-BODY
|
70
|
+
{"firstname":"James","lastname":"Bond"}
|
71
|
+
BODY
|
72
|
+
|
73
|
+
get 'users/3'
|
74
|
+
status.should == 200
|
75
|
+
json['firstname'].should == "James"
|
76
|
+
json['lastname'].should == "Bond"
|
77
|
+
end
|
78
|
+
|
79
|
+
POST post data from file
|
80
|
+
|
81
|
+
sequence 'Create new user with body from file' do
|
82
|
+
post 'users', :file => "new_user.json"
|
83
|
+
|
84
|
+
get 'users/4'
|
85
|
+
status.should == 200
|
86
|
+
json['firstname'].should == "Bob"
|
87
|
+
json['lastname'].should == "Marley"
|
88
|
+
end
|
89
|
+
|
90
|
+
DELETE
|
91
|
+
|
92
|
+
sequence 'Delete users' do
|
93
|
+
delete 'users/3'
|
94
|
+
status.should == 200
|
95
|
+
get 'users/3'
|
96
|
+
status.should == 404
|
97
|
+
|
98
|
+
delete 'users/4'
|
99
|
+
status.should == 200
|
100
|
+
get 'users/4'
|
101
|
+
status.should == 404
|
102
|
+
end
|
103
|
+
|
104
|
+
Checking raw response content
|
105
|
+
|
106
|
+
sequence 'Error when creating' do
|
107
|
+
post 'users', <<-BODY
|
108
|
+
{"firstname":"James"}
|
109
|
+
BODY
|
110
|
+
|
111
|
+
response.should =~ /lastname is missing/
|
112
|
+
|
113
|
+
post 'users', <<-BODY
|
114
|
+
{"lastname":"Bond"}
|
115
|
+
BODY
|
116
|
+
|
117
|
+
response.should =~ /firstname is missing/
|
118
|
+
end
|
119
|
+
|
120
|
+
== Copyright
|
121
|
+
|
122
|
+
Copyright (c) 2013 simcap. See LICENSE.txt for
|
123
|
+
further details.
|
124
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
gem.name = "restflow"
|
17
|
+
gem.homepage = "http://github.com/simcap/restflow"
|
18
|
+
gem.license = "MIT"
|
19
|
+
gem.summary = %Q{Simple DSL to assert REST services}
|
20
|
+
gem.description = %Q{Simple DSL to assert REST services}
|
21
|
+
gem.authors = ["simcap"]
|
22
|
+
gem.files.exclude "samples"
|
23
|
+
# dependencies defined in Gemfile
|
24
|
+
end
|
25
|
+
Jeweler::RubygemsDotOrgTasks.new
|
26
|
+
|
27
|
+
require 'rspec/core'
|
28
|
+
require 'rspec/core/rake_task'
|
29
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
30
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
31
|
+
end
|
32
|
+
|
33
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
34
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
35
|
+
spec.rcov = true
|
36
|
+
end
|
37
|
+
|
38
|
+
task :default => :spec
|
39
|
+
|
40
|
+
require 'rdoc/task'
|
41
|
+
Rake::RDocTask.new do |rdoc|
|
42
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
43
|
+
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
45
|
+
rdoc.title = "restflow #{version}"
|
46
|
+
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/bin/restflow
ADDED
data/lib/restflow.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Restflow
|
2
|
+
|
3
|
+
module Report
|
4
|
+
|
5
|
+
require 'builder'
|
6
|
+
|
7
|
+
def self.run(sequences)
|
8
|
+
report = File.new("sequences-report.html", "w")
|
9
|
+
b = Builder::XmlMarkup.new :target => report, :indent => 2
|
10
|
+
b.instruct!
|
11
|
+
b.html {
|
12
|
+
b.head { b.title("Sequences")}
|
13
|
+
b.style(self.css_content)
|
14
|
+
b.body {
|
15
|
+
sequences.each { |sequence|
|
16
|
+
b.section(:class => "sequence") {
|
17
|
+
b.h2(sequence.description)
|
18
|
+
sequence.responses.each { |response|
|
19
|
+
b.p(:class => "request"){
|
20
|
+
b.span(response.request.http_method.to_s.split("::").last, :class => "verb")
|
21
|
+
b.span(response.request.path, :class => "original-request")
|
22
|
+
b.span(response.code, :class => "status")
|
23
|
+
}
|
24
|
+
b.code(response.body)
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
report.close
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def self.css_content
|
37
|
+
<<-CSS
|
38
|
+
body { }
|
39
|
+
.request { }
|
40
|
+
span.verb { font-weight: bold; text-transform: uppercase;}
|
41
|
+
span.original-request { text-align: center;}
|
42
|
+
span.status { font-weight: bold; float: right;}
|
43
|
+
CSS
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Restflow
|
2
|
+
|
3
|
+
class Sequences
|
4
|
+
|
5
|
+
def parse_flow_file(path)
|
6
|
+
@sequences = []
|
7
|
+
@execution_dir = File.dirname(path)
|
8
|
+
instance_eval(File.read(path), path)
|
9
|
+
Restflow::Report.run(@sequences)
|
10
|
+
end
|
11
|
+
|
12
|
+
def sequence(description, &block)
|
13
|
+
puts "Running < #{description} >"
|
14
|
+
@sequences << Sequence.new(@execution_dir, description , @base_url, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def base_url(url)
|
18
|
+
@base_url = url
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class Sequence
|
24
|
+
|
25
|
+
attr_reader :description, :responses
|
26
|
+
|
27
|
+
def initialize(execution_dir, description, base_url = nil, &block)
|
28
|
+
@responses = []
|
29
|
+
@execution_dir = execution_dir
|
30
|
+
@base_url = base_url if base_url
|
31
|
+
@description = description
|
32
|
+
raise "Sequence block is empty!!" unless block
|
33
|
+
instance_eval &block
|
34
|
+
end
|
35
|
+
|
36
|
+
def base_url(url)
|
37
|
+
@base_url = url
|
38
|
+
end
|
39
|
+
|
40
|
+
def get(path)
|
41
|
+
@response = HTTParty.get("#{@base_url}/#{path}")
|
42
|
+
@responses << @response
|
43
|
+
@response
|
44
|
+
end
|
45
|
+
|
46
|
+
def post(path, data)
|
47
|
+
@response = send_post_data(:post, path, data)
|
48
|
+
@responses << @response
|
49
|
+
@response
|
50
|
+
end
|
51
|
+
|
52
|
+
def delete(path, data = nil)
|
53
|
+
@response = send_post_data(:delete, path, data)
|
54
|
+
@responses << @response
|
55
|
+
@response
|
56
|
+
end
|
57
|
+
|
58
|
+
def put(path, data)
|
59
|
+
@response = send_post_data(:put, path, data)
|
60
|
+
@responses << @response
|
61
|
+
@response
|
62
|
+
end
|
63
|
+
|
64
|
+
def response
|
65
|
+
@response.body
|
66
|
+
end
|
67
|
+
|
68
|
+
def html
|
69
|
+
Nokogiri::HTML(@response.body)
|
70
|
+
end
|
71
|
+
|
72
|
+
def json
|
73
|
+
JSON.parse(@response.body) if @response.body
|
74
|
+
end
|
75
|
+
|
76
|
+
def status
|
77
|
+
@response.code
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def send_post_data(verb, path, post_data)
|
83
|
+
if post_data.is_a?(Hash)
|
84
|
+
file_path = File.expand_path(post_data[:file], @execution_dir)
|
85
|
+
body = File.new(file_path).read
|
86
|
+
else
|
87
|
+
body = post_data
|
88
|
+
end
|
89
|
+
HTTParty.send(verb, "#{@base_url}/#{path}", :body => body)
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
data/restflow.gemspec
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "restflow"
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["simcap"]
|
12
|
+
s.date = "2013-02-24"
|
13
|
+
s.description = "Simple DSL to assert REST services"
|
14
|
+
s.executables = ["restflow"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/restflow",
|
29
|
+
"lib/restflow.rb",
|
30
|
+
"lib/restflow/report.rb",
|
31
|
+
"lib/restflow/sequence.rb",
|
32
|
+
"restflow.gemspec",
|
33
|
+
"samples/github_calls.rb",
|
34
|
+
"samples/local_server.rb",
|
35
|
+
"samples/local_sinatra_calls.rb",
|
36
|
+
"samples/new_user.json",
|
37
|
+
"spec/restflow_spec.rb",
|
38
|
+
"spec/spec_helper.rb"
|
39
|
+
]
|
40
|
+
s.homepage = "http://github.com/simcap/restflow"
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = "1.8.24"
|
44
|
+
s.summary = "Simple DSL to assert REST services"
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
56
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
57
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
58
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
62
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
63
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
base_url 'https://api.github.com'
|
2
|
+
|
3
|
+
sequence 'Retrieve info of a Github user' do
|
4
|
+
get 'users/simcap'
|
5
|
+
json['login'].should == "simcap"
|
6
|
+
status.should == 200
|
7
|
+
end
|
8
|
+
|
9
|
+
sequence 'Retrieve info of a Github repo' do
|
10
|
+
get 'users/simcap/repos'
|
11
|
+
json[0]['full_name'].should == "simcap/anagram-kata"
|
12
|
+
status.should == 200
|
13
|
+
|
14
|
+
get 'repos/simcap/anagram-kata'
|
15
|
+
json['name'].should == "anagram-kata"
|
16
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class UsersWebApp < Sinatra::Base
|
5
|
+
|
6
|
+
USERS = { 1 => { "firstname" => "John", "lastname" => "Doe"},
|
7
|
+
2 => { "firstname" => "Sue", "lastname" => "Helen"}
|
8
|
+
}
|
9
|
+
|
10
|
+
get '/users/:id' do
|
11
|
+
user_id = params[:id].to_i
|
12
|
+
return status 404 unless USERS[user_id]
|
13
|
+
JSON.generate(USERS[user_id])
|
14
|
+
end
|
15
|
+
|
16
|
+
get '/users' do
|
17
|
+
JSON.generate(USERS)
|
18
|
+
end
|
19
|
+
|
20
|
+
post '/users' do
|
21
|
+
json_data = JSON.parse request.body.read
|
22
|
+
return "firstname is missing" unless json_data['firstname']
|
23
|
+
return "lastname is missing" unless json_data['lastname']
|
24
|
+
USERS[USERS.keys.length + 1] = json_data
|
25
|
+
status 200
|
26
|
+
end
|
27
|
+
|
28
|
+
delete '/users/:id' do
|
29
|
+
user_id = params[:id].to_i
|
30
|
+
return status 404 unless USERS[user_id]
|
31
|
+
USERS.delete(user_id)
|
32
|
+
status 200
|
33
|
+
end
|
34
|
+
|
35
|
+
run!
|
36
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
base_url 'http://localhost:4567'
|
2
|
+
|
3
|
+
sequence 'List all users' do
|
4
|
+
get 'users'
|
5
|
+
json['1']['firstname'].should == "John"
|
6
|
+
json['2']['lastname'].should == "Helen"
|
7
|
+
status.should == 200
|
8
|
+
end
|
9
|
+
|
10
|
+
sequence 'List one users' do
|
11
|
+
get 'users/1'
|
12
|
+
json['firstname'].should == "John"
|
13
|
+
json['lastname'].should == "Doe"
|
14
|
+
status.should == 200
|
15
|
+
|
16
|
+
get 'users/2'
|
17
|
+
json['firstname'].should == "Sue"
|
18
|
+
json['lastname'].should == "Helen"
|
19
|
+
status.should == 200
|
20
|
+
end
|
21
|
+
|
22
|
+
sequence 'Cannot find user' do
|
23
|
+
get 'users/3'
|
24
|
+
status.should == 404
|
25
|
+
end
|
26
|
+
|
27
|
+
sequence 'Create new user' do
|
28
|
+
post 'users', <<-BODY
|
29
|
+
{"firstname":"James","lastname":"Bond"}
|
30
|
+
BODY
|
31
|
+
|
32
|
+
get 'users/3'
|
33
|
+
status.should == 200
|
34
|
+
json['firstname'].should == "James"
|
35
|
+
json['lastname'].should == "Bond"
|
36
|
+
end
|
37
|
+
|
38
|
+
sequence 'Create new user with body from file' do
|
39
|
+
post 'users', :file => "new_user.json"
|
40
|
+
|
41
|
+
get 'users/4'
|
42
|
+
status.should == 200
|
43
|
+
json['firstname'].should == "Bob"
|
44
|
+
json['lastname'].should == "Marley"
|
45
|
+
end
|
46
|
+
|
47
|
+
sequence 'Delete users' do
|
48
|
+
delete 'users/3'
|
49
|
+
status.should == 200
|
50
|
+
get 'users/3'
|
51
|
+
status.should == 404
|
52
|
+
|
53
|
+
delete 'users/4'
|
54
|
+
status.should == 200
|
55
|
+
get 'users/4'
|
56
|
+
status.should == 404
|
57
|
+
end
|
58
|
+
|
59
|
+
sequence 'Error when creating' do
|
60
|
+
post 'users', <<-BODY
|
61
|
+
{"firstname":"James"}
|
62
|
+
BODY
|
63
|
+
|
64
|
+
response.should =~ /lastname is missing/
|
65
|
+
|
66
|
+
post 'users', <<-BODY
|
67
|
+
{"lastname":"Bond"}
|
68
|
+
BODY
|
69
|
+
|
70
|
+
response.should =~ /firstname is missing/
|
71
|
+
end
|
72
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
{"firstname":"Bob","lastname":"Marley"}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'restflow'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: restflow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- simcap
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rdoc
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
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: jeweler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.4
|
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: 1.8.4
|
78
|
+
description: Simple DSL to assert REST services
|
79
|
+
email:
|
80
|
+
executables:
|
81
|
+
- restflow
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files:
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.rdoc
|
86
|
+
files:
|
87
|
+
- .document
|
88
|
+
- .rspec
|
89
|
+
- Gemfile
|
90
|
+
- Gemfile.lock
|
91
|
+
- LICENSE.txt
|
92
|
+
- README.rdoc
|
93
|
+
- Rakefile
|
94
|
+
- VERSION
|
95
|
+
- bin/restflow
|
96
|
+
- lib/restflow.rb
|
97
|
+
- lib/restflow/report.rb
|
98
|
+
- lib/restflow/sequence.rb
|
99
|
+
- restflow.gemspec
|
100
|
+
- samples/github_calls.rb
|
101
|
+
- samples/local_server.rb
|
102
|
+
- samples/local_sinatra_calls.rb
|
103
|
+
- samples/new_user.json
|
104
|
+
- spec/restflow_spec.rb
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
homepage: http://github.com/simcap/restflow
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
segments:
|
120
|
+
- 0
|
121
|
+
hash: 3599554636587573763
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 1.8.24
|
131
|
+
signing_key:
|
132
|
+
specification_version: 3
|
133
|
+
summary: Simple DSL to assert REST services
|
134
|
+
test_files: []
|