unencumbered 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +11 -14
- data/VERSION +1 -1
- data/lib/unencumbered.rb +12 -28
- data/spec/lib/unencumbered_spec.rb +126 -0
- data/spec/spec.opts +4 -0
- data/unencumbered.gemspec +7 -2
- metadata +6 -4
data/README.textile
CHANGED
@@ -4,6 +4,7 @@ _You got Cucumber in my RSpec!_
|
|
4
4
|
|
5
5
|
Write Cucumber-flavored integration tests as easily as you write your RSpec.
|
6
6
|
|
7
|
+
|
7
8
|
h2. To Get Output Like This
|
8
9
|
|
9
10
|
Output from a @rake spec:integration@ run:
|
@@ -20,10 +21,10 @@ User creates a vurl
|
|
20
21
|
</code>
|
21
22
|
</pre>
|
22
23
|
|
24
|
+
|
23
25
|
h2. Make a Feature Like This
|
24
26
|
|
25
|
-
Put it in a spec file in the _spec/integration_ folder. Here's
|
26
|
-
_user_creates_vurl_spec.rb_ for example:
|
27
|
+
Put it in a spec file in the _spec/integration_ folder. Here's _user_creates_vurl_spec.rb_ for example:
|
27
28
|
|
28
29
|
<pre>
|
29
30
|
<code>
|
@@ -33,21 +34,21 @@ Feature "User creates a vurl" do
|
|
33
34
|
Scenario "creating" do
|
34
35
|
Given "I am on the home page" do
|
35
36
|
executes { visit root_path }
|
36
|
-
|
37
|
+
|
37
38
|
When "I submit a valid vurl" do
|
38
39
|
executes do
|
39
40
|
fill_in "vurl_url", :with => 'http://example.com'
|
40
41
|
click_button 'Vurlify!'
|
41
42
|
end
|
42
|
-
|
43
|
+
|
43
44
|
Then "I should be on the vurl stats page" do
|
44
45
|
current_url.should == stats_url(Vurl.last.slug)
|
45
46
|
end
|
46
|
-
|
47
|
+
|
47
48
|
And "I should see a success message" do
|
48
49
|
response.body.should include('Vurl was successfully created')
|
49
50
|
end
|
50
|
-
|
51
|
+
|
51
52
|
And "my vurl was created" do
|
52
53
|
Vurl.last.url.should == 'http://example.com'
|
53
54
|
end
|
@@ -58,13 +59,12 @@ end
|
|
58
59
|
</code>
|
59
60
|
</pre>
|
60
61
|
|
62
|
+
|
61
63
|
h2. Set Up
|
62
64
|
|
63
65
|
h3. Environment
|
64
66
|
|
65
|
-
Add this line to your _config/environments/test.rb_ file. Make sure to use the
|
66
|
-
@:lib => false@ item. We need to require the library manually in the
|
67
|
-
_spec_helper.rb_, since it patches RSpec.
|
67
|
+
Add this line to your _config/environments/test.rb_ file. Make sure to use the @:lib => false@ item. We need to require the library manually in the _spec_helper.rb_, since it patches RSpec.
|
68
68
|
|
69
69
|
<pre>
|
70
70
|
<code>
|
@@ -75,9 +75,7 @@ config.gem "unencumbered", :lib => false, :version => 'x.x.x'
|
|
75
75
|
|
76
76
|
h3. spec_helper.rb
|
77
77
|
|
78
|
-
Meld these lines into your existing _spec/spec_helper.rb_. Note the
|
79
|
-
_unencumbered_ require needs to be after your RSpec requires, since it patches
|
80
|
-
RSpec.
|
78
|
+
Meld these lines into your existing _spec/spec_helper.rb_. Note the _unencumbered_ require needs to be after your RSpec requires, since it patches RSpec.
|
81
79
|
|
82
80
|
<pre>
|
83
81
|
<code>
|
@@ -102,8 +100,7 @@ class ActionController::Integration::Session; include Spec::Matchers; end
|
|
102
100
|
|
103
101
|
h3. spec.opts
|
104
102
|
|
105
|
-
RSpec's nested format reads nicely. Put this line in your _spec/spec.opts_
|
106
|
-
file.
|
103
|
+
RSpec's nested format reads nicely. Put this line in your _spec/spec.opts_ file.
|
107
104
|
|
108
105
|
<pre>
|
109
106
|
<code>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/unencumbered.rb
CHANGED
@@ -1,40 +1,24 @@
|
|
1
1
|
module Spec::DSL::Main
|
2
|
-
|
3
|
-
def
|
2
|
+
alias_method :Feature, :describe
|
3
|
+
def narrative(description)
|
4
4
|
@description_args.push("\n#{description}\n")
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
8
|
module Spec::Example::ExampleGroupMethods
|
9
|
-
def Scenario(description, &
|
10
|
-
describe("Scenario:
|
9
|
+
def Scenario(description, &implementation)
|
10
|
+
describe("Scenario: #{description}", &implementation)
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
13
|
+
def executes(scope=:all, &implementation)
|
14
|
+
before(scope, &implementation)
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def And(description, &blk)
|
26
|
-
example("And #{description}", &blk)
|
27
|
-
end
|
28
|
-
|
29
|
-
def But(description, &blk)
|
30
|
-
example("But #{description}", &blk)
|
31
|
-
end
|
32
|
-
|
33
|
-
def executes(scope=:all, &blk)
|
34
|
-
before(scope, &blk)
|
35
|
-
end
|
36
|
-
|
37
|
-
def Background(description, &blk)
|
38
|
-
describe("Background #{description}", &blk)
|
17
|
+
def method_missing(symbol,*args,&block)
|
18
|
+
if symbol.to_s =~ /Given|When|Background/
|
19
|
+
describe("#{symbol} #{args.first}", &block)
|
20
|
+
elsif symbol.to_s =~ /Then|And|But/
|
21
|
+
example("#{symbol} #{args.first}", &block)
|
22
|
+
end
|
39
23
|
end
|
40
24
|
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require File.expand_path('../../../lib/unencumbered', __FILE__)
|
2
|
+
|
3
|
+
describe Spec::DSL::Main do
|
4
|
+
class TestBed
|
5
|
+
include Spec::DSL::Main
|
6
|
+
def initialize
|
7
|
+
@description_args = []
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'responds to Feature' do
|
12
|
+
Spec::DSL::Main.should respond_to(:Feature)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#narrative' do
|
16
|
+
it '#narrative appends the description to description_args' do
|
17
|
+
dsl_main = TestBed.new
|
18
|
+
dsl_main.instance_variable_get(:@description_args).should_receive(:push).with("\nfoo\n")
|
19
|
+
dsl_main.narrative('foo'){}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe Spec::Example::ExampleGroupMethods do
|
25
|
+
class TestBed
|
26
|
+
include Spec::Example::ExampleGroupMethods
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:example_group){ TestBed.new }
|
30
|
+
|
31
|
+
shared_examples_for 'a standard describe proxy' do
|
32
|
+
let(:spec_method){ spec_type.gsub(/\:/,'') }
|
33
|
+
|
34
|
+
it 'calls describe' do
|
35
|
+
example_group.should_receive(:describe)
|
36
|
+
example_group.send(spec_method,'foo'){}
|
37
|
+
end
|
38
|
+
|
39
|
+
it "prefaces the description" do
|
40
|
+
example_group.should_receive(:describe).with("#{spec_type} foo")
|
41
|
+
example_group.send(spec_method,'foo'){}
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'passes along the implementation block' do
|
45
|
+
impl = lambda{ 'foo' }
|
46
|
+
example_group.should_receive(:describe).with(anything,&impl)
|
47
|
+
example_group.send(spec_method,'foo',&impl)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
shared_examples_for 'a standard example proxy' do
|
52
|
+
it 'calls example' do
|
53
|
+
example_group.should_receive(:example)
|
54
|
+
example_group.send(spec_method,'foo'){}
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'prefaces the description' do
|
58
|
+
example_group.should_receive(:example).with("#{spec_method} foo")
|
59
|
+
example_group.send(spec_method,'foo'){}
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'passes along the implementation block' do
|
63
|
+
impl = lambda{ 'foo' }
|
64
|
+
example_group.should_receive(:example).with(anything,&impl)
|
65
|
+
example_group.send(spec_method,'foo',&impl)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#executes' do
|
70
|
+
it 'calls before' do
|
71
|
+
example_group.should_receive(:before)
|
72
|
+
example_group.send(:executes){}
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'defaults the scope to :all' do
|
76
|
+
example_group.should_receive(:before).with(:all)
|
77
|
+
example_group.send(:executes){}
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'allows you to override the scope' do
|
81
|
+
example_group.should_receive(:before).with(:each)
|
82
|
+
example_group.send(:executes,:each){}
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'passes along the implementation block' do
|
86
|
+
impl = lambda{ 'foo' }
|
87
|
+
example_group.should_receive(:before).with(anything,&impl)
|
88
|
+
example_group.send(:executes,&impl)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#Scenario" do
|
93
|
+
let(:spec_type){ 'Scenario:' }
|
94
|
+
it_should_behave_like 'a standard describe proxy'
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "#Given" do
|
98
|
+
let(:spec_type){ 'Given' }
|
99
|
+
it_should_behave_like 'a standard describe proxy'
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#When" do
|
103
|
+
let(:spec_type){ 'When' }
|
104
|
+
it_should_behave_like 'a standard describe proxy'
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#Background" do
|
108
|
+
let(:spec_type){ 'Background' }
|
109
|
+
it_should_behave_like 'a standard describe proxy'
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#And" do
|
113
|
+
let(:spec_method){ 'And' }
|
114
|
+
it_should_behave_like 'a standard example proxy'
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#But" do
|
118
|
+
let(:spec_method){ 'But' }
|
119
|
+
it_should_behave_like 'a standard example proxy'
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "#Then" do
|
123
|
+
let(:spec_method){ 'Then' }
|
124
|
+
it_should_behave_like 'a standard example proxy'
|
125
|
+
end
|
126
|
+
end
|
data/spec/spec.opts
ADDED
data/unencumbered.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{unencumbered}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Hashrocket"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-01-25}
|
13
13
|
s.description = %q{You got Cucumber in my RSpec!}
|
14
14
|
s.email = %q{info@hashrocket.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,6 +24,8 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"lib/unencumbered.rb",
|
27
|
+
"spec/lib/unencumbered_spec.rb",
|
28
|
+
"spec/spec.opts",
|
27
29
|
"unencumbered.gemspec"
|
28
30
|
]
|
29
31
|
s.homepage = %q{http://github.com/hashrocket/unencumbered}
|
@@ -31,6 +33,9 @@ Gem::Specification.new do |s|
|
|
31
33
|
s.require_paths = ["lib"]
|
32
34
|
s.rubygems_version = %q{1.3.5}
|
33
35
|
s.summary = %q{Just enough Cucumber in RSpec.}
|
36
|
+
s.test_files = [
|
37
|
+
"spec/lib/unencumbered_spec.rb"
|
38
|
+
]
|
34
39
|
|
35
40
|
if s.respond_to? :specification_version then
|
36
41
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unencumbered
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hashrocket
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-25 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -30,6 +30,8 @@ files:
|
|
30
30
|
- Rakefile
|
31
31
|
- VERSION
|
32
32
|
- lib/unencumbered.rb
|
33
|
+
- spec/lib/unencumbered_spec.rb
|
34
|
+
- spec/spec.opts
|
33
35
|
- unencumbered.gemspec
|
34
36
|
has_rdoc: true
|
35
37
|
homepage: http://github.com/hashrocket/unencumbered
|
@@ -59,5 +61,5 @@ rubygems_version: 1.3.5
|
|
59
61
|
signing_key:
|
60
62
|
specification_version: 3
|
61
63
|
summary: Just enough Cucumber in RSpec.
|
62
|
-
test_files:
|
63
|
-
|
64
|
+
test_files:
|
65
|
+
- spec/lib/unencumbered_spec.rb
|