doctest-rspec 0.0.1

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,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzMxNzlmNjFkMmU5MTdjYzljMDIwM2UxM2NkODkxMGUzZTU5NTM4MQ==
5
+ data.tar.gz: !binary |-
6
+ NWM2YjYyNTE3ZWU0N2U5Y2Q4YjZjZmM1ODIyOWI4ZDQzNWFhOTZjMg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YjNkNzkwNTA1MzQzMDA0ZWVjOTlmNjQ3YjgxNGQ4YWI1MjBlY2UxMDAyZWNh
10
+ N2Y0MTcxNzM5MGYzNzM1MzIzMzBhODczZDBiMzAzMTExNGM3NjVmZjRlZWZh
11
+ YjljMTI1NzNjOGYyYjg0MzVhMjFkOWE2NDA0ZmRmNTk3ZDBmNjE=
12
+ data.tar.gz: !binary |-
13
+ ZDExZWViZjE2NGI3MjBmNWNjMmQ0MjRmZDMyMDg4NjcwMTJmYzExNGZiYWQ3
14
+ OGEyYWIwNWM0Mjk3ZTc0ZThjZDFiNmNiNmQ1YTQwZGQ3NWIyYzc5ODU2MDMy
15
+ MTY5ZjA1ZGFkYTEyYjZhMDRhZjgzZWE2NGExZTNjYTczYmJkMDE=
data/.gitignore ADDED
@@ -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/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - rbx-19mode
5
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in doctest-rspec.gemspec
4
+ gemspec
5
+
6
+ gem 'doctest-core', github: 'hzeus/doctest-core'
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Heiko Zeus
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.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ [![Code Climate](https://codeclimate.com/github/hzeus/doctest-rspec.png)](https://codeclimate.com/github/hzeus/doctest-rspec)
2
+ [![Build Status](https://travis-ci.org/hzeus/doctest-rspec.png)](https://travis-ci.org/hzeus/doctest-rspec)
3
+
4
+ # Doctest::RSpec
5
+
6
+ Add doctest to your rspec
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'doctest-rspec'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install doctest-rspec
21
+
22
+ ## Usage
23
+
24
+ Add doctest-formatted tests to your ruby files (see http://github.com/hzeus/doctest-extractor for syntax examples)
25
+
26
+ Configure RSpec:
27
+
28
+ ```ruby
29
+ RSpec.configure do |c|
30
+ c.extend Doctest::RSpec::DoctestHelpers
31
+ end
32
+ ```
33
+
34
+ Add doctest:
35
+
36
+ ```ruby
37
+ describe 'whatever' do
38
+ doctest MyClassWithDoctests
39
+ end
40
+ ```
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'doctest/rspec/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "doctest-rspec"
8
+ spec.version = Doctest::RSpec::VERSION
9
+ spec.authors = ["Heiko Zeus"]
10
+ spec.email = ["heiko.zeus@zweitag.de"]
11
+ spec.description = %q{Use doctests in your rspec suite}
12
+ spec.summary = %q{This provide elixir-like doctests for your rspec suite}
13
+ spec.homepage = "https://github.com/hzeus/doctest-rspec"
14
+ spec.license = "MIT"
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 "rspec"
22
+ spec.add_dependency "doctest-core"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "guard-rspec"
27
+ spec.add_development_dependency "pry"
28
+
29
+ end
@@ -0,0 +1,11 @@
1
+ ::RSpec::Matchers.define :be_a_valid_doctest do |expected|
2
+
3
+ match do |actual|
4
+ actual.code_evaluation == actual.result_evaluation
5
+ end
6
+
7
+ failure_message_for_should do |actual|
8
+ "expected #{actual.code_evaluation} to equal #{actual.result_evaluation}"
9
+ end
10
+
11
+ end
@@ -0,0 +1,17 @@
1
+ module Doctest::RSpec
2
+
3
+ module DoctestHelpers
4
+
5
+ def doctest(source)
6
+ context "doctests for #{source}" do
7
+ Doctest::Core.extract_from(source).each do |doctest|
8
+ it "at #{doctest.original_file}:#{doctest.line}" do
9
+ doctest.should be_a_valid_doctest
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,5 @@
1
+ module Doctest
2
+ module RSpec
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "doctest/rspec/version"
2
+ require "doctest/rspec/be_a_valid_doctest"
3
+ require "doctest/rspec/doctest_helpers"
4
+
5
+ module Doctest
6
+ module RSpec
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ class ClassWithDoctests
4
+ # >> ClassWithDoctests.a
5
+ # => 'a'
6
+ def self.a
7
+ end
8
+ end
9
+
10
+ RSpec.configure do |c|
11
+ c.extend Doctest::RSpec::DoctestHelpers
12
+ end
13
+
14
+ describe 'doctest' do
15
+ doctest ClassWithDoctests
16
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ module Doctest::RSpec
4
+
5
+ describe 'expect(doctest).to be_a_valid_doctest' do
6
+
7
+ let(:valid_doctest){ Doctest::Core::Doctest.new("5", "5", nil, nil) }
8
+ let(:invalid_doctest){ Doctest::Core::Doctest.new("4", "5", nil, nil) }
9
+
10
+ it 'passes if the doctest is valid' do
11
+ expect(valid_doctest).to be_a_valid_doctest
12
+ end
13
+
14
+ it 'fails if the doctest is invalid' do
15
+ expect {
16
+ expect(invalid_doctest).to be_a_valid_doctest
17
+ }.to raise_error("expected 4 to equal 5")
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'open3'
3
+ require 'pry'
4
+
5
+ describe 'doctest helper methods' do
6
+
7
+ it 'performs tests' do
8
+ stdout_str, stderr_str, status = Open3.capture3('rspec spec/fixtures/specfile_with_doctests.rb')
9
+ stderr_str.should be_empty
10
+ stdout_str.lines.should include("1 example, 1 failure\n")
11
+ status.exitstatus.should == 1
12
+ end
13
+
14
+ end
@@ -0,0 +1 @@
1
+ require 'spec_helper'
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ Bundler.require(:default)
5
+
6
+ require 'doctest/rspec'
7
+
8
+ def fixture(filename)
9
+ File.join(Gem::Specification.find_by_name('doctest-rspec').gem_dir, 'spec', 'fixtures', filename)
10
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doctest-rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Heiko Zeus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-01 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: doctest-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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: guard-rspec
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
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: Use doctests in your rspec suite
98
+ email:
99
+ - heiko.zeus@zweitag.de
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .travis.yml
106
+ - Gemfile
107
+ - Guardfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - doctest-rspec.gemspec
112
+ - lib/doctest/rspec.rb
113
+ - lib/doctest/rspec/be_a_valid_doctest.rb
114
+ - lib/doctest/rspec/doctest_helpers.rb
115
+ - lib/doctest/rspec/version.rb
116
+ - spec/fixtures/specfile_with_doctests.rb
117
+ - spec/lib/doctest/rspec/be_a_valid_doctest_spec.rb
118
+ - spec/lib/doctest/rspec/doctest_helpers_spec.rb
119
+ - spec/lib/doctest/rspec_spec.rb
120
+ - spec/spec_helper.rb
121
+ homepage: https://github.com/hzeus/doctest-rspec
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.1.5
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: This provide elixir-like doctests for your rspec suite
145
+ test_files:
146
+ - spec/fixtures/specfile_with_doctests.rb
147
+ - spec/lib/doctest/rspec/be_a_valid_doctest_spec.rb
148
+ - spec/lib/doctest/rspec/doctest_helpers_spec.rb
149
+ - spec/lib/doctest/rspec_spec.rb
150
+ - spec/spec_helper.rb
151
+ has_rdoc: