fanforce-test 1.0.0.rc1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8279dda30036ffa1426091df72cbff564888cd12
4
+ data.tar.gz: be5aad5ce70a6621553052db96302ee7b7b00ab7
5
+ SHA512:
6
+ metadata.gz: b6e31e249ac27abe22586dfbaf5701593a41c3a67e9a99ae654400953ea7fe905e1c6a3924f0f3226b3aceaa08da259201f01579adc90abc32ca9ba7ac91cf5b
7
+ data.tar.gz: a4a6f1498a24c6d98cb3e109b17cd119544b6e37c8860e7bb8fb3ac74c2dac514e637d5e0dfd15ba20028b577d1ce5935e349f1fac9ed9236cdfc70e01557279
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+ .DS_Store
20
+ .idea/
21
+ .idea/*
22
+ Gemfile.lock
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p576
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ --load ./.yardopts.rb
3
+ --markup-provider=redcarpet
4
+ --markup=markdown
5
+ --readme README.md
data/.yardopts.rb ADDED
@@ -0,0 +1 @@
1
+ require 'redcarpet/compat'
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ group :development, :test do
5
+ gem 'minitest'
6
+ gem 'rack-test'
7
+ gem 'simplecov', :require => false
8
+ gem 'yard'
9
+ gem 'redcarpet'
10
+ gem 'github-markup', :require => true
11
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015, The Fanforce Company
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1 @@
1
+ fanforce-test
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ task :run_test do
7
+ Rake::Task['test'].execute
8
+ puts '---------------------------------------------------------------------'
9
+ puts 'TESTS PASSED... READY TO BUILD...'
10
+ puts '---------------------------------------------------------------------'
11
+ end
12
+ task :build => :run_test
13
+ task :default => :build
14
+
15
+ ########################################################################
16
+
17
+ Rake::TestTask.new do |t|
18
+ t.libs.push 'lib'
19
+ t.libs.push 'test'
20
+ t.pattern = 'test/**/*_test.rb'
21
+ t.verbose = false
22
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fanforce/test/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'fanforce-test'
8
+ gem.version = Fanforce::Test::VERSION
9
+ gem.date = Time.now.utc.strftime('%Y-%m-%d')
10
+ gem.summary = %q{Helper gem for tests that need access to the local supercore-api}
11
+
12
+ gem.authors = ['Caleb Clark']
13
+ gem.email = ['cclark@fanforce.com']
14
+ gem.homepage = 'http://github.com/fanforce/gem-fanforce-test'
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.add_runtime_dependency 'fanforce-api', '>= 2.0.0.rc1'
21
+ end
@@ -0,0 +1,59 @@
1
+ require 'fileutils'
2
+ require 'fanforce/api'
3
+ require 'active_support/all'
4
+
5
+ class Fanforce::Test
6
+
7
+ def self.setup_env(base_dir)
8
+ puts "##### SETTING RACK_ENV IN SUPERCORE API ##################################################################################################################\n\n"
9
+ Fanforce::Test.start(base_dir)
10
+ at_exit do
11
+ puts "\n##### REMOVING RACK_ENV IN SUPERCORE API ##################################################################################################################\n\n"
12
+ Fanforce::Test.finish(base_dir)
13
+ end
14
+ end
15
+
16
+ def self.start(base_dir)
17
+ instance = self.new(base_dir)
18
+ instance.set_rack_env('test')
19
+ instance.restart_server
20
+ end
21
+
22
+ def self.finish(base_dir)
23
+ instance = self.new(base_dir)
24
+ instance.set_rack_env(nil)
25
+ instance.restart_server
26
+ end
27
+
28
+ ######################################################################################################################
29
+
30
+ def initialize(base_dir)
31
+ @base_dir = base_dir
32
+ end
33
+
34
+ def set_rack_env(value)
35
+ lines = File.exists?(powenv_path) ? File.readlines(powenv_path) : []
36
+ lines.reject!{|line| /RACK_ENV\=/.match(line) }
37
+ lines << "export RACK_ENV=#{value}" if value
38
+ File.open(powenv_path, 'w+'){|f| f.puts(lines) }
39
+ end
40
+
41
+ def restart_server
42
+ FileUtils.touch(File.join(supercore_path, 'api', 'tmp', 'restart.txt'))
43
+ end
44
+
45
+ def supercore_path(dir=@base_dir)
46
+ @supercore_path ||= begin
47
+ parent_dir = File.join(dir, '..')
48
+ supercore_dir = File.expand_path(File.join(parent_dir, 'supercore'))
49
+ File.directory?(supercore_dir) ? supercore_dir : supercore_path(parent_dir)
50
+ end
51
+ end
52
+
53
+ def powenv_path
54
+ @powenv_path ||= File.join(supercore_path, 'api', '.powenv')
55
+ end
56
+
57
+ end
58
+
59
+ require_relative 'test/rake_helpers'
@@ -0,0 +1,83 @@
1
+ def use_fanforce_test_helpers(browser_method)
2
+ include Fanforce::Test::RakeHelpers
3
+ load_helper_methods(browser_method)
4
+ end
5
+
6
+ def enable_fanforce_test(base_dir)
7
+ Fanforce::Test.setup_env(base_dir)
8
+ end
9
+
10
+ module Fanforce::Test::RakeHelpers
11
+
12
+ def load_helper_methods(browser_method)
13
+ @@api_browser_method = browser_method
14
+ end
15
+
16
+ def api_browser
17
+ method(@@api_browser_method).call
18
+ end
19
+
20
+ def last_api_response(response)
21
+ @last_api_response = response
22
+ end
23
+
24
+ def reset_fanforce_db
25
+ @supercore_api_key = api_post('/test/clean_dbs', show_error_details: 'text')[:supercore_api_key]
26
+ end
27
+
28
+ def reset_fanforce_db_with_plugins
29
+ reset_fanforce_db
30
+ api_post('/test/setup_plugins', show_error_details: 'text')
31
+ end
32
+
33
+ def supercore_api_key
34
+ @supercore_api_key
35
+ end
36
+
37
+ def ff
38
+ @ff ||= Fanforce::API.new
39
+ end
40
+
41
+ def api_get(path, query={}, rack_env={})
42
+ query.update(api_key: supercore_api_key) if rack_env[:access_type] == :supercore
43
+ last_api_response ff.get(path, query)
44
+ end
45
+
46
+ def api_post(path, query={}, rack_env={})
47
+ query.update(api_key: supercore_api_key) if rack_env[:access_type] == :supercore
48
+ last_api_response ff.post path, query
49
+ end
50
+
51
+ def api_put(path, query={}, rack_env={})
52
+ query.update(api_key: supercore_api_key) if rack_env[:access_type] == :supercore
53
+ last_api_response ff.put path, query
54
+ end
55
+
56
+ def api_delete(path, query={}, rack_env={})
57
+ query.update(api_key: supercore_api_key) if rack_env[:access_type] == :supercore
58
+ last_api_response ff.delete path, query
59
+ end
60
+
61
+ def method_missing(method, *args, &block)
62
+ return @last_api_response if method == :last_response
63
+ super
64
+ end
65
+
66
+ end
67
+
68
+ ########################################################################################################################
69
+
70
+ class Rack::MockResponse
71
+ def to_hash
72
+ @hash ||= MultiJson.load(body, :symbolize_keys => true)
73
+ end
74
+ def to_json
75
+ body.to_s
76
+ end
77
+ def to_s
78
+ body.to_s
79
+ end
80
+ def [](key)
81
+ to_hash[key]
82
+ end
83
+ end
@@ -0,0 +1,5 @@
1
+ class Fanforce
2
+ class Test
3
+ VERSION = '1.0.0.rc1'
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ describe Fanforce::API do
4
+
5
+ it 'should test if var is blank' do
6
+ assert Fanforce.is_blank?(nil)
7
+ assert !Fanforce.is_blank?('value')
8
+
9
+ ff = Fanforce::API.new
10
+ assert ff.is_blank?(nil)
11
+ assert !ff.is_blank?('value')
12
+ end
13
+
14
+ it 'should create new instance of fanforce with api_key' do
15
+ assert Fanforce::API.new('13d90b01-6df7-4618-881c-c79320a0dc21')
16
+ end
17
+
18
+ end
@@ -0,0 +1,11 @@
1
+ require 'simplecov'
2
+ SimpleCov.start { add_filter '/test/' }
3
+
4
+ require 'rubygems'
5
+ require 'minitest/autorun'
6
+ require 'minitest/spec'
7
+ require 'rack/test'
8
+
9
+ ENV['RACK_ENV'] = 'test'
10
+
11
+ require 'fanforce/api'
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fanforce-test
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.rc1
5
+ platform: ruby
6
+ authors:
7
+ - Caleb Clark
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fanforce-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0.rc1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0.rc1
27
+ description:
28
+ email:
29
+ - cclark@fanforce.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - .ruby-version
36
+ - .yardopts
37
+ - .yardopts.rb
38
+ - Gemfile
39
+ - LICENSE.md
40
+ - README.md
41
+ - Rakefile
42
+ - fanforce-test.gemspec
43
+ - lib/fanforce/test.rb
44
+ - lib/fanforce/test/rake_helpers.rb
45
+ - lib/fanforce/test/version.rb
46
+ - test/api/auth_test.rb
47
+ - test/test_helper.rb
48
+ homepage: http://github.com/fanforce/gem-fanforce-test
49
+ licenses: []
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - '>'
63
+ - !ruby/object:Gem::Version
64
+ version: 1.3.1
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 2.0.14
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Helper gem for tests that need access to the local supercore-api
71
+ test_files:
72
+ - test/api/auth_test.rb
73
+ - test/test_helper.rb
74
+ has_rdoc: