soaspec 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,42 +1,51 @@
1
- # Soaspec
2
-
3
- This gem helps to represent multiple API tests against a backend briefly, concisely and clearly. It is essentially a wrapper around the Savon and RestClient gems.
4
-
5
-
6
- ## Installation
7
-
8
- Add this line to your application's Gemfile:
9
-
10
- ```ruby
11
- gem 'soaspec'
12
- ```
13
-
14
- And then execute:
15
-
16
- $ bundle
17
-
18
- Or install it yourself as:
19
-
20
- $ gem install soaspec
21
-
22
- ## Usage
23
-
24
- See specs for example of usage. This will be added to later.
25
-
26
- ## Development
27
-
28
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
-
30
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
-
32
- ## Contributing
33
-
34
- Bug reports and pull requests are welcome on GitLab at https://gitlab.com/samuel-garratt/soaspec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
35
-
36
- ## License
37
-
38
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
39
-
40
- ## Code of Conduct
41
-
42
- Everyone interacting in the Soaspec project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/samuel-garratt/soaspec/blob/master/CODE_OF_CONDUCT.md).
1
+ # Soaspec
2
+
3
+ This gem helps to represent multiple API tests against a backend briefly, concisely and clearly. It is essentially a wrapper around the Savon and RestClient gems. Note it is still in early stages of development.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'soaspec'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install soaspec
21
+
22
+ ## Todo
23
+
24
+ Handle REST
25
+ Give examples and convience methods for building classes for each SOAP or REST operation
26
+ Potentially have in built use of vcr and http_stub gems
27
+
28
+ ## Usage
29
+
30
+ See specs for example of usage. This will be added to later.
31
+
32
+ It is recommended that a class be created representing a Web Service Operation or REST call. Then tests refer back to
33
+ that class. See get_weather_web_service class in spec/soaspec/soap folder for example
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitLab at https://gitlab.com/samuel-garratt/soaspec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
+
49
+ ## Code of Conduct
50
+
51
+ Everyone interacting in the Soaspec project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/samuel-garratt/soaspec/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,17 +1,20 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:run_spec) do |t|
5
- t.pattern = "spec/*/#{ENV['test_name']}*_spec.rb"
6
- end
7
-
8
- desc 'Prepare log files'
9
- task :logs do
10
- mkdir_p 'logs'
11
- touch 'logs/traffic.log'
12
- end
13
-
14
- desc 'Run tests'
15
- task :spec => %w[logs run_spec]
16
-
17
- task :default => :spec
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rake/clean'
4
+
5
+ RSpec::Core::RakeTask.new(:run_spec) do |t|
6
+ t.pattern = "spec/*/*/*_spec.rb"
7
+ end
8
+
9
+ desc 'Prepare log files'
10
+ task :logs do
11
+ mkdir_p 'logs'
12
+ touch 'logs/traffic.log'
13
+ end
14
+
15
+ desc 'Run tests'
16
+ task :spec => %w[logs run_spec]
17
+
18
+ task :default => :spec
19
+
20
+ CLOBBER.include 'logs/*'
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "soaspec"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "soaspec"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/soaspec-init CHANGED
@@ -1,142 +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)
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)