Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding missing specs

  • Loading branch information...
commit d9a565993abe2161164acf1d6e684307a0a5089d 1 parent 040d263
@akitaonrails authored
View
1  .rspec
@@ -0,0 +1 @@
+--colour
View
4 Gemfile
@@ -47,4 +47,8 @@ gem 'ActiveAdmin-Globalize3-inputs'
group :development, :test do
gem 'rspec-rails'
gem 'pry-rails'
+
+ gem 'guard'
+ gem 'guard-rspec'
+ gem 'growl'
end
View
19 Gemfile.lock
@@ -65,6 +65,7 @@ GEM
execjs (1.4.0)
multi_json (~> 1.0)
fastercsv (1.5.5)
+ ffi (1.0.11)
formtastic (2.1.1)
actionpack (~> 3.0)
friendly_id (4.0.7)
@@ -72,6 +73,12 @@ GEM
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
paper_trail (~> 2)
+ growl (1.0.3)
+ guard (1.2.3)
+ listen (>= 0.4.2)
+ thor (>= 0.14.6)
+ guard-rspec (1.1.0)
+ guard (>= 1.1)
has_scope (0.5.1)
hike (1.2.1)
i18n (0.6.0)
@@ -90,6 +97,10 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
+ listen (0.4.7)
+ rb-fchange (~> 0.0.5)
+ rb-fsevent (~> 0.9.1)
+ rb-inotify (~> 0.8.8)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -140,6 +151,11 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
+ rb-fchange (0.0.5)
+ ffi
+ rb-fsevent (0.9.1)
+ rb-inotify (0.8.8)
+ ffi (>= 0.5.0)
rdiscount (1.6.8)
rdoc (3.12)
json (~> 1.4)
@@ -191,6 +207,9 @@ DEPENDENCIES
devise
friendly_id
globalize3
+ growl
+ guard
+ guard-rspec
jquery-rails
jquery-ui-rails
pry-rails
View
24 Guardfile
@@ -0,0 +1,24 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+
+ # Rails example
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+
+ # Turnip features and steps
+ watch(%r{^spec/acceptance/(.+)\.feature$})
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
+end
+
View
7 app/controllers/application_controller.rb
@@ -7,9 +7,10 @@ class ApplicationController < ActionController::Base
private
def set_locale
- lang = request.env['HTTP_ACCEPT_LANGUAGE']
- lang = lang[/^[a-z]{2}/]
- lang = :"pt-BR" if lang == "pt"
+ if lang = request.env['HTTP_ACCEPT_LANGUAGE']
+ lang = lang[/^[a-z]{2}/]
+ lang = :"pt-BR" if lang == "pt"
+ end
I18n.locale = params[:locale] || lang
end
end
View
7 spec/controllers/articles_controller_spec.rb
@@ -1,11 +1,16 @@
require 'spec_helper'
describe ArticlesController do
+ render_views
describe "GET 'show'" do
it "returns http success" do
- get 'show'
+ I18n.locale = :en
+ @article = Article.create title: "hello-world", body: "**test**"
+ get 'show', id: @article.slug, locale: "en"
response.should be_success
+
+ response.body.should include "<p><strong>test</strong></p>\n"
end
end
View
12 spec/controllers/welcome_controller_spec.rb
@@ -1,12 +0,0 @@
-require 'spec_helper'
-
-describe WelcomeController do
-
- describe "GET 'index'" do
- it "returns http success" do
- get 'index'
- response.should be_success
- end
- end
-
-end
View
17 spec/helpers/application_helper_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe ApplicationHelper do
+ it "should print locale links for English" do
+ I18n.locale = :en
+ helper.stub(:url_for).and_return("/pt-BR")
+ helper.language_links.should_not include("/en")
+ helper.language_links.should include("/pt-BR")
+ end
+
+ it "should print locale links for Portuguese" do
+ I18n.locale = :"pt-BR"
+ helper.stub(:url_for).and_return("/en")
+ helper.language_links.should_not include("/pt-BR")
+ helper.language_links.should include("/en")
+ end
+end
View
15 spec/helpers/articles_helper_spec.rb
@@ -1,15 +0,0 @@
-require 'spec_helper'
-
-# Specs in this file have access to a helper object that includes
-# the ArticlesHelper. For example:
-#
-# describe ArticlesHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
-describe ArticlesHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
View
15 spec/helpers/welcome_helper_spec.rb
@@ -1,15 +0,0 @@
-require 'spec_helper'
-
-# Specs in this file have access to a helper object that includes
-# the WelcomeHelper. For example:
-#
-# describe WelcomeHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
-describe WelcomeHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
View
5 spec/models/admin_user_spec.rb
@@ -1,5 +0,0 @@
-require 'spec_helper'
-
-describe AdminUser do
- pending "add some examples to (or delete) #{__FILE__}"
-end
View
33 spec/models/article_spec.rb
@@ -1,5 +1,36 @@
require 'spec_helper'
describe Article do
- pending "add some examples to (or delete) #{__FILE__}"
+ before(:each) do
+ I18n.locale = :en
+ @article = Article.create title: "Hello World", body: "**Test**"
+ I18n.locale = :"pt-BR"
+ @article.update_attributes(title: "Ola Mundo", body: "__Teste__")
+ end
+
+ context "translations" do
+ it "should read the correct translation" do
+ @article = Article.last
+ I18n.locale = :en
+ @article.title.should == "Hello World"
+ @article.body.should == "**Test**"
+ I18n.locale = :"pt-BR"
+ @article.title.should == "Ola Mundo"
+ @article.body.should == "__Teste__"
+ end
+
+ it "shouls generate the correct HTML" do
+ @article = Article.last
+ I18n.locale = :en
+ @article.body_html.should == "<p><strong>Test</strong></p>\n"
+ I18n.locale = :"pt-BR"
+ @article.body_html.should == "<p><strong>Teste</strong></p>\n"
+ end
+ end
+
+ context "slug" do
+ it "should generate a slug" do
+ @article.slug.should == "hello-world"
+ end
+ end
end
View
5 spec/models/user_spec.rb
@@ -1,5 +0,0 @@
-require 'spec_helper'
-
-describe User do
- pending "add some examples to (or delete) #{__FILE__}"
-end
View
32 spec/spec_helper.rb
@@ -0,0 +1,32 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+require 'rspec/autorun'
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+RSpec.configure do |config|
+ # ## Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ # If true, the base class of anonymous controllers will be inferred
+ # automatically. This will be the default behavior in future versions of
+ # rspec-rails.
+ config.infer_base_class_for_anonymous_controllers = false
+end
View
5 spec/views/articles/show.html.erb_spec.rb
@@ -1,5 +0,0 @@
-require 'spec_helper'
-
-describe "articles/show.html.erb" do
- pending "add some examples to (or delete) #{__FILE__}"
-end
View
5 spec/views/welcome/index.html.erb_spec.rb
@@ -1,5 +0,0 @@
-require 'spec_helper'
-
-describe "welcome/index.html.erb" do
- pending "add some examples to (or delete) #{__FILE__}"
-end
Please sign in to comment.
Something went wrong with that request. Please try again.