Permalink
Browse files

Use current thoughtbot style in specs

  • Loading branch information...
1 parent cc03053 commit af8f9a7bffa238db2648dfc28f23b7618f6881f2 @gabebw gabebw committed Dec 20, 2012
Showing with 1,880 additions and 2,167 deletions.
  1. +7 −7 features/step_definitions/rails_steps.rb
  2. +1 −1 features/support/env.rb
  3. +3 −3 gemfiles/3.0.gemfile.lock
  4. +3 −3 gemfiles/3.1.gemfile.lock
  5. +4 −4 gemfiles/3.2.gemfile.lock
  6. +2 −2 lib/shoulda/matchers/action_controller.rb
  7. +0 −1 lib/shoulda/matchers/action_controller/assign_to_matcher.rb
  8. +0 −1 lib/shoulda/matchers/action_controller/redirect_to_matcher.rb
  9. +0 −1 lib/shoulda/matchers/action_controller/render_template_matcher.rb
  10. +4 −4 lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb
  11. +8 −8 lib/shoulda/matchers/action_controller/route_matcher.rb
  12. +1 −2 lib/shoulda/matchers/action_controller/set_session_matcher.rb
  13. +8 −7 lib/shoulda/matchers/action_controller/set_the_flash_matcher.rb
  14. +2 −2 lib/shoulda/matchers/action_mailer/have_sent_email_matcher.rb
  15. +1 −1 lib/shoulda/matchers/active_model.rb
  16. +3 −3 lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb
  17. +2 −2 lib/shoulda/matchers/active_model/allow_value_matcher.rb
  18. +1 −1 lib/shoulda/matchers/active_model/disallow_value_matcher.rb
  19. +1 −1 lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb
  20. +0 −1 lib/shoulda/matchers/active_model/exception_message_finder.rb
  21. +1 −1 lib/shoulda/matchers/active_model/only_integer_matcher.rb
  22. +8 −6 lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb
  23. +15 −9 lib/shoulda/matchers/active_model/validate_format_of_matcher.rb
  24. +2 −2 lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb
  25. +9 −10 lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb
  26. +1 −1 lib/shoulda/matchers/active_model/validation_message_finder.rb
  27. +3 −3 lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb
  28. +1 −1 lib/shoulda/matchers/active_record/association_matcher.rb
  29. +9 −5 lib/shoulda/matchers/active_record/have_db_column_matcher.rb
  30. +1 −1 lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb
  31. +1 −1 lib/shoulda/matchers/active_record/serialize_matcher.rb
  32. +2 −2 lib/shoulda/matchers/assertion_error.rb
  33. +19 −16 spec/shoulda/matchers/action_controller/assign_to_matcher_spec.rb
  34. +15 −13 spec/shoulda/matchers/action_controller/filter_param_matcher_spec.rb
  35. +19 −17 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
  36. +40 −31 spec/shoulda/matchers/action_controller/render_template_matcher_spec.rb
  37. +28 −25 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
  38. +20 −17 spec/shoulda/matchers/action_controller/respond_with_content_type_matcher_spec.rb
  39. +18 −70 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
  40. +28 −28 spec/shoulda/matchers/action_controller/route_matcher_spec.rb
  41. +29 −24 spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb
  42. +91 −66 spec/shoulda/matchers/action_controller/set_the_flash_matcher_spec.rb
  43. +95 −104 spec/shoulda/matchers/action_mailer/have_sent_email_spec.rb
  44. +54 −58 spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb
  45. +64 −71 spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb
  46. +20 −42 spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb
  47. +39 −50 spec/shoulda/matchers/active_model/ensure_exclusion_of_matcher_spec.rb
  48. +102 −112 spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb
  49. +63 −89 spec/shoulda/matchers/active_model/ensure_length_of_matcher_spec.rb
  50. +2 −2 spec/shoulda/matchers/active_model/exception_message_finder_spec.rb
  51. +98 −87 spec/shoulda/matchers/active_model/helpers_spec.rb
  52. +30 −45 spec/shoulda/matchers/active_model/only_integer_matcher_spec.rb
  53. +23 −25 spec/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb
  54. +23 −30 spec/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb
  55. +50 −47 spec/shoulda/matchers/active_model/validate_format_of_matcher_spec.rb
  56. +41 −80 spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb
  57. +66 −74 spec/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb
  58. +113 −92 spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb
  59. +0 −1 spec/shoulda/matchers/active_model/validation_message_finder_spec.rb
  60. +69 −47 spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb
  61. +268 −377 spec/shoulda/matchers/active_record/association_matcher_spec.rb
  62. +66 −140 spec/shoulda/matchers/active_record/have_db_column_matcher_spec.rb
  63. +36 −63 spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb
  64. +24 −29 spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb
  65. +10 −10 spec/shoulda/matchers/active_record/query_the_database_matcher_spec.rb
  66. +59 −53 spec/shoulda/matchers/active_record/serialize_matcher_spec.rb
  67. +23 −29 spec/shoulda/matchers/independent/delegate_matcher_spec.rb
  68. +1 −1 spec/spec_helper.rb
  69. +19 −0 spec/support/activemodel_helpers.rb
  70. +3 −3 spec/support/controller_builder.rb
  71. +8 −2 spec/support/model_builder.rb
@@ -25,8 +25,8 @@
And I set the "BUNDLE_GEMFILE" environment variable to "Gemfile"
And I successfully run `bundle install --local`
}
- if RUBY_VERSION >= "1.9.3"
- append_to_gemfile %(gem "rake", "~> 0.9.3.beta.1")
+ if RUBY_VERSION >= '1.9.3'
+ append_to_gemfile %(gem 'rake', '~> 0.9.3.beta.1')
step %(I successfully run `bundle update rake`)
end
end
@@ -52,7 +52,7 @@
end
When 'I configure the application to use rspec-rails' do
- append_to_gemfile "gem 'rspec-rails', '~> 2.8.1'"
+ append_to_gemfile %q(gem 'rspec-rails', '~> 2.8.1')
steps %{And I run `bundle install --local`}
end
@@ -66,7 +66,7 @@
end
When 'I configure the application to use shoulda-context' do
- append_to_gemfile "gem 'shoulda-context', '~> 1.0.0'"
+ append_to_gemfile %q(gem 'shoulda-context', '~> 1.0.0')
steps %{And I run `bundle install --local`}
end
@@ -106,7 +106,7 @@
module FileHelpers
def append_to(path, contents)
in_current_dir do
- File.open(path, "a") do |file|
+ File.open(path, 'a') do |file|
file.puts
file.puts contents
end
@@ -119,9 +119,9 @@ def append_to_gemfile(contents)
def comment_out_gem_in_gemfile(gemname)
in_current_dir do
- gemfile = File.read("Gemfile")
+ gemfile = File.read('Gemfile')
gemfile.sub!(/^(\s*)(gem\s*['"]#{gemname})/, "\\1# \\2")
- File.open("Gemfile", 'w'){ |file| file.write(gemfile) }
+ File.open('Gemfile', 'w'){ |file| file.write(gemfile) }
end
end
end
View
@@ -1,5 +1,5 @@
require 'aruba/cucumber'
Before do
- @aruba_timeout_seconds = 120
+ @aruba_timeout_seconds = 60 * 2
end
@@ -1,5 +1,5 @@
PATH
- remote: /Users/draper/Dropbox/Development/shoulda-matchers
+ remote: /Users/gabe/thoughtbot/open-source/shoulda-matchers
specs:
shoulda-matchers (1.4.2)
activesupport (>= 3.0.0)
@@ -90,7 +90,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
- rake (10.0.2)
+ rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
rspec (2.8.0)
@@ -106,7 +106,7 @@ GEM
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.8.0)
- shoulda-context (1.0.1)
+ shoulda-context (1.0.2)
sqlite3 (1.3.6)
thor (0.14.6)
treetop (1.4.12)
@@ -1,5 +1,5 @@
PATH
- remote: /Users/draper/Dropbox/Development/shoulda-matchers
+ remote: /Users/gabe/thoughtbot/open-source/shoulda-matchers
specs:
shoulda-matchers (1.4.2)
activesupport (>= 3.0.0)
@@ -99,7 +99,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
- rake (10.0.2)
+ rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
rspec (2.8.0)
@@ -121,7 +121,7 @@ GEM
railties (~> 3.1.0)
sass (>= 3.1.10)
tilt (~> 1.3.2)
- shoulda-context (1.0.1)
+ shoulda-context (1.0.2)
sprockets (2.0.4)
hike (~> 1.2)
rack (~> 1.0)
@@ -1,5 +1,5 @@
PATH
- remote: /Users/draper/Dropbox/Development/shoulda-matchers
+ remote: /Users/gabe/thoughtbot/open-source/shoulda-matchers
specs:
shoulda-matchers (1.4.2)
activesupport (>= 3.0.0)
@@ -73,7 +73,7 @@ GEM
mime-types (1.19)
mocha (0.12.7)
metaclass (~> 0.0.1)
- multi_json (1.4.0)
+ multi_json (1.5.0)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -97,7 +97,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
- rake (10.0.2)
+ rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
rspec (2.8.0)
@@ -118,7 +118,7 @@ GEM
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
- shoulda-context (1.0.1)
+ shoulda-context (1.0.2)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
@@ -16,7 +16,7 @@ module Matchers
#
# This code segment:
#
- # describe UsersController, "on GET to show with a valid id" do
+ # describe UsersController, 'on GET to show with a valid id' do
# before(:each) do
# get :show, :id => User.first.to_param
# end
@@ -26,7 +26,7 @@ module Matchers
# it { should render_template(:show) }
# it { should not_set_the_flash) }
#
- # it "should do something else really cool" do
+ # it 'does something else really cool' do
# assigns[:user].id.should == 1
# end
# end
@@ -1,7 +1,6 @@
module Shoulda # :nodoc:
module Matchers
module ActionController # :nodoc:
-
# Ensures that the controller assigned to the named instance variable.
#
# Options:
@@ -1,7 +1,6 @@
module Shoulda # :nodoc:
module Matchers
module ActionController # :nodoc:
-
# Ensures a controller redirected to the given url.
#
# Example:
@@ -1,7 +1,6 @@
module Shoulda # :nodoc:
module Matchers
module ActionController # :nodoc:
-
# Ensures a controller rendered the given template.
#
# Example:
@@ -42,9 +42,9 @@ def negative_failure_message
end
def description
- description = "render with "
+ description = 'render with '
if @expected_layout.nil?
- description << "a layout"
+ description << 'a layout'
else
description << "the #{@expected_layout.inspect} layout"
end
@@ -83,9 +83,9 @@ def expectation
def result
if rendered_with_layout?
- "rendered with " + rendered_layouts.map(&:inspect).join(", ")
+ 'rendered with ' + rendered_layouts.map(&:inspect).join(', ')
else
- "rendered without a layout"
+ 'rendered without a layout'
end
end
end
@@ -11,16 +11,16 @@ module ActionController # :nodoc:
#
# Examples:
#
- # it { should route(:get, "/posts").
+ # it { should route(:get, '/posts').
# to(:controller => :posts, :action => :index) }
- # it { should route(:get, "/posts/new").to(:action => :new) }
- # it { should route(:post, "/posts").to(:action => :create) }
- # it { should route(:get, "/posts/1").to(:action => :show, :id => 1) }
- # it { should route(:get, "/posts/1/edit").to(:action => :edit, :id => 1) }
- # it { should route(:put, "/posts/1").to(:action => :update, :id => 1) }
- # it { should route(:delete, "/posts/1").
+ # it { should route(:get, '/posts/new').to(:action => :new) }
+ # it { should route(:post, '/posts').to(:action => :create) }
+ # it { should route(:get, '/posts/1').to(:action => :show, :id => 1) }
+ # it { should route(:get, '/posts/1/edit').to(:action => :edit, :id => 1) }
+ # it { should route(:put, '/posts/1').to(:action => :update, :id => 1) }
+ # it { should route(:delete, '/posts/1').
# to(:action => :destroy, :id => 1) }
- # it { should route(:get, "/users/1/posts/1").
+ # it { should route(:get, '/users/1/posts/1').
# to(:action => :show, :id => 1, :user_id => 1) }
def route(method, path)
RouteMatcher.new(method, path, self)
@@ -82,12 +82,11 @@ def expectation
if @value
expectation << " to #{@value.inspect}"
end
- expectation
end
def result
if session.empty?
- "no session variables were set"
+ 'no session variables were set'
else
"the session was #{session.inspect}"
end
@@ -8,9 +8,9 @@ module ActionController # :nodoc:
# Example:
#
# it { should set_the_flash }
- # it { should set_the_flash.to("Thank you for placing this order.") }
+ # it { should set_the_flash.to('Thank you for placing this order.') }
# it { should set_the_flash.to(/created/i) }
- # it { should set_the_flash[:alert].to("Password doesn't match") }
+ # it { should set_the_flash[:alert].to('Password does not match') }
# it { should set_the_flash.to(/logged in/i).now }
# it { should_not set_the_flash }
def set_the_flash
@@ -96,7 +96,8 @@ def flash
@flash
else
@flash = @controller.flash.dup
- @flash.instance_variable_set(:@used, @controller.flash.instance_variable_get(:@used).dup)
+ used = @controller.flash.instance_variable_get(:@used).dup
+ @flash.instance_variable_set(:@used, used)
sweep_flash_if_necessary
@flash
end
@@ -117,7 +118,7 @@ def expectation
def flash_description
if flash.blank?
- "no flash was set"
+ 'no flash was set'
else
"was #{flash.inspect}"
end
@@ -129,17 +130,17 @@ def expected_flash_invocation
def pretty_now
if @options[:now]
- ".now"
+ '.now'
else
- ""
+ ''
end
end
def pretty_key
if @options[:key]
"[:#{@options[:key]}]"
else
- ""
+ ''
end
end
end
@@ -115,7 +115,7 @@ def negative_failure_message
end
def description
- description = "send an email"
+ description = 'send an email'
description << " with a subject of #{@email_subject.inspect}" if @email_subject
description << " containing #{@body.inspect}" if @body
if @parts
@@ -136,7 +136,7 @@ def description
private
def expectation
- expectation = "sent email"
+ expectation = 'sent email'
expectation << " with subject #{@email_subject.inspect}" if @subject_failed
expectation << " with body #{@body.inspect}" if @body_failed
@parts.each do |_, body, content_type|
@@ -30,7 +30,7 @@ module Matchers
# %w(abcd 1234).each do |value|
# it { should_not allow_value(value).for(:phone_number) }
# end
- # it { should allow_value("(123) 456-7890").for(:phone_number) }
+ # it { should allow_value('(123) 456-7890').for(:phone_number) }
# it { should_not allow_mass_assignment_of(:password) }
# it { should allow_value('Activated', 'Pending').for(:status).strict }
# it { should_not allow_value('Amazing').for(:status).strict }
@@ -25,7 +25,7 @@ def initialize(attribute)
def as(role)
if active_model_less_than_3_1?
- raise "You can specify role only in Rails 3.1 or greater"
+ raise 'You can specify role only in Rails 3.1 or greater'
end
@options[:role] = role
self
@@ -38,7 +38,7 @@ def matches?(subject)
@negative_failure_message = "#{@attribute} was made accessible"
else
if protected_attributes.empty?
- @negative_failure_message = "no attributes were protected"
+ @negative_failure_message = 'no attributes were protected'
else
@negative_failure_message = "#{class_name} is protecting " <<
"#{protected_attributes.to_a.to_sentence}, " <<
@@ -57,7 +57,7 @@ def matches?(subject)
end
def description
- [base_description, role_description].compact.join(" ")
+ [base_description, role_description].compact.join(' ')
end
private
@@ -17,11 +17,11 @@ module ActiveModel # :nodoc:
#
# Example:
# it { should_not allow_value('bad').for(:isbn) }
- # it { should allow_value("isbn 1 2345 6789 0").for(:isbn) }
+ # it { should allow_value('isbn 1 2345 6789 0').for(:isbn) }
#
def allow_value(*values)
if values.empty?
- raise ArgumentError, "need at least one argument"
+ raise ArgumentError, 'need at least one argument'
else
AllowValueMatcher.new(*values)
end
@@ -25,7 +25,7 @@ def failure_message
end
def allowed_types
- ""
+ ''
end
end
end
@@ -22,7 +22,7 @@ def ensure_inclusion_of(attr)
end
class EnsureInclusionOfMatcher < ValidationMatcher # :nodoc:
- ARBITRARY_OUTSIDE_STRING = "shouldamatchersteststring"
+ ARBITRARY_OUTSIDE_STRING = 'shouldamatchersteststring'
def initialize(attribute)
super(attribute)
@@ -1,7 +1,6 @@
module Shoulda
module Matchers
module ActiveModel
-
# Finds message information from exceptions thrown by #valid?
class ExceptionMessageFinder
def initialize(instance, attribute)
Oops, something went wrong.

0 comments on commit af8f9a7

Please sign in to comment.