shoulda-let 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.
- data/.travis.yml +4 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +21 -0
- data/Rakefile +6 -0
- data/Readme.md +56 -0
- data/lib/shoulda/let.rb +21 -0
- data/shoulda-let.gemspec +11 -0
- data/test/shoulda_let_test.rb +10 -0
- metadata +75 -0
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shoulda-let (0.0.1)
|
5
|
+
shoulda
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
rake (0.9.2)
|
11
|
+
shoulda (2.11.3)
|
12
|
+
test-unit (2.5.1)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
rake
|
19
|
+
shoulda (~> 2.11)
|
20
|
+
shoulda-let!
|
21
|
+
test-unit (>= 2.5.1)
|
data/Rakefile
ADDED
data/Readme.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
A simple let for shoulda
|
2
|
+
|
3
|
+
Install
|
4
|
+
=======
|
5
|
+
|
6
|
+
gem install shoulda-let
|
7
|
+
|
8
|
+
# Gemfile
|
9
|
+
gem "shoulda-let", :require => "shoulda/let"
|
10
|
+
|
11
|
+
Usage
|
12
|
+
=====
|
13
|
+
<!-- example -->
|
14
|
+
context "foo" do
|
15
|
+
setup do
|
16
|
+
@result = let(:thing)
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:thing){ "parent" }
|
20
|
+
|
21
|
+
context "with something" do
|
22
|
+
let(:thing){ "something" }
|
23
|
+
should "be something" do
|
24
|
+
assert_equal "something", @result
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with cache" do
|
29
|
+
let(:thing){ rand }
|
30
|
+
|
31
|
+
should "be stable" do
|
32
|
+
assert_equal @result, let(:thing)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "be different" do
|
36
|
+
assert_not_equal $last_thing, let(:thing)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "prepare for be different" do
|
40
|
+
$last_thing = let(:thing)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "with parent" do
|
45
|
+
should "be parent" do
|
46
|
+
assert_equal "parent", @result
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
<!-- example -->
|
51
|
+
Author
|
52
|
+
======
|
53
|
+
[Michael Grosser](http://grosser.it)<br/>
|
54
|
+
michael@grosser.it<br/>
|
55
|
+
License: MIT<br/>
|
56
|
+
[](http://travis-ci.org/grosser/shoulda_let)
|
data/lib/shoulda/let.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "shoulda"
|
2
|
+
|
3
|
+
Shoulda::Context.class_eval do
|
4
|
+
def let(name, &block)
|
5
|
+
@let ||= {}
|
6
|
+
if block
|
7
|
+
@let[name] = block
|
8
|
+
else
|
9
|
+
@let.fetch(name){ parent.let(name) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Shoulda::InstanceMethods.class_eval do
|
15
|
+
def let(name)
|
16
|
+
@let ||= {}
|
17
|
+
@let.fetch(name) do
|
18
|
+
@let[name] = instance_exec(&@shoulda_context.let(name))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/shoulda-let.gemspec
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
name = "shoulda-let"
|
2
|
+
|
3
|
+
Gem::Specification.new name, "0.0.1" do |s|
|
4
|
+
s.summary = "A simple let for shoulda"
|
5
|
+
s.authors = ["Michael Grosser"]
|
6
|
+
s.email = "michael@grosser.it"
|
7
|
+
s.homepage = "http://github.com/grosser/#{name}"
|
8
|
+
s.files = `git ls-files`.split("\n")
|
9
|
+
s.license = "MIT"
|
10
|
+
s.add_runtime_dependency "shoulda"
|
11
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
require "shoulda/let"
|
4
|
+
|
5
|
+
class ShouldaLetTest < Test::Unit::TestCase
|
6
|
+
context "Readme" do
|
7
|
+
example = File.read(File.expand_path("../../Readme.md", __FILE__)).match(/<!-- example -->(.*)<!-- example -->/m)[1]
|
8
|
+
eval example
|
9
|
+
end
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shoulda-let
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michael Grosser
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: shoulda
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description:
|
31
|
+
email: michael@grosser.it
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- .travis.yml
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- Rakefile
|
40
|
+
- Readme.md
|
41
|
+
- lib/shoulda/let.rb
|
42
|
+
- shoulda-let.gemspec
|
43
|
+
- test/shoulda_let_test.rb
|
44
|
+
homepage: http://github.com/grosser/shoulda-let
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
hash: -2456576844475002993
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
hash: -2456576844475002993
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.8.24
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: A simple let for shoulda
|
75
|
+
test_files: []
|