Skip to content

Commit

Permalink
Fixed whitespace in helper specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemens committed Sep 20, 2008
1 parent 980699e commit b22cad4
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 161 deletions.
8 changes: 4 additions & 4 deletions spec/helpers/admin/base_helper_spec.rb
Expand Up @@ -6,11 +6,11 @@
before :each do
@user = stub_user
helper.stub!(:current_user).and_return @user

helper.stub!(:admin_sites_path).and_return 'admin_sites_path'
helper.stub!(:admin_users_path).and_return 'admin_users_path'
helper.stub!(:admin_site_path).and_return 'admin_site_path'

helper.stub!(:request).and_return mock('request', :path => 'path')
end

Expand All @@ -34,11 +34,11 @@
before :each do
@user.stub!(:has_role?).with(:superuser).and_return false
end

it "shows the site overview option in the site select menu" do
helper.admin_site_select_tag.should_not have_tag('select#site-select option[value=?]', 'admin_sites_path')
end

it "shows the user manager option in the site select menu" do
helper.admin_site_select_tag.should_not have_tag('select#site-select option[value=?]', 'admin_users_path')
end
Expand Down
36 changes: 18 additions & 18 deletions spec/helpers/base_helper_spec.rb
Expand Up @@ -2,75 +2,75 @@

describe BaseHelper do
it '#link_to_section_main_action should probably be solved differently'

describe '#split_form_for' do
before :each do
@args = 'name', stub_model(Article), {:url => 'path/to/article'}
@head = '<form action="path/to/article" method="post">'
@form = "the form\n</form>"

helper.stub!(:capture_erb_with_buffer).and_return "#{@head}\n#{@form}"
helper.stub! :content_for
helper.stub! :concat
end

it 'splits off the form head tag from the generated form' do
_erbout = ''
helper.should_receive(:concat).with('the form', anything())
helper.split_form_for *@args do 'the form' end
end

it 'captures form head tag to content_for :form' do
_erbout = ''
helper.should_receive(:content_for).with(:form, @head)
helper.split_form_for *@args do 'the form' end
end
end

describe '#pluralize_str' do
before :each do
@singular = 'apple'
@plural = 'apples'
@singular_with_format = '%s apple'
end

it 'returns the singular of the passed string if count equals 1' do
helper.pluralize_str(1, @singular, @plural).should == 'apple'
end

it 'returns the passed plural of the passed string if count equals 1 and a plural has been passed' do
helper.pluralize_str(2, @singular, @plural).should == 'apples'
end

it "returns the passed singluar's pluralization if count equals 1 and no plural has been passed" do
Inflector.should_receive(:pluralize).and_return 'cherries'
helper.pluralize_str(2, @singular).should == 'cherries'
end

it 'interpolates the count to the returned result' do
helper.pluralize_str(2, @singular_with_format).should == '2 apples'
end
end
end

describe 'date helpers' do
before :each do
Time.zone.stub!(:now).and_return Time.local(2008, 1, 2)
Time.zone.now.stub!(:yesterday).and_return Time.local(2008, 1, 1)
end

it '#todays_short_date returns a short formatted version of Time.zone.now' do
helper.todays_short_date.should == 'January 2nd'
end

it '#yesterdays_short_date returns a short formatted version of Time.zone.now.yesterday' do
helper.yesterdays_short_date.should == 'January 1st'
end
end

it '#filter_options returns a nested array containing the installed column filters' do
helper.filter_options.sort.should == [["Plain HTML", ""],
["Markdown", "markdown_filter"],
["Markdown with Smarty Pants", "smartypants_filter"],
helper.filter_options.sort.should == [["Plain HTML", ""],
["Markdown", "markdown_filter"],
["Markdown with Smarty Pants", "smartypants_filter"],
["Textile", "textile_filter"]].sort
end
end
end
12 changes: 6 additions & 6 deletions spec/helpers/cached_pages_helper_spec.rb
Expand Up @@ -2,30 +2,30 @@

describe CachedPagesHelper do
include Stubby

describe '#cached_page_date' do
before :each do
scenario :cached_pages

@time_now = Time.local 2008, 1, 2, 12
@yesterday = Time.local 2008, 1, 1, 12

Time.stub!(:now).and_return @time_now # wtf ... time_now_in_words ignores the timezone
Time.zone.stub!(:now).and_return @time_now
Time.zone.now.stub!(:yesterday).and_return @yesterday
Date.stub!(:today).and_return Time.zone.now.to_date
end

it 'returns a variant of time_ago_in_words if the cached page was updated no more than 4 hours ago' do
@page.stub!(:updated_at).and_return @time_now - 55.minutes
helper.cached_page_date(@page).should == '~ 1 hour ago'
end

it "returns a formatted date preceeded with 'Today' if the cached page was updated earlier today" do
@page.stub!(:updated_at).and_return @time_now - 6.hours
helper.cached_page_date(@page).should =~ /Today, /
end

it "returns a formatted date if the cached page was updated before today" do
@page.stub!(:updated_at).and_return Time.local(2008, 1, 1)
helper.cached_page_date(@page).should == 'Jan 01, 2008'
Expand Down
26 changes: 13 additions & 13 deletions spec/helpers/comments_helper_spec.rb
Expand Up @@ -2,53 +2,53 @@

describe CommentsHelper do
include Stubby, UrlMatchers, CommentsHelper

before :each do
scenario :blog_with_published_article, :blog_comments
end

it '#comments_feed_title joins the titles of site, section and commentable' do
helper.comments_feed_title(@site, @section, @article).should ==
helper.comments_feed_title(@site, @section, @article).should ==
'Comments: site title &raquo; blog title &raquo; An article'
end

it '#link_to_remote_comment_preview returns a rote link to preview_comments_path' do
helper.should_receive(:preview_comments_path).and_return '/path/to/comments/preview'
helper.link_to_remote_comment_preview.should =~ /Ajax.Updater/
end

describe '#comment_form_hidden_fields returns hidden fields for generic comment form usage' do
before :each do
before :each do
@fields = comment_form_hidden_fields(@article)
end

it 'including return_to' do
@fields.should have_tag('input[type=?][name=?]', 'hidden', 'return_to')
end

it 'including comment[commentable_type]' do
@fields.should have_tag('input[type=?][name=?]', 'hidden', 'comment[commentable_type]')
end

it 'including comment[commentable_id]' do
@fields.should have_tag('input[type=?][name=?]', 'hidden', 'comment[commentable_id]')
end
end

describe "the admin_comment_path helper" do
it "calls admin_site_comment_path helper" do
should_receive(:admin_site_comments_path)
admin_comments_path
end

describe "with no :section_id param given" do
describe "and with no :content_id param given" do
it "returns the admin_site_comment_path with no further params" do
stub!(:params).and_return :site_id => 1
admin_comments_path(@site).should_not have_parameters
end
end

describe "and with a :content_id param given" do
it "returns the admin_site_comment_path with the :content_id param" do
stub!(:params).and_return :site_id => 1, :content_id => 1
Expand All @@ -64,7 +64,7 @@
admin_comments_path(@site).should have_parameters(:section_id)
end
end

describe "and with a :content_id param given" do
it "returns the admin_site_comment_path with the :content_id param" do
stub!(:params).and_return :site_id => 1, :section_id => 1, :content_id => 1
Expand Down

0 comments on commit b22cad4

Please sign in to comment.