rspec-rails 2.0.0.a4 → 2.0.0.a5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,11 +12,13 @@ Currently in super-pre-alpha state - explore at your own risk!
12
12
 
13
13
  Install:
14
14
 
15
+ gem install rspec-rails --pre
16
+
17
+ Build from source and install:
18
+
15
19
  git clone git://github.com/rspec/rspec-dev
16
20
  cd rspec-dev
17
- rake git:clone
18
- rake gem:build
19
- rake gem:install
21
+ rake
20
22
 
21
23
  This installs the following gems:
22
24
 
@@ -30,29 +32,19 @@ This installs the following gems:
30
32
 
31
33
  Currently supported:
32
34
 
33
- * controller specs in spec/controllers
34
- * no view isolation yet
35
+ * each example runs in its own transaction
36
+ * not yet configurable
35
37
  * model specs in spec/models
36
38
  * request specs in spec/requests
37
39
  * these wrap rails integration tests
38
40
  * rails assertions
39
41
  * webrat matchers
40
- * rails-specific matchers
41
- * response.should redirect_to(...)
42
- * wraps assert_redirected_to
43
- * only works with should (not should_not)
44
42
  * generators
45
- * borrowed from José Valim's third_rails repo on github
46
- * the generators work, but not all the generated specs
47
- work yet :(
48
43
 
49
44
  ### Known issues
50
45
 
51
- None (or very little) of the following are supported yet (but will be soon):
46
+ * no controller specs
47
+ * no view specs
48
+ * no helper specs
49
+ * no routing specs
52
50
 
53
- * rails-specific matchers
54
- * only supports "response.should redirect_to(..)"
55
- * isolation from views in controller specs
56
- * view specs
57
- * helper specs
58
- * routing specs
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ begin
17
17
  gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
18
18
  gem.homepage = "http://github.com/rspec/rspec-rails"
19
19
  gem.authors = ["David Chelimsky", "Chad Humphries"]
20
- gem.add_dependency "rspec", ">= 2.0.0.a2"
20
+ gem.add_dependency "rspec", ">= 2.0.0.a5"
21
21
  gem.add_dependency "webrat", "0.7.0"
22
22
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
23
23
  end
@@ -4,27 +4,15 @@ require 'rspec/rails/version'
4
4
  # - would be nicer if we could source them from the <repo>/pkg dirs
5
5
  gem 'rspec-rails', :version => "'#{Rspec::Rails::Version::STRING}'"
6
6
 
7
- initializer 'generators.rb', <<-CODE
8
- module ExampleApp
9
- class Application < Rails::Application
10
- config.generators do |g|
11
- g.test_framework :rspec,
12
- :fixtures => false,
13
- :routes => false,
14
- :views => false
15
- end
16
- end
17
- end
18
- CODE
19
-
20
7
  run('bundle install')
21
8
 
22
9
  run('script/rails g rspec:install')
23
- run('script/rails g model thing name:string')
24
- run('script/rails g controller widgets index')
25
- run('script/rails g integration_test widgets')
10
+ # run('script/rails g model thing name:string')
11
+ run('script/rails g scaffold wombats name:string')
12
+ # run('script/rails g controller widgets index')
13
+ # run('script/rails g integration_test widgets')
26
14
 
27
15
  run('rake db:migrate')
28
16
  run('rake db:test:prepare')
29
- run('bin/rspec spec')
17
+ run('rspec spec')
30
18
  run('rake spec')
@@ -6,13 +6,19 @@ module Rspec
6
6
  argument :actions, :type => :array, :default => [], :banner => "action action"
7
7
 
8
8
  class_option :template_engine, :desc => "Template engine to generate view files"
9
+ class_option :controllers, :type => :boolean, :default => false
10
+ class_option :views, :type => :boolean, :default => false
9
11
 
10
12
  def create_controller_files
13
+ return unless options[:controllers]
14
+
11
15
  template 'controller_spec.rb',
12
16
  File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
13
17
  end
14
18
 
15
19
  def create_view_files
20
+ return unless options[:views]
21
+
16
22
  empty_directory File.join("spec", "views", file_path)
17
23
 
18
24
  actions.each do |action|
@@ -3,7 +3,11 @@ require 'generators/rspec'
3
3
  module Rspec
4
4
  module Generators
5
5
  class HelperGenerator < Base
6
+ class_option :helpers, :type => :boolean, :default => false
7
+
6
8
  def create_helper_files
9
+ return unless options[:helpers]
10
+
7
11
  template 'helper_spec.rb', File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
8
12
  end
9
13
  end
@@ -1,7 +1,6 @@
1
1
  module Rspec
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
4
- add_shebang_option!
5
4
 
6
5
  desc <<DESC
7
6
  Description:
@@ -16,14 +15,20 @@ DESC
16
15
  directory 'lib'
17
16
  end
18
17
 
19
- # def copy_script_files
20
- # directory "script"
21
- # chmod "script/rspec", 0755, :verbose => false
22
- # end
18
+ def create_config_files
19
+ inside "config" do
20
+ directory "initializers"
21
+ end
22
+ end
23
23
 
24
24
  def copy_spec_files
25
25
  directory 'spec'
26
26
  end
27
+
28
+ def app_name
29
+ Rails.application.class.name
30
+ end
31
+
27
32
  end
28
33
  end
29
34
  end
@@ -0,0 +1,16 @@
1
+ <%= app_name %>.configure do
2
+ # We're still in alpha, so we're only generating model specs
3
+ # and request (integration) specs. We'll change these defaults
4
+ # as we add support for controller specs, etc.
5
+ config.generators do |g|
6
+ g.integration_tool :rspec
7
+ g.test_framework :rspec,
8
+ :fixture => false,
9
+ :controllers => false,
10
+ :views => false,
11
+ :helpers => false,
12
+ :routes => false,
13
+ :integration => true
14
+
15
+ end
16
+ end
@@ -1,4 +1,2 @@
1
- --colour
1
+ --color
2
2
  --format progress
3
- --loadby mtime
4
- --reverse
@@ -15,14 +15,24 @@ Rspec::Core.configure do |config|
15
15
  require 'rspec/expectations'
16
16
  config.include Rspec::Matchers
17
17
 
18
+ # == Mock Framework
19
+ #
20
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
21
+ #
22
+ # config.mock_with :mocha
23
+ # config.mock_with :flexmock
24
+ # config.mock_with :rr
25
+ config.mock_with :rspec
26
+
27
+ # == Fixtures
28
+ #
18
29
  # If you're not using ActiveRecord you should remove these
19
30
  # lines, delete config/database.yml and disable :active_record
20
31
  # in your config/boot.rb
32
+ #
21
33
  # config.use_transactional_fixtures = true
22
34
  # config.use_instantiated_fixtures = false
23
35
  # config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
24
-
25
- # == Fixtures
26
36
  #
27
37
  # You can declare fixtures for each example_group like this:
28
38
  # describe "...." do
@@ -41,15 +51,6 @@ Rspec::Core.configure do |config|
41
51
  #
42
52
  # config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
43
53
  #
44
- # == Mock Framework
45
- #
46
- # RSpec uses it's own mocking framework by default. If you prefer to
47
- # use mocha, flexmock or RR, uncomment the appropriate line:
48
- #
49
- # config.mock_with :mocha
50
- # config.mock_with :flexmock
51
- # config.mock_with :rr
52
- #
53
54
  # == Notes
54
55
  #
55
56
  # For more information take a look at Rspec::Core::Configuration
@@ -1,4 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "<%= class_name.pluralize %>" do
3
+ describe <%= class_name.pluralize %> do
4
+ describe "GET /<%= table_name %>" do
5
+ it "works! (now write some real specs)" do
6
+ get "/<%= table_name %>"
7
+ end
8
+ end
4
9
  end
@@ -1,5 +1,5 @@
1
1
  require 'generators/rspec'
2
- require 'generators/resource_helpers'
2
+ require 'rails/generators/resource_helpers'
3
3
 
4
4
  module Rspec
5
5
  module Generators
@@ -11,10 +11,13 @@ module Rspec
11
11
  class_option :template_engine, :desc => "Template engine to generate view files"
12
12
  class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"
13
13
 
14
- class_option :views, :type => :boolean, :default => true
15
- class_option :routes, :type => :boolean, :default => true
14
+ class_option :controllers, :type => :boolean, :default => false
15
+ class_option :views, :type => :boolean, :default => false
16
+ class_option :routes, :type => :boolean, :default => false
16
17
 
17
18
  def copy_controller_files
19
+ return unless options[:controllers]
20
+
18
21
  template 'controller_spec.rb',
19
22
  File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
20
23
  end
@@ -80,7 +83,7 @@ module Rspec
80
83
  # should! orm_class.find(User, "37")
81
84
  # #=> User.should_receive(:get).with(37)
82
85
  #
83
- def should!(chain)
86
+ def should_receive!(chain)
84
87
  stub_or_should_chain(:should_receive, chain)
85
88
  end
86
89
 
@@ -95,7 +98,7 @@ module Rspec
95
98
  # #=> User.stub!(:get).with(37)
96
99
  #
97
100
  def stub!(chain)
98
- stub_or_should_chain(:stub!, chain)
101
+ stub_or_should_chain(:stub, chain)
99
102
  end
100
103
 
101
104
  def stub_or_should_chain(mode, chain)
@@ -9,7 +9,7 @@ describe <%= controller_class_name %>Controller do
9
9
  <% unless options[:singleton] -%>
10
10
  describe "GET index" do
11
11
  it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
12
- <%= stub! orm_class.all(class_name) %>.and_return([<%= mock_file_name %>])
12
+ <%= stub orm_class.all(class_name) %>.and_return([<%= mock_file_name %>])
13
13
  get :index
14
14
  assigns[:<%= table_name %>].should == [<%= mock_file_name %>]
15
15
  end
@@ -18,7 +18,7 @@ describe <%= controller_class_name %>Controller do
18
18
 
19
19
  describe "GET show" do
20
20
  it "assigns the requested <%= file_name %> as @<%= file_name %>" do
21
- <%= stub! orm_class.find(class_name, "37".inspect) %>.and_return(<%= mock_file_name %>)
21
+ <%= stub orm_class.find(class_name, "37".inspect) %>.and_return(<%= mock_file_name %>)
22
22
  get :show, :id => "37"
23
23
  assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
24
24
  end
@@ -26,7 +26,7 @@ describe <%= controller_class_name %>Controller do
26
26
 
27
27
  describe "GET new" do
28
28
  it "assigns a new <%= file_name %> as @<%= file_name %>" do
29
- <%= stub! orm_class.build(class_name) %>.and_return(<%= mock_file_name %>)
29
+ <%= stub orm_class.build(class_name) %>.and_return(<%= mock_file_name %>)
30
30
  get :new
31
31
  assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
32
32
  end
@@ -34,7 +34,7 @@ describe <%= controller_class_name %>Controller do
34
34
 
35
35
  describe "GET edit" do
36
36
  it "assigns the requested <%= file_name %> as @<%= file_name %>" do
37
- <%= stub! orm_class.find(class_name, "37".inspect) %>.and_return(<%= mock_file_name %>)
37
+ <%= stub orm_class.find(class_name, "37".inspect) %>.and_return(<%= mock_file_name %>)
38
38
  get :edit, :id => "37"
39
39
  assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
40
40
  end
@@ -44,13 +44,13 @@ describe <%= controller_class_name %>Controller do
44
44
 
45
45
  describe "with valid params" do
46
46
  it "assigns a newly created <%= file_name %> as @<%= file_name %>" do
47
- <%= stub! orm_class.build(class_name, params) %>.and_return(<%= mock_file_name(:save => true) %>)
47
+ <%= stub orm_class.build(class_name, params) %>.and_return(<%= mock_file_name(:save => true) %>)
48
48
  post :create, :<%= file_name %> => <%= params %>
49
49
  assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
50
50
  end
51
51
 
52
52
  it "redirects to the created <%= file_name %>" do
53
- <%= stub! orm_class.build(class_name) %>.and_return(<%= mock_file_name(:save => true) %>)
53
+ <%= stub orm_class.build(class_name) %>.and_return(<%= mock_file_name(:save => true) %>)
54
54
  post :create, :<%= file_name %> => {}
55
55
  response.should redirect_to(<%= table_name.singularize %>_url(<%= mock_file_name %>))
56
56
  end
@@ -58,13 +58,13 @@ describe <%= controller_class_name %>Controller do
58
58
 
59
59
  describe "with invalid params" do
60
60
  it "assigns a newly created but unsaved <%= file_name %> as @<%= file_name %>" do
61
- <%= stub! orm_class.build(class_name, params) %>.and_return(<%= mock_file_name(:save => false) %>)
61
+ <%= stub orm_class.build(class_name, params) %>.and_return(<%= mock_file_name(:save => false) %>)
62
62
  post :create, :<%= file_name %> => <%= params %>
63
63
  assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
64
64
  end
65
65
 
66
66
  it "re-renders the 'new' template" do
67
- <%= stub! orm_class.build(class_name) %>.and_return(<%= mock_file_name(:save => false) %>)
67
+ <%= stub orm_class.build(class_name) %>.and_return(<%= mock_file_name(:save => false) %>)
68
68
  post :create, :<%= file_name %> => {}
69
69
  response.should render_template('new')
70
70
  end
@@ -82,13 +82,13 @@ describe <%= controller_class_name %>Controller do
82
82
  end
83
83
 
84
84
  it "assigns the requested <%= file_name %> as @<%= file_name %>" do
85
- <%= stub! orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => true) %>)
85
+ <%= stub orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => true) %>)
86
86
  put :update, :id => "1"
87
87
  assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
88
88
  end
89
89
 
90
90
  it "redirects to the <%= file_name %>" do
91
- <%= stub! orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => true) %>)
91
+ <%= stub orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => true) %>)
92
92
  put :update, :id => "1"
93
93
  response.should redirect_to(<%= table_name.singularize %>_url(<%= mock_file_name %>))
94
94
  end
@@ -96,13 +96,13 @@ describe <%= controller_class_name %>Controller do
96
96
 
97
97
  describe "with invalid params" do
98
98
  it "assigns the <%= file_name %> as @<%= file_name %>" do
99
- <%= stub! orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => false) %>)
99
+ <%= stub orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => false) %>)
100
100
  put :update, :id => "1"
101
101
  assigns[:<%= file_name %>].should equal(<%= mock_file_name %>)
102
102
  end
103
103
 
104
104
  it "re-renders the 'edit' template" do
105
- <%= stub! orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => false) %>)
105
+ <%= stub orm_class.find(class_name) %>.and_return(<%= mock_file_name(:update_attributes => false) %>)
106
106
  put :update, :id => "1"
107
107
  response.should render_template('edit')
108
108
  end
@@ -118,7 +118,7 @@ describe <%= controller_class_name %>Controller do
118
118
  end
119
119
 
120
120
  it "redirects to the <%= table_name %> list" do
121
- <%= stub! orm_class.find(class_name) %>.and_return(<%= mock_file_name(:destroy => true) %>)
121
+ <%= stub orm_class.find(class_name) %>.and_return(<%= mock_file_name(:destroy => true) %>)
122
122
  delete :destroy, :id => "1"
123
123
  response.should redirect_to(<%= table_name %>_url)
124
124
  end
@@ -18,14 +18,14 @@ module ControllerExampleGroupBehaviour
18
18
 
19
19
  %w[get post put delete head].map do |method|
20
20
  eval <<-CODE
21
- def #{method}(action)
22
- @_action = action
21
+ def #{method}(*args)
22
+ @_action = args.shift
23
23
  super '/'
24
24
  end
25
25
  CODE
26
26
  end
27
27
 
28
28
  Rspec::Core.configure do |c|
29
- c.include self, :behaviour => { :file_path => /\/spec\/controllers\// }
29
+ c.include self, :example_group => { :file_path => /\/spec\/controllers\// }
30
30
  end
31
31
  end
@@ -21,6 +21,6 @@ module RequestExampleGroupBehaviour
21
21
  end
22
22
 
23
23
  Rspec::Core.configure do |c|
24
- c.include self, :behaviour => { :file_path => /\/spec\/requests\// }
24
+ c.include self, :example_group => { :file_path => /\/spec\/requests\// }
25
25
  end
26
26
  end
@@ -5,7 +5,7 @@ module Rspec # :nodoc:
5
5
  MAJOR = 2
6
6
  MINOR = 0
7
7
  TINY = 0
8
- PRE = 'a4'
8
+ PRE = 'a5'
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
11
11
 
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec-rails}
8
- s.version = "2.0.0.a4"
8
+ s.version = "2.0.0.a5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Chelimsky", "Chad Humphries"]
12
- s.date = %q{2010-02-04}
12
+ s.date = %q{2010-02-07}
13
13
  s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.markdown"
@@ -26,8 +26,8 @@ Gem::Specification.new do |s|
26
26
  "lib/generators/rspec/helper/helper_generator.rb",
27
27
  "lib/generators/rspec/helper/templates/helper_spec.rb",
28
28
  "lib/generators/rspec/install/install_generator.rb",
29
+ "lib/generators/rspec/install/templates/config/initializers/rspec_generator.rb.tt",
29
30
  "lib/generators/rspec/install/templates/lib/tasks/rspec.rake",
30
- "lib/generators/rspec/install/templates/spec/rcov.opts",
31
31
  "lib/generators/rspec/install/templates/spec/spec.opts",
32
32
  "lib/generators/rspec/install/templates/spec/spec_helper.rb",
33
33
  "lib/generators/rspec/integration/integration_generator.rb",
@@ -71,14 +71,14 @@ Gem::Specification.new do |s|
71
71
  s.specification_version = 3
72
72
 
73
73
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
74
- s.add_runtime_dependency(%q<rspec>, [">= 2.0.0.a2"])
74
+ s.add_runtime_dependency(%q<rspec>, [">= 2.0.0.a5"])
75
75
  s.add_runtime_dependency(%q<webrat>, ["= 0.7.0"])
76
76
  else
77
- s.add_dependency(%q<rspec>, [">= 2.0.0.a2"])
77
+ s.add_dependency(%q<rspec>, [">= 2.0.0.a5"])
78
78
  s.add_dependency(%q<webrat>, ["= 0.7.0"])
79
79
  end
80
80
  else
81
- s.add_dependency(%q<rspec>, [">= 2.0.0.a2"])
81
+ s.add_dependency(%q<rspec>, [">= 2.0.0.a5"])
82
82
  s.add_dependency(%q<webrat>, ["= 0.7.0"])
83
83
  end
84
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.a4
4
+ version: 2.0.0.a5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-04 00:00:00 -06:00
13
+ date: 2010-02-07 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: 2.0.0.a2
24
+ version: 2.0.0.a5
25
25
  version:
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: webrat
@@ -53,8 +53,8 @@ files:
53
53
  - lib/generators/rspec/helper/helper_generator.rb
54
54
  - lib/generators/rspec/helper/templates/helper_spec.rb
55
55
  - lib/generators/rspec/install/install_generator.rb
56
+ - lib/generators/rspec/install/templates/config/initializers/rspec_generator.rb.tt
56
57
  - lib/generators/rspec/install/templates/lib/tasks/rspec.rake
57
- - lib/generators/rspec/install/templates/spec/rcov.opts
58
58
  - lib/generators/rspec/install/templates/spec/spec.opts
59
59
  - lib/generators/rspec/install/templates/spec/spec_helper.rb
60
60
  - lib/generators/rspec/integration/integration_generator.rb
@@ -1,2 +0,0 @@
1
- --exclude "spec/*,gems/*"
2
- --rails