tapioca-test_helpers 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 28d52afa41d5203a3e925e553efc40d49774f236
4
+ data.tar.gz: df30d3e53325c5760dda1f84d6c833dd044b1daa
5
+ SHA512:
6
+ metadata.gz: e37845b1a86b2d3ca05206d3000152fdc147377d94840772b94b324cdf156299ca2ae2f96bbf26f211c6c65102ce3e93da97a6860d9f31700656d180cc5eaa7e
7
+ data.tar.gz: 1c4caa5270170636ab9dde52fc4eda49cc0bf04ce98af8f451f2b738c947e8b0f38e9de9df1f6b5e9133ac49bdde8008e551139dd89d193137f208c21a3d66d0
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tapioca-test_helpers.gemspec
4
+ gemspec
5
+
6
+ gem "rake"
7
+ gem "minitest"
@@ -0,0 +1,13 @@
1
+ Copyright 2012-2014 Plataformatec.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,39 @@
1
+ # Tapioca::TestHelpers
2
+
3
+ A set of test helper to be used in Rails applications.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```
10
+ gem 'tapioca-test_helpers'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```
22
+ $ gem install tapioca-test_helpers
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### `Tapioca::TestHelpers.disable_animations`
28
+
29
+ This method generates JavaScript code to disable all animations.
30
+
31
+ Adding this to your templates will avoid that your tests timeout waiting for animations to run.
32
+
33
+ To use it includes in the bottom of your template, near to `</body>`
34
+
35
+ ```erb
36
+ <%= Tapioca::TestHelpers.disable_animations if Rails.env.test? %>
37
+ </body>
38
+ </html>
39
+ ```
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task default: :test
7
+
8
+ desc 'Rin the tests.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
@@ -0,0 +1,31 @@
1
+ require "tapioca/test_helpers/version"
2
+ require "action_view"
3
+ require "action_view/helpers"
4
+ require "action_view/helpers/javascript_helper"
5
+
6
+ module Tapioca
7
+ module TestHelpers
8
+ extend ActionView::Helpers::TagHelper
9
+ extend ActionView::Helpers::JavaScriptHelper
10
+
11
+ # Public: generates JavasCript code to disable all animations so that tests
12
+ # won't timeout waiting for animations to run.
13
+ #
14
+ # - Turns off jQuery.fx.
15
+ # - Turns off bootstrap transition support.
16
+ # - Removes the fade class from modal boxes since that uses css animations.
17
+ # - Overrides collapsible elements to avoid waiting for the height css transition.
18
+ def self.disable_animations
19
+ javascript_tag <<-JAVASCRIPT
20
+ $.fx.off = true;
21
+ $.support.transition = false;
22
+
23
+ var disableBootstrapTransitions = function() {
24
+ $('.modal').removeClass('fade');
25
+ $('.collapse').css({ 'transition': 'height 0.005s', '-webkit-transition': 'height 0.005s' });
26
+ };
27
+ $(disableBootstrapTransitions); $(document).ajaxComplete(disableBootstrapTransitions);
28
+ JAVASCRIPT
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ module Tapioca
2
+ module TestHelpers
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tapioca/test_helpers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tapioca-test_helpers"
8
+ spec.version = Tapioca::TestHelpers::VERSION
9
+ spec.authors = ["Rafael Mendonça França", "Carlos Antonio da Silva"]
10
+ spec.email = ["opensource@plataformatec.com.br"]
11
+ spec.summary = %q{A set of test helper to be used in Rails applications}
12
+ spec.description = %q{Test helpers for Rails applications}
13
+ spec.homepage = "https://github.com/rafaelfranca/tapioca-test_helpers"
14
+ spec.license = "Apache 2.0"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "actionpack", '>= 3', '< 5'
22
+ end
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ class DisableAnimationsTest < MiniTest::Unit::TestCase
4
+ def test_disable_animations_generates_javascript_tag
5
+ expected_result = <<-JAVASCRIPT
6
+ <script>
7
+ //<![CDATA[
8
+ $.fx.off = true;
9
+ $.support.transition = false;
10
+
11
+ var disableBootstrapTransitions = function() {
12
+ $('.modal').removeClass('fade');
13
+ $('.collapse').css({ 'transition': 'height 0.005s', '-webkit-transition': 'height 0.005s' });
14
+ };
15
+ $(disableBootstrapTransitions); $(document).ajaxComplete(disableBootstrapTransitions);
16
+
17
+ //]]>
18
+ </script>
19
+ JAVASCRIPT
20
+
21
+ assert_equal expected_result.chop, Tapioca::TestHelpers.disable_animations
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'minitest/autorun'
4
+
5
+ require 'tapioca/test_helpers'
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tapioca-test_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rafael Mendonça França
8
+ - Carlos Antonio da Silva
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: actionpack
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '3'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '5'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '3'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ description: Test helpers for Rails applications
35
+ email:
36
+ - opensource@plataformatec.com.br
37
+ executables: []
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - ".gitignore"
42
+ - Gemfile
43
+ - LICENSE.txt
44
+ - README.md
45
+ - Rakefile
46
+ - lib/tapioca/test_helpers.rb
47
+ - lib/tapioca/test_helpers/version.rb
48
+ - tapioca-test_helpers.gemspec
49
+ - test/disable_animations_test.rb
50
+ - test/test_helper.rb
51
+ homepage: https://github.com/rafaelfranca/tapioca-test_helpers
52
+ licenses:
53
+ - Apache 2.0
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.2.0
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: A set of test helper to be used in Rails applications
75
+ test_files:
76
+ - test/disable_animations_test.rb
77
+ - test/test_helper.rb