Skip to content

Commit

Permalink
Fixing some specs
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorHP committed Apr 19, 2015
1 parent b67df8a commit b345299
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 30 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -45,6 +45,7 @@ end
group :development, :test do
gem 'pry'
gem 'rspec-rails', '~> 3.0.0'
gem 'rspec-activemodel-mocks' # for compatibility
gem 'capybara', '~> 2.2.0', :require => false
gem 'capybara-webkit', :require => false
gem 'database_cleaner', :require => false
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Expand Up @@ -144,6 +144,10 @@ GEM
ffi (>= 0.5.0)
responders (1.1.2)
railties (>= 3.2, < 4.2)
rspec-activemodel-mocks (1.0.1)
activemodel (>= 3.0)
activesupport (>= 3.0)
rspec-mocks (>= 2.99, < 4.0)
rspec-core (3.0.4)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.4)
Expand Down Expand Up @@ -219,6 +223,7 @@ DEPENDENCIES
pry
rack
rails (~> 4.0.0)
rspec-activemodel-mocks
rspec-rails (~> 3.0.0)
sass-rails
schema_plus
Expand Down
2 changes: 2 additions & 0 deletions config/environments/development.rb
Expand Up @@ -28,4 +28,6 @@

# Raise exception on mass assignment protection for Active Record models
#config.active_record.mass_assignment_sanitizer = :strict

Rails.application.routes.default_url_options = { :host => 'localhost' }
end
1 change: 1 addition & 0 deletions config/environments/test.rb
Expand Up @@ -36,6 +36,7 @@
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr

Rails.application.routes.default_url_options = { :host => 'test.host' }
# Raise exception on mass assignment protection for Active Record models
#config.active_record.mass_assignment_sanitizer = :strict
end
20 changes: 12 additions & 8 deletions spec/requests/admin/dashboard_spec.rb
Expand Up @@ -7,19 +7,23 @@
visit root_path
page.should have_content("Let's setup an administrator account first!")
end

it "offers to setup a site if the logged in user doesn't have any" do
login(admin)
visit root_path
page.should have_content("Let's get started!")
page.should have_content("So you want to embed comments on a bunch of web pages.")
end

it "redirects to the sites page if the user is logged in, there are administrators and the current user has sites" do
FactoryGirl.create(:site1, :user => admin)
login(admin)
visit root_path
current_url.should == admin_sites_url

context 'when logged in as an admin' do
before do |example|
FactoryGirl.create(:site1, :user => admin)
login(admin)
end

it "redirects to the sites page if the user is logged in, there are administrators and the current user has sites" do
visit root_path
current_url.should == admin_sites_url
end
end
end

Expand Down
11 changes: 2 additions & 9 deletions spec/spec_helper.rb
Expand Up @@ -28,16 +28,9 @@
config.include Devise::TestHelpers, :type => :view
config.include Capybara::DSL
config.include Rails.application.routes.url_helpers

# == 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

config.mock_with :rspec

config.before(:each) do
DatabaseCleaner.start
end
Expand Down
1 change: 1 addition & 0 deletions spec/support/spec_support.rb
@@ -1,5 +1,6 @@
module SpecSupport
def login(user)
binding.pry
if example.metadata[:type] == :request
visit("/test/login?user_id=#{user.id}")
page.should have_content("ok")
Expand Down
7 changes: 3 additions & 4 deletions spec/views/admin/sites/edit.html.erb_spec.rb
@@ -1,11 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")

describe "admin/sites/edit.html.erb" do
before(:each) do
@site = assign(:site, stub_model(Site))
end
describe "admin/sites/edit.html.erb", type: :view do

it "renders the edit site form" do
@site = assign(:site, stub_model(Site))

render

# Run the generator again with the --webrat flag if you want to use webrat matchers
Expand Down
8 changes: 4 additions & 4 deletions spec/views/admin/sites/index.html.erb_spec.rb
@@ -1,15 +1,15 @@
require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")

describe "admin/sites/index.html.erb" do
describe "admin/sites/index.html.erb", type: :view do
before(:each) do
sign_in(kotori)
end

it "renders a list of sites" do
assign(:sites, [
FactoryGirl.create(:site1, :user => kotori),
FactoryGirl.create(:site2, :user => kotori)
])
end

it "renders a list of sites" do
render
end
end
7 changes: 3 additions & 4 deletions spec/views/admin/sites/new.html.erb_spec.rb
@@ -1,11 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")

describe "admin/sites/new.html.erb" do
before(:each) do
assign(:site, stub_model(Site).as_new_record)
end
describe "admin/sites/new.html.erb", type: :view do

it "renders new site form" do
assign(:site, stub_model(Site).as_new_record)

render

# Run the generator again with the --webrat flag if you want to use webrat matchers
Expand Down
2 changes: 1 addition & 1 deletion spec/views/admin/sites/show.html.erb_spec.rb
@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")

describe "admin/sites/show.html.erb" do
describe "admin/sites/show.html.erb", type: :view do
before(:each) do
sign_in(kotori)
@site = assign(:site, FactoryGirl.create(:site1, :user => kotori))
Expand Down

0 comments on commit b345299

Please sign in to comment.