Skip to content

Commit

Permalink
Upgrade to RSpec 3
Browse files Browse the repository at this point in the history
  • Loading branch information
pranas committed Dec 7, 2015
1 parent 70d1db7 commit 6a262ff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
4 changes: 2 additions & 2 deletions formtastic.gemspec
Expand Up @@ -28,14 +28,14 @@ Gem::Specification.new do |s|
s.add_dependency(%q<actionpack>, [">= 3.2.13"])

s.add_development_dependency(%q<nokogiri>)
s.add_development_dependency(%q<rspec-rails>, ["~> 2.14"])
s.add_development_dependency(%q<rspec-rails>, ["~> 3.3.2"])
s.add_development_dependency(%q<rspec_tag_matchers>, ["~> 1.0"])
s.add_development_dependency(%q<hpricot>, ["~> 0.8.3"])
s.add_development_dependency(%q<RedCloth>, ["~> 4.2"]) # for YARD Textile formatting
s.add_development_dependency(%q<yard>, ["~> 0.8"])
s.add_development_dependency(%q<colored>, ["~> 1.2"])
s.add_development_dependency(%q<tzinfo>)
s.add_development_dependency(%q<ammeter>, ["1.1.1"])
s.add_development_dependency(%q<ammeter>, ["~> 1.1.3"])
s.add_development_dependency(%q<appraisal>, ["~> 1.0"])
s.add_development_dependency(%q<rake>)
s.add_development_dependency(%q<activemodel>, [">= 3.2.13"])
Expand Down
4 changes: 3 additions & 1 deletion lib/formtastic/inputs/country_input.rb
Expand Up @@ -67,8 +67,10 @@ module Inputs
class CountryInput
include Base

CountrySelectPluginMissing = Class.new(StandardError)

def to_html
raise "To use the :country input, please install a country_select plugin, like this one: https://github.com/stefanpenner/country_select" unless builder.respond_to?(:country_select)
raise CountrySelectPluginMissing, "To use the :country input, please install a country_select plugin, like this one: https://github.com/stefanpenner/country_select" unless builder.respond_to?(:country_select)
input_wrapping do
label_html <<
builder.country_select(method, priority_countries, input_options, input_html_options)
Expand Down
2 changes: 1 addition & 1 deletion spec/inputs/country_input_spec.rb
Expand Up @@ -17,7 +17,7 @@
semantic_form_for(@new_post) do |builder|
concat(builder.input(:country, :as => :country))
end
}.should raise_error
}.should raise_error(Formtastic::Inputs::CountryInput::CountrySelectPluginMissing)
end

end
Expand Down
25 changes: 2 additions & 23 deletions spec/spec_helper.rb
Expand Up @@ -492,29 +492,8 @@ def with_config(config_method_name, value, &block)
Formtastic::FormBuilder.send(:"#{config_method_name}=", old_value)
end

class ToSMatcher
def initialize(str)
@str=str.to_s
end

def matches?(value)
value.to_s==@str
end

def failure_message_for_should
"Expected argument that converted to #{@str}"
end
end

def errors_matcher(method)
# In edge rails (Rails 4) tags store method_name as a string and index the errors object using a string
# therefore allow stubs to match on either string or symbol. The errors object calls to_sym on all index
# accesses so @object.errors[:abc] is equivalent to @object.errors["abc"]
if Rails::VERSION::MAJOR == 4
ToSMatcher.new(method)
else
method
end
RSpec::Matchers.define :errors_matcher do |expected|
match { |actual| actual.to_s == expected.to_s }
end
end

Expand Down

0 comments on commit 6a262ff

Please sign in to comment.