Sha256: 73d2b476b3512b2b110d36e36c62845058d80c6ad71aef1d2ac18be4f66615a4

Contents?: true

Size: 1.51 KB

Versions: 5

Compression:

Stored size: 1.51 KB

Contents

require 'test_helper'

class StatsTest < Minitest::Test
  describe "API Call: stats" do
    before do
      api_url = 'http://api.sailthru.com'
      @secret = 'my_secret'
      @api_key = 'my_api_key'
      @sailthru_client = Sailthru::Client.new(@api_key, @secret, api_url)
      @api_call_url = sailthru_api_call_url(api_url, 'stats')
    end

    it "can get information about given valid field" do
      stat_field = 'list'
      params = {'stat' => stat_field}
      query_string = create_json_payload(@api_key, @secret, params)
      stub_get(@api_call_url + '?' + query_string, 'stat_get_valid.json')
      response = @sailthru_client.stats_list()
      assert_nil response['error']
      assert_nil response['errormsg']
    end

    it "can get stats list data when list and date are not null" do
      params = {'stat' => 'list'}
      query_string = create_json_payload(@api_key, @secret, params)
      stub_get(@api_call_url + '?' + query_string, 'stats_lists_valid.json')
      response = @sailthru_client.stats_list
      refute_nil response['lists_signup_count']
    end

    it "cannot stats list data when list is given and invalid" do
      list = 'not-listed'
      params = {}
      params[:list] = list
      params[:stat] = 'list'
      query_string = create_json_payload(@api_key, @secret, params)
      stub_get(@api_call_url + '?' + query_string, 'stats_lists_invalid.json')
      response = @sailthru_client.stats_list(list)
      refute_nil response['error']
      refute_nil response['errormsg']
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sailthru-client-4.3.0 test/sailthru/stats_test.rb
sailthru-client-4.2.0 test/sailthru/stats_test.rb
sailthru-client-4.1.0 test/sailthru/stats_test.rb
sailthru-client-4.0.7 test/sailthru/stats_test.rb
sailthru-client-4.0.6 test/sailthru/stats_test.rb