cog-rb 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9627fde94c9865e063c5f49cf0de68751f7e9de
4
- data.tar.gz: c8c652c3ced6dc6d9b5dea11b8103b1629a743d3
3
+ metadata.gz: 7ecf2692d6236c91b5f90a0e4acae34191e67959
4
+ data.tar.gz: 4c36954c1a905479360952f03a8ec1490ab74b15
5
5
  SHA512:
6
- metadata.gz: 4c1f0360004b838e0ffd3002b1cdd56c52ef3b6816e9530bb23e0cff73d68ae56b41f40110839a7c407abd862774c0bfbf55ecb8a4e749227b437e3924d04e8d
7
- data.tar.gz: 8522d05aa0c2c5b9c6d471b75f0af6fc36fdf3d11d34e972a13bde62f815dbdb33b2eb0ed9588243b32d7ff4e08134addd6dd17c365dd9ca11395e137cd3f054
6
+ metadata.gz: 887b6031722158ba5742b05a2b159509eaa03284f8eeaff83fc3fd167c3f161da7652fb9014b2efd357b1fc8c66ff7da3829c4a052e4d71c6f455aa8b91917af
7
+ data.tar.gz: a5ddfadd53303282b851ef21dad519c7d8d57d593d3406df107a20683a92bd78029987f3d70431275f036e1a6a34dfdaef1b27cda718cdce206b9d07333b8f62
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.5
2
+
3
+ * Bugfix for "warning: toplevel constant RSpec referenced by Cog::RSpec"
4
+
1
5
  ## 0.3.4
2
6
 
3
7
  * Bugfix for rspec tests for commands that take a single input
data/lib/cog/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Cog
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -2,77 +2,80 @@ require 'yaml'
2
2
  require 'securerandom'
3
3
  require 'rspec/core'
4
4
 
5
- module Cog::RSpec::Setup
6
- extend RSpec::SharedContext
7
-
8
- before(:each) do
9
- # Ensure a clean ENV, as far as Cog cares
10
- # NOTE: Does not do anything pertaining to dynamic config
11
- # variables yet
12
- ENV.delete_if{|name, value| name.start_with?("COG_")}
13
- end
14
-
15
- let(:base_dir) do
16
- # Cog Ruby commands expect to be run from a script in the
17
- # top-level directory. This code thus assumes that the tests are
18
- # being run from that same top-level directory.
19
- File.absolute_path(Dir.pwd)
20
- end
21
-
22
- let(:config_file) do
23
- File.join(base_dir, "config.yaml")
24
- end
25
-
26
- let(:bundle_name) do
27
- # Read the bundle name from the bundle configuration; no need to
28
- # repeat that everywhere
29
- YAML.load(File.read(config_file))["name"]
30
- end
31
-
32
- let!(:bundle) do
33
- # This is `let!` instead of `let` because this call actually
34
- # *creates* the bundle module that our commands live in; we want
35
- # to ensure that this gets called before we start doing anything else
36
- Cog::Bundle.new(bundle_name, base_dir: base_dir)
37
- end
38
-
39
- let(:command_name){ raise "Must supply a :command_name!" }
40
-
41
- let(:command) do
42
- bundle.command_instance(command_name)
43
- end
44
-
45
- let(:invocation_id) { SecureRandom.uuid }
46
-
47
- let(:service_root) { "http://localhost:4002" }
48
-
49
- let(:cog_env) { [] }
50
-
51
- def run_command(args: [], options: {})
52
- ENV["COG_COMMAND"] = command_name
53
- ENV["COG_INVOCATION_ID"] = invocation_id
54
- ENV["COG_SERVICES_ROOT"] = service_root
55
-
56
- # populate arguments
57
- ENV["COG_ARGC"] = args.size.to_s
58
- args.each_with_index{|arg, i| ENV["COG_ARGV_#{i}"] = arg.to_s}
59
-
60
- # populate_options
61
- if !options.keys.empty?
62
- ENV["COG_OPTS"] = options.keys.join(",")
63
- options.each{|k,v| ENV["COG_OPT_#{k.upcase}"] = v.to_s}
5
+ class Cog
6
+ module RSpec
7
+ module Setup
8
+ extend ::RSpec::SharedContext
9
+
10
+ before(:each) do
11
+ # Ensure a clean ENV, as far as Cog cares
12
+ # NOTE: Does not do anything pertaining to dynamic config
13
+ # variables yet
14
+ ENV.delete_if{|name, value| name.start_with?("COG_")}
15
+ end
16
+
17
+ let(:base_dir) do
18
+ # Cog Ruby commands expect to be run from a script in the
19
+ # top-level directory. This code thus assumes that the tests are
20
+ # being run from that same top-level directory.
21
+ File.absolute_path(Dir.pwd)
22
+ end
23
+
24
+ let(:config_file) do
25
+ File.join(base_dir, "config.yaml")
26
+ end
27
+
28
+ let(:bundle_name) do
29
+ # Read the bundle name from the bundle configuration; no need to
30
+ # repeat that everywhere
31
+ YAML.load(File.read(config_file))["name"]
32
+ end
33
+
34
+ let!(:bundle) do
35
+ # This is `let!` instead of `let` because this call actually
36
+ # *creates* the bundle module that our commands live in; we want
37
+ # to ensure that this gets called before we start doing anything else
38
+ Cog::Bundle.new(bundle_name, base_dir: base_dir)
39
+ end
40
+
41
+ let(:command_name){ raise "Must supply a :command_name!" }
42
+
43
+ let(:command) do
44
+ bundle.command_instance(command_name)
45
+ end
46
+
47
+ let(:invocation_id) { SecureRandom.uuid }
48
+
49
+ let(:service_root) { "http://localhost:4002" }
50
+
51
+ let(:cog_env) { [] }
52
+
53
+ def run_command(args: [], options: {})
54
+ ENV["COG_COMMAND"] = command_name
55
+ ENV["COG_INVOCATION_ID"] = invocation_id
56
+ ENV["COG_SERVICES_ROOT"] = service_root
57
+
58
+ # populate arguments
59
+ ENV["COG_ARGC"] = args.size.to_s
60
+ args.each_with_index{|arg, i| ENV["COG_ARGV_#{i}"] = arg.to_s}
61
+
62
+ # populate_options
63
+ if !options.keys.empty?
64
+ ENV["COG_OPTS"] = options.keys.join(",")
65
+ options.each{|k,v| ENV["COG_OPT_#{k.upcase}"] = v.to_s}
66
+ end
67
+
68
+ # TODO: receive a single input on request(:input) and
69
+ # multiple for :fetch_input
70
+
71
+ # Expose previous inputs on request.input
72
+ # We use allow because not all commands receive input
73
+ allow(command.request).to receive(:input).and_return(cog_env)
74
+
75
+ # Use allow because not all commands will need to do this
76
+ allow(command).to receive(:fetch_input).and_return(cog_env)
77
+ command.run_command
78
+ end
64
79
  end
65
-
66
- # TODO: receive a single input on request(:input) and
67
- # multiple for :fetch_input
68
-
69
- # Expose previous inputs on request.input
70
- # We use allow because not all commands receive input
71
- allow(command.request).to receive(:input).and_return(cog_env)
72
-
73
- # Use allow because not all commands will need to do this
74
- allow(command).to receive(:fetch_input).and_return(cog_env)
75
- command.run_command
76
80
  end
77
-
78
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cog-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Imbriaco