Skip to content

Commit

Permalink
fix rails 4 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed May 19, 2013
1 parent e586634 commit a90fd76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions gemfiles/actionpack4.0.gemfile.lock
Expand Up @@ -18,9 +18,11 @@ GEM
rake
atomic (1.1.9)
builder (3.1.4)
coderay (1.0.9)
diff-lcs (1.2.4)
erubis (2.7.0)
i18n (0.6.4)
method_source (0.8.1)
minitest (4.7.4)
multi_json (1.7.3)
rack (1.5.2)
Expand All @@ -35,6 +37,7 @@ GEM
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.1)
slop (3.4.4)
thread_safe (0.1.0)
atomic
tzinfo (0.3.37)
Expand Down
15 changes: 12 additions & 3 deletions spec/country_select_spec.rb
Expand Up @@ -7,6 +7,8 @@ module ActionView
module Helpers

describe CountrySelect do
include TagHelper

class Walrus
attr_accessor :country_name
end
Expand All @@ -19,6 +21,14 @@ class Walrus
"<select id=\"walrus_country_name\" name=\"walrus[country_name]\">"
end

let(:selected_us_option) do
if defined?(Tags::Base)
content_tag(:option, 'United States', selected: :selected, value: 'us')
else
"<option value=\"us\" selected=\"selected\">United States</option>"
end
end

let(:builder) do
if defined?(Tags::Base)
FormBuilder.new(:walrus, walrus, template, {})
Expand All @@ -36,15 +46,14 @@ class Walrus

it "creates option tags of the countries" do
::CountrySelect::COUNTRIES.each do |code,name|
name.gsub!(/'/,'&#x27;')
tag.should include("<option value=\"#{code}\">#{name}</option>")
tag.should include(content_tag(:option, name, value: code))
end
end

it "selects the value of country_name" do
walrus.country_name = 'us'
t = builder.country_select(:country_name)
t.should include("<option value=\"us\" selected=\"selected\">United States</option>")
t.should include(selected_us_option)
end
end

Expand Down

0 comments on commit a90fd76

Please sign in to comment.