rspec-rails 2.0.0.rc → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -9,8 +9,8 @@ gem 'rspec-expectations', :path => "../rspec-expectations"
9
9
  gem 'rspec-mocks', :path => "../rspec-mocks"
10
10
  gem 'rspec', :path => "../rspec"
11
11
 
12
- gem 'cucumber'
13
- gem 'aruba', ">= 0.2.0", :require => nil
12
+ gem 'cucumber', '~> 0.9.2'
13
+ gem 'aruba', "~> 0.2.3", :require => nil
14
14
  gem 'webrat', ">= 0.7.2.beta.1"
15
15
  gem 'sqlite3-ruby', :require => 'sqlite3'
16
16
 
data/History.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## rspec-rails release history (incomplete)
2
2
 
3
+ ### 2.0.0 / 2010-10-10
4
+
5
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0.rc...v2.0.0)
6
+
7
+ * Changes
8
+ * route_to matcher delegates to assert_recognizes instead of assert_routing
9
+ * update generators to use as_new_record instead of :new_record => true
10
+
3
11
  ### 2.0.0.rc / 2010-10-05
4
12
 
5
13
  [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0.beta.22...v2.0.0.rc)
data/Rakefile CHANGED
@@ -20,7 +20,6 @@ require 'rspec'
20
20
  require 'rspec/core/rake_task'
21
21
  require 'cucumber/rake/task'
22
22
 
23
- RSpec::Core::RakeTask.new(:spec)
24
23
  class Cucumber::Rake::Task::ForkedCucumberRunner
25
24
  # When cucumber shells out, we still need it to run in the context of our
26
25
  # bundle.
@@ -28,8 +27,37 @@ class Cucumber::Rake::Task::ForkedCucumberRunner
28
27
  sh "bundle exec #{RUBY} " + args.join(" ")
29
28
  end
30
29
  end
30
+
31
+ task :cleanup_rcov_files do
32
+ rm_rf 'coverage.data'
33
+ end
34
+
35
+ desc "Run all examples"
36
+ RSpec::Core::RakeTask.new(:spec) do |t|
37
+ t.rspec_opts = %w[--color]
38
+ end
39
+
31
40
  Cucumber::Rake::Task.new(:cucumber)
32
41
 
42
+ namespace :spec do
43
+ desc "Run all examples using rcov"
44
+ RSpec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
45
+ t.rcov = true
46
+ t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
47
+ t.rcov_opts << %[--text-report --sort coverage --no-html --aggregate coverage.data]
48
+ end
49
+ end
50
+
51
+ namespace :cucumber do
52
+ desc "Run cucumber features using rcov"
53
+ Cucumber::Rake::Task.new :rcov => :cleanup_rcov_files do |t|
54
+ t.cucumber_opts = %w{--format progress}
55
+ t.rcov = true
56
+ t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
57
+ t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data]
58
+ end
59
+ end
60
+
33
61
  namespace :generate do
34
62
  desc "generate a fresh app with rspec installed"
35
63
  task :app do |t|
@@ -85,5 +113,11 @@ namespace :clobber do
85
113
  end
86
114
  end
87
115
 
88
- task :default => [:spec, "clobber:app", "generate:app", "generate:stuff", :cucumber, :smoke]
116
+ desc "Push cukes to relishapp using the relish-client-gem"
117
+ task :relish, :version do |t, args|
118
+ raise "rake relish[VERSION]" unless args[:version]
119
+ sh "bundle exec relish --organization rspec --project rspec-rails -v #{args[:version]} push"
120
+ end
121
+
122
+ task :default => [:spec, "clobber:app", "generate:app", "generate:stuff", :smoke, :cucumber]
89
123
 
@@ -1,11 +1,10 @@
1
- # Changes in beta.20
2
-
3
- ### Webrat or Capybara
1
+ # Upgrade to rspec-rails-2
4
2
 
5
- rspec-rails-2.0.0.beta.20 removes the dependency and offers you a choice of
6
- using webrat or capybara. Just add the library of your choice to your Gemfile.
3
+ ## Webrat and Capybara
7
4
 
8
- # Upgrade to rspec-rails-2
5
+ Earlier 2.0.0.beta versions depended on Webrat. As of
6
+ rspec-rails-2.0.0.beta.20, this dependency and offers you a choice of using
7
+ webrat or capybara. Just add the library of your choice to your Gemfile.
9
8
 
10
9
  ## Controller specs
11
10
 
@@ -29,3 +28,17 @@ partial gets rendered:
29
28
  render
30
29
  view.should render_template(:partial => "widget/_row")
31
30
 
31
+ ## as_new_record
32
+
33
+ Earlier versions of the view generators generated stub_model with `:new_record?
34
+ => true`. As of rspec-rails-2.0.0.rc, that is no longer recognized, so you need
35
+ to change this:
36
+
37
+ stub_model(Widget, :new_record? => true)
38
+
39
+ to this:
40
+
41
+ stub_model(Widget).as_new_record
42
+
43
+ Generators in 2.0.0 final release will do the latter.
44
+
@@ -1,12 +1,17 @@
1
- # Cucumber features
1
+ rspec-rails extends Rails' built-in testing framework to support rspec examples
2
+ for requests, controllers, models, views, and helpers.
2
3
 
3
- RSpec is specified using both RSpec and
4
- [Cucumber](http://github.com/aslakhellesoy/cucumber). Cucumber provides
5
- _executable documentation_. This means that the _.feature_ files below this
6
- directory serve as specification, documentation _and_ regression tests of the
7
- behaviour.
4
+ ## Rails-3
5
+
6
+ rspec-rails-2 supports rails-3.0.0 and later. For earlier versions of Rails,
7
+ you need [rspec-rails-1.3](http://rspec.info).
8
8
 
9
9
  ## Issues
10
10
 
11
- If you find this documentation incomplete or confusing, please [submit an
12
- issue](http://github.com/rspec/rspec-rails/issues).
11
+ The documentation for rspec-rails is a work in progress. We'll be adding
12
+ Cucumber features over time, and clarifying existing ones. If you have
13
+ specific features you'd like to see added, find the existing documentation
14
+ incomplete or confusing, or, better yet, wish to write a missing Cucumber
15
+ feature yourself, please [submit an
16
+ issue](http://github.com/rspec/rspec-rails/issues) or a [pull
17
+ request](http://github.com/rspec/rspec-rails).
@@ -71,7 +71,7 @@ class Autotest::RailsRspec2 < Autotest::Rspec2
71
71
  add_mapping(%r%^config/database\.yml$%) { |_, m|
72
72
  files_matching %r%^spec/models/.*_spec\.rb$%
73
73
  }
74
- add_mapping(%r%^(spec/(spec_helper|shared/.*)|config/(boot|environment(s/test)?))\.rb$%) {
74
+ add_mapping(%r%^(spec/(spec_helper|support/.*)|config/(boot|environment(s/test)?))\.rb$%) {
75
75
  files_matching %r%^spec/(models|controllers|routing|views|helpers)/.*_spec\.rb$%
76
76
  }
77
77
  add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
@@ -3,13 +3,11 @@ require 'spec_helper'
3
3
  <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
4
4
  describe "<%= table_name %>/new.html.<%= options[:template_engine] %>" do
5
5
  before(:each) do
6
- assign(:<%= file_name %>, stub_model(<%= class_name %>,
7
- :new_record? => true<%= output_attributes.empty? ? '' : ',' %>
6
+ assign(:<%= file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? ').as_new_record)' : ',' %>
8
7
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
9
8
  :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
10
9
  <% end -%>
11
- ))
12
- end
10
+ <%= !output_attributes.empty? ? " ).as_new_record)\n end" : " end" %>
13
11
 
14
12
  it "renders new <%= file_name %> form" do
15
13
  render
@@ -8,6 +8,11 @@ module RSpec
8
8
  end
9
9
  end
10
10
 
11
+ RSpec::configure do |c|
12
+ c.backtrace_clean_patterns << /vendor\//
13
+ c.backtrace_clean_patterns << /lib\/rspec\/rails/
14
+ end
15
+
11
16
  require 'rspec/core'
12
17
  require 'rspec/rails/extensions'
13
18
  require 'rspec/rails/view_rendering'
@@ -5,7 +5,7 @@ module RSpec::Rails::Matchers
5
5
  matcher :route_to do |route_options|
6
6
  match_unless_raises Test::Unit::AssertionFailedError do |path|
7
7
  assertion_path = { :method => path.keys.first, :path => path.values.first }
8
- assert_routing(assertion_path, route_options)
8
+ assert_recognizes(route_options, assertion_path)
9
9
  end
10
10
 
11
11
  failure_message_for_should do
@@ -1,7 +1,7 @@
1
1
  module RSpec # :nodoc:
2
2
  module Rails # :nodoc:
3
3
  module Version # :nodoc:
4
- STRING = '2.0.0.rc'
4
+ STRING = '2.0.0'
5
5
  end
6
6
  end
7
7
  end
@@ -45,8 +45,8 @@ Gem::Specification.new do |s|
45
45
  Even if you've run it before, this ensures that you have the latest updates
46
46
  to spec/spec_helper.rb and any other support files.
47
47
 
48
- Previous versions of rspec-rails-2.0.0.beta installed files that are no
49
- longer being used, so please remove these files if you have them:
48
+ Beta versions of rspec-rails-2 installed files that are no longer being used,
49
+ so please remove these files if you have them:
50
50
 
51
51
  lib/tasks/rspec.rake
52
52
  config/initializers/rspec_generator.rb
@@ -2,24 +2,40 @@ require "spec_helper"
2
2
  require "autotest/rails_rspec2"
3
3
 
4
4
  describe Autotest::RailsRspec2 do
5
- before(:each) do
6
- rails_rspec2_autotest = Autotest::RailsRspec2.new
7
- @re = rails_rspec2_autotest.exceptions
8
- end
9
5
 
10
- it "should match './log/test.log'" do
11
- @re.should match('./log/test.log')
12
- end
6
+ let(:rails_rspec2_autotest) { Autotest::RailsRspec2.new }
13
7
 
14
- it "should match 'log/test.log'" do
15
- @re.should match('log/test.log')
16
- end
8
+ describe 'exceptions' do
9
+ let(:exceptions_regexp) { rails_rspec2_autotest.exceptions }
10
+
11
+ it "should match './log/test.log'" do
12
+ exceptions_regexp.should match('./log/test.log')
13
+ end
17
14
 
18
- it "should not match './spec/models/user_spec.rb'" do
19
- @re.should_not match('./spec/models/user_spec.rb')
15
+ it "should match 'log/test.log'" do
16
+ exceptions_regexp.should match('log/test.log')
17
+ end
18
+
19
+ it "should not match './spec/models/user_spec.rb'" do
20
+ exceptions_regexp.should_not match('./spec/models/user_spec.rb')
21
+ end
22
+
23
+ it "should not match 'spec/models/user_spec.rb'" do
24
+ exceptions_regexp.should_not match('spec/models/user_spec.rb')
25
+ end
20
26
  end
21
27
 
22
- it "should not match 'spec/models/user_spec.rb'" do
23
- @re.should_not match('spec/models/user_spec.rb')
28
+ describe 'mappings' do
29
+ before do
30
+ rails_rspec2_autotest.find_order = %w(
31
+ spec/models/user_spec.rb
32
+ spec/support/blueprints.rb
33
+ )
34
+ end
35
+
36
+ it 'runs model specs when support files change' do
37
+ rails_rspec2_autotest.test_files_for('spec/support/blueprints.rb').should(
38
+ include('spec/models/user_spec.rb'))
39
+ end
24
40
  end
25
41
  end
@@ -3,8 +3,8 @@ require "spec_helper"
3
3
  describe "route_to" do
4
4
  include RSpec::Rails::Matchers::RoutingMatchers
5
5
 
6
- it "uses failure message from assert_routing" do
7
- self.stub!(:assert_routing).and_raise(
6
+ it "uses failure message from assert_recognizes" do
7
+ self.stub!(:assert_recognizes).and_raise(
8
8
  Test::Unit::AssertionFailedError.new("this message"))
9
9
  expect do
10
10
  {"this" => "path"}.should route_to("these" => "options")
metadata CHANGED
@@ -1,14 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7712058
5
- prerelease: true
4
+ prerelease: false
6
5
  segments:
7
6
  - 2
8
7
  - 0
9
8
  - 0
10
- - rc
11
- version: 2.0.0.rc
9
+ version: 2.0.0
12
10
  platform: ruby
13
11
  authors:
14
12
  - David Chelimsky
@@ -17,26 +15,24 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2010-10-04 00:00:00 -05:00
18
+ date: 2010-10-10 00:00:00 -05:00
21
19
  default_executable:
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ name: rspec
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - "="
28
27
  - !ruby/object:Gem::Version
29
- hash: 7712058
30
28
  segments:
31
29
  - 2
32
30
  - 0
33
31
  - 0
34
- - rc
35
- version: 2.0.0.rc
36
- requirement: *id001
32
+ version: 2.0.0
37
33
  type: :runtime
38
- name: rspec
39
34
  prerelease: false
35
+ version_requirements: *id001
40
36
  description: RSpec-2 for Rails-3
41
37
  email: dchelimsky@gmail.com;chad.humphries@gmail.com
42
38
  executables: []
@@ -49,7 +45,6 @@ files:
49
45
  - .document
50
46
  - .gitignore
51
47
  - Gemfile
52
- - Gotchas.markdown
53
48
  - History.md
54
49
  - README.markdown
55
50
  - Rakefile
@@ -170,7 +165,7 @@ licenses: []
170
165
  post_install_message: |
171
166
  **************************************************
172
167
 
173
- Thank you for installing rspec-rails-2.0.0.rc!
168
+ Thank you for installing rspec-rails-2.0.0!
174
169
 
175
170
  This version of rspec-rails only works with versions of rails >= 3.0.0
176
171
 
@@ -180,7 +175,7 @@ post_install_message: |
180
175
  can access its generators and rake tasks.
181
176
 
182
177
  group :development, :test do
183
- gem "rspec-rails", ">= 2.0.0.rc"
178
+ gem "rspec-rails", ">= 2.0.0"
184
179
  end
185
180
 
186
181
  Be sure to run the following command in each of your Rails apps if you're
@@ -191,8 +186,8 @@ post_install_message: |
191
186
  Even if you've run it before, this ensures that you have the latest updates
192
187
  to spec/spec_helper.rb and any other support files.
193
188
 
194
- Previous versions of rspec-rails-2.0.0.beta installed files that are no
195
- longer being used, so please remove these files if you have them:
189
+ Beta versions of rspec-rails-2 installed files that are no longer being used,
190
+ so please remove these files if you have them:
196
191
 
197
192
  lib/tasks/rspec.rake
198
193
  config/initializers/rspec_generator.rb
@@ -211,28 +206,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
211
206
  requirements:
212
207
  - - ">="
213
208
  - !ruby/object:Gem::Version
214
- hash: 3
209
+ hash: 4170741284803000716
215
210
  segments:
216
211
  - 0
217
212
  version: "0"
218
213
  required_rubygems_version: !ruby/object:Gem::Requirement
219
214
  none: false
220
215
  requirements:
221
- - - ">"
216
+ - - ">="
222
217
  - !ruby/object:Gem::Version
223
- hash: 25
218
+ hash: 4170741284803000716
224
219
  segments:
225
- - 1
226
- - 3
227
- - 1
228
- version: 1.3.1
220
+ - 0
221
+ version: "0"
229
222
  requirements: []
230
223
 
231
224
  rubyforge_project: rspec
232
225
  rubygems_version: 1.3.7
233
226
  signing_key:
234
227
  specification_version: 3
235
- summary: rspec-rails-2.0.0.rc
228
+ summary: rspec-rails-2.0.0
236
229
  test_files:
237
230
  - features/README.markdown
238
231
  - features/controller_specs/anonymous_controller.feature
@@ -1,14 +0,0 @@
1
- # Gotchas
2
-
3
- ## Name conflicts with upstream dependencies
4
-
5
- Examples in rspec-rails mix in Rails' assertion modules, which mix in assertion
6
- libraries from Minitest (if available) or Test::Unit. This makes it easy to
7
- accidentally override a method defined in one of those upstream modules in an
8
- example.
9
-
10
- For example, if you have a model named `Message`, and you define a `message`
11
- method (using `def message` or `let(:message)` in an example group, it will
12
- override Minitest's `message` method, which is used internally by Minitest, and
13
- is also a public API of Minitest. In this case, you would need to use a
14
- different method name or work with instance variables instead of methods.