Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

update to rspec-rails 2.14 #951

Merged
merged 1 commit into from

2 participants

@twalpole
Collaborator

This updates to latest rspec-rails and fixes all deprecations

@justinfrench justinfrench merged commit bdc68e1 into justinfrench:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 11, 2013
  1. @twalpole

    update to rspec-rails 2.14

    twalpole authored
This page is out of date. Refresh to see the latest.
Showing with 453 additions and 444 deletions.
  1. +2 −2 formtastic.gemspec
  2. +3 −3 spec/actions/generic_action_spec.rb
  3. +7 −7 spec/builder/custom_builder_spec.rb
  4. +8 −8 spec/builder/semantic_fields_for_spec.rb
  5. +6 −6 spec/generators/formtastic/form/form_generator_spec.rb
  6. +11 −11 spec/helpers/action_helper_spec.rb
  7. +2 −2 spec/helpers/form_helper_spec.rb
  8. +44 −44 spec/helpers/input_helper_spec.rb
  9. +30 −30 spec/helpers/inputs_helper_spec.rb
  10. +12 −12 spec/helpers/semantic_errors_helper_spec.rb
  11. +5 −5 spec/i18n_spec.rb
  12. +4 −4 spec/inputs/boolean_input_spec.rb
  13. +9 −9 spec/inputs/check_boxes_input_spec.rb
  14. +5 −5 spec/inputs/country_input_spec.rb
  15. +1 −1  spec/inputs/custom_input_spec.rb
  16. +4 −4 spec/inputs/date_picker_input_spec.rb
  17. +4 −4 spec/inputs/datetime_picker_input_spec.rb
  18. +3 −3 spec/inputs/hidden_input_spec.rb
  19. +2 −2 spec/inputs/include_blank_spec.rb
  20. +36 −36 spec/inputs/number_input_spec.rb
  21. +5 −5 spec/inputs/radio_input_spec.rb
  22. +19 −19 spec/inputs/range_input_spec.rb
  23. +20 −20 spec/inputs/select_input_spec.rb
  24. +2 −2 spec/inputs/string_input_spec.rb
  25. +4 −4 spec/inputs/time_picker_input_spec.rb
  26. +1 −1  spec/localizer_spec.rb
  27. +196 −187 spec/spec_helper.rb
  28. +8 −8 spec/support/custom_macros.rb
View
4 formtastic.gemspec
@@ -26,14 +26,14 @@ Gem::Specification.new do |s|
s.add_dependency(%q<actionpack>, [">= 3.0"])
s.add_development_dependency(%q<nokogiri>, ["< 1.6.0"]) # 1.6 requires Ruby 1.9.2, drop in v3.0
- s.add_development_dependency(%q<rspec-rails>, ["~> 2.12.0"])
+ s.add_development_dependency(%q<rspec-rails>, ["~> 2.14.0"])
s.add_development_dependency(%q<rspec_tag_matchers>, [">= 1.0.0"])
s.add_development_dependency(%q<hpricot>, ["~> 0.8.3"])
s.add_development_dependency(%q<BlueCloth>) # for YARD
s.add_development_dependency(%q<yard>, ["~> 0.6"])
s.add_development_dependency(%q<colored>)
s.add_development_dependency(%q<tzinfo>)
- s.add_development_dependency(%q<ammeter>, ["0.2.5"])
+ s.add_development_dependency(%q<ammeter>)
s.add_development_dependency(%q<appraisal>)
s.add_development_dependency(%q<rake>)
s.add_development_dependency(%q<activemodel>)
View
6 spec/actions/generic_action_spec.rb
@@ -244,7 +244,7 @@ def to_html
describe 'when used on a new record' do
before do
- @new_post.stub!(:new_record?).and_return(true)
+ @new_post.stub(:new_record?).and_return(true)
end
describe 'when explicit label is provided' do
@@ -344,7 +344,7 @@ def to_html
describe 'when used on an existing record' do
before do
- @new_post.stub!(:persisted?).and_return(true)
+ @new_post.stub(:persisted?).and_return(true)
end
describe 'when explicit label is provided' do
@@ -466,7 +466,7 @@ def self.human_name
end
@new_user_post = ::UserPost.new
- @new_user_post.stub!(:new_record?).and_return(true)
+ @new_user_post.stub(:new_record?).and_return(true)
concat(semantic_form_for(@new_user_post, :url => '') do |builder|
concat(builder.action(:submit, :as => :generic))
concat(builder.action(:reset, :as => :generic))
View
14 spec/builder/custom_builder_spec.rb
@@ -47,7 +47,7 @@ def to_html
describe "when using a custom builder" do
before do
- @new_post.stub!(:title)
+ @new_post.stub(:title)
Formtastic::Helpers::FormHelper.builder = MyCustomFormBuilder
end
@@ -72,9 +72,9 @@ def to_html
# See: https://github.com/justinfrench/formtastic/issues/657
it "should not conflict with navigasmic" do
- stub!(:builder).and_return('navigasmic')
-
- lambda { semantic_form_for(@new_post) }.should_not raise_error(NoMethodError)
+ self.class.any_instance.stub(:builder).and_return('navigasmic')
+
+ lambda { semantic_form_for(@new_post) { |f| } }.should_not raise_error
end
end
@@ -82,8 +82,8 @@ def to_html
describe "fields_for" do
it "should yield an instance of the parent form builder" do
- @new_post.stub!(:comment).and_return([@fred])
- @new_post.stub!(:comment_attributes=)
+ @new_post.stub(:comment).and_return([@fred])
+ @new_post.stub(:comment_attributes=)
semantic_form_for(@new_post, :builder => MyCustomFormBuilder) do |builder|
builder.class.should.kind_of?(MyCustomFormBuilder)
@@ -102,7 +102,7 @@ def to_html
describe "fields_for" do
it "should yield an instance of the parent form builder" do
- @new_post.stub!(:author_attributes=)
+ @new_post.stub(:author_attributes=)
semantic_form_for(@new_post, :builder => MyCustomFormBuilder) do |builder|
builder.fields_for(:author) do |nested_builder|
nested_builder.class.should.kind_of?(MyCustomFormBuilder)
View
16 spec/builder/semantic_fields_for_spec.rb
@@ -8,7 +8,7 @@
before do
@output_buffer = ''
mock_everything
- @new_post.stub!(:author).and_return(::Author.new)
+ @new_post.stub(:author).and_return(::Author.new)
end
context 'outside a form_for block' do
@@ -77,7 +77,7 @@
end
it 'should sanitize html id for li tag' do
- @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
+ @bob.stub(:column_for_attribute).and_return(double('column', :type => :string, :limit => 255))
concat(semantic_form_for(@new_post) do |builder|
concat(builder.semantic_fields_for(@bob, :index => 1) do |nested_builder|
concat(nested_builder.inputs(:login))
@@ -90,7 +90,7 @@
end
it 'should use namespace provided in nested fields' do
- @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
+ @bob.stub(:column_for_attribute).and_return(double('column', :type => :string, :limit => 255))
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
concat(builder.semantic_fields_for(@bob, :index => 1) do |nested_builder|
concat(nested_builder.inputs(:login))
@@ -100,9 +100,9 @@
end
it 'should render errors on the nested inputs' do
- @errors = mock('errors')
- @errors.stub!(:[]).with(errors_matcher(:login)).and_return(['oh noes'])
- @bob.stub!(:errors).and_return(@errors)
+ @errors = double('errors')
+ @errors.stub(:[]).with(errors_matcher(:login)).and_return(['oh noes'])
+ @bob.stub(:errors).and_return(@errors)
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
concat(builder.semantic_fields_for(@bob) do |nested_builder|
@@ -120,8 +120,8 @@
output_buffer.replace ''
@fred.posts.size.should == 1
- @fred.posts.first.stub!(:persisted?).and_return(true)
- @fred.stub!(:posts_attributes=)
+ @fred.posts.first.stub(:persisted?).and_return(true)
+ @fred.stub(:posts_attributes=)
concat(semantic_form_for(@fred) do |builder|
concat(builder.semantic_fields_for(:posts) do |nested_builder|
concat(nested_builder.input(:id, :as => :hidden))
View
12 spec/generators/formtastic/form/form_generator_spec.rb
@@ -14,11 +14,11 @@
@output_buffer = ''
prepare_destination
mock_everything
- ::Post.stub!(:reflect_on_all_associations).with(:belongs_to).and_return([
- mock('reflection', :name => :author, :options => {}, :klass => ::Author, :macro => :belongs_to),
- mock('reflection', :name => :reviewer, :options => {:class_name => 'Author'}, :klass => ::Author, :macro => :belongs_to),
- mock('reflection', :name => :main_post, :options => {}, :klass => ::Post, :macro => :belongs_to),
- mock('reflection', :name => :attachment, :options => {:polymorphic => true}, :macro => :belongs_to),
+ ::Post.stub(:reflect_on_all_associations).with(:belongs_to).and_return([
+ double('reflection', :name => :author, :options => {}, :klass => ::Author, :macro => :belongs_to),
+ double('reflection', :name => :reviewer, :options => {:class_name => 'Author'}, :klass => ::Author, :macro => :belongs_to),
+ double('reflection', :name => :main_post, :options => {}, :klass => ::Post, :macro => :belongs_to),
+ double('reflection', :name => :attachment, :options => {:polymorphic => true}, :macro => :belongs_to),
])
end
@@ -34,7 +34,7 @@
describe 'with existing model' do
it 'should not raise an exception' do
- lambda { run_generator %w(Post) }.should_not raise_error(Thor::RequiredArgumentMissingError)
+ lambda { run_generator %w(Post) }.should_not raise_error
end
end
View
22 spec/helpers/action_helper_spec.rb
@@ -53,7 +53,7 @@
it 'should call the corresponding action class with .to_html' do
[:input, :button, :link].each do |action_style|
semantic_form_for(:project, :url => "http://test.host") do |builder|
- action_instance = mock('Action instance')
+ action_instance = double('Action instance')
action_class = "#{action_style.to_s}_action".classify
action_constant = "Formtastic::Actions::#{action_class}".constantize
@@ -99,7 +99,7 @@
# it 'should render a label with localized text and not apply the label_str_method' do
# with_config :label_str_method, :reverse do
# @localized_label_text = 'Localized title'
- # @new_post.stub!(:meta_description)
+ # @new_post.stub(:meta_description)
# ::I18n.backend.store_translations :en,
# :formtastic => {
# :labels => {
@@ -132,7 +132,7 @@
#
# describe 'and object is given' do
# it 'should delegate the label logic to class human attribute name and pass it down to the label tag' do
- # @new_post.stub!(:meta_description) # a two word method name
+ # @new_post.stub(:meta_description) # a two word method name
# @new_post.class.should_receive(:human_attribute_name).with('meta_description').and_return('meta_description'.humanize)
#
# concat(semantic_form_for(@new_post) do |builder|
@@ -145,7 +145,7 @@
# describe 'and object is given with label_str_method set to :capitalize' do
# it 'should capitalize method name, passing it down to the label tag' do
# with_config :label_str_method, :capitalize do
- # @new_post.stub!(:meta_description)
+ # @new_post.stub(:meta_description)
#
# concat(semantic_form_for(@new_post) do |builder|
# concat(builder.input(:meta_description))
@@ -266,7 +266,7 @@
context 'when a customized top-level class does not exist' do
it 'should instantiate the Formtastic action' do
- action = mock('action', :to_html => 'some HTML')
+ action = double('action', :to_html => 'some HTML')
Formtastic::Actions::ButtonAction.should_receive(:new).and_return(action)
concat(semantic_form_for(@new_post) do |builder|
builder.action(:commit, :as => :button)
@@ -280,7 +280,7 @@
class ::ButtonAction < Formtastic::Actions::ButtonAction
end
- action = mock('action', :to_html => 'some HTML')
+ action = double('action', :to_html => 'some HTML')
Formtastic::Actions::ButtonAction.should_not_receive(:new)
::ButtonAction.should_receive(:new).and_return(action)
@@ -330,31 +330,31 @@ class ::ButtonAction < Formtastic::Actions::ButtonAction
concat(semantic_form_for(@new_post) do |builder|
concat(builder.action(:cancel, :as => :link))
end)
- }.should_not raise_error(Formtastic::UnsupportedMethodForAction)
+ }.should_not raise_error
lambda {
concat(semantic_form_for(@new_post) do |builder|
concat(builder.action(:submit, :as => :input))
end)
- }.should_not raise_error(Formtastic::UnsupportedMethodForAction)
+ }.should_not raise_error
lambda {
concat(semantic_form_for(@new_post) do |builder|
concat(builder.action(:submit, :as => :button))
end)
- }.should_not raise_error(Formtastic::UnsupportedMethodForAction)
+ }.should_not raise_error
lambda {
concat(semantic_form_for(@new_post) do |builder|
concat(builder.action(:reset, :as => :input))
end)
- }.should_not raise_error(Formtastic::UnsupportedMethodForAction)
+ }.should_not raise_error
lambda {
concat(semantic_form_for(@new_post) do |builder|
concat(builder.action(:reset, :as => :button))
end)
- }.should_not raise_error(Formtastic::UnsupportedMethodForAction)
+ }.should_not raise_error
end
end
View
4 spec/helpers/form_helper_spec.rb
@@ -142,7 +142,7 @@
end
end
- describe ActionView::Base.field_error_proc do
+ describe 'ActionView::Base.field_error_proc' do
it 'is set to no-op wrapper by default' do
semantic_form_for(@new_post, :url => '/hello') do |builder|
::ActionView::Base.field_error_proc.call("html", nil).should == "html"
@@ -150,7 +150,7 @@
end
it 'is set to the configured custom field_error_proc' do
- field_error_proc = mock()
+ field_error_proc = double()
Formtastic::Helpers::FormHelper.field_error_proc = field_error_proc
semantic_form_for(@new_post, :url => '/hello') do |builder|
::ActionView::Base.field_error_proc.should == field_error_proc
View
88 spec/helpers/input_helper_spec.rb
@@ -9,9 +9,9 @@
@output_buffer = ''
mock_everything
- @errors = mock('errors')
- @errors.stub!(:[]).and_return([])
- @new_post.stub!(:errors).and_return(@errors)
+ @errors = double('errors')
+ @errors.stub(:[]).and_return([])
+ @new_post.stub(:errors).and_return(@errors)
end
after do
@@ -72,7 +72,7 @@
end
it 'should set and "optional" class also when there is presence validator' do
- @new_post.class.should_receive(:validators_on).with(:title).any_number_of_times.and_return([
+ @new_post.class.should_receive(:validators_on).with(:title).at_least(:once).and_return([
active_model_presence_validator([:title])
])
concat(semantic_form_for(@new_post) do |builder|
@@ -112,20 +112,20 @@
describe 'and an object with :validators_on was given (ActiveModel, Active Resource)' do
before do
- @new_post.stub!(:class).and_return(::PostModel)
+ @new_post.stub(:class).and_return(::PostModel)
end
after do
- @new_post.stub!(:class).and_return(::Post)
+ @new_post.stub(:class).and_return(::Post)
end
describe 'and validates_presence_of was called for the method' do
it 'should be required' do
- @new_post.class.should_receive(:validators_on).with(:title).any_number_of_times.and_return([
+ @new_post.class.should_receive(:validators_on).with(:title).at_least(:once).and_return([
active_model_presence_validator([:title])
])
- @new_post.class.should_receive(:validators_on).with(:body).any_number_of_times.and_return([
+ @new_post.class.should_receive(:validators_on).with(:body).at_least(:once).and_return([
active_model_presence_validator([:body], {:if => true})
])
@@ -139,7 +139,7 @@
it 'should be required when there is :on => :create option on create' do
with_config :required_string, " required yo!" do
- @new_post.class.should_receive(:validators_on).with(:title).any_number_of_times.and_return([
+ @new_post.class.should_receive(:validators_on).with(:title).at_least(:once).and_return([
active_model_presence_validator([:title], {:on => :create})
])
concat(semantic_form_for(@new_post) do |builder|
@@ -152,7 +152,7 @@
it 'should be required when there is :on => :save option on create' do
with_config :required_string, " required yo!" do
- @new_post.class.should_receive(:validators_on).with(:title).any_number_of_times.and_return([
+ @new_post.class.should_receive(:validators_on).with(:title).at_least(:once).and_return([
active_model_presence_validator([:title], {:on => :save})
])
concat(semantic_form_for(@new_post) do |builder|
@@ -165,7 +165,7 @@
it 'should be required when there is :on => :save option on update' do
with_config :required_string, " required yo!" do
- @fred.class.should_receive(:validators_on).with(:login).any_number_of_times.and_return([
+ @fred.class.should_receive(:validators_on).with(:login).at_least(:once).and_return([
active_model_presence_validator([:login], {:on => :save})
])
concat(semantic_form_for(@fred) do |builder|
@@ -177,7 +177,7 @@
end
it 'should not be required when there is :on => :create option on update' do
- @fred.class.should_receive(:validators_on).with(:login).any_number_of_times.and_return([
+ @fred.class.should_receive(:validators_on).with(:login).at_least(:once).and_return([
active_model_presence_validator([:login], {:on => :create})
])
concat(semantic_form_for(@fred) do |builder|
@@ -188,7 +188,7 @@
end
it 'should not be required when there is :on => :update option on create' do
- @new_post.class.should_receive(:validators_on).with(:title).any_number_of_times.and_return([
+ @new_post.class.should_receive(:validators_on).with(:title).at_least(:once).and_return([
active_model_presence_validator([:title], {:on => :update})
])
concat(semantic_form_for(@new_post) do |builder|
@@ -241,14 +241,14 @@
describe 'and validates_inclusion_of was called for the method' do
it 'should be required' do
- @new_post.class.should_receive(:validators_on).with(:published).any_number_of_times.and_return([
+ @new_post.class.should_receive(:validators_on).with(:published).at_least(:once).and_return([
active_model_inclusion_validator([:published], {:in => [false, true]})
])
should_be_required(:tag => :published, :required => true)
end
it 'should not be required if allow_blank is true' do
- @new_post.class.should_receive(:validators_on).with(:published).any_number_of_times.and_return([
+ @new_post.class.should_receive(:validators_on).with(:published).at_least(:once).and_return([
active_model_inclusion_validator([:published], {:in => [false, true], :allow_blank => true})
])
should_be_required(:tag => :published, :required => false)
@@ -282,13 +282,13 @@
end
def add_presence_validator(options)
- @new_post.class.stub!(:validators_on).with(options[:tag]).and_return([
+ @new_post.class.stub(:validators_on).with(options[:tag]).and_return([
active_model_presence_validator([options[:tag]], options[:options])
])
end
def add_length_validator(options)
- @new_post.class.should_receive(:validators_on).with(options[:tag]).any_number_of_times {[
+ @new_post.class.should_receive(:validators_on).with(options[:tag]).at_least(:once) {[
active_model_length_validator([options[:tag]], options[:options])
]}
end
@@ -377,32 +377,32 @@ def length_should_be_required(options)
end
it 'should default to a string for methods on objects that don\'t respond to "column_for_attribute"' do
- @new_post.stub!(:method_without_a_database_column)
- @new_post.stub!(:column_for_attribute).and_return(nil)
+ @new_post.stub(:method_without_a_database_column)
+ @new_post.stub(:column_for_attribute).and_return(nil)
default_input_type(nil, :method_without_a_database_column).should == :string
end
it 'should default to :password for methods that don\'t have a column in the database but "password" is in the method name' do
- @new_post.stub!(:password_method_without_a_database_column)
- @new_post.stub!(:column_for_attribute).and_return(nil)
+ @new_post.stub(:password_method_without_a_database_column)
+ @new_post.stub(:column_for_attribute).and_return(nil)
default_input_type(nil, :password_method_without_a_database_column).should == :password
end
it 'should default to :password for methods on objects that don\'t respond to "column_for_attribute" but "password" is in the method name' do
- @new_post.stub!(:password_method_without_a_database_column)
- @new_post.stub!(:column_for_attribute).and_return(nil)
+ @new_post.stub(:password_method_without_a_database_column)
+ @new_post.stub(:column_for_attribute).and_return(nil)
default_input_type(nil, :password_method_without_a_database_column).should == :password
end
it 'should default to :number for "integer" column with name ending in "_id"' do
- @new_post.stub!(:aws_instance_id)
- @new_post.stub!(:column_for_attribute).with(:aws_instance_id).and_return(mock('column', :type => :integer))
+ @new_post.stub(:aws_instance_id)
+ @new_post.stub(:column_for_attribute).with(:aws_instance_id).and_return(double('column', :type => :integer))
default_input_type(:integer, :aws_instance_id).should == :number
end
it 'should default to :select for associations' do
- @new_post.class.stub!(:reflect_on_association).with(:user_id).and_return(mock('ActiveRecord::Reflection::AssociationReflection'))
- @new_post.class.stub!(:reflect_on_association).with(:section_id).and_return(mock('ActiveRecord::Reflection::AssociationReflection'))
+ @new_post.class.stub(:reflect_on_association).with(:user_id).and_return(double('ActiveRecord::Reflection::AssociationReflection'))
+ @new_post.class.stub(:reflect_on_association).with(:section_id).and_return(double('ActiveRecord::Reflection::AssociationReflection'))
default_input_type(:integer, :user_id).should == :select
default_input_type(:integer, :section_id).should == :select
end
@@ -473,11 +473,11 @@ def length_should_be_required(options)
describe 'defaulting to file column' do
Formtastic::FormBuilder.file_methods.each do |method|
it "should default to :file for attributes that respond to ##{method}" do
- column = mock('column')
+ column = double('column')
Formtastic::FormBuilder.file_methods.each do |test|
### TODO: Check if this is ok
- column.stub!(method).with(test).and_return(method == test)
+ column.stub(method).with(test).and_return(method == test)
end
@new_post.should_receive(method).and_return(column)
@@ -493,10 +493,10 @@ def length_should_be_required(options)
it 'should call the corresponding input class with .to_html' do
[:select, :time_zone, :radio, :date_select, :datetime_select, :time_select, :boolean, :check_boxes, :hidden, :string, :password, :number, :text, :file].each do |input_style|
- @new_post.stub!(:generic_column_name)
- @new_post.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
+ @new_post.stub(:generic_column_name)
+ @new_post.stub(:column_for_attribute).and_return(double('column', :type => :string, :limit => 255))
semantic_form_for(@new_post) do |builder|
- input_instance = mock('Input instance')
+ input_instance = double('Input instance')
input_class = "#{input_style.to_s}_input".classify
input_constant = "Formtastic::Inputs::#{input_class}".constantize
@@ -542,7 +542,7 @@ def length_should_be_required(options)
it 'should render a label with localized text and not apply the label_str_method' do
with_config :label_str_method, :reverse do
@localized_label_text = 'Localized title'
- @new_post.stub!(:meta_description)
+ @new_post.stub(:meta_description)
::I18n.backend.store_translations :en,
:formtastic => {
:labels => {
@@ -575,7 +575,7 @@ def length_should_be_required(options)
describe 'and object is given' do
it 'should delegate the label logic to class human attribute name and pass it down to the label tag' do
- @new_post.stub!(:meta_description) # a two word method name
+ @new_post.stub(:meta_description) # a two word method name
@new_post.class.should_receive(:human_attribute_name).with('meta_description').and_return('meta_description'.humanize)
concat(semantic_form_for(@new_post) do |builder|
@@ -588,7 +588,7 @@ def length_should_be_required(options)
describe 'and object is given with label_str_method set to :capitalize' do
it 'should capitalize method name, passing it down to the label tag' do
with_config :label_str_method, :capitalize do
- @new_post.stub!(:meta_description)
+ @new_post.stub(:meta_description)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:meta_description))
@@ -838,15 +838,15 @@ def length_should_be_required(options)
describe ':collection option' do
it "should be required on polymorphic associations" do
- @new_post.stub!(:commentable)
- @new_post.class.stub!(:reflections).and_return({
- :commentable => mock('macro_reflection', :options => { :polymorphic => true }, :macro => :belongs_to)
+ @new_post.stub(:commentable)
+ @new_post.class.stub(:reflections).and_return({
+ :commentable => double('macro_reflection', :options => { :polymorphic => true }, :macro => :belongs_to)
})
- @new_post.stub!(:column_for_attribute).with(:commentable).and_return(
- mock('column', :type => :integer)
+ @new_post.stub(:column_for_attribute).with(:commentable).and_return(
+ double('column', :type => :integer)
)
- @new_post.class.stub!(:reflect_on_association).with(:commentable).and_return(
- mock('reflection', :macro => :belongs_to, :options => { :polymorphic => true })
+ @new_post.class.stub(:reflect_on_association).with(:commentable).and_return(
+ double('reflection', :macro => :belongs_to, :options => { :polymorphic => true })
)
expect {
concat(semantic_form_for(@new_post) do |builder|
@@ -892,7 +892,7 @@ def length_should_be_required(options)
context 'when a customized top-level class does not exist' do
it 'should instantiate the Formtastic input' do
- input = mock('input', :to_html => 'some HTML')
+ input = double('input', :to_html => 'some HTML')
Formtastic::Inputs::StringInput.should_receive(:new).and_return(input)
concat(semantic_form_for(@new_post) do |builder|
builder.input(:title, :as => :string)
@@ -906,7 +906,7 @@ def length_should_be_required(options)
class ::StringInput < Formtastic::Inputs::StringInput
end
- input = mock('input', :to_html => 'some HTML')
+ input = double('input', :to_html => 'some HTML')
Formtastic::Inputs::StringInput.should_not_receive(:new)
::StringInput.should_receive(:new).and_return(input)
View
60 spec/helpers/inputs_helper_spec.rb
@@ -56,13 +56,13 @@
describe 'when a :for option is provided' do
before do
- @new_post.stub!(:respond_to?).and_return(true, true)
- @new_post.stub!(:respond_to?).with(:empty?).and_return(false)
- @new_post.stub!(:author).and_return(@bob)
+ @new_post.stub(:respond_to?).and_return(true, true)
+ @new_post.stub(:respond_to?).with(:empty?).and_return(false)
+ @new_post.stub(:author).and_return(@bob)
end
it 'should render nested inputs' do
- @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
+ @bob.stub(:column_for_attribute).and_return(double('column', :type => :string, :limit => 255))
concat(semantic_form_for(@new_post) do |builder|
inputs = builder.inputs :for => [:author, @bob] do |bob_builder|
@@ -75,7 +75,7 @@
end
it 'should concat rendered nested inputs to the template' do
- @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
+ @bob.stub(:column_for_attribute).and_return(double('column', :type => :string, :limit => 255))
concat(semantic_form_for(@new_post) do |builder|
builder.inputs :for => [:author, @bob] do |bob_builder|
@@ -104,8 +104,8 @@
describe "as a symbol representing a has_many association name" do
before do
- @new_post.stub!(:authors).and_return([@bob, @fred])
- @new_post.stub!(:authors_attributes=)
+ @new_post.stub(:authors).and_return([@bob, @fred])
+ @new_post.stub(:authors_attributes=)
end
it 'should nest the inputs with a fieldset, legend and :name input for each item' do
@@ -177,7 +177,7 @@
end
it 'should pass options down to semantic_fields_for' do
- @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
+ @bob.stub(:column_for_attribute).and_return(double('column', :type => :string, :limit => 255))
concat(semantic_form_for(@new_post) do |builder|
inputs = builder.inputs :for => [:author, @bob], :for_options => { :index => 10 } do |bob_builder|
@@ -341,17 +341,17 @@
describe 'without a block' do
before do
- ::Post.stub!(:reflections).and_return({:author => mock('reflection', :options => {}, :macro => :belongs_to),
- :comments => mock('reflection', :options => {}, :macro => :has_many) })
+ ::Post.stub(:reflections).and_return({:author => double('reflection', :options => {}, :macro => :belongs_to),
+ :comments => double('reflection', :options => {}, :macro => :has_many) })
- @new_post.stub!(:title)
- @new_post.stub!(:body)
- @new_post.stub!(:author_id)
+ @new_post.stub(:title)
+ @new_post.stub(:body)
+ @new_post.stub(:author_id)
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :string, :limit => 255))
- @new_post.stub!(:column_for_attribute).with(:body).and_return(mock('column', :type => :text))
- @new_post.stub!(:column_for_attribute).with(:created_at).and_return(mock('column', :type => :datetime))
- @new_post.stub!(:column_for_attribute).with(:author).and_return(nil)
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :string, :limit => 255))
+ @new_post.stub(:column_for_attribute).with(:body).and_return(double('column', :type => :text))
+ @new_post.stub(:column_for_attribute).with(:created_at).and_return(double('column', :type => :datetime))
+ @new_post.stub(:column_for_attribute).with(:author).and_return(nil)
end
describe 'with no args (quick forms syntax)' do
@@ -402,12 +402,12 @@
context "with a polymorphic association" do
before do
- @new_post.stub!(:commentable)
- @new_post.class.stub!(:reflections).and_return({
- :commentable => mock('macro_reflection', :options => { :polymorphic => true }, :macro => :belongs_to)
+ @new_post.stub(:commentable)
+ @new_post.class.stub(:reflections).and_return({
+ :commentable => double('macro_reflection', :options => { :polymorphic => true }, :macro => :belongs_to)
})
- @new_post.stub!(:column_for_attribute).with(:commentable).and_return(
- mock('column', :type => :integer)
+ @new_post.stub(:column_for_attribute).with(:commentable).and_return(
+ double('column', :type => :integer)
)
end
@@ -447,15 +447,15 @@
context "with a polymorphic association" do
it 'should raise an error for polymorphic associations (the collection class cannot be guessed)' do
- @new_post.stub!(:commentable)
- @new_post.class.stub!(:reflections).and_return({
- :commentable => mock('macro_reflection', :options => { :polymorphic => true }, :macro => :belongs_to)
+ @new_post.stub(:commentable)
+ @new_post.class.stub(:reflections).and_return({
+ :commentable => double('macro_reflection', :options => { :polymorphic => true }, :macro => :belongs_to)
})
- @new_post.stub!(:column_for_attribute).with(:commentable).and_return(
- mock('column', :type => :integer)
+ @new_post.stub(:column_for_attribute).with(:commentable).and_return(
+ double('column', :type => :integer)
)
- @new_post.class.stub!(:reflect_on_association).with(:commentable).and_return(
- mock('reflection', :macro => :belongs_to, :options => { :polymorphic => true })
+ @new_post.class.stub(:reflect_on_association).with(:commentable).and_return(
+ double('reflection', :macro => :belongs_to, :options => { :polymorphic => true })
)
expect {
@@ -472,7 +472,7 @@
describe 'when a :for option is provided' do
describe 'and an object is given' do
it 'should render nested inputs' do
- @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
+ @bob.stub(:column_for_attribute).and_return(double('column', :type => :string, :limit => 255))
concat(semantic_form_for(@new_post) do |builder|
concat(builder.inputs(:login, :for => @bob))
end)
View
24 spec/helpers/semantic_errors_helper_spec.rb
@@ -11,13 +11,13 @@
@title_errors = ['must not be blank', 'must be awesome']
@base_errors = ['base error message', 'nasty error']
@base_error = 'one base error'
- @errors = mock('errors')
- @new_post.stub!(:errors).and_return(@errors)
+ @errors = double('errors')
+ @new_post.stub(:errors).and_return(@errors)
end
describe 'when there is only one error on base' do
before do
- @errors.stub!(:[]).with(errors_matcher(:base)).and_return(@base_error)
+ @errors.stub(:[]).with(errors_matcher(:base)).and_return(@base_error)
end
it 'should render an unordered list' do
@@ -29,7 +29,7 @@
describe 'when there is more than one error on base' do
before do
- @errors.stub!(:[]).with(errors_matcher(:base)).and_return(@base_errors)
+ @errors.stub(:[]).with(errors_matcher(:base)).and_return(@base_errors)
end
it 'should render an unordered list' do
@@ -44,8 +44,8 @@
describe 'when there are errors on title' do
before do
- @errors.stub!(:[]).with(errors_matcher(:title)).and_return(@title_errors)
- @errors.stub!(:[]).with(errors_matcher(:base)).and_return([])
+ @errors.stub(:[]).with(errors_matcher(:title)).and_return(@title_errors)
+ @errors.stub(:[]).with(errors_matcher(:base)).and_return([])
end
it 'should render an unordered list' do
@@ -58,8 +58,8 @@
describe 'when there are errors on title and base' do
before do
- @errors.stub!(:[]).with(errors_matcher(:title)).and_return(@title_errors)
- @errors.stub!(:[]).with(errors_matcher(:base)).and_return(@base_error)
+ @errors.stub(:[]).with(errors_matcher(:title)).and_return(@title_errors)
+ @errors.stub(:[]).with(errors_matcher(:base)).and_return(@base_error)
end
it 'should render an unordered list' do
@@ -73,8 +73,8 @@
describe 'when there are no errors' do
before do
- @errors.stub!(:[]).with(errors_matcher(:title)).and_return(nil)
- @errors.stub!(:[]).with(errors_matcher(:base)).and_return(nil)
+ @errors.stub(:[]).with(errors_matcher(:title)).and_return(nil)
+ @errors.stub(:[]).with(errors_matcher(:base)).and_return(nil)
end
it 'should return nil' do
@@ -86,7 +86,7 @@
describe 'when there is one error on base and options with class is passed' do
before do
- @errors.stub!(:[]).with(errors_matcher(:base)).and_return(@base_error)
+ @errors.stub(:[]).with(errors_matcher(:base)).and_return(@base_error)
end
it 'should render an unordered list with given class' do
@@ -98,7 +98,7 @@
describe 'when :base is passed in as an argument' do
before do
- @errors.stub!(:[]).with(errors_matcher(:base)).and_return(@base_error)
+ @errors.stub(:[]).with(errors_matcher(:base)).and_return(@base_error)
end
it 'should ignore :base and only render base errors once' do
View
10 spec/i18n_spec.rb
@@ -6,12 +6,12 @@
FORMTASTIC_KEYS = [:required, :yes, :no, :create, :update].freeze
it "should be defined" do
- lambda { Formtastic::I18n }.should_not raise_error(::NameError)
+ lambda { Formtastic::I18n }.should_not raise_error
end
describe "default translations" do
it "should be defined" do
- lambda { Formtastic::I18n::DEFAULT_VALUES }.should_not raise_error(::NameError)
+ lambda { Formtastic::I18n::DEFAULT_VALUES }.should_not raise_error
Formtastic::I18n::DEFAULT_VALUES.is_a?(::Hash).should == true
end
@@ -98,8 +98,8 @@
}
}}
- @new_post.stub!(:title)
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :string, :limit => 255))
+ @new_post.stub(:title)
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :string, :limit => 255))
end
after do
@@ -108,7 +108,7 @@
it "lookup scopes should be defined" do
with_config :i18n_lookups_by_default, true do
- lambda { Formtastic::I18n::SCOPES }.should_not raise_error(::NameError)
+ lambda { Formtastic::I18n::SCOPES }.should_not raise_error
end
end
View
8 spec/inputs/boolean_input_spec.rb
@@ -98,7 +98,7 @@
end
it 'should generate a checked input if object.method returns checked value' do
- @new_post.stub!(:allow_comments).and_return('yes')
+ @new_post.stub(:allow_comments).and_return('yes')
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'yes', :unchecked_value => 'no'))
@@ -108,7 +108,7 @@
end
it 'should not generate a checked input if object.method returns unchecked value' do
- @new_post.stub!(:allow_comments).and_return('no')
+ @new_post.stub(:allow_comments).and_return('no')
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'yes', :unchecked_value => 'no'))
@@ -118,7 +118,7 @@
end
it 'should generate a checked input if object.method returns checked value' do
- @new_post.stub!(:allow_comments).and_return('yes')
+ @new_post.stub(:allow_comments).and_return('yes')
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'yes', :unchecked_value => 'no'))
@@ -128,7 +128,7 @@
end
it 'should not generate a checked input if object.method returns unchecked value' do
- @new_post.stub!(:allow_comments).and_return('no')
+ @new_post.stub(:allow_comments).and_return('no')
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'yes', :unchecked_value => 'no'))
View
18 spec/inputs/check_boxes_input_spec.rb
@@ -194,7 +194,7 @@
describe "no disabled items" do
before do
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :check_boxes, :disabled => nil))
@@ -208,7 +208,7 @@
describe "single disabled item" do
before do
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :check_boxes, :disabled => @fred.id))
@@ -224,7 +224,7 @@
describe "multiple disabled items" do
before do
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :check_boxes, :disabled => [@bob.id, @fred.id]))
@@ -247,7 +247,7 @@
before do
::I18n.backend.store_translations :en, :formtastic => { :labels => { :post => { :authors => "Translated!" }}}
with_config :i18n_lookups_by_default, true do
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :check_boxes))
end)
@@ -266,7 +266,7 @@
describe "when :label option is set" do
before do
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :check_boxes, :label => 'The authors'))
end)
@@ -280,7 +280,7 @@
describe "when :label option is false" do
before do
@output_buffer = ''
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :check_boxes, :label => false))
end)
@@ -298,7 +298,7 @@
describe "when :required option is true" do
before do
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :check_boxes, :required => true))
end)
@@ -344,9 +344,9 @@
end
it 'to set the right input value' do
- item = mock('item')
+ item = double('item')
item.should_not_receive(:id)
- item.stub!(:custom_value).and_return('custom_value')
+ item.stub(:custom_value).and_return('custom_value')
item.should_receive(:custom_value).exactly(3).times
@new_post.author.should_receive(:custom_value).exactly(1).times
concat(semantic_form_for(@new_post) do |builder|
View
10 spec/inputs/country_input_spec.rb
@@ -26,7 +26,7 @@
before do
concat(semantic_form_for(@new_post) do |builder|
- builder.stub!(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
+ builder.stub(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
concat(builder.input(:country, :as => :country))
end)
end
@@ -55,7 +55,7 @@
it "should be passed down to the country_select helper when provided" do
priority_countries = ["Foo", "Bah"]
semantic_form_for(@new_post) do |builder|
- builder.stub!(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
+ builder.stub(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
builder.should_receive(:country_select).with(:country, priority_countries, {}, {:id => "post_country", :required => false, :autofocus => false}).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
concat(builder.input(:country, :as => :country, :priority_countries => priority_countries))
@@ -68,7 +68,7 @@
priority_countries.should_not be_nil
semantic_form_for(@new_post) do |builder|
- builder.stub!(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
+ builder.stub(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
builder.should_receive(:country_select).with(:country, priority_countries, {}, {:id => "post_country", :required => false, :autofocus => false}).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
concat(builder.input(:country, :as => :country))
@@ -84,7 +84,7 @@
mock_everything
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
- builder.stub!(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
+ builder.stub(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
builder.should_receive(:country_select).with(:country, [], {}, {:id => "context2_post_country", :required => false, :autofocus => false}).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
concat(builder.input(:country, :priority_countries => []))
end)
@@ -101,7 +101,7 @@
before do
concat(semantic_form_for(@new_post) do |builder|
- builder.stub!(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
+ builder.stub(:country_select).and_return(Formtastic::Util.html_safe("<select><option>...</option></select>"))
concat(builder.input(:country))
end)
end
View
2  spec/inputs/custom_input_spec.rb
@@ -45,7 +45,7 @@ def to_html
describe 'with an implementation' do
it "should raise a NotImplementedError exception" do
- expect { ::ImplementedInput.new(*input_args).to_html }.to_not raise_error(NotImplementedError)
+ expect { ::ImplementedInput.new(*input_args).to_html }.to_not raise_error
end
end
View
8 spec/inputs/date_picker_input_spec.rb
@@ -122,7 +122,7 @@
before do
@date = Date.new(2000, 11, 11)
- @new_post.stub!(:publish_at).and_return(@date)
+ @new_post.stub(:publish_at).and_return(@date)
end
it "renders the date as YYYY-MM-DD" do
@@ -149,7 +149,7 @@
before do
@time = Time.utc(2000,11,11,11,11,11)
- @new_post.stub!(:publish_at).and_return(@time)
+ @new_post.stub(:publish_at).and_return(@time)
end
it "renders the time as a YYYY-MM-DD" do
@@ -175,7 +175,7 @@
context "when method returns an empty String" do
before do
- @new_post.stub!(:publish_at).and_return("")
+ @new_post.stub(:publish_at).and_return("")
end
it "will be empty" do
@@ -201,7 +201,7 @@
context "when method returns a String" do
before do
- @new_post.stub!(:publish_at).and_return("yeah")
+ @new_post.stub(:publish_at).and_return("yeah")
end
it "will be the string" do
View
8 spec/inputs/datetime_picker_input_spec.rb
@@ -157,7 +157,7 @@
before do
@date = Date.new(2000, 11, 11)
- @new_post.stub!(:publish_at).and_return(@date)
+ @new_post.stub(:publish_at).and_return(@date)
end
it "renders the date as YYYY-MM-DDT00:00:00" do
@@ -184,7 +184,7 @@
before do
@time = Time.utc(2000,11,11,11,11,11)
- @new_post.stub!(:publish_at).and_return(@time)
+ @new_post.stub(:publish_at).and_return(@time)
end
it "renders the time as a YYYY-MM-DD HH:MM" do
@@ -210,7 +210,7 @@
context "when method returns an empty String" do
before do
- @new_post.stub!(:publish_at).and_return("")
+ @new_post.stub(:publish_at).and_return("")
end
it "will be empty" do
@@ -236,7 +236,7 @@
context "when method returns a String" do
before do
- @new_post.stub!(:publish_at).and_return("yeah")
+ @new_post.stub(:publish_at).and_return("yeah")
end
it "will be the string" do
View
6 spec/inputs/hidden_input_spec.rb
@@ -53,9 +53,9 @@
end
it "should not render inline errors" do
- @errors = mock('errors')
- @errors.stub!(:[]).with(errors_matcher(:secret)).and_return(["foo", "bah"])
- @new_post.stub!(:errors).and_return(@errors)
+ @errors = double('errors')
+ @errors.stub(:[]).with(errors_matcher(:secret)).and_return(["foo", "bah"])
+ @new_post.stub(:errors).and_return(@errors)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:secret, :as => :hidden))
View
4 spec/inputs/include_blank_spec.rb
@@ -9,8 +9,8 @@
@output_buffer = ''
mock_everything
- @new_post.stub!(:author_id).and_return(nil)
- @new_post.stub!(:publish_at).and_return(nil)
+ @new_post.stub(:author_id).and_return(nil)
+ @new_post.stub(:publish_at).and_return(nil)
end
SELECT_INPUT_TYPES = {
View
72 spec/inputs/number_input_spec.rb
@@ -9,7 +9,7 @@
@output_buffer = ''
mock_everything
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=>2})
])
end
@@ -109,7 +109,7 @@
describe "when validations require a minimum value (:greater_than)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=>2})
])
end
@@ -144,7 +144,7 @@
describe "and the column is an integer" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
end
it "should add a min attribute to the input one greater than the validation" do
@@ -157,7 +157,7 @@
describe "and the column is a float" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
end
it "should raise an error" do
@@ -171,7 +171,7 @@
describe "and the column is a big decimal" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
end
it "should raise an error" do
@@ -187,7 +187,7 @@
describe "when validations require a minimum value (:greater_than) that takes a proc" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=> Proc.new {|post| 2}})
])
end
@@ -222,7 +222,7 @@
describe "and the column is an integer" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
end
it "should add a min attribute to the input one greater than the validation" do
@@ -235,7 +235,7 @@
describe "and the column is a float" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
end
it "should raise an error" do
@@ -249,7 +249,7 @@
describe "and the column is a big decimal" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
end
it "should raise an error" do
@@ -265,7 +265,7 @@
describe "when validations require a minimum value (:greater_than_or_equal_to)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than_or_equal_to=>2})
])
end
@@ -302,7 +302,7 @@
[:integer, :decimal, :float].each do |column_type|
describe "and the column is a #{column_type}" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => column_type))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
end
it "should add a max attribute to the input equal to the validation" do
@@ -316,7 +316,7 @@
describe "and there is no column" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(nil)
+ @new_post.stub(:column_for_attribute).with(:title).and_return(nil)
end
it "should add a max attribute to the input equal to the validation" do
@@ -330,7 +330,7 @@
describe "when validations require a minimum value (:greater_than_or_equal_to) that takes a Proc" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than_or_equal_to=> Proc.new { |post| 2}})
])
end
@@ -367,7 +367,7 @@
[:integer, :decimal, :float].each do |column_type|
describe "and the column is a #{column_type}" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => column_type))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
end
it "should add a max attribute to the input equal to the validation" do
@@ -381,7 +381,7 @@
describe "and there is no column" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(nil)
+ @new_post.stub(:column_for_attribute).with(:title).and_return(nil)
end
it "should add a max attribute to the input equal to the validation" do
@@ -396,7 +396,7 @@
describe "when validations require a maximum value (:less_than)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than=>20})
])
end
@@ -431,7 +431,7 @@
describe "and the column is an integer" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
end
it "should add a max attribute to the input one greater than the validation" do
@@ -444,7 +444,7 @@
describe "and the column is a float" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
end
it "should raise an error" do
@@ -458,7 +458,7 @@
describe "and the column is a big decimal" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
end
it "should raise an error" do
@@ -471,7 +471,7 @@
end
describe "and the validator takes a proc" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
end
end
end
@@ -479,7 +479,7 @@
describe "when validations require a maximum value (:less_than) that takes a Proc" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than=> Proc.new {|post| 20 }})
])
end
@@ -514,7 +514,7 @@
describe "and the column is an integer" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
end
it "should add a max attribute to the input one greater than the validation" do
@@ -527,7 +527,7 @@
describe "and the column is a float" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
end
it "should raise an error" do
@@ -541,7 +541,7 @@
describe "and the column is a big decimal" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
end
it "should raise an error" do
@@ -554,7 +554,7 @@
end
describe "and the validator takes a proc" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
end
end
end
@@ -562,7 +562,7 @@
describe "when validations require a maximum value (:less_than_or_equal_to)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than_or_equal_to=>20})
])
end
@@ -598,7 +598,7 @@
[:integer, :decimal, :float].each do |column_type|
describe "and the column is a #{column_type}" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => column_type))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
end
it "should add a max attribute to the input equal to the validation" do
@@ -612,7 +612,7 @@
describe "and there is no column" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(nil)
+ @new_post.stub(:column_for_attribute).with(:title).and_return(nil)
end
it "should add a max attribute to the input equal to the validation" do
@@ -626,7 +626,7 @@
describe "when validations require a maximum value (:less_than_or_equal_to) that takes a proc" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than_or_equal_to=> Proc.new { |post| 20 }})
])
end
@@ -662,7 +662,7 @@
[:integer, :decimal, :float].each do |column_type|
describe "and the column is a #{column_type}" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => column_type))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
end
it "should add a max attribute to the input equal to the validation" do
@@ -676,7 +676,7 @@
describe "and there is no column" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(nil)
+ @new_post.stub(:column_for_attribute).with(:title).and_return(nil)
end
it "should add a max attribute to the input equal to the validation" do
@@ -690,7 +690,7 @@
describe "when validations require conflicting minimum values (:greater_than, :greater_than_or_equal_to)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than => 20, :greater_than_or_equal_to=>2})
])
end
@@ -705,7 +705,7 @@
describe "when validations require conflicting maximum values (:less_than, :less_than_or_equal_to)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than => 20, :less_than_or_equal_to=>2})
])
end
@@ -721,7 +721,7 @@
describe "when validations require only an integer (:only_integer)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:allow_nil=>false, :only_integer=>true})
])
end
@@ -752,7 +752,7 @@
describe "when validations require a :step (non standard)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:allow_nil=>false, :only_integer=>true, :step=>2})
])
end
@@ -783,7 +783,7 @@
describe "when validations do not specify :step (non standard) or :only_integer" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:allow_nil=>false})
])
end
View
10 spec/inputs/radio_input_spec.rb
@@ -158,7 +158,7 @@
::I18n.backend.store_translations :en, :formtastic => { :labels => { :post => { :authors => "Translated!" }}}
with_config :i18n_lookups_by_default, true do
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :radio))
end)
@@ -177,7 +177,7 @@
describe "when :label option is set" do
before do
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :radio, :label => 'The authors'))
end)
@@ -191,7 +191,7 @@
describe "when :label option is false" do
before do
@output_buffer = ''
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :radio, :label => false))
end)
@@ -209,7 +209,7 @@
describe "when :required option is true" do
before do
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:authors, :as => :radio, :required => true))
end)
@@ -223,7 +223,7 @@
describe "when :namespace is given on form" do
before do
@output_buffer = ''
- @new_post.stub!(:author_ids).and_return(nil)
+ @new_post.stub(:author_ids).and_return(nil)
concat(semantic_form_for(@new_post, :namespace => "custom_prefix") do |builder|
concat(builder.input(:authors, :as => :radio, :label => ''))
end)
View
38 spec/inputs/range_input_spec.rb
@@ -73,7 +73,7 @@
describe "when validations require a minimum value (:greater_than)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than=>2})
])
end
@@ -108,7 +108,7 @@
describe "and the column is an integer" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
end
it "should add a min attribute to the input one greater than the validation" do
@@ -121,7 +121,7 @@
describe "and the column is a float" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
end
it "should raise an error" do
@@ -135,7 +135,7 @@
describe "and the column is a big decimal" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
end
it "should raise an error" do
@@ -151,7 +151,7 @@
describe "when validations require a minimum value (:greater_than_or_equal_to)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than_or_equal_to=>2})
])
end
@@ -188,7 +188,7 @@
[:integer, :decimal, :float].each do |column_type|
describe "and the column is a #{column_type}" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => column_type))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
end
it "should add a max attribute to the input equal to the validation" do
@@ -202,7 +202,7 @@
describe "and there is no column" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(nil)
+ @new_post.stub(:column_for_attribute).with(:title).and_return(nil)
end
it "should add a max attribute to the input equal to the validation" do
@@ -227,7 +227,7 @@
describe "when validations require a maximum value (:less_than)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than=>20})
])
end
@@ -262,7 +262,7 @@
describe "and the column is an integer" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :integer))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :integer))
end
it "should add a max attribute to the input one greater than the validation" do
@@ -275,7 +275,7 @@
describe "and the column is a float" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :float))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :float))
end
it "should raise an error" do
@@ -289,7 +289,7 @@
describe "and the column is a big decimal" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :decimal))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => :decimal))
end
it "should raise an error" do
@@ -305,7 +305,7 @@
describe "when validations require a maximum value (:less_than_or_equal_to)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than_or_equal_to=>20})
])
end
@@ -341,7 +341,7 @@
[:integer, :decimal, :float].each do |column_type|
describe "and the column is a #{column_type}" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => column_type))
+ @new_post.stub(:column_for_attribute).with(:title).and_return(double('column', :type => column_type))
end
it "should add a max attribute to the input equal to the validation" do
@@ -355,7 +355,7 @@
describe "and there is no column" do
before do
- @new_post.stub!(:column_for_attribute).with(:title).and_return(nil)
+ @new_post.stub(:column_for_attribute).with(:title).and_return(nil)
end
it "should add a max attribute to the input equal to the validation" do
@@ -380,7 +380,7 @@
describe "when validations require conflicting minimum values (:greater_than, :greater_than_or_equal_to)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :greater_than => 20, :greater_than_or_equal_to=>2})
])
end
@@ -395,7 +395,7 @@
describe "when validations require conflicting maximum values (:less_than, :less_than_or_equal_to)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:only_integer=>false, :allow_nil=>false, :less_than => 20, :less_than_or_equal_to=>2})
])
end
@@ -411,7 +411,7 @@
describe "when validations require only an integer (:only_integer)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:allow_nil=>false, :only_integer=>true})
])
end
@@ -442,7 +442,7 @@
describe "when validations require a :step (non standard)" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:allow_nil=>false, :only_integer=>true, :step=>2})
])
end
@@ -473,7 +473,7 @@
describe "when validations do not specify :step (non standard) or :only_integer" do
before do
- @new_post.class.stub!(:validators_on).with(:title).and_return([
+ @new_post.class.stub(:validators_on).with(:title).and_return([
active_model_numericality_validator([:title], {:allow_nil=>false})
])
end
View
40 spec/inputs/select_input_spec.rb
@@ -33,7 +33,7 @@
describe "using a related model without reflection's options (Mongoid Document)" do
before do
- @new_post.stub!(:mongoid_reviewer)
+ @new_post.stub(:mongoid_reviewer)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:mongoid_reviewer, :as => :select))
end)
@@ -188,9 +188,9 @@
end
it 'should not singularize the association name' do
- @new_post.stub!(:author_status).and_return(@bob)
- @new_post.stub!(:author_status_id).and_return(@bob.id)
- @new_post.stub!(:column_for_attribute).and_return(mock('column', :type => :integer, :limit => 255))
+ @new_post.stub(:author_status).and_return(@bob)
+ @new_post.stub(:author_status_id).and_return(@bob.id)
+ @new_post.stub(:column_for_attribute).and_return(double('column', :type => :integer, :limit => 255))
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:author_status, :as => :select))
@@ -202,9 +202,9 @@
describe "for a belongs_to association with :group_by => :author" do
it "should call author.posts" do
- ::Author.stub!(:reflect_on_all_associations).and_return { |macro| macro == :has_many ? [mock('reflection', :klass => Post, :name => :posts)] : []}
+ ::Author.stub(:reflect_on_all_associations).and_return { |macro| macro == :has_many ? [double('reflection', :klass => Post, :name => :posts)] : []}
- [@freds_post].each { |post| post.stub!(:to_label).and_return("Post - #{post.id}") }
+ [@freds_post].each { |post| post.stub(:to_label).and_return("Post - #{post.id}") }
@fred.should_receive(:posts)
with_deprecation_silenced do
@@ -217,9 +217,9 @@
describe "for a belongs_to association with :conditions" do
before do
- ::Post.stub!(:reflect_on_association).with(:author).and_return do
- mock = mock('reflection', :options => {:conditions => {:active => true}}, :klass => ::Author, :macro => :belongs_to)
- mock.stub!(:[]).with(:class_name).and_return("Author")
+ ::Post.stub(:reflect_on_association).with(:author).and_return do
+ mock = double('reflection', :options => {:conditions => {:active => true}}, :klass => ::Author, :macro => :belongs_to)
+ mock.stub(:[]).with(:class_name).and_return("Author")
mock
end
end
@@ -241,7 +241,7 @@
::Author.should_receive(:scoped).with(:conditions => {:active => true})
::Author.should_receive(:where).with({:publisher => true})
else
- proxy = stub
+ proxy = double
::Author.should_receive(:where).with({:active => true}).and_return(proxy)
proxy.should_receive(:where).with({:publisher => true})
end
@@ -258,19 +258,19 @@
describe 'for a belongs_to association with :group_by => :continent' do
before do
@authors = [@bob, @fred, @fred, @fred]
- ::Author.stub!(:find).and_return(@authors)
+ ::Author.stub(:find).and_return(@authors)
@continent_names = %w(Europe Africa)
- @continents = (0..1).map { |i| c = ::Continent.new; c.stub!(:id).and_return(100 - i);c }
- @authors[0..1].each_with_index { |author, i| author.stub!(:continent).and_return(@continents[i]) }
+ @continents = (0..1).map { |i| c = ::Continent.new; c.stub(:id).and_return(100 - i);c }
+ @authors[0..1].each_with_index { |author, i| author.stub(:continent).and_return(@continents[i]) }
- ::Continent.stub!(:reflect_on_all_associations).and_return { |macro| macro == :has_many ? [mock('reflection', :klass => Author, :name => :authors)] : [] }
- ::Continent.stub!(:reflect_on_association).and_return {|column_name| mock('reflection', :klass => Author) if column_name == :authors}
- ::Author.stub!(:reflect_on_association).and_return { |column_name| mock('reflection', :options => {}, :klass => Continent, :macro => :belongs_to) if column_name == :continent }
+ ::Continent.stub(:reflect_on_all_associations).and_return { |macro| macro == :has_many ? [double('reflection', :klass => Author, :name => :authors)] : [] }
+ ::Continent.stub(:reflect_on_association).and_return {|column_name| double('reflection', :klass => Author) if column_name == :authors}
+ ::Author.stub(:reflect_on_association).and_return { |column_name| double('reflection', :options => {}, :klass => Continent, :macro => :belongs_to) if column_name == :continent }
@continents.each_with_index do |continent, i|
- continent.stub!(:to_label).and_return(@continent_names[i])
- continent.stub!(:authors).and_return([@authors[i]])
+ continent.stub(:to_label).and_return(@continent_names[i])
+ continent.stub(:authors).and_return([@authors[i]])
end
with_deprecation_silenced do
@@ -456,7 +456,7 @@
describe 'when :prompt => "choose something" is set' do
before do
- @new_post.stub!(:author_id).and_return(nil)
+ @new_post.stub(:author_id).and_return(nil)
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:author, :as => :select, :prompt => "choose author"))
end)
@@ -549,7 +549,7 @@
before do
@output_buffer = ''
@some_meta_descriptions = ["One", "Two", "Three"]
- @new_post.stub!(:meta_description).any_number_of_times
+ @new_post.stub(:meta_description).at_least(:once)
end
describe ":as is not set" do
View
4 spec/inputs/string_input_spec.rb
@@ -44,11 +44,11 @@ def input_field_for_method_should_have_maxlength(method, maxlength)
let(:default_maxlength) { 50 }
before do
- @new_post.stub!(:class).and_return(::PostModel)
+ @new_post.stub(:class).and_return(::PostModel)
end
after do