activesupport-testing-metadata 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: e7f7b39e26964c5df1417d2e5dfdbb2d2528efcd
4
+ data.tar.gz: 8b527df971a7ff92af93b92ead9bcff812a39e05
5
+ SHA512:
6
+ metadata.gz: 200b3ea2a85118657d8d0a917c6d9cce9116114e7f95b32be946553f1c78650d52ce19d8769ccb4fe166e23f84f3c5fd01cbac00ed4be133f3c9663bf41205e3
7
+ data.tar.gz: 3d8e9ce3a3de5bf5f45239fa22dda18bd9ae32d270269d9b78ed837fac230c0f289b4179e8596623a30b50ce211269d31aff7f2941c69cd75c8bd068fd0c525e
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in activesupport-testing-metadata.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 yuuji.yaginuma
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # activesupport-testing-metadata
2
+
3
+ [![Build Status](https://travis-ci.org/y-yagi/activesupport-testing-metadata.svg?branch=master)](https://travis-ci.org/y-yagi/activesupport-testing-metadata)
4
+
5
+ Metadata (key-value) support for `ActiveSupport::TestCase.test` method.
6
+
7
+ ## Example
8
+
9
+ ```ruby
10
+ require 'active_support/testing/metadata'
11
+
12
+ class IntegrationTest < ActionDispatch::IntegrationTest
13
+ def setup
14
+ if metadata[:js]
15
+ Capybara.current_driver = Capybara.javascript_driver
16
+ else
17
+ Capybara.current_driver = Capybara.default_driver
18
+ end
19
+ end
20
+
21
+ test 'without js' do
22
+ # write test without js
23
+ end
24
+
25
+ test 'with js', js: true do
26
+ # write test with js
27
+ end
28
+ end
29
+ ```
30
+
31
+ ## Installation
32
+
33
+ Add this line to your application's Gemfile:
34
+
35
+ ```ruby
36
+ gem 'activesupport-testing-metadata'
37
+ ```
38
+
39
+ And then execute:
40
+
41
+ $ bundle
42
+
43
+ Or install it yourself as:
44
+
45
+ $ gem install activesupport-testing-metadata
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it ( https://github.com/y-yagi/activesupport-testing-metadata/fork )
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create a new Pull Request
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.pattern = "test/**/*_test.rb"
7
+ t.verbose = true
8
+ end
9
+
10
+ task :default => :test
11
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'active_support/testing/metadata/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "activesupport-testing-metadata"
8
+ spec.version = ActiveSupport::Testing::Metadata::VERSION
9
+ spec.authors = ["Yuji Yaginuma"]
10
+ spec.email = ["yuuji.yaginuma@gmail.com"]
11
+ spec.summary = %q{Metadata (key-value) support for ActiveSupport::TestCase}
12
+ spec.homepage = "https://github.com/y-yagi/activesupport-testing-metadata"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "activesupport", ">= 4.0"
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "pry"
25
+ spec.add_development_dependency "pry-doc"
26
+ end
@@ -0,0 +1,40 @@
1
+ require "active_support"
2
+ require "active_support/test_case"
3
+
4
+ module ActiveSupport
5
+ module Testing
6
+ module Metadata
7
+ def self.included(base)
8
+ base.extend(ClassMethods)
9
+ end
10
+
11
+ module ClassMethods
12
+ def test(name, *metadata, &block)
13
+ super(name, &block)
14
+ test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
15
+ self.metadata[test_name.to_s] = compute_metadata(metadata)
16
+ end
17
+
18
+ def compute_metadata(metadata)
19
+ meta = if metadata[-1].is_a?(Hash)
20
+ metadata.pop
21
+ else
22
+ {}
23
+ end
24
+ metadata.each { |key| meta[key] = true }
25
+ meta
26
+ end
27
+
28
+ def metadata
29
+ @metadata ||= Hash.new({})
30
+ end
31
+ end
32
+
33
+ def metadata
34
+ self.class.metadata[name] || {}
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ ActiveSupport::TestCase.include(ActiveSupport::Testing::Metadata)
@@ -0,0 +1,7 @@
1
+ module ActiveSupport
2
+ module Testing
3
+ module Metadata
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ require 'minitest_helper'
2
+
3
+ class ActiveSupportTestingMetadataTest< Minitest::Test
4
+ def test_metadata_returns_metadata_hash_for_each_test_method
5
+ @a = TestClass
6
+
7
+ expect = { js: true }
8
+ assert_equal expect, @a.metadata['test_test1']
9
+
10
+ expect = {}
11
+ assert_equal expect, @a.metadata['test_test2']
12
+
13
+ expect = { js: false }
14
+ assert_equal expect, @a.metadata['test_test3']
15
+
16
+ expect = { vcr: true, js: false }
17
+ assert_equal expect, @a.metadata['test_test4']
18
+ end
19
+ end
20
+
21
+ class TestClass < ActiveSupport::TestCase
22
+ ActiveSupport.test_order = :random
23
+
24
+ test 'test1', js: true do; end
25
+ test 'test2' do; end
26
+ test 'test3', js: false do; end
27
+ test 'test4', :vcr, js: false do; end
28
+ end
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'pry'
3
+ require 'active_support/testing/metadata'
4
+ require 'minitest/autorun'
5
+
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activesupport-testing-metadata
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuji Yaginuma
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-doc
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - yuuji.yaginuma@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - active_support-testing-metadata.gemspec
111
+ - lib/active_support/testing/metadata.rb
112
+ - lib/active_support/testing/metadata/version.rb
113
+ - test/activesupport-testing-metadata_test.rb
114
+ - test/minitest_helper.rb
115
+ homepage: https://github.com/y-yagi/activesupport-testing-metadata
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.4.5
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Metadata (key-value) support for ActiveSupport::TestCase
139
+ test_files:
140
+ - test/activesupport-testing-metadata_test.rb
141
+ - test/minitest_helper.rb
142
+ has_rdoc: