chibineko-rspec 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: adafd6224a71e2b617c66d2926ec37029d7c628d
4
+ data.tar.gz: a843bda464a12220d913479f2e975838ad7901b1
5
+ SHA512:
6
+ metadata.gz: bfebf8b301c58f4e0195b38c214ebefe69d949a06addeaa7b75c288c91471baadc8580797a209433cf5a0a18e393651abf7d4a38a2325a3f1d0283d58b428ced
7
+ data.tar.gz: 187b94cf61db81693f9a9ea29e8cad12245fed6ca2b57de4a77a9a20ac169ce3a198af0a01b998425be239f12c8abc7812057fc924c750d9459db055d12cccc3
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-ci
2
+ repo_token: zhQKkQSV1fqkG6LN9UJDZhhJsPbYRasLS
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ *~
2
+ /vendor/
3
+ /.bundle/
4
+ /.yardoc
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
12
+ /bin/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --tag "~@ignore"
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.1.5
5
+ before_install:
6
+ - gem update --system
7
+ - gem --version
8
+ - gem update bundler
9
+ script: 'bundle exec rake'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chibineko-rspec.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Kousuke TANIGUCHI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Chibineko::RSpec
2
+
3
+ [![Build Status](https://travis-ci.org/tinsep19/chibineko-rspec.svg?branch=master)](https://travis-ci.org/tinsep19/chibineko-rspec)
4
+ [![Code Climate](https://codeclimate.com/github/tinsep19/chibineko-rspec/badges/gpa.svg)](https://codeclimate.com/github/tinsep19/chibineko-rspec)
5
+ [![Coverage Status](https://coveralls.io/repos/tinsep19/chibineko-rspec/badge.svg)](https://coveralls.io/r/tinsep19/chibineko-rspec)
6
+
7
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/chibineko/rspec`.
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ''Now, this is not published yet.''
15
+
16
+
17
+ ```ruby
18
+ gem 'chibineko-rspec'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle install
24
+
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install chibineko-rspec
29
+
30
+ ## Usage
31
+
32
+ ### Set up
33
+
34
+ add following in spec_helper.rb
35
+
36
+ ```
37
+
38
+ require "chibineko/rspec"
39
+ RSpec.configure do |c|
40
+ c.extend Chibineko::RSpec::Helper
41
+ end
42
+
43
+ ```
44
+
45
+ ### Automatically inclusion.
46
+
47
+ 1. Sign up chibineko and create test-case.
48
+ 2. You write rspec like following and run `rspec`
49
+
50
+ ```
51
+
52
+ RSpec.describe "release spec" do
53
+ includes_chibineko("https://chibineko.jp/t/_pzoN-sPUk7xDy42Mq-4_Q")
54
+ end
55
+
56
+ ```
57
+
58
+
59
+ `includes_chibineko` will download csv and generate examples in current example-group.
60
+
61
+ ## Development
62
+
63
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
64
+
65
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it ( https://github.com/tinsep19/chibineko-rspec/fork )
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => [:spec]
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = 'spec/**/*_spec.rb'
7
+ spec.rspec_opts = ['-cfd']
8
+ end
9
+ rescue LoadError => e
10
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "chibineko/rspec"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'chibineko/rspec/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "chibineko-rspec"
8
+ spec.version = Chibineko::RSpec::VERSION
9
+ spec.authors = ["Kousuke TANIGUCHI"]
10
+ spec.email = ["kousuke.taniguchi@gmail.com"]
11
+
12
+ spec.summary = %q{Integration Chibineko in RSpec.}
13
+ spec.description = %q{Chibineko result into RSpec}
14
+ spec.homepage = "https://github.com/tinsep19"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "rspec"
31
+ spec.add_development_dependency "rspec-its"
32
+ spec.add_development_dependency "bundler", "~> 1.9"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "simplecov"
35
+ spec.add_development_dependency "rubocop"
36
+ spec.add_development_dependency "travis"
37
+ spec.add_development_dependency "travis-lint"
38
+ spec.add_development_dependency "coveralls"
39
+ end
@@ -0,0 +1,46 @@
1
+ # coding: utf-8
2
+ module Chibineko
3
+ module RSpec
4
+ class ExampleGroupExporter
5
+ attr_accessor :root, :testcase
6
+ def initialize(exgroup, testcase)
7
+ self.root = exgroup
8
+ self.testcase = testcase
9
+ end
10
+
11
+ def export(parent=root,items=testcase.items,depth=0)
12
+ exporter = self
13
+ items.group_by {|item|
14
+ item.groups[depth]
15
+ }.each {|group,items|
16
+ if group
17
+ parent.describe "#{group}" do
18
+ exporter.export(self, items, depth + 1)
19
+ end
20
+ else
21
+ items.each do |item|
22
+ create_example(parent,item)
23
+ end
24
+ end
25
+ }
26
+ end
27
+ def create_example(parent, item)
28
+
29
+ if item.pending?
30
+ parent.it "#{item.item}" do
31
+ pending(item.memo)
32
+ end
33
+ elsif item.skip?
34
+ parent.xit "#{item.item}" do
35
+ expect(item).to be_ok
36
+ end
37
+ else
38
+ parent.it "#{item.item}" do |ex|
39
+ # TODO 専用のMatcherつくろう
40
+ expect(item).to be_ok
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,11 @@
1
+ require 'net/http'
2
+ module Chibineko
3
+ module RSpec
4
+ module Helper
5
+ def include_chibineko(testcase_url)
6
+ testcase = Chibineko::TestCase.retrieve(testcase_url)
7
+ ExampleGroupExporter.new(self,testcase).export
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,22 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "rspec/expectations"
3
+
4
+ RSpec::Matchers.define :be_ok do
5
+ match do |actual|
6
+ actual.ok?
7
+ end
8
+
9
+ description do
10
+ "should be complete."
11
+ end
12
+
13
+ failure_message do |actual|
14
+ if actual.execute?
15
+ # NG
16
+ "expected that #{actual.item} should be completed."
17
+ else
18
+ # 未実施
19
+ "expected that #{actual.item} should be executed."
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module Chibineko
2
+ module RSpec
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ require "chibineko/testitem"
2
+ require "chibineko/testcase"
3
+ require "chibineko/rspec/version"
4
+ require "chibineko/rspec/helper"
5
+ require "chibineko/rspec/example_group_exporter"
6
+ require "chibineko/rspec/matcher"
7
+
8
+ module Chibineko
9
+ module RSpec
10
+ end
11
+ end
@@ -0,0 +1,26 @@
1
+ module Chibineko
2
+ class TestCase
3
+ URL_REGEXP = %r{^http://chibineko.jp/t/[^/]*$}
4
+ class << self
5
+ def retrieve(testcase_url)
6
+ uri = URI.parse( testcase_url + "/test_case.csv?encode=utf-8")
7
+ content = Net::HTTP.get(uri)
8
+ # Content-Type: text/csv; charset=utf-8
9
+ # But some japanese charactors was not read.
10
+ new(content.encode("UTF-8", "UTF-8"), testcase_url)
11
+ end
12
+ def load_from_file(file_path)
13
+ content = File.read(file_path, encoding: "UTF-8")
14
+ new(content,File.expand_path(file_path))
15
+ end
16
+ end
17
+ attr_accessor :items, :source
18
+ def initialize(content, src=nil)
19
+ self.source = src
20
+ csv = CSV.new(content, return_headers: false, headers: :first_row)
21
+ self.items = csv.to_enum.with_index(1).map { |row,line|
22
+ TestItem.new(row,source,line)
23
+ }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,44 @@
1
+ # coding: utf-8
2
+ require "csv"
3
+
4
+ module Chibineko
5
+ class TestItem
6
+ STATUS_OK=["OK"]
7
+ STATUS_PENDING=["保留"]
8
+ STATUS_FAIL=["NG","未実施"]
9
+ STATUS_SKIP=["対象外"]
10
+ GROUP_DEPTH=5
11
+
12
+ attr_accessor :groups, :item, :status, :memo, :source, :line
13
+
14
+ def initialize(row, src, line_num = -1)
15
+ self.memo= row.field(-1)
16
+ self.status= row.field(-2)
17
+ self.item= row.field(-3)
18
+ self.groups= GROUP_DEPTH.times.map {|offset|
19
+ group = row.field('-', offset)
20
+ (group.nil? or group.empty?) ? nil : group
21
+ }
22
+ self.source= src
23
+ self.line=line_num
24
+ end
25
+ def ok?
26
+ STATUS_OK.include?(status)
27
+ end
28
+ def ng?
29
+ STATUS_FAIL.include?(status)
30
+ end
31
+ def execute?
32
+ ok? or ng?
33
+ end
34
+ def skip?
35
+ STATUS_SKIP.include?(status)
36
+ end
37
+ def pending?
38
+ STATUS_PENDING.include?(status)
39
+ end
40
+ def location
41
+ source + "#" + line
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chibineko-rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kousuke TANIGUCHI
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-its
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
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: rubocop
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
+ - !ruby/object:Gem::Dependency
98
+ name: travis
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: travis-lint
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: coveralls
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Chibineko result into RSpec
140
+ email:
141
+ - kousuke.taniguchi@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".coveralls.yml"
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".travis.yml"
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/setup
156
+ - chibineko-rspec.gemspec
157
+ - lib/chibineko/rspec.rb
158
+ - lib/chibineko/rspec/example_group_exporter.rb
159
+ - lib/chibineko/rspec/helper.rb
160
+ - lib/chibineko/rspec/matcher.rb
161
+ - lib/chibineko/rspec/version.rb
162
+ - lib/chibineko/testcase.rb
163
+ - lib/chibineko/testitem.rb
164
+ homepage: https://github.com/tinsep19
165
+ licenses:
166
+ - MIT
167
+ metadata:
168
+ allowed_push_host: https://rubygems.org
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.4.6
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Integration Chibineko in RSpec.
189
+ test_files: []