rspec-situations 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -5
- data/README.md +10 -4
- data/lib/rspec/situations/class_extensions.rb +10 -1
- data/lib/rspec/situations/version.rb +2 -2
- metadata +1 -1
data/Gemfile
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
|
3
4
|
gemspec
|
4
5
|
|
6
|
+
|
5
7
|
gem 'rake'
|
6
8
|
gem 'rspec'
|
7
9
|
gem 'bundler'
|
8
|
-
gem 'growl'
|
9
|
-
gem 'debugger'
|
10
|
-
gem 'guard'
|
11
|
-
gem 'guard-bundler'
|
12
|
-
gem 'guard-rspec'
|
13
10
|
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem 'growl'
|
14
|
+
gem 'debugger'
|
15
|
+
gem 'guard'
|
16
|
+
gem 'guard-bundler'
|
17
|
+
gem 'guard-rspec'
|
18
|
+
end
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/brett-richardson/rspec-situations.png?branch=master)](https://travis-ci.org/brett-richardson/rspec-situations)
|
2
|
+
|
1
3
|
Using Rspec Situations
|
2
4
|
======================
|
3
5
|
|
@@ -16,16 +18,20 @@ describe Apple do
|
|
16
18
|
subject( :apple ){ create :apple }
|
17
19
|
|
18
20
|
situation( :bought ){ subject.bought_by = create :user }
|
19
|
-
situation( :red ){ subject.color = :
|
21
|
+
situation( :red ){ subject.color = :red }
|
20
22
|
|
21
|
-
situation( :
|
23
|
+
situation( :one_yr_old, 'a year old' ){ subject.created_at = 1.years.ago } # With optional description
|
22
24
|
|
23
|
-
describe_situation :
|
25
|
+
describe_situation :bought, :red do
|
24
26
|
it{ should be_tasty }
|
25
27
|
end
|
26
28
|
|
27
|
-
describe_situation :
|
29
|
+
describe_situation :bought, :one_yr_old, 'bought a year ago' do # With optional description
|
28
30
|
it{ should_not be_tasty }
|
29
31
|
end
|
32
|
+
|
33
|
+
describe_situation :bought, :one_yr_old do
|
34
|
+
it{ should_not be_tasty }
|
35
|
+
end
|
30
36
|
end
|
31
37
|
```
|
@@ -42,7 +42,15 @@ module RSpec::Situations
|
|
42
42
|
|
43
43
|
# Combine each situation's description into a string
|
44
44
|
def _rsits_describe_name( *keys )
|
45
|
-
|
45
|
+
hash = _rsits *keys
|
46
|
+
|
47
|
+
'when ' + keys.map do |key|
|
48
|
+
if hash[key]
|
49
|
+
hash[key].description
|
50
|
+
else # Fall back to simple key.to_s if the situation isn't found
|
51
|
+
key
|
52
|
+
end
|
53
|
+
end.join( ' and ' )
|
46
54
|
end
|
47
55
|
|
48
56
|
|
@@ -53,6 +61,7 @@ module RSpec::Situations
|
|
53
61
|
|
54
62
|
def _rsits_combined_hash
|
55
63
|
_rsits_hash # TODO: Combine with parents, not needed until you want parent and local situations to interact directly with each other.
|
64
|
+
# FIXME: How do we access previous contexts from here?
|
56
65
|
end
|
57
66
|
|
58
67
|
|