Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rspec/rspec-rails
...
head fork: rspec/rspec-rails
Checking mergeability… Don't worry, you can still create the pull request.
  • 12 commits
  • 17 files changed
  • 0 commit comments
  • 1 contributor
View
18 Gemfile
@@ -1,20 +1,18 @@
source "http://rubygems.org"
-gem 'arel', :path => "./vendor/arel"
-gem 'rails', :path => "./vendor/rails"
+gem 'rails', :path => File.expand_path("../vendor/rails", __FILE__)
-gem 'rspec-rails', :path => "."
-gem 'rspec-core', :path => "../rspec-core"
-gem 'rspec-expectations', :path => "../rspec-expectations"
-gem 'rspec-mocks', :path => "../rspec-mocks"
-gem 'rspec', :path => "../rspec"
+%w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
+ gem lib, :path => File.expand_path("../../#{lib}", __FILE__)
+end
-gem 'cucumber', '~> 0.9.2'
-gem 'aruba', "~> 0.2.3", :require => nil
-gem 'webrat', ">= 0.7.2.beta.1"
gem 'sqlite3-ruby', :require => 'sqlite3'
+gem "cucumber", "0.8.5"
+gem "aruba", "0.2.2"
+gem 'webrat', ">= 0.7.2"
gem 'autotest'
+gem 'relish'
case RUBY_VERSION
when /^1\.9/
View
7 History.md
@@ -1,5 +1,12 @@
## rspec-rails-2 release history (incomplete)
+### 2.0.2 / in development
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.1...master)
+
+* Enhancements
+ * Re-added and properly deprecated `integrate_views` from rspec-rails-1
+
### 2.0.1 / 2010-10-15
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0...v2.0.1)
View
13 README.markdown
@@ -2,9 +2,16 @@
rspec-2 for rails-3 with lightweight extensions to each
+NOTE: rspec-2 does _not_ support rails-2. Use rspec-rails-1.3.x for rails-2.
+
+## Documentation
+
+* [Cucumber features](http://relishapp.com/rspec/rspec-rails/v/2-0)
+* [RDoc](http://rubydoc.info/gems/rspec-rails/2.0.1/frames)
+
## Install
- gem install rspec-rails --pre
+ gem install rspec-rails
This installs the following gems:
@@ -19,7 +26,7 @@ This installs the following gems:
Add `rspec-rails` to the `:test` and `:development` groups in the Gemfile:
group :test, :development do
- gem "rspec-rails", ">= 2.0.0.beta.22"
+ gem "rspec-rails", "~> 2.0.1"
end
It needs to be in the `:development` group to expose generators and rake
@@ -99,8 +106,6 @@ not send you to the doctor with a migraine.
See http://github.com/rspec/rspec-rails/issues
-Also see [Gotchas.markdown](http://github.com/rspec/rspec-rails/blob/master/Gotchas.markdown)
-
# Request Specs
Request specs live in spec/requests.
View
39 Rakefile
@@ -1,9 +1,8 @@
-unless File.directory?("vendor/rails") && File.directory?("vendor/arel")
+unless File.directory?("vendor/rails")
raise <<-MESSAGE
-You need to clone the rails and arel git repositories into ./vendor
-before you can use any of the rake tasks.
+You need to clone the rails git repository into ./vendor before you can use any
+of the rake tasks.
- git clone git://github.com/rails/arel.git vendor/arel
git clone git://github.com/rails/rails.git vendor/rails
MESSAGE
@@ -20,14 +19,6 @@ require 'rspec'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
-class Cucumber::Rake::Task::ForkedCucumberRunner
- # When cucumber shells out, we still need it to run in the context of our
- # bundle.
- def run
- sh "bundle exec #{RUBY} " + args.join(" ")
- end
-end
-
task :cleanup_rcov_files do
rm_rf 'coverage.data'
end
@@ -70,33 +61,33 @@ namespace :generate do
desc "generate a bunch of stuff with generators"
task :stuff do
- Dir.chdir("./tmp/example_app/") do
- sh "rake rails:template LOCATION='../../templates/generate_stuff.rb'"
+ in_example_app "rake rails:template LOCATION='../../templates/generate_stuff.rb'"
+ end
+end
+
+def in_example_app(command)
+ Dir.chdir("./tmp/example_app/") do
+ Bundler.with_clean_env do
+ sh command
end
end
end
namespace :db do
task :migrate do
- Dir.chdir("./tmp/example_app/") do
- sh "rake db:migrate"
- end
+ in_example_app "rake db:migrate"
end
namespace :test do
task :prepare do
- Dir.chdir("./tmp/example_app/") do
- sh "rake db:test:prepare"
- end
+ in_example_app "rake db:test:prepare"
end
end
end
desc "run a variety of specs against the generated app"
task :smoke do
- Dir.chdir("./tmp/example_app/") do
- sh "rake rails:template LOCATION='../../templates/run_specs.rb'"
- end
+ in_example_app "rake rails:template --trace LOCATION='../../templates/run_specs.rb'"
end
desc 'clobber generated files'
@@ -116,7 +107,7 @@ end
desc "Push cukes to relishapp using the relish-client-gem"
task :relish, :version do |t, args|
raise "rake relish[VERSION]" unless args[:version]
- sh "bundle exec relish --organization rspec --project rspec-rails -v #{args[:version]} push"
+ sh "relish push --organization rspec --project rspec-rails -v #{args[:version]}"
end
task :default => [:spec, "clobber:app", "generate:app", "generate:stuff", :smoke, :cucumber]
View
35 Thorfile
@@ -1,43 +1,16 @@
class Rails < Thor
- VERSIONS = {
- :rails => {
- "master" => "master",
- "3.0.0" => "v3.0.0",
- "3.0.1" => "v3.0.1",
- "3-0-stable" => "origin/3-0-stable"
- },
- :arel => {
- "master" => "master",
- "3.0.0" => "v1.0.0",
- "3.0.1" => "v1.0.0",
- "3-0-stable" => "master"
- }
- }
-
- desc "checkout VERSION", "checks it out (and arel)"
+ desc "checkout VERSION", "checks it out"
def checkout(version)
- unless VERSIONS[:rails].has_key?(version)
- raise "\n#{"*"*50}\nvalid versions are: #{VERSIONS[:rails].keys.join(", ")}\n#{"*"*50}\n"
- end
-
- puts "***** checking out rails at #{VERSIONS[:rails][version]} ..."
+ puts "***** checking out rails at #{version} ..."
Dir.chdir("vendor/rails") do
- `git checkout #{VERSIONS[:rails][version]}`
- end
-
- puts "***** checking out arel at #{VERSIONS[:arel][version]} ..."
- Dir.chdir("vendor/arel") do
- `git checkout #{VERSIONS[:arel][version]}`
+ `git checkout #{version}`
end
end
- desc "fetch", "update vendor/rails and vendor/arel"
+ desc "fetch", "update vendor/rails"
def fetch
Dir.chdir("vendor/rails") do
`git fetch`
end
- Dir.chdir("vendor/arel") do
- `git fetch`
- end
end
end
View
25 features/support/env.rb
@@ -1,6 +1,22 @@
require 'aruba'
require 'webrat'
+module Aruba::Api
+ alias_method :orig_run, :run
+
+ def run(cmd, fail_on_error=false)
+ if cmd =~ /^rspec/
+ orig_run("bundle exec #{cmd}", fail_on_error)
+ else
+ orig_run(cmd, fail_on_error)
+ end
+ end
+end
+
+Before do
+ unset_bundler_env_vars
+end
+
unless File.directory?('./tmp/example_app')
system "rake generate:app generate:stuff"
end
@@ -25,15 +41,14 @@ def copy(file_or_dir)
system "cp -r #{source} #{target}"
end
+
Before do
steps %Q{
Given a directory named "spec"
}
Dir['tmp/example_app/*'].each do |file_or_dir|
- if file_or_dir =~ /Gemfile/
- copy(file_or_dir)
- elsif !(file_or_dir =~ /spec$/)
+ if !(file_or_dir =~ /spec$/)
write_symlink(file_or_dir)
end
end
@@ -43,3 +58,7 @@ def copy(file_or_dir)
end
end
+
+Around do |scenario, block|
+ Bundler.with_clean_env &block
+end
View
10 lib/rspec/rails.rb
@@ -1,13 +1,3 @@
-module RSpec
- module Rails
- class << self
- def using_active_record?
- ::Rails.configuration.generators.options[:rails][:orm] == :active_record
- end
- end
- end
-end
-
require 'rspec/core'
RSpec::configure do |c|
View
60 lib/rspec/rails/extensions/active_record/base.rb
@@ -1,44 +1,40 @@
module RSpec
module Rails
- if using_active_record?
+ if defined?(ActiveRecord)
module Extensions
module ActiveRecord
- module ClassMethods
- # :call-seq:
- # ModelClass.should have(:no).records
- # ModelClass.should have(1).record
- # ModelClass.should have(n).records
- #
- # Extension to enhance <tt>should have</tt> on AR Model classes
- def records
- find(:all)
- end
- alias :record :records
- end
-
- module InstanceMethods
- # :call-seq:
- # model.should have(:no).errors_on(:attribute)
- # model.should have(1).error_on(:attribute)
- # model.should have(n).errors_on(:attribute)
- #
- # Extension to enhance <tt>should have</tt> on AR Model instances.
- # Calls model.valid? in order to prepare the object's errors
- # object.
- def errors_on(attribute)
- self.valid?
- [self.errors[attribute]].flatten.compact
- end
- alias :error_on :errors_on
+ # :call-seq:
+ # ModelClass.should have(:no).records
+ # ModelClass.should have(1).record
+ # ModelClass.should have(n).records
+ #
+ # Extension to enhance <tt>should have</tt> on AR Model classes
+ def records
+ find(:all)
end
+ alias :record :records
end
- end
- class ::ActiveRecord::Base #:nodoc:
- extend RSpec::Rails::Extensions::ActiveRecord::ClassMethods
- include RSpec::Rails::Extensions::ActiveRecord::InstanceMethods
+ class ::ActiveRecord::Base #:nodoc:
+ extend RSpec::Rails::Extensions::ActiveRecord
+ end
end
end
end
end
+module ::ActiveModel::Validations
+ # :call-seq:
+ # model.should have(:no).errors_on(:attribute)
+ # model.should have(1).error_on(:attribute)
+ # model.should have(n).errors_on(:attribute)
+ #
+ # Extension to enhance <tt>should have</tt> on AR Model instances.
+ # Calls model.valid? in order to prepare the object's errors
+ # object.
+ def errors_on(attribute)
+ self.valid?
+ [self.errors[attribute]].flatten.compact
+ end
+ alias :error_on :errors_on
+end
View
2  lib/rspec/rails/fixture_support.rb
@@ -1,6 +1,6 @@
module RSpec
module Rails
- if using_active_record?
+ if defined?(ActiveRecord)
module FixtureSupport
extend ActiveSupport::Concern
View
4 lib/rspec/rails/mocks.rb
@@ -70,7 +70,7 @@ def mock_model(string_or_model_class, stubs = {})
m.extend ActiveModelInstanceMethods
m.singleton_class.__send__ :include, ActiveModel::Conversion
m.singleton_class.__send__ :include, ActiveModel::Validations
- if RSpec::Rails::using_active_record?
+ if defined?(ActiveRecord)
m.extend ActiveRecordInstanceMethods
[:save, :update_attributes].each do |key|
if stubs[key] == false
@@ -175,7 +175,7 @@ def connection
def stub_model(model_class, stubs={})
model_class.new.tap do |m|
m.extend ActiveModelStubExtensions
- if RSpec::Rails::using_active_record? && model_class < ActiveRecord::Base
+ if defined?(ActiveRecord) && model_class < ActiveRecord::Base
m.extend ActiveRecordStubExtensions
primary_key = model_class.primary_key.to_sym
stubs = stubs.reverse_merge(primary_key => next_id)
View
2  lib/rspec/rails/version.rb
@@ -1,7 +1,7 @@
module RSpec # :nodoc:
module Rails # :nodoc:
module Version # :nodoc:
- STRING = '2.0.1'
+ STRING = '2.0.2.pre'
end
end
end
View
5 lib/rspec/rails/view_rendering.rb
@@ -15,6 +15,11 @@ def render_views
metadata_for_rspec_rails[:render_views] = true
end
+ def integrate_views
+ RSpec.deprecate("integrate_views","render_views")
+ render_views
+ end
+
def render_views?
!!metadata_for_rspec_rails[:render_views]
end
View
2  rspec-rails.gemspec
@@ -57,6 +57,6 @@ Gem::Specification.new do |s|
**************************************************
}
- s.add_runtime_dependency "rspec", "~> 2.0.0"
+ s.add_runtime_dependency "rspec", "~> 2.0.2.pre"
end
View
18 spec/rspec/rails/deprecations_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe "rspec-rails-2 deprecations" do
+ context "controller specs" do
+ describe "::integrate_views" do
+ let(:group) do
+ RSpec::Core::ExampleGroup.describe do
+ include RSpec::Rails::ControllerExampleGroup
+ end
+ end
+
+ it "is deprecated" do
+ RSpec.should_receive(:deprecate)
+ group.integrate_views
+ end
+ end
+ end
+end
View
23 spec/rspec/rails/extensions/active_model/errors_on_spec.rb
@@ -0,0 +1,23 @@
+require "spec_helper"
+
+describe "errors_on" do
+ let(:klass) do
+ Class.new do
+ include ActiveModel::Validations
+ end
+ end
+
+ it "calls valid?" do
+ model = klass.new
+ model.should_receive(:valid?)
+ model.errors_on(:foo)
+ end
+
+ it "returns the errors on that attribute" do
+ model = klass.new
+ model.stub(:errors) do
+ { :foo => ['a', 'b'] }
+ end
+ model.errors_on(:foo).should eq(['a','b'])
+ end
+end
View
9 spec/rspec/rails/extensions/active_record/records_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe "records" do
+ it "delegates to find(:all)" do
+ klass = Class.new(ActiveRecord::Base)
+ klass.should_receive(:find).with(:all)
+ klass.records
+ end
+end
View
27 templates/Gemfile
@@ -1,18 +1,19 @@
-source 'http://rubygems.org'
+source "http://rubygems.org"
-gem 'arel', :path => "../../vendor/arel"
-gem 'rails', :path => "../../vendor/rails"
+gem 'rails', :path => File.expand_path("../../../vendor/rails", __FILE__)
+
+%w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
+ gem lib, :path => File.expand_path("../../../../#{lib}", __FILE__)
+end
gem 'sqlite3-ruby', :require => 'sqlite3'
-group :development, :test do
- gem "rspec-rails", :path => "../../../rspec-rails"
- gem "rspec", :path => "../../../rspec"
- gem "rspec-core", :path => "../../../rspec-core"
- gem "rspec-expectations", :path => "../../../rspec-expectations"
- gem "rspec-mocks", :path => "../../../rspec-mocks"
- gem "rcov"
- gem "webrat"
- gem "autotest"
- gem "watchr"
+gem 'webrat', ">= 0.7.2"
+
+case RUBY_VERSION
+when /^1\.9/
+ gem 'ruby-debug19'
+when /^1\.8/
+ gem 'ruby-debug'
end
+

No commit comments for this range

Something went wrong with that request. Please try again.