Sha256: f55ea3be41776a02a0d0a80309656a52e9b15033fe30a100090ca1693a99b66f
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
require 'helper' require "webmock" class TestFactory < Test::Unit::TestCase include WebMock::API setup do @api = GeekierFactory.factorize(File.join(File.dirname(File.expand_path(__FILE__)), 'mock_definition.json')) @action = @api.available_actions["test api"].first end test "api should be factorized" do assert @api assert @api.is_a? GeekierFactory::API end test "api should have one operation with action" do assert_equal 1, @api.available_actions.size assert @api.available_actions.is_a? Hash assert_equal 1, @api.available_actions["test api"].size end test "action should have 4 parameters" do assert_equal 6, @action.params.size assert_equal ['q1', 'q2', 'b1', 'b2', 'action', 'format'], @action.params.map{ |p| p['name'] } end test "action should have 2 body and 2 query parameters and they should be different" do assert_equal 2, @action.body_params.size assert_equal 2, @action.url_params.size assert_not_equal @action.body_params, @action.url_params end test "calling the action should call the right url" do stub_http_request(:post, "localhost/api/v0.1/call.json"). with(:body => {:b1 => "body", :b2 => "test"}, :query => {:q1 => 'testing', :q2 => 'query'}) @action.call(:b1 => "body", :b2 => "test", :q1 => 'testing', :q2 => 'query', :action => 'call', :format => 'json') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geekier_factory-0.1.4 | test/test_factory.rb |