thoughtbot-shoulda 2.10.0 → 2.10.1
Sign up to get free protection for your applications and to get access to all the features.
data/lib/shoulda.rb
CHANGED
@@ -26,7 +26,7 @@ module Shoulda # :nodoc:
|
|
26
26
|
|
27
27
|
def matches?(controller)
|
28
28
|
@controller = controller
|
29
|
-
assigned_value? && assigned_correct_value?
|
29
|
+
(assigned_value? && assigned_correct_value?) || cleared_value?
|
30
30
|
end
|
31
31
|
|
32
32
|
def failure_message
|
@@ -39,7 +39,7 @@ module Shoulda # :nodoc:
|
|
39
39
|
|
40
40
|
def description
|
41
41
|
description = "set session variable #{@key.inspect}"
|
42
|
-
description << " to #{@value.inspect}" if @value
|
42
|
+
description << " to #{@value.inspect}" if defined?(@value)
|
43
43
|
description
|
44
44
|
end
|
45
45
|
|
@@ -49,6 +49,10 @@ module Shoulda # :nodoc:
|
|
49
49
|
!assigned_value.blank?
|
50
50
|
end
|
51
51
|
|
52
|
+
def cleared_value?
|
53
|
+
defined?(@value) && @value.nil? && assigned_value.nil?
|
54
|
+
end
|
55
|
+
|
52
56
|
def assigned_correct_value?
|
53
57
|
return true if @value.nil?
|
54
58
|
assigned_value == @value
|
@@ -69,11 +69,20 @@ class PostsControllerTest < Test::Unit::TestCase
|
|
69
69
|
should_respond_with_content_type 'application/rss+xml'
|
70
70
|
should_respond_with_content_type :rss
|
71
71
|
should_respond_with_content_type /rss/
|
72
|
-
|
72
|
+
context "deprecated" do # to avoid redefining a test
|
73
|
+
should_return_from_session :special, "'$2 off your next purchase'"
|
74
|
+
end
|
75
|
+
should_fail do
|
76
|
+
should_return_from_session :special, "'not special'"
|
77
|
+
end
|
78
|
+
should_set_session(:mischief) { nil }
|
79
|
+
should_return_from_session :malarky, "nil"
|
73
80
|
should_set_session :special, "'$2 off your next purchase'"
|
74
81
|
should_set_session :special_user_id, '@user.id'
|
75
|
-
|
76
|
-
|
82
|
+
context "with a block" do
|
83
|
+
should_set_session(:special_user_id) { @user.id }
|
84
|
+
end
|
85
|
+
should_fail do # to avoid redefining a test
|
77
86
|
should_set_session(:special_user_id) { 'value' }
|
78
87
|
end
|
79
88
|
should_assign_to :user, :posts
|
@@ -83,7 +92,9 @@ class PostsControllerTest < Test::Unit::TestCase
|
|
83
92
|
context "viewing a post on GET to #show" do
|
84
93
|
setup { get :show, :user_id => users(:first), :id => posts(:first) }
|
85
94
|
should_render_with_layout 'wide'
|
86
|
-
|
95
|
+
context "with a symbol" do # to avoid redefining a test
|
96
|
+
should_render_with_layout :wide
|
97
|
+
end
|
87
98
|
should_assign_to :false_flag
|
88
99
|
end
|
89
100
|
|
@@ -22,6 +22,10 @@ class SetSessionMatcherTest < Test::Unit::TestCase # :nodoc:
|
|
22
22
|
should "reject assigning to another variable" do
|
23
23
|
assert_rejects set_session(:other), @controller
|
24
24
|
end
|
25
|
+
|
26
|
+
should "accept assigning nil to another variable" do
|
27
|
+
assert_accepts set_session(:other).to(nil), @controller
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thoughtbot-shoulda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.
|
4
|
+
version: 2.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tammer Saleh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-05 00:00:00 -08:00
|
13
13
|
default_executable: convert_to_should_syntax
|
14
14
|
dependencies: []
|
15
15
|
|