Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
switching to rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Oct 16, 2010
1 parent bd195ad commit 82daa91
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 65 deletions.
1 change: 1 addition & 0 deletions .rspec
@@ -0,0 +1 @@
--colour
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -4,3 +4,4 @@ gem 'rails', '3.0.0'
gem 'mysql2'
gem 'nifty-generators'
gem "mocha", :group => :test
gem 'rspec-rails', '>= 2.0.1', :group => [:development, :test]
14 changes: 14 additions & 0 deletions Gemfile.lock
Expand Up @@ -31,6 +31,7 @@ GEM
arel (1.0.1)
activesupport (~> 3.0.0)
builder (2.1.2)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.4.1)
Expand Down Expand Up @@ -63,6 +64,18 @@ GEM
rake (>= 0.8.4)
thor (~> 0.14.0)
rake (0.8.7)
rspec (2.0.0)
rspec-core (= 2.0.0)
rspec-expectations (= 2.0.0)
rspec-mocks (= 2.0.0)
rspec-core (2.0.0)
rspec-expectations (2.0.0)
diff-lcs (>= 1.1.2)
rspec-mocks (2.0.0)
rspec-core (= 2.0.0)
rspec-expectations (= 2.0.0)
rspec-rails (2.0.1)
rspec (~> 2.0.0)
thor (0.14.3)
treetop (1.4.8)
polyglot (>= 0.3.1)
Expand All @@ -76,3 +89,4 @@ DEPENDENCIES
mysql2
nifty-generators
rails (= 3.0.0)
rspec-rails (>= 2.0.1)
2 changes: 2 additions & 0 deletions autotest/discover.rb
@@ -0,0 +1,2 @@
Autotest.add_discovery { "rails" }
Autotest.add_discovery { "rspec2" }
33 changes: 33 additions & 0 deletions spec/controllers/games_controller_spec.rb
@@ -0,0 +1,33 @@
require File.dirname(__FILE__) + '/../spec_helper'

describe GamesController do
fixtures :all
render_views

it "index action should render index template" do
get :index
response.should render_template(:index)
end

it "show action should render show template" do
get :show, :id => Game.first
response.should render_template(:show)
end

it "new action should render new template" do
get :new
response.should render_template(:new)
end

it "create action should render new template when model is invalid" do
Game.any_instance.stubs(:valid?).returns(false)
post :create
response.should render_template(:new)
end

it "create action should redirect when model is valid" do
Game.any_instance.stubs(:valid?).returns(true)
post :create
response.should redirect_to(game_url(assigns[:game]))
end
end
12 changes: 6 additions & 6 deletions test/fixtures/games.yml → spec/fixtures/games.yml
Expand Up @@ -11,9 +11,9 @@ one:
komi: 1.5
handicap: 1
board_size: 1
last_move_at: 2010-10-15 17:07:01
started_at: 2010-10-15 17:07:01
finished_at: 2010-10-15 17:07:01
last_move_at: 2010-10-15 17:15:53
started_at: 2010-10-15 17:15:53
finished_at: 2010-10-15 17:15:53

two:
black_player_id: 1
Expand All @@ -28,6 +28,6 @@ two:
komi: 1.5
handicap: 1
board_size: 1
last_move_at: 2010-10-15 17:07:01
started_at: 2010-10-15 17:07:01
finished_at: 2010-10-15 17:07:01
last_move_at: 2010-10-15 17:15:53
started_at: 2010-10-15 17:15:53
finished_at: 2010-10-15 17:15:53
7 changes: 7 additions & 0 deletions spec/models/game_spec.rb
@@ -0,0 +1,7 @@
require File.dirname(__FILE__) + '/../spec_helper'

describe Game do
it "should be valid" do
Game.new.should be_valid
end
end
27 changes: 27 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,27 @@
# 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'

# 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
config.mock_with :rspec

# 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
end
30 changes: 0 additions & 30 deletions test/functional/games_controller_test.rb

This file was deleted.

9 changes: 0 additions & 9 deletions test/performance/browsing_test.rb

This file was deleted.

13 changes: 0 additions & 13 deletions test/test_helper.rb

This file was deleted.

7 changes: 0 additions & 7 deletions test/unit/game_test.rb

This file was deleted.

0 comments on commit 82daa91

Please sign in to comment.