remarkable_rails 3.0.7 → 3.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ * Ensure set_cookies and set_session work with arrays [#55]
2
+
1
3
  * Added set_cookies matcher [#51]
2
4
 
3
5
  * Add a helper to declare that a XmlHttpRequest should be performed:
@@ -15,14 +15,23 @@ module Remarkable
15
15
  #
16
16
  # On Rails 2.3.2:
17
17
  #
18
- # 1. Convert :to values to string, unless it's nil
18
+ # 1. Return nil if nil, join when array or convert to string;
19
19
  # 2. Convert all keys to string.
20
20
  #
21
21
  before_assert do
22
- if @subject.request.env.key?("rack.input")
23
- @options[:to] = @options[:to].to_s if @options.key?(:to) && !@options[:to].nil?
24
- else
25
- @options[:to] = @options[:to] ? [@options[:to]] : [] if @options.key?(:to)
22
+ if @options.key?(:to)
23
+ if @subject.request.env.key?("rack.input")
24
+ @options[:to] = case @options[:to]
25
+ when nil
26
+ nil
27
+ when Array
28
+ @options[:to].join('&')
29
+ else
30
+ @options[:to].to_s
31
+ end
32
+ else
33
+ @options[:to] = @options[:to] ? Array(@options[:to]) : []
34
+ end
26
35
  end
27
36
 
28
37
  @keys.collect!(&:to_s)
@@ -44,7 +44,7 @@ module Remarkable
44
44
  #
45
45
  def is_equal_value?
46
46
  return true unless value_to_compare?
47
- assert_contains(session[@key], @options[:to])
47
+ assert_contains([session[@key]], @options[:to])
48
48
  end
49
49
 
50
50
  def session
@@ -30,7 +30,7 @@ describe 'set_cookies' do
30
30
  @matcher.failure_message.should == 'Expected cookie user to be set, got {}'
31
31
  end
32
32
 
33
- if RAILS_VERSION =~ /^2.1/ || RAILS_VERSION =~ /^2.2/
33
+ if RAILS_VERSION =~ /^2.(1|2)/
34
34
  it 'should set contains_value? message' do
35
35
  build_response { cookies[:user] = 10 }
36
36
  @matcher = set_cookies.to(1)
@@ -63,10 +63,11 @@ describe 'set_cookies' do
63
63
  before(:each) do
64
64
  build_response {
65
65
  cookies[:user] = 'jose'
66
- cookies[:address] = 'Avenue'
67
66
  cookies[:true] = true
68
67
  cookies[:false] = false
69
- cookies[:nil] = nil
68
+ cookies[:nil] = nil
69
+ cookies[:array] = [1,2]
70
+ cookies[:date] = Date.today
70
71
  }
71
72
  end
72
73
 
@@ -96,17 +97,26 @@ describe 'set_cookies' do
96
97
 
97
98
  it { should set_cookies(:nil) }
98
99
  it { should set_cookies(:nil).to(nil) }
99
- it { should_not set_cookies(:nil).to(true) }
100
+ it { should_not set_cookies(:nil).to(true) }
101
+
102
+ it { should set_cookies(:array) }
103
+ it { should set_cookies(:array).to([1,2]) }
104
+ it { should_not set_cookies(:array).to([2,1]) }
105
+
106
+ it { should set_cookies(:date) }
107
+ it { should set_cookies(:date).to(Date.today) }
108
+ it { should_not set_cookies(:date).to(Date.today + 1) }
100
109
  end
101
110
 
102
111
  describe 'macro' do
103
112
  before(:each) do
104
113
  build_response {
105
114
  cookies[:user] = 'jose'
106
- cookies[:address] = 'Avenue'
107
115
  cookies[:true] = true
108
116
  cookies[:false] = false
109
- cookies[:nil] = nil
117
+ cookies[:nil] = nil
118
+ cookies[:array] = [1,2]
119
+ cookies[:date] = Date.today
110
120
  }
111
121
  end
112
122
 
@@ -136,7 +146,15 @@ describe 'set_cookies' do
136
146
 
137
147
  should_set_cookies :nil
138
148
  should_set_cookies :nil, :to => nil
139
- should_not_set_cookies :nil, :to => true
149
+ should_not_set_cookies :nil, :to => true
150
+
151
+ should_set_cookies :array
152
+ should_set_cookies :array, :to => [1,2]
153
+ should_not_set_cookies :array, :to => [2,1]
154
+
155
+ should_set_cookies :date
156
+ should_set_cookies :date, :to => Date.today
157
+ should_not_set_cookies :date, :to => (Date.today + 1)
140
158
  end
141
159
 
142
160
  describe 'with no parameter' do
@@ -48,10 +48,11 @@ describe 'set_session' do
48
48
  before(:each) do
49
49
  build_response {
50
50
  session[:user] = 'jose'
51
- session[:address] = 'Avenue'
52
51
  session[:true] = true
53
52
  session[:false] = false
54
- session[:nil] = nil
53
+ session[:nil] = nil
54
+ session[:array] = [1,2]
55
+ session[:date] = Date.today
55
56
  }
56
57
  end
57
58
 
@@ -81,17 +82,26 @@ describe 'set_session' do
81
82
 
82
83
  it { should set_session(:nil) }
83
84
  it { should set_session(:nil).to(nil) }
84
- it { should_not set_session(:nil).to(true) }
85
+ it { should_not set_session(:nil).to(true) }
86
+
87
+ it { should set_session(:array) }
88
+ it { should set_session(:array).to([1,2]) }
89
+ it { should_not set_session(:array).to([2,1]) }
90
+
91
+ it { should set_session(:date) }
92
+ it { should set_session(:date).to(Date.today) }
93
+ it { should_not set_session(:date).to(Date.today + 1) }
85
94
  end
86
95
 
87
96
  describe 'macro' do
88
97
  before(:each) do
89
98
  build_response {
90
99
  session[:user] = 'jose'
91
- session[:address] = 'Avenue'
92
100
  session[:true] = true
93
101
  session[:false] = false
94
- session[:nil] = nil
102
+ session[:nil] = nil
103
+ session[:array] = [1,2]
104
+ session[:date] = Date.today
95
105
  }
96
106
  end
97
107
 
@@ -121,7 +131,15 @@ describe 'set_session' do
121
131
 
122
132
  should_set_session :nil
123
133
  should_set_session :nil, :to => nil
124
- should_not_set_session :nil, :to => true
134
+ should_not_set_session :nil, :to => true
135
+
136
+ should_set_session :array
137
+ should_set_session :array, :to => [1,2]
138
+ should_not_set_session :array, :to => [2,1]
139
+
140
+ should_set_session :date
141
+ should_set_session :date, :to => Date.today
142
+ should_not_set_session :date, :to => (Date.today + 1)
125
143
  end
126
144
 
127
145
  describe 'with no parameter' do
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'ruby-debug'
3
3
 
4
4
  RAILS_ENV = 'test'
5
- RAILS_VERSION = ENV['RAILS_VERSION'] || '=2.2.2'
5
+ RAILS_VERSION = ENV['RAILS_VERSION'] || '2.2.2'
6
6
  RSPEC_VERSION = ENV['RSPEC_VERSION'] || Spec::VERSION::STRING
7
7
 
8
8
  # Load Rails
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remarkable_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Brando
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-04-22 00:00:00 +02:00
13
+ date: 2009-04-24 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 3.0.7
34
+ version: 3.0.8
35
35
  version:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: remarkable_activerecord
@@ -41,7 +41,7 @@ dependencies:
41
41
  requirements:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: 3.0.7
44
+ version: 3.0.8
45
45
  version:
46
46
  description: "Remarkable Rails: collection of matchers and macros with I18n for Rails"
47
47
  email:
@@ -60,13 +60,9 @@ files:
60
60
  - LICENSE
61
61
  - CHANGELOG
62
62
  - lib/remarkable_rails.rb
63
- - lib/remarkable_rails
64
- - lib/remarkable_rails/action_view
65
63
  - lib/remarkable_rails/action_view/base.rb
66
- - lib/remarkable_rails/action_controller
67
64
  - lib/remarkable_rails/action_controller/macro_stubs.rb
68
65
  - lib/remarkable_rails/action_controller/base.rb
69
- - lib/remarkable_rails/action_controller/matchers
70
66
  - lib/remarkable_rails/action_controller/matchers/route_matcher.rb
71
67
  - lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb
72
68
  - lib/remarkable_rails/action_controller/matchers/set_session_matcher.rb
@@ -82,6 +78,8 @@ files:
82
78
  - locale/en.yml
83
79
  has_rdoc: true
84
80
  homepage: http://github.com/carlosbrando/remarkable
81
+ licenses: []
82
+
85
83
  post_install_message:
86
84
  rdoc_options: []
87
85
 
@@ -102,24 +100,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
100
  requirements: []
103
101
 
104
102
  rubyforge_project: remarkable
105
- rubygems_version: 1.3.1
103
+ rubygems_version: 1.3.2
106
104
  signing_key:
107
- specification_version: 2
105
+ specification_version: 3
108
106
  summary: "Remarkable Rails: collection of matchers and macros with I18n for Rails"
109
107
  test_files:
110
- - spec/application
111
- - spec/application/examples
112
108
  - spec/application/examples/new.html.erb
113
109
  - spec/application/examples/example.xml.builder
114
110
  - spec/application/examples/_example.html.erb
115
111
  - spec/application/examples/example.html.erb
116
112
  - spec/application/application.rb
117
- - spec/application/projects
118
113
  - spec/application/projects/new.html.erb
119
- - spec/application/layouts
120
114
  - spec/application/layouts/examples.html.erb
121
115
  - spec/application/tasks_controller.rb
122
- - spec/action_controller
123
116
  - spec/action_controller/macro_stubs_spec.rb
124
117
  - spec/action_controller/assign_to_matcher_spec.rb
125
118
  - spec/action_controller/set_cookies_matcher_spec.rb