saki 0.1.0 → 0.1.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.
- data/README.markdown +13 -1
- data/VERSION +1 -1
- data/lib/saki.rb +27 -19
- data/saki.gemspec +2 -2
- metadata +3 -7
data/README.markdown
CHANGED
@@ -41,7 +41,11 @@ The only assumption is that you are using factories instead of fixtures. You al
|
|
41
41
|
|
42
42
|
with_existing :user, :state => "happy" do...
|
43
43
|
|
44
|
-
`on_visiting` preferably uses some dynamic functions for establishing a path: `new_X_path`, `Xs_path`, `edit_X_path`, `X_path` and `new_X_path`. In these cases, substitute X for the resource name (e.g. `new_user_path`).
|
44
|
+
`on_visiting` preferably uses some dynamic functions for establishing a path: `new_X_path`, `Xs_path`, `edit_X_path`, `X_path` and `new_X_path`. In these cases, substitute X for the resource name (e.g. `new_user_path`).
|
45
|
+
|
46
|
+
Note that for examples like `edit_user_path`, it behaves with a slight difference from the rails route helpers, because it assumes that there already exists an instance variable named `@user`. Since the `edit_user_path` call occurs when there is no `@user`, we can't mention it explicitly.
|
47
|
+
|
48
|
+
For cases where the resource is nested, these path helpers have a :parent => parent_resource option. This lets you set up blocks like:
|
45
49
|
|
46
50
|
on_visiting auctions_path(:parent => :user) do ...
|
47
51
|
|
@@ -114,6 +118,14 @@ You can generate new acceptance tests with `rails generate saki:spec SPEC_NAME`.
|
|
114
118
|
end
|
115
119
|
end
|
116
120
|
|
121
|
+
## Why no specs/tests for Saki, oh test guy?
|
122
|
+
|
123
|
+
They'll get there :). Saki is extracted from some spec helpers I used in moving from Cucumber to Steak. Once I realized they also work as helpers for vanilla RSpec acceptance testing I made them a separate gem.
|
124
|
+
|
125
|
+
## Why are there ugly command-line descriptions?
|
126
|
+
|
127
|
+
I haven't pimped that up yet, but will at some point. Personally I'm a "green-dot" guy and just care what line a test fails on.
|
128
|
+
|
117
129
|
## References
|
118
130
|
|
119
131
|
The motivation behind my migration from Cucumber and to Saki, are described in blog posts [Encumbered by Cucumber](http://ludicast.com/articles/1), [Introducing Saki](http://ludicast.com/articles/2).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/saki.rb
CHANGED
@@ -1,13 +1,36 @@
|
|
1
1
|
require 'rspec/core'
|
2
2
|
|
3
3
|
module Saki
|
4
|
-
module
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
4
|
+
module GeneralHelpers
|
5
|
+
extend ActiveSupport::Concern
|
7
6
|
def default_factory(name, opts = {})
|
8
7
|
Factory name, opts
|
9
8
|
end
|
10
9
|
|
10
|
+
module ClassMethods
|
11
|
+
def with_existing resource, opts={}, &block
|
12
|
+
context "with exisiting #{resource}" do
|
13
|
+
before do
|
14
|
+
instance_variable_set "@#{resource}", default_factory(resource, opts)
|
15
|
+
end
|
16
|
+
module_eval &block
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def where(executable, *opts, &block)
|
21
|
+
context "anonymous closure" do
|
22
|
+
before { instance_eval &executable }
|
23
|
+
module_eval &block
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
module AcceptanceHelpers
|
31
|
+
extend ActiveSupport::Concern
|
32
|
+
|
33
|
+
|
11
34
|
def get_path(path)
|
12
35
|
if path.is_a? String
|
13
36
|
path
|
@@ -67,15 +90,6 @@ module Saki
|
|
67
90
|
end
|
68
91
|
|
69
92
|
module ClassMethods
|
70
|
-
def with_existing resource, opts={}, &block
|
71
|
-
context "with exisiting #{resource}" do
|
72
|
-
before do
|
73
|
-
instance_variable_set "@#{resource}", default_factory(resource, opts)
|
74
|
-
end
|
75
|
-
module_eval &block
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
93
|
def on_following_link_to path, &block
|
80
94
|
context "on following link" do
|
81
95
|
before do
|
@@ -128,13 +142,6 @@ module Saki
|
|
128
142
|
add_opts "/#{resource.to_s.pluralize}", opts, context
|
129
143
|
end
|
130
144
|
end
|
131
|
-
|
132
|
-
def where(executable, *opts, &block)
|
133
|
-
context "anonymous closure" do
|
134
|
-
before { instance_eval &executable }
|
135
|
-
module_eval &block
|
136
|
-
end
|
137
|
-
end
|
138
145
|
end
|
139
146
|
end
|
140
147
|
end
|
@@ -187,4 +194,5 @@ module RSpec::Core::ObjectExtensions
|
|
187
194
|
end
|
188
195
|
end
|
189
196
|
|
197
|
+
RSpec.configuration.include Saki::GeneralHelpers
|
190
198
|
RSpec.configuration.include Saki::AcceptanceHelpers, :type => :acceptance
|
data/saki.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{saki}
|
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 = ["Nate Kidwell"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-19}
|
13
13
|
s.description = %q{Cucumber scenarios are long and confusing sometimes. Release yourself from the tyranny of client-centered specing!}
|
14
14
|
s.email = %q{nate@ludicast.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 27
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Nate Kidwell
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-09-19 00:00:00 -04:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
version: "0"
|
@@ -71,7 +69,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
69
|
requirements:
|
72
70
|
- - ">="
|
73
71
|
- !ruby/object:Gem::Version
|
74
|
-
hash: 3
|
75
72
|
segments:
|
76
73
|
- 0
|
77
74
|
version: "0"
|
@@ -80,7 +77,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
77
|
requirements:
|
81
78
|
- - ">="
|
82
79
|
- !ruby/object:Gem::Version
|
83
|
-
hash: 3
|
84
80
|
segments:
|
85
81
|
- 0
|
86
82
|
version: "0"
|