rest_baby 1.4 → 1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e4434fba088d6a097f2be5d36e96e90227dff78
4
- data.tar.gz: e8cf38ebd5ff70ef6a94b0661db322b0f8d8b031
3
+ metadata.gz: d9b78022bb0d698df2e50d51b909858d234cb5ab
4
+ data.tar.gz: 4a6fb2d570c791bcd9caed0f412384210bc984ce
5
5
  SHA512:
6
- metadata.gz: d0b4fd87625544ca1a47861a1323bf36a20c311753053c843da69fe1e164c86f4af032081ba6d054d988391c542c103044d6846ab9e7829689474f9fda973d40
7
- data.tar.gz: 72ae4238bc08f17d051f361c470cd9fff142731be56ccb9cbe462d4a40f0155b3349ae8a79beb960b813a7199d7f6323a4fe3efee5b19a027a2dac4293f6ef8c
6
+ metadata.gz: 16f917d2687fdcc235d23c222ba316d024be3ad426afb1999957d0aa355b75e8494b2606b4c5763f3cc625cc5e64b22ee7d6a8b98b7ed9ae7b60cebd3849efc1
7
+ data.tar.gz: c8fa2018f450147372f866492a139da6739e535863cd3d3d5a3ce39544bfc382e5dae83e81f12e4b187315dbd70b413b9e4d83b4ad1948bce7dafa0a41ce6e4e
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/ChangeLog CHANGED
@@ -47,3 +47,7 @@
47
47
  * Revise gem list to support yardoc in dev mode
48
48
  * cleaned up rake file, added support for cleaning yardocs
49
49
  * Add support for travis-ci
50
+ === Version 1.5 / 2015-12-12
51
+ * Add code coverage
52
+ * Created scenario for combination of authentication & url parameters
53
+ * Fixed Simple Cov formatter issue
data/Gemfile CHANGED
@@ -10,8 +10,10 @@ group :development do
10
10
  gem 'fig_newton'
11
11
  gem 'rspec'
12
12
  gem 'webmock'
13
+ gem 'coveralls'
14
+ gem 'simplecov'
13
15
  gem 'rubocop'
14
- if ENV["JRUBY"] || RUBY_PLATFORM == "java"
16
+ if ENV['JRUBY'] || RUBY_PLATFORM == 'java'
15
17
  # Skip the yard gems for jruby
16
18
  else
17
19
  gem 'yard'
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  Small rest client, supports ruby-2.0.0, ruby-2.1.0, ruby-2.2.0, jruby (based 1.9). You can only updated docs in ruby, not jruby.
4
4
 
5
+ ## Coverage
6
+ [![Coverage Status](https://coveralls.io/repos/dmcnulla/rest_baby/badge.svg?branch=v1_5&service=github)](https://coveralls.io/github/dmcnulla/rest_baby?branch=v1_5)
7
+
5
8
  ## Installation
6
9
 
7
10
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -2,22 +2,25 @@ require 'bundler/gem_tasks'
2
2
  require 'rubygems'
3
3
  require 'cucumber'
4
4
  require 'cucumber/rake/task'
5
- if ENV["JRUBY"] || RUBY_PLATFORM == "java"
5
+ require 'coveralls/rake/task'
6
+
7
+ if ENV['JRUBY'] || RUBY_PLATFORM == 'java'
6
8
  # Skip the yard gems for jruby
7
9
  else
8
10
  require 'yard'
9
11
  # rake yard
10
12
  YARD::Rake::YardocTask.new do |t|
11
- t.files = ['lib/**/*.rb', 'features/**/*.feature', 'features/**/*.rb']
13
+ t.files = ['lib/**/*.rb', 'features/**/*.feature', 'features/**/*.rb']
12
14
  end
13
15
  end
14
16
 
15
-
16
17
  Cucumber::Rake::Task.new(:features) do |t|
17
18
  t.profile = 'default'
18
19
  end
19
20
 
20
- task default: :features
21
+ Coveralls::RakeTask.new
22
+
23
+ task default: [:features, 'coveralls:push']
21
24
 
22
25
  task :clean do
23
26
  `rm -rf doc`
data/cucumber.yml CHANGED
@@ -1,4 +1,4 @@
1
- default: FIG_NEWTON_FILE=mock.yml DEBUG_HTTP=false --tags ~@wip --no-source --color --format pretty
1
+ default: FIG_NEWTON_FILE=mock.yml DEBUG_HTTP=true --tags ~@wip --no-source --color --format pretty
2
2
  debug: FIG_NEWTON_FILE=mock.yml DEBUG_HTTP=true --no-source --color --format pretty
3
3
  report: FIG_NEWTON_FILE=mock.yml DEBUG_HTTP=false --no-source --color --format progress --format html --out='features_<%= Time.new.strftime('%Y-%m-%d_%H_%M_%S') %>.html'
4
4
  wip: FIG_NEWTON_FILE=mock.yml DEBUG_HTTP=true --tags @wip --color --format pretty
@@ -14,7 +14,12 @@ end
14
14
  Given(/^I have "(GET|DELETE)" service for "([^"]*)" for \
15
15
  user "([^"]*)" and password "([^"]*)"$/) do |type, path, user, password|
16
16
  @path = path
17
- @mockservice.store_msg(type, path, DEFAULT_MSG, {}, user, password)
17
+ message = hasParams(path) ? path.split('?')[1] : DEFAULT_MSG
18
+ @mockservice.store_msg(type, path, message, {}, user, password)
19
+ end
20
+
21
+ def hasParams(path)
22
+ path.include?('?')
18
23
  end
19
24
 
20
25
  Given(/^I have "(PUT|POST)" service for "([^"]*)" for \
@@ -1,5 +1,10 @@
1
1
  DEFAULT_MSG = '{"Answer": "What did you expect?"}'
2
2
  DEFAULT_RESPONSE = '{"Question": "What is the meaning of life?"}'
3
+ DEFAULT_XML = '<Questions><Question>What is the meaning of life?</Question></Questions>'
4
+ XML_HEADERS = {
5
+ 'Content-Type' => 'application/xml',
6
+ 'Accept' => 'application/xml'
7
+ }
3
8
 
4
9
  Given(/^I have a web service$/) do
5
10
  @protocol = 'http'
@@ -19,6 +24,12 @@ Given(/^I have "(GET|PUT|POST|DELETE)" service for "([^"]*)"$/) do |type, path|
19
24
  end
20
25
  end
21
26
 
27
+ Given(/^I have an xml service for "([^"]*)"$/) do |path|
28
+ @path = path
29
+ @mockservice.store_msg('POST', path, DEFAULT_XML,
30
+ XML_HEADERS, nil, nil, DEFAULT_XML)
31
+ end
32
+
22
33
  Given(/^I have "(GET|PUT|POST|DELETE)" service for "([^"]*)" as follows$/) \
23
34
  do |type, path, message|
24
35
  @path = path
@@ -51,6 +62,16 @@ When(/^I "(GET|DELETE)" from the web service$/) do |type|
51
62
  end
52
63
  end
53
64
 
65
+ When(/^I "(.*?)" to the web service with the following xml$/) do |type, message|
66
+ @message = message.strip
67
+ case type.downcase
68
+ when 'put'
69
+ @response = @restbaby.put(@message, XML_HEADERS)
70
+ when 'post'
71
+ @response = @restbaby.post(@message, XML_HEADERS)
72
+ end
73
+ end
74
+
54
75
  When(/^I "(PUT|POST)" to the web service with the following$/) \
55
76
  do |type, message|
56
77
  @message = message.strip
@@ -79,3 +100,8 @@ Then(/^I receive a message with "([^"]*)"$/) do |message|
79
100
  expect(@response.code).to eq('200')
80
101
  expect(@response.body).to eq(message)
81
102
  end
103
+
104
+ Then(/^I receive the xml message$/) do
105
+ expect(@response.code).to eq('200')
106
+ expect(@response.body).to eq(DEFAULT_XML)
107
+ end
@@ -3,10 +3,21 @@ require 'fig_newton'
3
3
  require 'cucumber/rspec/doubles'
4
4
  require 'rubygems'
5
5
  require 'webmock/cucumber'
6
+ require 'coveralls'
7
+ require 'simplecov'
8
+
9
+ puts "Using environment in #{ENV['FIG_NEWTON_FILE']}"
10
+ FigNewton.load(ENV['FIG_NEWTON_FILE'])
11
+
12
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
13
+ SimpleCov::Formatter::HTMLFormatter,
14
+ Coveralls::SimpleCov::Formatter
15
+ ])
16
+ SimpleCov.start do
17
+ add_filter 'features'
18
+ end
19
+
6
20
  require File.expand_path(File.join(File.dirname(__FILE__),
7
21
  '..', '..', 'lib', 'rest_baby.rb'))
8
22
 
9
23
  include RestBaby
10
-
11
- puts "Using environment in #{ENV['FIG_NEWTON_FILE']}"
12
- FigNewton.load(ENV['FIG_NEWTON_FILE'])
@@ -11,3 +11,16 @@ Scenario: Send parameter to a service.
11
11
  | second | 2 |
12
12
  | third | 3 |
13
13
  Then I receive a message with "first=1&second=2&third=3"
14
+
15
+ @extended @post @authentication @parameter
16
+ @parameter.S2
17
+ Scenario: Send parameter to a service.
18
+ Given I have a web service
19
+ And I have "GET" service for "/test?first=1&second=2&third=3" for user "test" and password "rest"
20
+ And I am a rest client
21
+ And I have basic auth for user "test" and password "rest"
22
+ When I "GET" from the web service with the parameters
23
+ | first | 1 |
24
+ | second | 2 |
25
+ | third | 3 |
26
+ Then I receive a message with "first=1&second=2&third=3"
@@ -0,0 +1,13 @@
1
+ Feature: Create a basic rest client that can get, put, post, and delete
2
+
3
+ @core @POST
4
+ @xml.S1
5
+ Scenario: client rest POST
6
+ Given I have a web service
7
+ And I have an xml service for "/testxml"
8
+ And I am a rest client
9
+ When I "POST" to the web service with the following xml
10
+ """
11
+ <Questions><Question>What is the meaning of life?</Question></Questions>
12
+ """
13
+ Then I receive the xml message
@@ -1,4 +1,4 @@
1
1
  # Identify the version
2
2
  module RestBaby
3
- VERSION = '1.4'
3
+ VERSION = '1.5'
4
4
  end
data/rest_baby.gemspec CHANGED
@@ -11,7 +11,6 @@ Gem::Specification.new do |spec|
11
11
  spec.description = 'Rest client'
12
12
  spec.summary = 'Small rest client developed to testing rest services.'
13
13
  spec.homepage = 'https://github.com/dmcnulla/rest_baby'
14
- spec.metadata = { 'ci' => 'https://travis-ci.org/dmcnulla/rest_baby' }
15
14
  spec.license = 'MIT'
16
15
 
17
16
  spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
@@ -30,4 +29,6 @@ Gem::Specification.new do |spec|
30
29
  spec.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7.6'
31
30
  spec.add_development_dependency 'yard-cucumber', '~> 2.3', '>= 2.3.2'
32
31
  spec.add_development_dependency 'redcarpet', '~> 3.3', '>= 3.3.0'
32
+ spec.add_development_dependency 'coveralls', '~> 0.7'
33
+ spec.add_development_dependency 'simplecov', '~> 0.11'
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_baby
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.4'
4
+ version: '1.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave McNulla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-12 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -206,6 +206,34 @@ dependencies:
206
206
  - - '>='
207
207
  - !ruby/object:Gem::Version
208
208
  version: 3.3.0
209
+ - !ruby/object:Gem::Dependency
210
+ name: coveralls
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ~>
214
+ - !ruby/object:Gem::Version
215
+ version: '0.7'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ~>
221
+ - !ruby/object:Gem::Version
222
+ version: '0.7'
223
+ - !ruby/object:Gem::Dependency
224
+ name: simplecov
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ~>
228
+ - !ruby/object:Gem::Version
229
+ version: '0.11'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ~>
235
+ - !ruby/object:Gem::Version
236
+ version: '0.11'
209
237
  description: Rest client
210
238
  email:
211
239
  - mcnulla@gmail.com
@@ -213,6 +241,7 @@ executables: []
213
241
  extensions: []
214
242
  extra_rdoc_files: []
215
243
  files:
244
+ - .coveralls.yml
216
245
  - .rubocop.yml
217
246
  - .travis.yml
218
247
  - ChangeLog
@@ -287,14 +316,14 @@ files:
287
316
  - features/support/mock_rest_service.rb
288
317
  - features/support/utility.rb
289
318
  - features/url_parameter.feature
319
+ - features/xml_message.feature
290
320
  - lib/rest_baby.rb
291
321
  - lib/rest_baby/version.rb
292
322
  - rest_baby.gemspec
293
323
  homepage: https://github.com/dmcnulla/rest_baby
294
324
  licenses:
295
325
  - MIT
296
- metadata:
297
- ci: https://travis-ci.org/dmcnulla/rest_baby
326
+ metadata: {}
298
327
  post_install_message:
299
328
  rdoc_options: []
300
329
  require_paths:
@@ -325,4 +354,5 @@ test_files:
325
354
  - features/support/mock_rest_service.rb
326
355
  - features/support/utility.rb
327
356
  - features/url_parameter.feature
357
+ - features/xml_message.feature
328
358
  has_rdoc: