rspec-rails 3.0.2 → 3.1.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +17 -0
- data/README.md +7 -7
- data/lib/generators/rspec.rb +10 -6
- data/lib/generators/rspec/controller/templates/controller_spec.rb +1 -1
- data/lib/generators/rspec/install/install_generator.rb +19 -2
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +13 -4
- data/lib/generators/rspec/integration/templates/request_spec.rb +1 -1
- data/lib/generators/rspec/job/job_generator.rb +12 -0
- data/lib/generators/rspec/job/templates/job_spec.rb.erb +7 -0
- data/lib/generators/rspec/model/model_generator.rb +18 -5
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +107 -100
- data/lib/rspec-rails.rb +1 -1
- data/lib/rspec/rails.rb +1 -0
- data/lib/rspec/rails/adapters.rb +9 -7
- data/lib/rspec/rails/configuration.rb +2 -3
- data/lib/rspec/rails/example/controller_example_group.rb +172 -149
- data/lib/rspec/rails/example/feature_example_group.rb +25 -23
- data/lib/rspec/rails/example/helper_example_group.rb +27 -25
- data/lib/rspec/rails/example/mailer_example_group.rb +26 -22
- data/lib/rspec/rails/example/model_example_group.rb +8 -6
- data/lib/rspec/rails/example/request_example_group.rb +19 -17
- data/lib/rspec/rails/example/routing_example_group.rb +40 -38
- data/lib/rspec/rails/example/view_example_group.rb +140 -137
- data/lib/rspec/rails/extensions/active_record/proxy.rb +0 -1
- data/lib/rspec/rails/feature_check.rb +35 -0
- data/lib/rspec/rails/fixture_support.rb +1 -1
- data/lib/rspec/rails/matchers.rb +5 -2
- data/lib/rspec/rails/matchers/be_a_new.rb +68 -64
- data/lib/rspec/rails/matchers/be_new_record.rb +24 -20
- data/lib/rspec/rails/matchers/be_valid.rb +38 -34
- data/lib/rspec/rails/matchers/have_http_status.rb +340 -334
- data/lib/rspec/rails/matchers/have_rendered.rb +35 -32
- data/lib/rspec/rails/matchers/redirect_to.rb +30 -27
- data/lib/rspec/rails/matchers/routing_matchers.rb +103 -101
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_assigns.rb +1 -2
- data/lib/rspec/rails/view_rendering.rb +6 -8
- metadata +16 -13
- metadata.gz.sig +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7082373e70e8e1b7a77e4a29acde414d3a0f88d
|
4
|
+
data.tar.gz: 0a6fd867ecf7f7d201e2b6f8d3ebaaef7357b6bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edae3eef56dee24c9ef3b6aa78e971ac353c83058a38a9bbc05efb7da6cd8ed00b89f4add64f54c5d606cf88b4df8ba0846d9315f966b4dc0709583bf51b1b50
|
7
|
+
data.tar.gz: ac61c06796d8788ba676bb95d1ee3551b727e4757e1b78c2bbecfdba86551fb4bfbc9d141c594f42a03ed6c8008009dea09237ea1ba2b75d3440a809ad2256c6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
### 3.1.0 / 2014-09-04
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.0.2...v3.1.0)
|
3
|
+
|
4
|
+
Enhancements:
|
5
|
+
|
6
|
+
* Switch to using the `have_http_status` matcher in spec generators. (Aaron Kromer, #1086)
|
7
|
+
* Update `rails_helper` generator to allow users to opt-in to auto-loading
|
8
|
+
`spec/support` files instead of forcing it upon them. (Aaron Kromer, #1137)
|
9
|
+
* Include generator for `ActiveJob`. (Abdelkader Boudih, #1155)
|
10
|
+
* Improve support for non-ActiveRecord apps by not loading ActiveRecord related
|
11
|
+
settings in the generated `rails_helper`. (Aaron Kromer, #1150)
|
12
|
+
* Remove Ruby warnings as a suggested configuration. (Aaron Kromer, #1163)
|
13
|
+
|
14
|
+
Bug Fixes:
|
15
|
+
|
16
|
+
* Fix controller route lookup for Rails 4.2. (Tomohiro Hashidate, #1142)
|
17
|
+
|
1
18
|
### 3.0.2 / 2014-07-21
|
2
19
|
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.0.1...v3.0.2)
|
3
20
|
|
data/README.md
CHANGED
@@ -102,7 +102,7 @@ Use model specs to describe behavior of models (usually ActiveRecord-based) in
|
|
102
102
|
the application.
|
103
103
|
|
104
104
|
Model specs default to residing in the `spec/models` folder. Tagging any
|
105
|
-
context with the metadata `:type => :model` treats
|
105
|
+
context with the metadata `:type => :model` treats its examples as model
|
106
106
|
specs.
|
107
107
|
|
108
108
|
For example:
|
@@ -128,7 +128,7 @@ specs](https://www.relishapp.com/rspec/rspec-rails/docs/model-specs).
|
|
128
128
|
Use controller specs to describe behavior of Rails controllers.
|
129
129
|
|
130
130
|
Controller specs default to residing in the `spec/controllers` folder. Tagging
|
131
|
-
any context with the metadata `:type => :controller` treats
|
131
|
+
any context with the metadata `:type => :controller` treats its examples as
|
132
132
|
controller specs.
|
133
133
|
|
134
134
|
For example:
|
@@ -177,7 +177,7 @@ end using a black box approach.
|
|
177
177
|
|
178
178
|
Request specs default to residing in the `spec/requests`, `spec/api`, and
|
179
179
|
`spec/integration` directories. Tagging any context with the metadata `:type =>
|
180
|
-
:request` treats
|
180
|
+
:request` treats its examples as request specs.
|
181
181
|
|
182
182
|
Request specs mix in behavior from
|
183
183
|
[ActionDispatch::Integration::Runner](http://api.rubyonrails.org/classes/ActionDispatch/Integration/Runner.html),
|
@@ -247,7 +247,7 @@ Feature specs test your application from the outside by simulating a browser.
|
|
247
247
|
simulated browser.
|
248
248
|
|
249
249
|
Feature specs default to residing in the `spec/features` folder. Tagging any
|
250
|
-
context with the metadata `:type => :feature` treats
|
250
|
+
context with the metadata `:type => :feature` treats its examples as feature
|
251
251
|
specs.
|
252
252
|
|
253
253
|
Feature specs mix in functionality from the capybara gem, thus they require
|
@@ -263,7 +263,7 @@ specs](https://www.relishapp.com/rspec/rspec-rails/v/3-0/docs/feature-specs/feat
|
|
263
263
|
## View specs
|
264
264
|
|
265
265
|
View specs default to residing in the `spec/views` folder. Tagging any context
|
266
|
-
with the metadata `:type => :view` treats
|
266
|
+
with the metadata `:type => :view` treats its examples as view specs.
|
267
267
|
|
268
268
|
View specs mix in `ActionView::TestCase::Behavior`.
|
269
269
|
|
@@ -370,7 +370,7 @@ expect(rendered).to xxx
|
|
370
370
|
## Routing specs
|
371
371
|
|
372
372
|
Routing specs default to residing in the `spec/routing` folder. Tagging any
|
373
|
-
context with the metadata `:type => :routing` treats
|
373
|
+
context with the metadata `:type => :routing` treats its examples as routing
|
374
374
|
specs.
|
375
375
|
|
376
376
|
```ruby
|
@@ -399,7 +399,7 @@ instead.
|
|
399
399
|
## Helper specs
|
400
400
|
|
401
401
|
Helper specs default to residing in the `spec/helpers` folder. Tagging any
|
402
|
-
context with the metadata `:type => :helper` treats
|
402
|
+
context with the metadata `:type => :helper` treats its examples as helper
|
403
403
|
specs.
|
404
404
|
|
405
405
|
Helper specs mix in ActionView::TestCase::Behavior. A `helper` object is
|
data/lib/generators/rspec.rb
CHANGED
@@ -7,8 +7,12 @@ module Rspec
|
|
7
7
|
module Generators
|
8
8
|
# @private
|
9
9
|
class Base < ::Rails::Generators::NamedBase
|
10
|
-
def self.source_root
|
11
|
-
|
10
|
+
def self.source_root(path = nil)
|
11
|
+
if path
|
12
|
+
@_rspec_source_root = path
|
13
|
+
else
|
14
|
+
@_rspec_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'rspec', generator_name, 'templates'))
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
if ::Rails::VERSION::STRING < '3.1'
|
@@ -27,10 +31,10 @@ module Rails
|
|
27
31
|
class GeneratedAttribute
|
28
32
|
def input_type
|
29
33
|
@input_type ||= if type == :text
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
"textarea"
|
35
|
+
else
|
36
|
+
"input"
|
37
|
+
end
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "rspec/support"
|
2
2
|
require "rspec/core"
|
3
3
|
RSpec::Support.require_rspec_core "project_initializer"
|
4
|
+
require "rspec/rails/feature_check"
|
4
5
|
|
5
6
|
module Rspec
|
6
7
|
module Generators
|
7
8
|
# @private
|
8
9
|
class InstallGenerator < ::Rails::Generators::Base
|
9
|
-
|
10
10
|
desc <<DESC
|
11
11
|
Description:
|
12
12
|
Copy rspec files to your application.
|
@@ -36,11 +36,28 @@ DESC
|
|
36
36
|
:report_stream => StringIO.new
|
37
37
|
)
|
38
38
|
initializer.run
|
39
|
-
|
39
|
+
|
40
|
+
spec_helper_path = File.join(tmpdir, 'spec', 'spec_helper.rb')
|
41
|
+
|
42
|
+
replace_generator_command(spec_helper_path)
|
43
|
+
remove_warnings_configuration(spec_helper_path)
|
44
|
+
end
|
45
|
+
|
46
|
+
def replace_generator_command(spec_helper_path)
|
47
|
+
gsub_file spec_helper_path,
|
40
48
|
'rspec --init',
|
41
49
|
'rails generate rspec:install',
|
42
50
|
:verbose => false
|
43
51
|
end
|
52
|
+
|
53
|
+
def remove_warnings_configuration(spec_helper_path)
|
54
|
+
empty_line = '^\n'
|
55
|
+
comment_line = '^\s*#.+\n'
|
56
|
+
gsub_file spec_helper_path,
|
57
|
+
/#{empty_line}(#{comment_line})+\s+config\.warnings = true\n/,
|
58
|
+
'',
|
59
|
+
:verbose => false
|
60
|
+
end
|
44
61
|
end
|
45
62
|
end
|
46
63
|
end
|
@@ -3,6 +3,7 @@ ENV["RAILS_ENV"] ||= 'test'
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require File.expand_path("../../config/environment", __FILE__)
|
5
5
|
require 'rspec/rails'
|
6
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
6
7
|
|
7
8
|
# Requires supporting ruby files with custom matchers and macros, etc, in
|
8
9
|
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
@@ -11,20 +12,27 @@ require 'rspec/rails'
|
|
11
12
|
# run twice. It is recommended that you do not name files matching this glob to
|
12
13
|
# end with _spec.rb. You can configure this pattern with the --pattern
|
13
14
|
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
14
|
-
|
15
|
+
#
|
16
|
+
# The following line is provided for convenience purposes. It has the downside
|
17
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
18
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
19
|
+
# require only the support files necessary.
|
20
|
+
#
|
21
|
+
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
15
22
|
|
16
|
-
<% if ::Rails::
|
23
|
+
<% if RSpec::Rails::FeatureCheck.can_maintain_test_schema? -%>
|
17
24
|
# Checks for pending migrations before tests are run.
|
18
25
|
# If you are not using ActiveRecord, you can remove this line.
|
19
26
|
ActiveRecord::Migration.maintain_test_schema!
|
20
27
|
|
21
|
-
<% elsif ::Rails::
|
28
|
+
<% elsif RSpec::Rails::FeatureCheck.can_check_pending_migrations? -%>
|
22
29
|
# Checks for pending migrations before tests are run.
|
23
30
|
# If you are not using ActiveRecord, you can remove this line.
|
24
|
-
ActiveRecord::Migration.check_pending!
|
31
|
+
ActiveRecord::Migration.check_pending!
|
25
32
|
|
26
33
|
<% end -%>
|
27
34
|
RSpec.configure do |config|
|
35
|
+
<% if RSpec::Rails::FeatureCheck.has_active_record? -%>
|
28
36
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
29
37
|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
30
38
|
|
@@ -33,6 +41,7 @@ RSpec.configure do |config|
|
|
33
41
|
# instead of true.
|
34
42
|
config.use_transactional_fixtures = true
|
35
43
|
|
44
|
+
<% end -%>
|
36
45
|
# RSpec Rails can automatically mix in different behaviours to your tests
|
37
46
|
# based on their file location, for example enabling you to call `get` and
|
38
47
|
# `post` in specs under `spec/controllers`.
|
@@ -4,7 +4,7 @@ RSpec.describe "<%= class_name.pluralize %>", :type => :request do
|
|
4
4
|
describe "GET /<%= table_name %>" do
|
5
5
|
it "works! (now write some real specs)" do
|
6
6
|
get <%= index_helper %>_path
|
7
|
-
expect(response
|
7
|
+
expect(response).to have_http_status(200)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -4,19 +4,32 @@ module Rspec
|
|
4
4
|
module Generators
|
5
5
|
# @private
|
6
6
|
class ModelGenerator < Base
|
7
|
-
argument :attributes,
|
7
|
+
argument :attributes,
|
8
|
+
:type => :array,
|
9
|
+
:default => [],
|
10
|
+
:banner => "field:type field:type"
|
8
11
|
class_option :fixture, :type => :boolean
|
9
12
|
|
10
13
|
def create_model_spec
|
11
|
-
|
14
|
+
template_file = File.join(
|
15
|
+
'spec/models',
|
16
|
+
class_path,
|
17
|
+
"#{file_name}_spec.rb"
|
18
|
+
)
|
19
|
+
template 'model_spec.rb', template_file
|
12
20
|
end
|
13
21
|
|
14
22
|
hook_for :fixture_replacement
|
15
23
|
|
16
24
|
def create_fixture_file
|
17
|
-
|
18
|
-
|
19
|
-
|
25
|
+
return unless missing_fixture_replacement?
|
26
|
+
template 'fixtures.yml', File.join('spec/fixtures', "#{table_name}.yml")
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def missing_fixture_replacement?
|
32
|
+
options[:fixture] && options[:fixture_replacement].nil?
|
20
33
|
end
|
21
34
|
end
|
22
35
|
end
|
@@ -21,8 +21,12 @@ module Rspec
|
|
21
21
|
def generate_controller_spec
|
22
22
|
return unless options[:controller_specs]
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
template_file = File.join(
|
25
|
+
'spec/controllers',
|
26
|
+
controller_class_path,
|
27
|
+
"#{controller_file_name}_controller_spec.rb"
|
28
|
+
)
|
29
|
+
template 'controller_spec.rb', template_file
|
26
30
|
end
|
27
31
|
|
28
32
|
def generate_view_specs
|
@@ -37,123 +41,126 @@ module Rspec
|
|
37
41
|
def generate_routing_spec
|
38
42
|
return unless options[:routing_specs]
|
39
43
|
|
40
|
-
|
41
|
-
|
44
|
+
template_file = File.join(
|
45
|
+
'spec/routing',
|
46
|
+
controller_class_path,
|
47
|
+
"#{controller_file_name}_routing_spec.rb"
|
48
|
+
)
|
49
|
+
template 'routing_spec.rb', template_file
|
42
50
|
end
|
43
51
|
|
44
52
|
hook_for :integration_tool, :as => :integration
|
45
53
|
|
46
|
-
|
54
|
+
protected
|
47
55
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
def formatted_hash(hash)
|
54
|
-
formatted = hash.inspect
|
55
|
-
formatted.gsub!("{", "{ ")
|
56
|
-
formatted.gsub!("}", " }")
|
57
|
-
formatted.gsub!("=>", " => ")
|
58
|
-
formatted
|
59
|
-
end
|
56
|
+
def copy_view(view)
|
57
|
+
template "#{view}_spec.rb",
|
58
|
+
File.join("spec/views", controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
|
59
|
+
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
def formatted_hash(hash)
|
62
|
+
formatted = hash.inspect
|
63
|
+
formatted.gsub!("{", "{ ")
|
64
|
+
formatted.gsub!("}", " }")
|
65
|
+
formatted.gsub!("=>", " => ")
|
66
|
+
formatted
|
67
|
+
end
|
65
68
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
69
|
+
# support for namespaced-resources
|
70
|
+
def ns_file_name
|
71
|
+
ns_parts.empty? ? file_name : "#{ns_parts[0].underscore}_#{ns_parts[1].singularize.underscore}"
|
72
|
+
end
|
70
73
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
74
|
+
# support for namespaced-resources
|
75
|
+
def ns_table_name
|
76
|
+
ns_parts.empty? ? table_name : "#{ns_parts[0].underscore}/#{ns_parts[1].tableize}"
|
77
|
+
end
|
77
78
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
# mock_file_name(:save => true)
|
85
|
-
# #=> mock_user(:save => true)
|
86
|
-
#
|
87
|
-
# If another ORM is being used and another method instead of save is
|
88
|
-
# called, it will be the one used.
|
89
|
-
#
|
90
|
-
def mock_file_name(hash=nil)
|
91
|
-
if hash
|
92
|
-
method, and_return = hash.to_a.first
|
93
|
-
method = orm_instance.send(method).split('.').last.gsub(/\(.*?\)/, '')
|
94
|
-
"mock_#{ns_file_name}(:#{method} => #{and_return})"
|
95
|
-
else
|
96
|
-
"mock_#{ns_file_name}"
|
97
|
-
end
|
98
|
-
end
|
79
|
+
def ns_parts
|
80
|
+
@ns_parts ||= begin
|
81
|
+
matches = ARGV[0].to_s.match(/\A(\w+)(?:\/|::)(\w+)/)
|
82
|
+
matches ? [matches[1], matches[2]] : []
|
83
|
+
end
|
84
|
+
end
|
99
85
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
86
|
+
# Returns the name of the mock. For example, if the file name is user,
|
87
|
+
# it returns mock_user.
|
88
|
+
#
|
89
|
+
# If a hash is given, it uses the hash key as the ORM method and the
|
90
|
+
# value as response. So, for ActiveRecord and file name "User":
|
91
|
+
#
|
92
|
+
# mock_file_name(:save => true)
|
93
|
+
# #=> mock_user(:save => true)
|
94
|
+
#
|
95
|
+
# If another ORM is being used and another method instead of save is
|
96
|
+
# called, it will be the one used.
|
97
|
+
#
|
98
|
+
def mock_file_name(hash = nil)
|
99
|
+
if hash
|
100
|
+
method, and_return = hash.to_a.first
|
101
|
+
method = orm_instance.send(method).split('.').last.gsub(/\(.*?\)/, '')
|
102
|
+
"mock_#{ns_file_name}(:#{method} => #{and_return})"
|
103
|
+
else
|
104
|
+
"mock_#{ns_file_name}"
|
112
105
|
end
|
106
|
+
end
|
113
107
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
108
|
+
# Receives the ORM chain and convert to expects. For ActiveRecord:
|
109
|
+
#
|
110
|
+
# should! orm_class.find(User, "37")
|
111
|
+
# #=> User.should_receive(:find).with(37)
|
112
|
+
#
|
113
|
+
# For Datamapper:
|
114
|
+
#
|
115
|
+
# should! orm_class.find(User, "37")
|
116
|
+
# #=> User.should_receive(:get).with(37)
|
117
|
+
#
|
118
|
+
def should_receive(chain)
|
119
|
+
stub_or_should_chain(:should_receive, chain)
|
120
|
+
end
|
127
121
|
|
128
|
-
|
129
|
-
|
130
|
-
|
122
|
+
# Receives the ORM chain and convert to stub. For ActiveRecord:
|
123
|
+
#
|
124
|
+
# stub orm_class.find(User, "37")
|
125
|
+
# #=> User.stub(:find).with(37)
|
126
|
+
#
|
127
|
+
# For Datamapper:
|
128
|
+
#
|
129
|
+
# stub orm_class.find(User, "37")
|
130
|
+
# #=> User.stub(:get).with(37)
|
131
|
+
#
|
132
|
+
def stub(chain)
|
133
|
+
stub_or_should_chain(:stub, chain)
|
134
|
+
end
|
131
135
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
end
|
136
|
+
def stub_or_should_chain(mode, chain)
|
137
|
+
receiver, method = chain.split(".")
|
138
|
+
method.gsub!(/\((.*?)\)/, '')
|
136
139
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
+
response = "#{receiver}.#{mode}(:#{method})"
|
141
|
+
response << ".with(#{$1})" unless $1.blank?
|
142
|
+
response
|
143
|
+
end
|
140
144
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
attribute.name.titleize
|
145
|
-
when :integer
|
146
|
-
@attribute_id_map ||= {}
|
147
|
-
@attribute_id_map[attribute] ||= @attribute_id_map.keys.size.next
|
148
|
-
else
|
149
|
-
attribute.default
|
150
|
-
end
|
151
|
-
end
|
145
|
+
def value_for(attribute)
|
146
|
+
raw_value_for(attribute).inspect
|
147
|
+
end
|
152
148
|
|
153
|
-
|
154
|
-
|
149
|
+
def raw_value_for(attribute)
|
150
|
+
case attribute.type
|
151
|
+
when :string
|
152
|
+
attribute.name.titleize
|
153
|
+
when :integer
|
154
|
+
@attribute_id_map ||= {}
|
155
|
+
@attribute_id_map[attribute] ||= @attribute_id_map.keys.size.next
|
156
|
+
else
|
157
|
+
attribute.default
|
155
158
|
end
|
159
|
+
end
|
156
160
|
|
161
|
+
def banner
|
162
|
+
self.class.banner
|
163
|
+
end
|
157
164
|
end
|
158
165
|
end
|
159
166
|
end
|