cogy 0.3.0 → 0.4.0

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.
@@ -7,17 +7,17 @@ module Cogy
7
7
  setup { @routes = Engine.routes }
8
8
 
9
9
  def test_args_helper_overrides_predefined_helpers
10
- post "/cogy/cmd/args_overrides/george", COG_ARGV_1: "hu", COG_ARGV_0: "haha"
10
+ cmd :args_overrides, COG_ARGV_1: "hu", COG_ARGV_0: "haha"
11
11
  assert_equal "hahahu", response.body
12
12
  end
13
13
 
14
14
  def test_args_with_empty_arguments
15
- post "/cogy/cmd/empty_args/george"
15
+ cmd :empty_args
16
16
  assert_equal "true", response.body
17
17
  end
18
18
 
19
19
  def test_args
20
- post "/cogy/cmd/add/george", COG_ARGV_0: 1, COG_ARGV_1: 2
20
+ cmd :add, COG_ARGV_0: 1, COG_ARGV_1: 2
21
21
  assert_equal "3", response.body
22
22
  end
23
23
  end
@@ -7,30 +7,30 @@ module Cogy
7
7
  setup { @routes = Engine.routes }
8
8
 
9
9
  def test_error_response_code
10
- post "/cogy/cmd/raiser/george"
10
+ cmd :raiser
11
11
  assert_equal 500, response.status
12
12
  end
13
13
 
14
14
  def test_calc_command
15
- post "/cogy/cmd/calc/george", COG_OPT_OP: "+", COG_ARGV_0: 1, COG_ARGV_1: 2
15
+ cmd :calc, { COG_OPT_OP: "+", COG_ARGV_0: 1, COG_ARGV_1: 2 }, "george"
16
16
  assert_equal "Hello george, the answer is: 3", response.body
17
17
 
18
- post "/cogy/cmd/calc/george", COG_OPT_OP: "/", COG_ARGV_0: 10, COG_ARGV_1: 5
18
+ cmd :calc, { COG_OPT_OP: "/", COG_ARGV_0: 10, COG_ARGV_1: 5 }, "george"
19
19
  assert_equal "Hello george, the answer is: 2", response.body
20
20
  end
21
21
 
22
22
  def test_command_not_found
23
- post "/cogy/cmd/idontexist/foo"
23
+ cmd :idontexist
24
24
  assert_equal 404, response.status
25
25
  end
26
26
 
27
27
  def test_cogy_env
28
- post "/cogy/cmd/print_env/george", foo: "ha", COG_FOO: "baz", FOO: "foo"
28
+ cmd :print_env, foo: "ha", COG_FOO: "baz", FOO: "foo"
29
29
  assert_equal "ha baz foo", response.body
30
30
  end
31
31
 
32
32
  def test_rails_url_helpers
33
- post "/cogy/cmd/rails_url_helpers/george"
33
+ cmd :rails_url_helpers
34
34
  assert_equal "http://dummy.com/baz /baz", response.body
35
35
  end
36
36
 
@@ -45,12 +45,12 @@ module Cogy
45
45
  end
46
46
 
47
47
  def test_args_ordering
48
- post "/cogy/cmd/args_order/george", COG_ARGV_2: 3, COG_ARGV_1: 2, COG_ARGV_0: 1
48
+ cmd :args_order, COG_ARGV_2: 3, COG_ARGV_1: 2, COG_ARGV_0: 1
49
49
  assert_equal "123", response.body
50
50
  end
51
51
 
52
52
  def test_opts_downcased_and_indifferent_access
53
- post "/cogy/cmd/test_opts_downcased/george", COG_OPT_A: "foo"
53
+ cmd :test_opts_downcased, COG_OPT_A: "foo"
54
54
  assert_equal "foo", response.body
55
55
  end
56
56
  end
@@ -7,13 +7,13 @@ module Cogy
7
7
  setup { @routes = Engine.routes }
8
8
 
9
9
  def test_error_tmpl_message
10
- post "/cogy/cmd/raiser/george"
10
+ cmd :raiser, {}, "george"
11
11
  assert response.body.include?("boom")
12
12
  assert response.body.include?("@george")
13
13
  end
14
14
 
15
15
  def test_error_tmpl_contenttype
16
- post "/cogy/cmd/raiser/george"
16
+ cmd :raiser, {}, "george"
17
17
  assert_equal "text/plain", response.content_type.to_s
18
18
  end
19
19
  end
@@ -7,12 +7,12 @@ module Cogy
7
7
  setup { @routes = Engine.routes }
8
8
 
9
9
  def test_custom_helpers_can_access_default_helpers
10
- post "/cogy/cmd/foohelper/george", cog_foo: "bar"
10
+ cmd :foohelper, cog_foo: "bar"
11
11
  assert_equal "bar", response.body
12
12
  end
13
13
 
14
14
  def test_custom_helper_with_arguments
15
- post "/cogy/cmd/titleize/george"
15
+ cmd :titleize
16
16
  assert_equal "This Should Be Titleized", response.body
17
17
  end
18
18
  end
@@ -7,7 +7,7 @@ module Cogy
7
7
  setup { @routes = Engine.routes }
8
8
 
9
9
  def test_json_output_and_default_template
10
- post "/cogy/cmd/simple_json/george"
10
+ cmd :simple_json
11
11
 
12
12
  expected = "COG_TEMPLATE: simple_json\n" \
13
13
  "JSON\n" \
@@ -17,7 +17,7 @@ module Cogy
17
17
  end
18
18
 
19
19
  def test_custom_template
20
- post "/cogy/cmd/custom_template/hyu"
20
+ cmd :custom_template
21
21
 
22
22
  expected = "COG_TEMPLATE: foo\n" \
23
23
  "JSON\n" \
@@ -1,6 +1,10 @@
1
1
  require "active_support/test_case"
2
2
 
3
3
  class ActiveSupport::TestCase
4
+ def cmd(name, env={}, as="someone")
5
+ post "/cogy/cmd/#{name}", env.merge("COG_CHAT_HANDLE" => as)
6
+ end
7
+
4
8
  def fetch_inventory
5
9
  get "/cogy/inventory"
6
10
  YAML.load(response.body)
data/test/test_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- # Configure Rails Environment
2
1
  ENV["RAILS_ENV"] = "test"
3
2
 
4
3
  require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
@@ -6,6 +5,7 @@ require "rails/test_help"
6
5
  require "minitest/spec"
7
6
 
8
7
  require "minitest/reporters"
8
+ # Standard minitest reporter but with red/green colors
9
9
  Minitest::Reporters.use!(Minitest::Reporters::DefaultReporter.new)
10
10
 
11
11
  # Filter out Minitest backtrace while allowing backtrace from other libraries
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cogy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agis Anastasopoulos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-29 00:00:00.000000000 Z
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.46.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.46.0
97
97
  description: Cogy integrates Cog with Rails in a way that writing and deploying commands
98
98
  from your application is a breeze.
99
99
  email: