botspec 0.4.6

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 619557860d2c22931d2920a9c16e89d15be35d77
4
+ data.tar.gz: b7a3505d6317b88f20fc564427a1ca5172fed1a8
5
+ SHA512:
6
+ metadata.gz: 79cef7e7b7609ca2c5ebc27aafc3eda79df51039f244c059a898faf89e4c3eeeb513c81832245eb1743cdb442af15ab20b60f1ed3f4d9304e19d018cbc647e3b
7
+ data.tar.gz: f5649c0cf94c247dc38884ccae497efae8bd1cfcf74550a5f815e16f7294a54e6476db921a40a607205d85e963913db628a71b8b4b290327c643d3f88b412917
data/.gitignore ADDED
@@ -0,0 +1,38 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ *.gem
11
+ *.rbc
12
+ .config
13
+
14
+ # rspec failure tracking
15
+ .rspec_status
16
+
17
+ .envrc
18
+
19
+ # project
20
+ dist/
21
+ tmp/
22
+
23
+ .envrc
24
+ .direnv/
25
+ .env
26
+ .rspec
27
+ .byebug_history
28
+ .
29
+ # ignore IDE resources
30
+ .vscode
31
+
32
+ # ignore vim tmp files
33
+ *.swp
34
+ *.swo
35
+
36
+ # ignore lock file
37
+ Gemfile.lock
38
+
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.2
7
+ before_install: gem install bundler -v 1.16.3
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ <a name="v0.3.0"></a>
2
+ ### v0.3.0 (2018-10-28)
3
+
4
+
5
+ #### Features
6
+
7
+ * **deploy**
8
+ * Fix up exe in gemspec ([f6175b8](/../../commit/f6175b8))
9
+
10
+
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at elliottmurray@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Dockerfile ADDED
@@ -0,0 +1,25 @@
1
+ FROM ruby:2.4-alpine AS base
2
+
3
+ RUN mkdir /app
4
+ RUN mkdir /app/bot
5
+
6
+ WORKDIR /app/bot
7
+
8
+ COPY ./ /app/bot
9
+
10
+ RUN apk update && apk add --no-cache git make gcc libc-dev
11
+
12
+ ENV SPEC_PATH=$SPEC_PATH
13
+
14
+ RUN gem install bundler thor
15
+ # RUN bundle install --path=/app/bot
16
+ RUN bundle install
17
+
18
+
19
+
20
+ RUN bundle exec thor install lib/cli.thor --as botspec --force
21
+
22
+
23
+
24
+ CMD ["bundle", "exec", "thor", "cli", "--dialogs="]
25
+ # CMD sh
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in botspec.gemspec
6
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,53 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, all_on_start: true, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Gemfiiles
44
+ watch(%r{^spec/.+_spec\.rb$})
45
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
46
+ watch('spec/spec_helper.rb') { "spec" }
47
+
48
+ # Turnip features and steps
49
+ watch(%r{^spec/acceptance/(.+)\.feature$})
50
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
51
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
52
+ end
53
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Elliott Murray
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # Botspec
2
+
3
+ Making specs for your bot that can be run in your build pipeline.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'botspec'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install botspec
20
+
21
+ ## Usage
22
+
23
+ You will need to have AWS credentials set up. A dot file or env vars normally apply. E.g.
24
+ * AWS_REGION
25
+ * AWS_ACCESS_KEY_ID
26
+ * AWS_SECRET_ACCESS_KEY
27
+
28
+ ## Development
29
+
30
+ 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.
31
+
32
+ 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).
33
+
34
+ ## Running a command
35
+ To install run
36
+ ```thor install lib/cli.thor --as botspec --force
37
+ ```
38
+ Then you can run
39
+
40
+ ```
41
+ thor cli:verify -f specs/simple_dialog.yaml
42
+ ```
43
+
44
+
45
+ ## Publishing
46
+ To publish run
47
+ ```
48
+ rake release[remote]
49
+ ```
50
+
51
+ Should create a changelog record
52
+
53
+ ## Docker
54
+ You can run the command with:
55
+ ```
56
+ docker run -e AWS_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -v `pwd`:/app/bot -it botspec thor cli:verify -f specs/simple_dialog.yaml
57
+ ```
58
+
59
+ Assuming you are in your project root directory and your specs are in the corresponding specs folder
60
+
61
+ To build the docker container you may run something like:
62
+ ```
63
+ docker build -t botspec .
64
+ docker tag botspec elliottmurray/botspec
65
+ docker push elliottmurray/botspec
66
+
67
+ ```
68
+
69
+
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/botspec. 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.
74
+
75
+ ## License
76
+
77
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
78
+
79
+ ## Code of Conduct
80
+
81
+ Everyone interacting in the Botspec project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/botspec/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ desc 'Generate change log'
9
+ task :generate_changelog do
10
+ require 'conventional_changelog'
11
+ require 'botspec/version'
12
+ ConventionalChangelog::Generator.new.generate! version: "v#{Botspec::VERSION}"
13
+ end
14
+
15
+ task :console do
16
+ exec "irb -r botspec -I ./lib"
17
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "botspec"
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 ADDED
@@ -0,0 +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
data/botspec.gemspec ADDED
@@ -0,0 +1,53 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "botspec/version"
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "botspec"
8
+ gem.version = Botspec::VERSION
9
+ gem.authors = ["Elliott Murray"]
10
+ gem.email = ["elliottmurray@gmail.com"]
11
+
12
+ gem.summary = %q{Acceptance tests for bots}
13
+ gem.description = %q{Acceptance tests for bots}
14
+ gem.homepage = "https://github.com/elliottmurray/botspec"
15
+ gem.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if gem.respond_to?(:metadata)
20
+ gem.metadata["allowed_push_host"] = "https://rubygems.org/"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ gem.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ gem.bindir = "exe"
32
+ #gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
33
+
34
+ # gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ gem.require_paths = ["lib"]
36
+
37
+ gem.add_runtime_dependency "rspec", "~> 3.0"
38
+ gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
39
+ gem.add_runtime_dependency 'aws-sdk', "~> 3.0.1"
40
+ #gem.add_runtime_dependency 'aws-sdk-lex', '~> 1'
41
+ #gem.add_runtime_dependency 'aws-sdk-lexmodelbuildingservice', '~> 1'
42
+ gem.add_runtime_dependency 'thor', "~> 0.20.0"
43
+ gem.add_runtime_dependency 'hashie', "~> 3.6.0"
44
+
45
+ gem.add_development_dependency "bundler", ">= 1.16"
46
+
47
+ gem.add_development_dependency "guard-rspec", "~> 4.7"
48
+ gem.add_development_dependency "rake", "~> 10.0"
49
+ gem.add_development_dependency "byebug"
50
+
51
+ gem.add_development_dependency 'conventional-changelog', '~> 1.3'
52
+ gem.add_development_dependency 'bump', '~> 0.6.1'
53
+ end
data/lib/botspec.rb ADDED
@@ -0,0 +1 @@
1
+ require 'botspec'
@@ -0,0 +1,43 @@
1
+ require 'aws-sdk'
2
+
3
+ module BotSpec
4
+ module AWS
5
+ class LexService
6
+ def self.load(config)
7
+ return LexService.new(config)
8
+ end
9
+
10
+ def initialize(config)
11
+ @config = config
12
+ @bot_name = config[:botname]
13
+ @user_id = "botspec-#{SecureRandom.uuid}"
14
+ end
15
+
16
+ def lex_client
17
+ @lex_client ||= Aws::Lex::Client.new
18
+ end
19
+
20
+ def interaction_to_lex_message(message)
21
+ return {
22
+ bot_name: @bot_name,
23
+ bot_alias: "$LATEST",
24
+ user_id: @user_id,
25
+ session_attributes: {
26
+ "String" => "String",
27
+ },
28
+ request_attributes: {
29
+ "String" => "String",
30
+ },
31
+ input_text: message,
32
+ }
33
+ end
34
+
35
+ def post_message message, user_id=''
36
+ resp = lex_client.post_text(interaction_to_lex_message(message))
37
+ sleep(1);
38
+ resp
39
+ end
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,60 @@
1
+ require 'load_dialogs.rb'
2
+ require 'rspec/botspec_runner.rb'
3
+
4
+ require 'rspec'
5
+ require 'rspec/core/formatters/json_formatter'
6
+
7
+ module Botspec
8
+ class VerificationTask < ::Rake::TaskLib
9
+ attr_reader :name, :dialogs_path
10
+
11
+ def initialize(name, dialogs_path)
12
+ @name = name
13
+ @dialogs_path = dialogs_path
14
+ yield self
15
+ rake_task
16
+ end
17
+
18
+ def rake_task
19
+ namespace :botspec do
20
+
21
+ desc "Verify botspecs #{name}"
22
+ task "verify:#{name}", :dialog_path do |t, args|
23
+ puts "Running botspecs in #{dialogs_path}"
24
+ BotSpec::BotSpecRunner.run({dialogs_path: dialogs_path, botname: name})
25
+
26
+ # config = RSpec.configuration
27
+ # json_formatter = RSpec::Core::Formatters::JsonFormatter.new(config.output_stream)
28
+ #
29
+ # # create reporter with json formatter
30
+ # reporter = RSpec::Core::Reporter.new(json_formatter)
31
+ # # set reporter for rspec configuration
32
+ # config.instance_variable_set(:@reporter, reporter)
33
+ #
34
+ # execute rspec runner
35
+ # 'example_spec.rb' is the location of the spec file
36
+
37
+ # output test result as json
38
+ # see example output in `rspec_json_formatter_result.rb`
39
+ # puts json_formatter.output_hash
40
+
41
+ # RSpec.configure do |config|
42
+ # # Enable flags like --only-failures and --next-failure
43
+ # config.example_status_persistence_file_path = ".rspec_status"
44
+ # config.expose_dsl_globally = true
45
+ #
46
+ # # Disable RSpec exposing methods globally on `Module` and `main`
47
+ # config.disable_monkey_patching!
48
+ #
49
+ # config.expect_with :rspec do |c|
50
+ # c.syntax = :expect
51
+ # end
52
+ # end
53
+ # BotSpec::RSpec::BotSpecRunner.new().run
54
+ #
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,3 @@
1
+ module Botspec
2
+ VERSION = "0.4.6"
3
+ end
data/lib/cli.thor ADDED
@@ -0,0 +1,27 @@
1
+
2
+ require 'botspec/lex/lex_service.rb'
3
+ require 'botspec/version'
4
+ require 'thor'
5
+ require 'load_dialogs.rb'
6
+ require 'rspec/botspec_runner.rb'
7
+
8
+ class CLI < Thor
9
+
10
+ desc 'verify', "Verify a chat suite"
11
+ method_option :dialogs, aliases: "-f", desc: "Yaml file containing dialogs", :required => true
12
+ method_option :botname, aliases: "-n", desc: "The name of the Amazon Web Services Lex chatbot"
13
+
14
+ def verify()
15
+ dialogs = options[:dialogs]
16
+
17
+ bot_name = 'ElliottOrderFlowers'
18
+ if options[:botname]
19
+ bot_name = options[:botname]
20
+ end
21
+
22
+ puts "running specs in #{dialogs} for bot #{bot_name}"
23
+
24
+ BotSpec::BotSpecRunner.run({dialogs_path: dialogs, botname: bot_name})
25
+ end
26
+
27
+ end
@@ -0,0 +1,80 @@
1
+ require 'yaml'
2
+ require 'hashie'
3
+ require 'botspec/lex/lex_service.rb'
4
+ require 'rspec'
5
+
6
+ require "bundler/setup"
7
+ require 'byebug'
8
+
9
+ class LoadDialogs
10
+
11
+ def self.run_dialogs botname, dialogs_path
12
+ @@botname = botname
13
+
14
+ dialog_paths = Dir.glob(dialogs_path).select{ |e| File.file? e }
15
+ #dialog_paths = Dir["#{dialogs_path}*\[yaml|yml\]"]
16
+ dialog_yamls = dialog_paths.collect{ |dialog_file| Hashie.symbolize_keys YAML.load_file(dialog_file).merge!(file: dialog_file) }
17
+
18
+ dialog_yamls.collect{ |dialog_content|
19
+ dialog_content[:dialogs].collect{ |dialog|
20
+ Dialog.new({describe: dialog_content[:description], name: dialog[:what], interactions: dialog[:dialog], file: dialog_content[:file]})
21
+ }.each{ |dialog|
22
+ dialog.create_example_group
23
+ }
24
+ }.flatten
25
+ end
26
+
27
+ def self.botname
28
+ @@botname
29
+ end
30
+ end
31
+
32
+ class Dialog
33
+ attr_reader :describe, :name, :interactions, :file
34
+
35
+ def initialize args
36
+ args.each do |k,v|
37
+ instance_variable_set("@#{k}", v) unless v.nil?
38
+ end
39
+ end
40
+
41
+ def file(file)
42
+ @file = file
43
+ end
44
+
45
+ def interactions
46
+ @interactions
47
+ end
48
+
49
+
50
+ def lex_chat
51
+ @lex_chat ||= BotSpec::AWS::LexService.new({botname: LoadDialogs.botname})
52
+ end
53
+
54
+ def create_example_group()
55
+ @examples = create_example(@interactions).flatten
56
+ end
57
+
58
+ def examples
59
+ @examples
60
+ end
61
+
62
+ def create_example(interactions, examples=[])
63
+ return if interactions.size == 0
64
+
65
+ @@lex_chat = lex_chat()
66
+ spec = ::RSpec.describe "#{@describe} #{@name}" do
67
+
68
+ it interactions[0] do
69
+ resp = @@lex_chat.post_message(interactions[0], 'user_id')
70
+
71
+ expect(resp[:message]).to eql(interactions[1])
72
+ end
73
+ end
74
+
75
+ examples << spec
76
+ create_example(interactions.drop(2), examples)
77
+
78
+ examples
79
+ end
80
+ end
@@ -0,0 +1,39 @@
1
+ require 'rspec'
2
+ require 'load_dialogs.rb'
3
+
4
+ module BotSpec
5
+ class BotSpecRunner < RSpec::Core::Runner
6
+
7
+ def configure_rspec
8
+ config = ::RSpec.configuration
9
+
10
+ end
11
+
12
+ def self.run(args, err=$stderr, out=$stdout)
13
+ trap_interrupt
14
+ options = RSpec::Core::ConfigurationOptions.new({})
15
+
16
+ if options.options[:runner]
17
+ options.options[:runner].call(options, err, out)
18
+ else
19
+ new(options).run(args, err, out)
20
+ end
21
+ end
22
+
23
+
24
+ def run(args, out, err)
25
+
26
+
27
+ setup(err, out)
28
+
29
+ botname = args[:botname]
30
+ return @configuration.reporter.exit_early(@configuration.failure_exit_code) if RSpec.world.wants_to_quit
31
+ dialogs_path = args[:dialogs_path]
32
+
33
+ run_specs(LoadDialogs.run_dialogs(botname, dialogs_path).map{|dialog| dialog.examples}.flatten).tap do
34
+ persist_example_statuses
35
+ end
36
+ end
37
+ end
38
+ end
39
+
data/script/minor.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ RELEASE_SCRIPT="$( dirname "${BASH_SOURCE[0]}" )"/release.sh
5
+ MODE="minor"
6
+
7
+ source $RELEASE_SCRIPT
data/script/patch.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ RELEASE_SCRIPT="$( dirname "${BASH_SOURCE[0]}" )"/release.sh
5
+ MODE="patch"
6
+
7
+ source $RELEASE_SCRIPT
data/script/release.sh ADDED
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ echo "release botspec ${MODE}"
5
+
6
+ bundle exec bump ${MODE} --no-commit
7
+
8
+ #bundle exec appraisal update
9
+ bundle exec rake generate_changelog
10
+ git add lib/botspec/version.rb CHANGELOG.md
11
+ git commit -m "chore(release): version $(ruby -r ./lib/botspec/version.rb -e "puts Botspec::VERSION")" && git push
12
+ bundle exec rake release
13
+
metadata ADDED
@@ -0,0 +1,223 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: botspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.6
5
+ platform: ruby
6
+ authors:
7
+ - Elliott Murray
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-06-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: term-ansicolor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aws-sdk
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.20.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.20.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: hashie
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.6.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.6.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '1.16'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '1.16'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '4.7'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '4.7'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: byebug
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: conventional-changelog
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.3'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.3'
153
+ - !ruby/object:Gem::Dependency
154
+ name: bump
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.6.1
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.6.1
167
+ description: Acceptance tests for bots
168
+ email:
169
+ - elliottmurray@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - ".travis.yml"
177
+ - CHANGELOG.md
178
+ - CODE_OF_CONDUCT.md
179
+ - Dockerfile
180
+ - Gemfile
181
+ - Guardfile
182
+ - LICENSE.txt
183
+ - README.md
184
+ - Rakefile
185
+ - bin/console
186
+ - bin/setup
187
+ - botspec.gemspec
188
+ - lib/botspec.rb
189
+ - lib/botspec/lex/lex_service.rb
190
+ - lib/botspec/tasks/verification_task.rb
191
+ - lib/botspec/version.rb
192
+ - lib/cli.thor
193
+ - lib/load_dialogs.rb
194
+ - lib/rspec/botspec_runner.rb
195
+ - script/minor.sh
196
+ - script/patch.sh
197
+ - script/release.sh
198
+ homepage: https://github.com/elliottmurray/botspec
199
+ licenses:
200
+ - MIT
201
+ metadata:
202
+ allowed_push_host: https://rubygems.org/
203
+ post_install_message:
204
+ rdoc_options: []
205
+ require_paths:
206
+ - lib
207
+ required_ruby_version: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ required_rubygems_version: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: '0'
217
+ requirements: []
218
+ rubyforge_project:
219
+ rubygems_version: 2.5.2.3
220
+ signing_key:
221
+ specification_version: 4
222
+ summary: Acceptance tests for bots
223
+ test_files: []