rspec-given 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/README.md +6 -4
- data/Rakefile +96 -15
- data/examples/stack/stack_spec.rb +0 -4
- data/examples/stack/stack_spec1.rb +3 -0
- data/lib/rspec/given.rb +7 -4
- data/lib/rspec/given/configure.rb +0 -1
- data/lib/rspec/given/extensions.rb +7 -1
- data/lib/rspec/given/rspec1_given.rb +10 -0
- data/lib/rspec/given/version.rb +5 -4
- metadata +23 -22
- data/examples/wrong/wrong_spec.rb +0 -26
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# rspec-given
|
2
2
|
|
3
|
-
rspec-given
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
Covering rspec-given, version 1.4.0.
|
4
|
+
|
5
|
+
rspec-given is an RSpec extension to allow Given/When/Then notation in
|
6
|
+
RSpec specifications. It is a natural extension of the experimental
|
7
|
+
work done on the Given framework. It turns out that 90% of the Given
|
8
|
+
framework can be trivially implemented on top of RSpec.
|
7
9
|
|
8
10
|
# Why Given/When/Then
|
9
11
|
|
data/Rakefile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/ruby -wKU
|
2
2
|
|
3
3
|
require 'rake/clean'
|
4
|
+
require './lib/rspec/given/version'
|
4
5
|
|
5
|
-
CLOBBER.include("*.gemspec", "html")
|
6
|
-
|
6
|
+
CLOBBER.include("*.gemspec", "html", "README", "README.old")
|
7
7
|
|
8
8
|
# README Formatting --------------------------------------------------
|
9
9
|
|
@@ -17,8 +17,16 @@ task :default => :examples
|
|
17
17
|
|
18
18
|
# Running examples ---------------------------------------------------
|
19
19
|
|
20
|
-
desc "Run the examples"
|
21
|
-
task :examples
|
20
|
+
desc "Run all the examples"
|
21
|
+
task :examples => [:examples1, :examples2]
|
22
|
+
|
23
|
+
desc "Run the examples in RSpec 1"
|
24
|
+
task :examples1 do
|
25
|
+
sh "spec examples/stack/stack_spec1.rb"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Run the examples in RSpec 2"
|
29
|
+
task :examples2 do
|
22
30
|
sh "rspec examples"
|
23
31
|
end
|
24
32
|
|
@@ -40,8 +48,43 @@ task "html/README.html" => ['html', 'README.md'] do
|
|
40
48
|
end
|
41
49
|
end
|
42
50
|
|
51
|
+
desc "Generate an RDoc README"
|
52
|
+
file "README.md" => ["examples/stack/stack_spec.rb", "lib/rspec/given/version.rb"] do
|
53
|
+
open("README.md") do |ins|
|
54
|
+
open("README.tmp", "w") do |outs|
|
55
|
+
state = :copy
|
56
|
+
while line = ins.gets
|
57
|
+
case state
|
58
|
+
when :copy
|
59
|
+
if line =~ /version +\d+\.\d+\.\d+/
|
60
|
+
line.gsub!(/version +\d+\.\d+\.\d+/, "version #{RSpec::Given::VERSION}")
|
61
|
+
outs.puts line
|
62
|
+
elsif line =~ /^<pre>/
|
63
|
+
state = :insert
|
64
|
+
else
|
65
|
+
outs.puts line
|
66
|
+
end
|
67
|
+
when :insert
|
68
|
+
outs.puts "<pre>"
|
69
|
+
outs.puts open("examples/stack/stack_spec.rb") { |codes| codes.read }
|
70
|
+
outs.puts "</pre>"
|
71
|
+
state = :skip
|
72
|
+
when :skip
|
73
|
+
state = :copy2 if line =~ /^<\/pre>/
|
74
|
+
when :copy2
|
75
|
+
outs.puts line
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
mv "README.md", "README.old"
|
81
|
+
mv "README.tmp", "README.md"
|
82
|
+
end
|
83
|
+
|
84
|
+
|
43
85
|
# RDoc ---------------------------------------------------------------
|
44
|
-
|
86
|
+
gem "rdoc"
|
87
|
+
require 'rdoc/task'
|
45
88
|
|
46
89
|
begin
|
47
90
|
require 'darkfish-rdoc'
|
@@ -50,19 +93,57 @@ rescue LoadError => ex
|
|
50
93
|
DARKFISH_ENABLED = false
|
51
94
|
end
|
52
95
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
96
|
+
def md_to_rdoc(infile, outfile)
|
97
|
+
open(infile) do |ins|
|
98
|
+
open(outfile, "w") do |outs|
|
99
|
+
state = :copy
|
100
|
+
while line = ins.gets
|
101
|
+
case state
|
102
|
+
when :ignore
|
103
|
+
if line =~ /^-->/
|
104
|
+
state = :copy
|
105
|
+
end
|
106
|
+
when :pre
|
107
|
+
if line =~ /^<\/pre>/
|
108
|
+
state = :copy
|
109
|
+
else
|
110
|
+
outs.puts " #{line}"
|
111
|
+
end
|
112
|
+
when :copy
|
113
|
+
if line =~ /^<!--/
|
114
|
+
state = :ignore
|
115
|
+
elsif line =~ /^<pre>/
|
116
|
+
state = :pre
|
117
|
+
else
|
118
|
+
line.gsub!(/^####/, '====')
|
119
|
+
line.gsub!(/^###/, '===')
|
120
|
+
line.gsub!(/^##/, '==')
|
121
|
+
line.gsub!(/^#/, '=')
|
122
|
+
outs.puts line
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
58
129
|
|
59
|
-
|
130
|
+
file "README" => ["README.md"] do
|
131
|
+
md_to_rdoc("README.md", "README")
|
132
|
+
end
|
133
|
+
|
134
|
+
RDoc::Task.new("rdoc") do |rdoc|
|
60
135
|
rdoc.rdoc_dir = 'html'
|
61
|
-
|
62
|
-
rdoc.
|
63
|
-
|
136
|
+
rdoc.title = "RSpec/Given -- A Given/When/Then extension for RSpec"
|
137
|
+
rdoc.options = [
|
138
|
+
'--line-numbers',
|
139
|
+
'--main' , 'README',
|
140
|
+
'--title', 'RSpec::Given - Given/When/Then Extensions for RSpec'
|
141
|
+
]
|
64
142
|
rdoc.options << '-SHN' << '-f' << 'darkfish' if DARKFISH_ENABLED
|
65
143
|
|
66
|
-
rdoc.rdoc_files.include('README
|
144
|
+
rdoc.rdoc_files.include('README')
|
145
|
+
rdoc.rdoc_files.include('MIT-LICENSE')
|
67
146
|
rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
|
68
147
|
end
|
148
|
+
|
149
|
+
task :rdoc => "README"
|
@@ -3,10 +3,6 @@ require 'spec_helper'
|
|
3
3
|
require 'stack'
|
4
4
|
|
5
5
|
describe Stack do
|
6
|
-
# NOTE: Invariants are not yet supported in rspec-given
|
7
|
-
# Invariant { stack.depth >= 0 }
|
8
|
-
# Invariant { stack.empty? == (stack.depth == 0) }
|
9
|
-
|
10
6
|
def stack_with(initial_contents)
|
11
7
|
stack = Stack.new
|
12
8
|
initial_contents.each do |item| stack.push(item) end
|
data/lib/rspec/given.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
2
|
-
require 'rspec/given/
|
3
|
-
|
4
|
-
|
1
|
+
if defined? Spec
|
2
|
+
require 'rspec/given/rspec1_given'
|
3
|
+
else
|
4
|
+
require 'rspec/given/version'
|
5
|
+
require 'rspec/given/extensions'
|
6
|
+
require 'rspec/given/configure'
|
7
|
+
end
|
@@ -2,6 +2,12 @@ module RSpec
|
|
2
2
|
module Given
|
3
3
|
module Extensions
|
4
4
|
|
5
|
+
# *DEPRECATED:*
|
6
|
+
#
|
7
|
+
# The Scenario command is deprecated. Future versions of
|
8
|
+
# rspec/given will start displaying warnings when used.
|
9
|
+
# Eventually the command will be removed.
|
10
|
+
#
|
5
11
|
# Declare a scenario to contain Given/When/Then declarations. A
|
6
12
|
# Scenario is essentially an RSpec context, with the additional
|
7
13
|
# expectations:
|
@@ -26,7 +32,7 @@ module RSpec
|
|
26
32
|
# Given(:name, &block)
|
27
33
|
# Given(&block)
|
28
34
|
#
|
29
|
-
def Given(*args
|
35
|
+
def Given(*args, &block)
|
30
36
|
if args.first.is_a?(Symbol)
|
31
37
|
let(args.first, &block)
|
32
38
|
else
|
data/lib/rspec/given/version.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Given
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
VERSION_NUMBERS = [
|
4
|
+
VERSION_MAJOR = 1,
|
5
|
+
VERSION_MINOR = 4,
|
6
|
+
VERSION_BUILD = 0,
|
7
|
+
]
|
7
8
|
VERSION = VERSION_NUMBERS.join(".")
|
8
9
|
end
|
9
10
|
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-given
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 3
|
8
|
-
- 1
|
9
|
-
version: 1.3.1
|
4
|
+
prerelease:
|
5
|
+
version: 1.4.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Jim Weirich
|
@@ -14,34 +10,41 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
18
|
-
default_executable:
|
13
|
+
date: 2011-06-05 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: rspec
|
22
17
|
prerelease: false
|
23
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
24
20
|
requirements:
|
25
|
-
- -
|
21
|
+
- - ">"
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 2
|
29
|
-
- 0
|
30
|
-
version: "2.0"
|
23
|
+
version: 1.2.8
|
31
24
|
type: :runtime
|
32
25
|
version_requirements: *id001
|
33
26
|
- !ruby/object:Gem::Dependency
|
34
27
|
name: bluecloth
|
35
28
|
prerelease: false
|
36
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
37
31
|
requirements:
|
38
32
|
- - ">="
|
39
33
|
- !ruby/object:Gem::Version
|
40
|
-
segments:
|
41
|
-
- 0
|
42
34
|
version: "0"
|
43
35
|
type: :development
|
44
36
|
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rdoc
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">"
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.4.2
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
45
48
|
description: |
|
46
49
|
Given is an RSpec extension that allows explicit definition of the
|
47
50
|
pre and post-conditions for code under test.
|
@@ -59,13 +62,13 @@ files:
|
|
59
62
|
- README.md
|
60
63
|
- lib/rspec/given/configure.rb
|
61
64
|
- lib/rspec/given/extensions.rb
|
65
|
+
- lib/rspec/given/rspec1_given.rb
|
62
66
|
- lib/rspec/given/version.rb
|
63
67
|
- lib/rspec/given.rb
|
64
68
|
- examples/spec_helper.rb
|
65
69
|
- examples/stack/stack.rb
|
66
70
|
- examples/stack/stack_spec.rb
|
67
|
-
- examples/
|
68
|
-
has_rdoc: true
|
71
|
+
- examples/stack/stack_spec1.rb
|
69
72
|
homepage: http://github.com/jimweirich/rspec-given
|
70
73
|
licenses: []
|
71
74
|
|
@@ -80,23 +83,21 @@ rdoc_options:
|
|
80
83
|
require_paths:
|
81
84
|
- lib
|
82
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
83
87
|
requirements:
|
84
88
|
- - ">="
|
85
89
|
- !ruby/object:Gem::Version
|
86
|
-
segments:
|
87
|
-
- 0
|
88
90
|
version: "0"
|
89
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
90
93
|
requirements:
|
91
94
|
- - ">="
|
92
95
|
- !ruby/object:Gem::Version
|
93
|
-
segments:
|
94
|
-
- 0
|
95
96
|
version: "0"
|
96
97
|
requirements: []
|
97
98
|
|
98
99
|
rubyforge_project: given
|
99
|
-
rubygems_version: 1.3
|
100
|
+
rubygems_version: 1.8.3
|
100
101
|
signing_key:
|
101
102
|
specification_version: 3
|
102
103
|
summary: Given/When/Then Specification Extensions for RSpec.
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rspec/given'
|
2
|
-
require 'wrong'
|
3
|
-
|
4
|
-
include Wrong
|
5
|
-
|
6
|
-
describe "Using Wrong" do
|
7
|
-
def self.Should(&block)
|
8
|
-
specify do
|
9
|
-
assert(&block)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
# Scenario "trying wrong's assert" do
|
14
|
-
# Given(:a) { 1 }
|
15
|
-
# Given(:b) { 1 }
|
16
|
-
# Then { a == b }
|
17
|
-
# end
|
18
|
-
|
19
|
-
context "trying wrong's assert" do
|
20
|
-
Given(:a) { 1 }
|
21
|
-
Given(:b) { 2 }
|
22
|
-
puts "DBG: BEFORE THEN"
|
23
|
-
Should { a == b }
|
24
|
-
puts "DBG: AFTER THEN"
|
25
|
-
end
|
26
|
-
end
|