test/integration/command_test.rb in cogy-0.2.1 vs test/integration/command_test.rb in cogy-0.3.0
- old
+ new
@@ -5,34 +5,34 @@
include Engine.routes.url_helpers
setup { @routes = Engine.routes }
def test_error_response_code
- get "/cogy/cmd/raiser/george"
+ post "/cogy/cmd/raiser/george"
assert_equal 500, response.status
end
def test_calc_command
- get "/cogy/cmd/calc/george", cog_opt_op: "+", cog_argv_0: 1, cog_argv_1: 2
+ post "/cogy/cmd/calc/george", COG_OPT_OP: "+", COG_ARGV_0: 1, COG_ARGV_1: 2
assert_equal "Hello george, the answer is: 3", response.body
- get "/cogy/cmd/calc/george", cog_opt_op: "/", cog_argv_0: 10, cog_argv_1: 5
+ post "/cogy/cmd/calc/george", COG_OPT_OP: "/", COG_ARGV_0: 10, COG_ARGV_1: 5
assert_equal "Hello george, the answer is: 2", response.body
end
def test_command_not_found
- get "/cogy/cmd/idontexist/foo"
+ post "/cogy/cmd/idontexist/foo"
assert_equal 404, response.status
end
def test_cogy_env
- get "/cogy/cmd/print_env/george", cogy_foo: "bar"
- assert_equal "bar", response.body
+ post "/cogy/cmd/print_env/george", foo: "ha", COG_FOO: "baz", FOO: "foo"
+ assert_equal "ha baz foo", response.body
end
def test_rails_url_helpers
- get "/cogy/cmd/rails_url_helpers/george"
+ post "/cogy/cmd/rails_url_helpers/george"
assert_equal "http://dummy.com/baz /baz", response.body
end
def test_invalid_opts_declaration
exception = assert_raises(ArgumentError) do
@@ -43,10 +43,15 @@
assert_match(/\[:type, :required\]/, exception.message)
end
def test_args_ordering
- get "/cogy/cmd/args_order/george", cog_argv_2: 3, cog_argv_1: 2, cog_argv_0: 1
+ post "/cogy/cmd/args_order/george", COG_ARGV_2: 3, COG_ARGV_1: 2, COG_ARGV_0: 1
assert_equal "123", response.body
+ end
+
+ def test_opts_downcased_and_indifferent_access
+ post "/cogy/cmd/test_opts_downcased/george", COG_OPT_A: "foo"
+ assert_equal "foo", response.body
end
end
end