soaspec 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/soaspec-init +142 -0
- data/lib/soaspec/version.rb +1 -1
- metadata +3 -3
- data/exe/soaspec +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1805cb5be5ab743cd17f02e7d53ddf24f0ba175
|
4
|
+
data.tar.gz: 36bc197f389c6793e2c19f04e6cd963a862037b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f54a833a24e00f025bc735a8ca53fa84873889be22a1cb506c4a419fd4593a17e046b02df5a03ef13e4b59e4c5f9accf8fb0bfaf8aa2edc6dac47bad881df5d5
|
7
|
+
data.tar.gz: 3014aba6ec80e3ff30ed71953c47b04149a91e9df7136fdee3e97f93f47cd746e6192f3b2ffbca59a74d73ca26c51c799dbd858c5722395e65e8e4016d4144c0
|
data/Gemfile.lock
CHANGED
data/exe/soaspec-init
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'soaspec'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
def create_file(options)
|
7
|
+
filename = options[:filename]
|
8
|
+
fail 'Need to pass filename' unless filename
|
9
|
+
content = options[:content]
|
10
|
+
fail 'Need to pass contents to insert into file' unless content
|
11
|
+
if File.exist? filename
|
12
|
+
old_content = File.read(filename)
|
13
|
+
if old_content != content
|
14
|
+
$stderr.puts "!! #{filename} already exists and differs from template"
|
15
|
+
end
|
16
|
+
else
|
17
|
+
File.open(filename, 'w') do |f|
|
18
|
+
f.puts content
|
19
|
+
end
|
20
|
+
puts 'Created: ' + filename
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_folder(folder)
|
25
|
+
if File.exists? folder
|
26
|
+
unless File.directory? folder
|
27
|
+
$stderr.puts "!! #{folder} already exists and is not a directory"
|
28
|
+
end
|
29
|
+
else
|
30
|
+
FileUtils.mkdir folder
|
31
|
+
puts "Created folder: #{folder}/"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
puts 'Creating files for soaspec'
|
36
|
+
|
37
|
+
gem_content = <<-EOF
|
38
|
+
|
39
|
+
source 'https://rubygems.org'
|
40
|
+
|
41
|
+
gem 'soaspec'
|
42
|
+
|
43
|
+
EOF
|
44
|
+
|
45
|
+
rake_content = <<-EOF
|
46
|
+
# The list of task for a Rake file can be seen with `rake -T`
|
47
|
+
require 'rspec/core/rake_task' # See See https://relishapp.com/rspec/rspec-core/docs/command-line/rake-task for details
|
48
|
+
|
49
|
+
# This runs `rspec` command with the following options. Type `rake spec` to run this task
|
50
|
+
RSpec::Core::RakeTask.new(:spec) do |t, task_args|
|
51
|
+
t.pattern = "spec/*_spec.rb" # Run all specs in 'spec' folder ending in '_spec'
|
52
|
+
# Next line shows output on the screen, Junit xml report and an HTML report
|
53
|
+
t.rspec_opts = "--format documentation --format RspecJunitFormatter --out logs/spec.xml --format html --out logs/spec.html"
|
54
|
+
t.fail_on_error = false
|
55
|
+
end
|
56
|
+
|
57
|
+
task :default => :spec # This runs the 'spec' task by default when no task is mentioned. E.g., if only `rake` is typed
|
58
|
+
EOF
|
59
|
+
|
60
|
+
|
61
|
+
spec_helper_content = <<-EOF
|
62
|
+
|
63
|
+
require 'soaspec'
|
64
|
+
|
65
|
+
EOF
|
66
|
+
|
67
|
+
soap_spec_content = <<-EOF
|
68
|
+
require 'spec_helper'
|
69
|
+
|
70
|
+
soap_example = Soaspec::BasicSoapHandler.new('Courier post',
|
71
|
+
wsdl: 'http://www.webservicex.com/globalweather.asmx?wsdl')
|
72
|
+
soap_example.namespaces = { 'ns1' => 'http://www.webserviceX.NET' }
|
73
|
+
soap_example.default_operation = :get_weather
|
74
|
+
soap_example.template_name = 'soap_template'
|
75
|
+
|
76
|
+
RSpec.context soap_example do
|
77
|
+
describe Exchange.new(:default) do
|
78
|
+
it { is_expected.to contain 'Data Not Found' }
|
79
|
+
it_behaves_like 'success scenario'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
EOF
|
83
|
+
|
84
|
+
soap_template_content = <<-EOF
|
85
|
+
<s12:Envelope xmlns:s12='http://www.w3.org/2003/05/soap-envelope'>
|
86
|
+
<s12:Body>
|
87
|
+
<ns1:GetWeather xmlns:ns1='http://www.webserviceX.NET'>
|
88
|
+
<!-- optional -->
|
89
|
+
<ns1:CityName><%= test_values[:city_name] || 'Wellington' %></ns1:CityName>
|
90
|
+
<!-- optional -->
|
91
|
+
<ns1:CountryName><%= test_values[:country] || 'New Zealand' %></ns1:CountryName>
|
92
|
+
</ns1:GetWeather>
|
93
|
+
</s12:Body>
|
94
|
+
</s12:Envelope>
|
95
|
+
EOF
|
96
|
+
|
97
|
+
readme_content = <<-EOF
|
98
|
+
|
99
|
+
# Prerequisites
|
100
|
+
This creates files within an existing folder. It could add onto an existing project.
|
101
|
+
For a new project create a folder and be at it's location on the command line
|
102
|
+
|
103
|
+
```
|
104
|
+
mkdir soaspec_test
|
105
|
+
cd soaspec_test
|
106
|
+
```
|
107
|
+
|
108
|
+
Run `bundle install` to install the gems mentioned in the Gemfile.
|
109
|
+
|
110
|
+
To avoid conflict with gems on the machine globally it may be better to specify gem location with:
|
111
|
+
|
112
|
+
`bundle install --path ~/.gem`
|
113
|
+
|
114
|
+
# Running tests
|
115
|
+
On the command line type:
|
116
|
+
`bundle exec rake spec` or simply `bundle exec rake`
|
117
|
+
|
118
|
+
# Structure
|
119
|
+
|
120
|
+
## Tests
|
121
|
+
Tests are within the 'spec' folder and end in '_spec'. Setup and teardown for tests is in 'spec/spec_helper'
|
122
|
+
|
123
|
+
## Templates
|
124
|
+
These are the base requests with ERB inside them to create smartly changing requests accoring to the test.yml
|
125
|
+
|
126
|
+
## Libaries
|
127
|
+
Libaries to be installed are in 'Gemfile'. Specific gem versions can be specified here and enforeced with `bundle exec rake`
|
128
|
+
|
129
|
+
## Reports
|
130
|
+
Reports are shown in the 'logs' folder. By default Rake produces a junit, an html report, and a traffic.log file with the API request and responses in it
|
131
|
+
|
132
|
+
EOF
|
133
|
+
|
134
|
+
create_file(filename: 'Gemfile', content: gem_content)
|
135
|
+
create_file(filename: 'Rakefile', content: rake_content)
|
136
|
+
create_file(filename: 'README.md', content: readme_content)
|
137
|
+
create_folder 'spec'
|
138
|
+
create_folder 'template'
|
139
|
+
create_folder 'logs'
|
140
|
+
create_file(filename: 'spec/spec_helper.rb', content: spec_helper_content)
|
141
|
+
create_file(filename: 'spec/soap_spec.rb', content: soap_spec_content)
|
142
|
+
create_file(filename: 'template/soap_template.xml', content: soap_template_content)
|
data/lib/soaspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soaspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
@@ -99,7 +99,7 @@ description: "Helps to create RSpec specs for SOAP or REST apis. Easily represen
|
|
99
99
|
email:
|
100
100
|
- samuel.garratt@integrationqa.com
|
101
101
|
executables:
|
102
|
-
- soaspec
|
102
|
+
- soaspec-init
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
@@ -114,7 +114,7 @@ files:
|
|
114
114
|
- Rakefile
|
115
115
|
- bin/console
|
116
116
|
- bin/setup
|
117
|
-
- exe/soaspec
|
117
|
+
- exe/soaspec-init
|
118
118
|
- lib/soaspec.rb
|
119
119
|
- lib/soaspec/basic_soap_handler.rb
|
120
120
|
- lib/soaspec/common.rb
|
data/exe/soaspec
DELETED