given_core 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +27 -0
- data/MIT-LICENSE +20 -0
- data/README.md +720 -0
- data/Rakefile +232 -0
- data/TODO +13 -0
- data/doc/main.rdoc +7 -0
- data/lib/given.rb +2 -0
- data/lib/given/core.rb +11 -0
- data/lib/given/evaluator.rb +38 -0
- data/lib/given/ext/numeric.rb +31 -0
- data/lib/given/extensions.rb +242 -0
- data/lib/given/failure.rb +56 -0
- data/lib/given/failure_matcher.rb +63 -0
- data/lib/given/file_cache.rb +18 -0
- data/lib/given/fuzzy_number.rb +68 -0
- data/lib/given/fuzzy_shortcuts.rb +1 -0
- data/lib/given/line_extractor.rb +41 -0
- data/lib/given/module_methods.rb +69 -0
- data/lib/given/natural_assertion.rb +177 -0
- data/lib/given/version.rb +11 -0
- data/lib/rspec-given.rb +9 -0
- data/rakelib/bundler_fix.rb +17 -0
- data/rakelib/gemspec.rake +157 -0
- data/rakelib/metrics.rake +30 -0
- data/rakelib/preview.rake +14 -0
- data/test/before_test.rb +22 -0
- data/test/meme_test.rb +36 -0
- metadata +93 -0
data/lib/rspec-given.rb
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'rubygems/package_task'
|
2
|
+
require './lib/given/version'
|
3
|
+
|
4
|
+
if ! defined?(Gem)
|
5
|
+
puts "Package Target requires RubyGEMs"
|
6
|
+
else
|
7
|
+
PKG_FILES = FileList[
|
8
|
+
'[A-Z]*',
|
9
|
+
'lib/*.rb',
|
10
|
+
'lib/**/*.rb',
|
11
|
+
'rakelib/**/*',
|
12
|
+
'test/**/*.rb',
|
13
|
+
'spec/**/*.rb',
|
14
|
+
'examples/**/*',
|
15
|
+
'doc/**/*',
|
16
|
+
]
|
17
|
+
PKG_FILES.exclude('TAGS')
|
18
|
+
GIVEN_CORE_FILES = FileList[*PKG_FILES].
|
19
|
+
exclude("lib/minitest/**/*").
|
20
|
+
exclude("lib/rspec/**/*").
|
21
|
+
exclude("spec/**/*").
|
22
|
+
exclude("examples/**/*")
|
23
|
+
RSPEC_GIVEN_FILES = FileList[*PKG_FILES].
|
24
|
+
exclude("lib/minitest/**/*").
|
25
|
+
exclude("lib/given/**/*")
|
26
|
+
MINITEST_GIVEN_FILES = FileList[*PKG_FILES].
|
27
|
+
exclude("spec/**/*").
|
28
|
+
exclude("lib/rspec/**/*").
|
29
|
+
exclude("lib/given/**/*")
|
30
|
+
|
31
|
+
RSPEC_GIVEN_SPEC = Gem::Specification.new do |s|
|
32
|
+
s.name = 'rspec-given'
|
33
|
+
s.version = Given::VERSION
|
34
|
+
s.summary = "Given/When/Then Specification Extensions for RSpec."
|
35
|
+
s.description = <<EOF
|
36
|
+
Given is an RSpec extension that allows the use of Given/When/Then
|
37
|
+
terminology when defining specifications.
|
38
|
+
EOF
|
39
|
+
s.files = RSPEC_GIVEN_FILES.to_a
|
40
|
+
s.require_path = 'lib' # Use these for libraries.
|
41
|
+
s.rdoc_options = [
|
42
|
+
'--line-numbers', '--inline-source',
|
43
|
+
'--main' , 'doc/main.rdoc',
|
44
|
+
'--title', 'RSpec Given Extensions'
|
45
|
+
]
|
46
|
+
|
47
|
+
s.add_dependency("given_core", "= #{Given::VERSION}")
|
48
|
+
s.add_dependency("rspec", ">= 2.12")
|
49
|
+
|
50
|
+
s.required_ruby_version = '>= 1.9.2'
|
51
|
+
s.license = "MIT"
|
52
|
+
|
53
|
+
s.author = "Jim Weirich"
|
54
|
+
s.email = "jim.weirich@gmail.com"
|
55
|
+
s.homepage = "http://github.com/jimweirich/rspec-given"
|
56
|
+
s.rubyforge_project = "given"
|
57
|
+
end
|
58
|
+
|
59
|
+
MINITEST_GIVEN_SPEC = Gem::Specification.new do |s|
|
60
|
+
s.name = 'minitest-given'
|
61
|
+
s.version = Given::VERSION
|
62
|
+
s.summary = "Given/When/Then Specification Extensions for MiniTest::Spec."
|
63
|
+
s.description = <<EOF
|
64
|
+
Given is a Minitest::Spec extension that allows the use of Given/When/Then
|
65
|
+
terminology when defining specifications.
|
66
|
+
EOF
|
67
|
+
s.files = MINITEST_GIVEN_FILES.to_a
|
68
|
+
s.require_path = 'lib' # Use these for libraries.
|
69
|
+
s.rdoc_options = [
|
70
|
+
'--line-numbers', '--inline-source',
|
71
|
+
'--main' , 'doc/main.rdoc',
|
72
|
+
'--title', 'Minitest Given Extensions'
|
73
|
+
]
|
74
|
+
|
75
|
+
s.add_dependency("given_core", "= #{Given::VERSION}")
|
76
|
+
s.add_dependency("minitest", "> 4.3")
|
77
|
+
|
78
|
+
s.required_ruby_version = '>= 1.9.2'
|
79
|
+
s.license = "MIT"
|
80
|
+
|
81
|
+
s.author = "Jim Weirich"
|
82
|
+
s.email = "jim.weirich@gmail.com"
|
83
|
+
s.homepage = "http://github.com/jimweirich/rspec-given"
|
84
|
+
s.rubyforge_project = "given"
|
85
|
+
end
|
86
|
+
|
87
|
+
GIVEN_CORE_SPEC = Gem::Specification.new do |s|
|
88
|
+
s.name = 'given_core'
|
89
|
+
s.version = Given::VERSION
|
90
|
+
s.summary = "Core engine for RSpec::Given and Minitest::Given."
|
91
|
+
s.description = <<EOF
|
92
|
+
Given is an RSpec/Minitest extension that allows the use of Given/When/Then
|
93
|
+
terminology when defining specifications.
|
94
|
+
EOF
|
95
|
+
s.files = GIVEN_CORE_FILES.to_a
|
96
|
+
s.require_path = 'lib' # Use these for libraries.
|
97
|
+
s.rdoc_options = [
|
98
|
+
'--line-numbers', '--inline-source',
|
99
|
+
'--main' , 'doc/main.rdoc',
|
100
|
+
'--title', 'RSpec Given Extensions'
|
101
|
+
]
|
102
|
+
|
103
|
+
s.add_dependency("sorcerer", ">= 0.3.7")
|
104
|
+
|
105
|
+
s.required_ruby_version = '>= 1.9.2'
|
106
|
+
s.license = "MIT"
|
107
|
+
|
108
|
+
s.author = "Jim Weirich"
|
109
|
+
s.email = "jim.weirich@gmail.com"
|
110
|
+
s.homepage = "http://github.com/jimweirich/rspec-given"
|
111
|
+
s.rubyforge_project = "given"
|
112
|
+
end
|
113
|
+
|
114
|
+
Gem::PackageTask.new(MINITEST_GIVEN_SPEC) do |pkg|
|
115
|
+
pkg.need_zip = false
|
116
|
+
pkg.need_tar = false
|
117
|
+
end
|
118
|
+
|
119
|
+
Gem::PackageTask.new(RSPEC_GIVEN_SPEC) do |pkg|
|
120
|
+
pkg.need_zip = false
|
121
|
+
pkg.need_tar = false
|
122
|
+
end
|
123
|
+
|
124
|
+
Gem::PackageTask.new(GIVEN_CORE_SPEC) do |pkg|
|
125
|
+
pkg.need_zip = false
|
126
|
+
pkg.need_tar = false
|
127
|
+
end
|
128
|
+
|
129
|
+
file "rspec-given.gemspec" => ["rakelib/gemspec.rake"] do |t|
|
130
|
+
require 'yaml'
|
131
|
+
open(t.name, "w") { |f| f.puts RSPEC_GIVEN_SPEC.to_yaml }
|
132
|
+
end
|
133
|
+
|
134
|
+
file "minitest-given.gemspec" => ["rakelib/gemspec.rake"] do |t|
|
135
|
+
require 'yaml'
|
136
|
+
open(t.name, "w") { |f| f.puts MINITEST_GIVEN_SPEC.to_yaml }
|
137
|
+
end
|
138
|
+
|
139
|
+
file "given_core.gemspec" => ["rakelib/gemspec.rake"] do |t|
|
140
|
+
require 'yaml'
|
141
|
+
open(t.name, "w") { |f| f.puts GIVEN_CORE_SPEC.to_yaml }
|
142
|
+
end
|
143
|
+
|
144
|
+
desc "Create a stand-alone gemspec"
|
145
|
+
task :gemspec => ["rspec-given.gemspec", "minitest-given.gemspec", "given_core.gemspec"]
|
146
|
+
|
147
|
+
desc "Check Filelists"
|
148
|
+
task :filelists do
|
149
|
+
puts "==============="
|
150
|
+
puts "GIVEN_CORE_FILES=#{GIVEN_CORE_FILES.inspect}"
|
151
|
+
puts "==============="
|
152
|
+
puts "RSPEC_GIVEN_FILES=#{RSPEC_GIVEN_FILES.inspect}"
|
153
|
+
puts "==============="
|
154
|
+
puts "MINITEST_GIVEN_FILES=#{MINITEST_GIVEN_FILES.inspect}"
|
155
|
+
puts "==============="
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require './rakelib/bundler_fix'
|
2
|
+
|
3
|
+
METRICS_FILES = FileList['lib/**/*.rb']
|
4
|
+
|
5
|
+
task :check_flog do
|
6
|
+
sh "type flog >/dev/null 2>&1", :verbose => false do |status|
|
7
|
+
fail "Install flog to generate complexity metrics" unless status
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
task :check_flay do
|
12
|
+
sh "type flay >/dev/null 2>&1", :verbose => false do |status|
|
13
|
+
fail "Install flay to generate complexity metrics" unless status
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run complexity metrics"
|
18
|
+
task :flog, [:all] => :check_flog do |t, args|
|
19
|
+
flags = args.all ? "--all" : ""
|
20
|
+
nobundle do
|
21
|
+
sh "flog #{flags} #{METRICS_FILES}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Run duplication metrics"
|
26
|
+
task :flay => :check_flay do
|
27
|
+
nobundle do
|
28
|
+
sh "flay #{METRICS_FILES}"
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require './rakelib/bundler_fix'
|
2
|
+
|
3
|
+
task :check_preview do
|
4
|
+
sh "type ghpreview >/dev/null 2>&1", :verbose => false do |status|
|
5
|
+
fail "Install ghpreview to generate a local REAMDE preview page" unless status
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Generate the GitHub readme locally"
|
10
|
+
task :preview => :check_preview do
|
11
|
+
nobundle do
|
12
|
+
sh "ghpreview #{FileList['README.*']}"
|
13
|
+
end
|
14
|
+
end
|
data/test/before_test.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/given"
|
3
|
+
|
4
|
+
Given.use_natural_assertions
|
5
|
+
|
6
|
+
describe "Before" do
|
7
|
+
_Gvn_before { puts "Before 1" }
|
8
|
+
def setup
|
9
|
+
puts "Setup 1"
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "not nil" do
|
14
|
+
_Gvn_before { puts "Before 2a" }
|
15
|
+
_Gvn_before { puts "Before 2b" }
|
16
|
+
def setup
|
17
|
+
super
|
18
|
+
puts "Setup 2"
|
19
|
+
end
|
20
|
+
Then { 1 != nil }
|
21
|
+
end
|
22
|
+
end
|
data/test/meme_test.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/given"
|
3
|
+
|
4
|
+
class Meme
|
5
|
+
def will_it_blend?
|
6
|
+
end
|
7
|
+
|
8
|
+
def i_can_has_cheezburger?
|
9
|
+
"OHAI!"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
Given.use_natural_assertions
|
15
|
+
|
16
|
+
describe Meme do
|
17
|
+
def setup
|
18
|
+
super
|
19
|
+
puts "SETUP"
|
20
|
+
end
|
21
|
+
|
22
|
+
Given(:meme) { Meme.new }
|
23
|
+
|
24
|
+
describe "not nil" do
|
25
|
+
def setup
|
26
|
+
super
|
27
|
+
puts "Setup 2"
|
28
|
+
end
|
29
|
+
_Gvn_before { puts "BEFORE" }
|
30
|
+
Then { meme != nil }
|
31
|
+
end
|
32
|
+
|
33
|
+
Then { meme.i_can_has_cheezburger? == "OHAI!" }
|
34
|
+
Then { meme.will_it_blend? !~ /^no/i }
|
35
|
+
Then { skip "test this later" }
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: given_core
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.0.beta.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jim Weirich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sorcerer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.3.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.3.7
|
27
|
+
description: |
|
28
|
+
Given is an RSpec/Minitest extension that allows the use of Given/When/Then
|
29
|
+
terminology when defining specifications.
|
30
|
+
email: jim.weirich@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- MIT-LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- TODO
|
41
|
+
- lib/given.rb
|
42
|
+
- lib/rspec-given.rb
|
43
|
+
- lib/given/core.rb
|
44
|
+
- lib/given/evaluator.rb
|
45
|
+
- lib/given/ext/numeric.rb
|
46
|
+
- lib/given/extensions.rb
|
47
|
+
- lib/given/failure.rb
|
48
|
+
- lib/given/failure_matcher.rb
|
49
|
+
- lib/given/file_cache.rb
|
50
|
+
- lib/given/fuzzy_number.rb
|
51
|
+
- lib/given/fuzzy_shortcuts.rb
|
52
|
+
- lib/given/line_extractor.rb
|
53
|
+
- lib/given/module_methods.rb
|
54
|
+
- lib/given/natural_assertion.rb
|
55
|
+
- lib/given/version.rb
|
56
|
+
- rakelib/bundler_fix.rb
|
57
|
+
- rakelib/gemspec.rake
|
58
|
+
- rakelib/metrics.rake
|
59
|
+
- rakelib/preview.rake
|
60
|
+
- test/before_test.rb
|
61
|
+
- test/meme_test.rb
|
62
|
+
- doc/main.rdoc
|
63
|
+
homepage: http://github.com/jimweirich/rspec-given
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options:
|
69
|
+
- --line-numbers
|
70
|
+
- --inline-source
|
71
|
+
- --main
|
72
|
+
- doc/main.rdoc
|
73
|
+
- --title
|
74
|
+
- RSpec Given Extensions
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.9.2
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>'
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.3.1
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project: given
|
89
|
+
rubygems_version: 2.0.3
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Core engine for RSpec::Given and Minitest::Given.
|
93
|
+
test_files: []
|