rspec-rails 2.0.0.beta.16 → 2.0.0.beta.17

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.
Files changed (43) hide show
  1. data/Gemfile +2 -2
  2. data/README.markdown +13 -7
  3. data/Rakefile +30 -8
  4. data/VERSION +1 -1
  5. data/features/controller_specs/isolation_from_views.feature +6 -24
  6. data/features/controller_specs/readers.feature +1 -1
  7. data/features/controller_specs/render_views.feature +6 -6
  8. data/features/mailer_specs/url_helpers.feature +2 -2
  9. data/features/matchers/be_routable_matcher.feature +5 -5
  10. data/features/matchers/new_record_matcher.feature +1 -1
  11. data/features/model_specs/errors_on.feature +1 -1
  12. data/features/model_specs/transactional_examples.feature +4 -4
  13. data/features/support/env.rb +0 -18
  14. data/features/view_specs/view_spec.feature +7 -7
  15. data/lib/generators/rspec/helper/helper_generator.rb +1 -2
  16. data/lib/generators/rspec/helper/templates/helper_spec.rb +3 -3
  17. data/lib/generators/rspec/install/install_generator.rb +0 -14
  18. data/lib/generators/rspec/scaffold/scaffold_generator.rb +3 -6
  19. data/lib/rspec-rails.rb +4 -0
  20. data/lib/rspec/rails/example.rb +1 -0
  21. data/lib/rspec/rails/example/controller_example_group.rb +1 -0
  22. data/lib/rspec/rails/example/helper_example_group.rb +1 -0
  23. data/lib/rspec/rails/example/mailer_example_group.rb +1 -0
  24. data/lib/rspec/rails/example/model_example_group.rb +14 -0
  25. data/lib/rspec/rails/example/request_example_group.rb +2 -0
  26. data/lib/rspec/rails/example/routing_example_group.rb +2 -0
  27. data/lib/rspec/rails/example/view_example_group.rb +2 -0
  28. data/lib/{generators/rspec/install/templates/lib → rspec/rails}/tasks/rspec.rake +5 -33
  29. data/lib/rspec/rails/view_rendering.rb +1 -1
  30. data/rspec-rails.gemspec +31 -12
  31. data/spec/rspec/rails/example/controller_example_group_spec.rb +7 -0
  32. data/spec/rspec/rails/example/helper_example_group_spec.rb +7 -0
  33. data/spec/rspec/rails/example/mailer_example_group_spec.rb +7 -1
  34. data/spec/rspec/rails/example/model_example_group_spec.rb +15 -0
  35. data/spec/rspec/rails/example/request_example_group_spec.rb +7 -0
  36. data/spec/rspec/rails/example/routing_example_group_spec.rb +7 -0
  37. data/spec/rspec/rails/example/view_example_group_spec.rb +7 -0
  38. data/spec/rspec/rails/matchers/render_template_spec.rb +1 -1
  39. data/spec/spec_helper.rb +0 -3
  40. data/templates/Gemfile +7 -5
  41. data/templates/generate_stuff.rb +2 -1
  42. metadata +33 -14
  43. data/lib/generators/rspec/install/templates/config/initializers/rspec_generator.rb.tt +0 -6
data/Gemfile CHANGED
@@ -3,14 +3,14 @@ source "http://rubygems.org"
3
3
  gem 'arel', :path => "./vendor/arel"
4
4
  gem 'rails', :path => "./vendor/rails"
5
5
 
6
+ gem 'rspec-rails', :path => "."
6
7
  gem 'rspec-core', :path => "../rspec-core"
7
8
  gem 'rspec-expectations', :path => "../rspec-expectations"
8
9
  gem 'rspec-mocks', :path => "../rspec-mocks"
9
10
  gem 'rspec', :path => "../rspec"
10
11
 
11
- gem 'thor'
12
12
  gem 'cucumber'
13
- gem 'aruba'
13
+ gem 'aruba', ">= 0.2.0", :require => nil
14
14
  gem 'jeweler'
15
15
  gem 'webrat'
16
16
  gem 'sqlite3-ruby', :require => 'sqlite3'
@@ -2,12 +2,7 @@
2
2
 
3
3
  rspec-2 for rails-3 with lightweight extensions to each
4
4
 
5
- NOTICE: rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4 or higher.
6
-
7
- NOTICE: This README aligns with the code in git HEAD. If you're looking for the
8
- README for the latest release, go to
9
- [http://github.com/rspec/rspec-rails](http://github.com/rspec/rspec-rails), and
10
- select the appropriate tag from the Switch Tags select list.
5
+ NOTICE: rspec-rails-2.0.0.beta.17 only works with rails-3.0.0.beta4 or higher.
11
6
 
12
7
  ## Install
13
8
 
@@ -25,7 +20,7 @@ This installs the following gems:
25
20
 
26
21
  Add this line to the Gemfile:
27
22
 
28
- gem "rspec-rails", ">= 2.0.0.beta.13"
23
+ gem "rspec-rails", ">= 2.0.0.beta.17"
29
24
 
30
25
  This will expose generators, including rspec:install. Now you can run:
31
26
 
@@ -241,3 +236,14 @@ Passes if the path is recognized by Rails' routing. This is primarily intended
241
236
  to be used with `should_not` to specify routes that should not be routable.
242
237
 
243
238
  { :get => "/widgets/1/edit" }.should_not be_routable
239
+
240
+ ## Contribute
241
+
242
+ See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev)
243
+
244
+ ## Also see
245
+
246
+ * [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
247
+ * [http://github.com/rspec/rspec-core](http://github.com/rspec/rspec-core)
248
+ * [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations)
249
+ * [http://github.com/rspec/rspec-mocks](http://github.com/rspec/rspec-mocks)
data/Rakefile CHANGED
@@ -23,9 +23,14 @@ require 'rspec/core/rake_task'
23
23
  require 'cucumber/rake/task'
24
24
 
25
25
  RSpec::Core::RakeTask.new(:spec)
26
- Cucumber::Rake::Task.new(:cucumber) do |t|
27
- t.cucumber_opts = %w{--format progress}
26
+ class Cucumber::Rake::Task::ForkedCucumberRunner
27
+ # When cucumber shells out, we still need it to run in the context of our
28
+ # bundle.
29
+ def run
30
+ sh "bundle exec #{RUBY} " + args.join(" ")
31
+ end
28
32
  end
33
+ Cucumber::Rake::Task.new(:cucumber)
29
34
 
30
35
  begin
31
36
  require 'jeweler'
@@ -45,16 +50,33 @@ begin
45
50
 
46
51
  Thank you for installing #{gem.summary}!
47
52
 
48
- This version of rspec-rails only works with
49
- versions of rails >= 3.0.0.pre.
53
+ This version of rspec-rails only works with versions of rails >= 3.0.0.beta.4.
54
+
55
+ To configure your app to use rspec-rails, add a declaration to your Gemfile.
56
+ If you are using Bundler's grouping feature in your Gemfile, be sure to include
57
+ rspec-rails in the :development group as well as the :test group so that you
58
+ can access its generators and rake tasks.
59
+
60
+ group :development, :test do
61
+ gem "rspec-rails", ">= #{RSpec::Rails::Version::STRING}"
62
+ end
50
63
 
51
- Be sure to run the following command in each of your
52
- Rails apps if you're upgrading:
64
+ Be sure to run the following command in each of your Rails apps if you're
65
+ upgrading:
53
66
 
54
67
  script/rails generate rspec:install
55
68
 
56
- Also, be sure to look at Upgrade.markdown to see
57
- what might have changed since the last release.
69
+ Even if you've run it before, this ensures that you have the latest updates
70
+ to spec/spec_helper.rb and any other support files.
71
+
72
+ Previous versions of rspec-rails-2.0.0.beta installed files that are no
73
+ longer being used, so please remove these files if you have them:
74
+
75
+ lib/tasks/rspec.rake
76
+ config/initializers/rspec_generator.rb
77
+
78
+ Lastly, be sure to look at Upgrade.markdown to see what might have changed
79
+ since the last release.
58
80
 
59
81
  #{"*"*50}
60
82
  EOM
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.beta.16
1
+ 2.0.0.beta.17
@@ -6,7 +6,7 @@ Feature: do not render views
6
6
 
7
7
  NOTE: unlike rspec-rails-1.x, the template must exist.
8
8
 
9
- Scenario: expect template that rendered by controller (passes)
9
+ Scenario: expect template that is rendered by controller action (passes)
10
10
  Given a file named "spec/controllers/widgets_controller_spec.rb" with:
11
11
  """
12
12
  require "spec_helper.rb"
@@ -16,20 +16,20 @@ Feature: do not render views
16
16
  it "renders the index template" do
17
17
  get :index
18
18
  response.should render_template("index")
19
- response.body.should =~ /generated by RSpec/
19
+ response.body.should == ""
20
20
  end
21
21
  it "renders the widgets/index template" do
22
22
  get :index
23
23
  response.should render_template("widgets/index")
24
- response.body.should =~ /generated by RSpec/
24
+ response.body.should == ""
25
25
  end
26
26
  end
27
27
  end
28
28
  """
29
29
  When I run "rspec ./spec"
30
- Then I should see "2 examples, 0 failures"
30
+ Then the output should contain "2 examples, 0 failures"
31
31
 
32
- Scenario: expect template that is not rendered by controller (fails)
32
+ Scenario: expect template that is not rendered by controller action (fails)
33
33
  Given a file named "spec/controllers/widgets_controller_spec.rb" with:
34
34
  """
35
35
  require "spec_helper.rb"
@@ -39,28 +39,10 @@ Feature: do not render views
39
39
  it "renders the 'new' template" do
40
40
  get :index
41
41
  response.should render_template("new")
42
- response.body.should =~ /generated by RSpec/
43
42
  end
44
43
  end
45
44
  end
46
45
  """
47
46
  When I run "rspec ./spec"
48
- Then I should see "1 example, 1 failure"
47
+ Then the output should contain "1 example, 1 failure"
49
48
 
50
- Scenario: set expectation about template content (fails with helpful message)
51
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
52
- """
53
- require "spec_helper.rb"
54
-
55
- describe WidgetsController do
56
- describe "index" do
57
- it "renders the 'new' template" do
58
- get :index
59
- response.should contain("foo")
60
- response.body.should =~ /generated by RSpec/
61
- end
62
- end
63
- end
64
- """
65
- When I run "rspec spec"
66
- Then I should see "Template source generated by RSpec"
@@ -15,4 +15,4 @@ Feature: controller spec readers
15
15
  end
16
16
  """
17
17
  When I run "rspec ./spec"
18
- Then I should see "1 example, 0 failures"
18
+ Then the output should contain "1 example, 0 failures"
@@ -25,7 +25,7 @@ Feature: render views
25
25
  end
26
26
  """
27
27
  When I run "rspec spec"
28
- Then I should see "2 examples, 0 failures"
28
+ Then the output should contain "2 examples, 0 failures"
29
29
 
30
30
  Scenario: expect template that does not exist and is rendered by controller (fails)
31
31
  Given a file named "spec/controllers/widgets_controller_spec.rb" with:
@@ -49,8 +49,8 @@ Feature: render views
49
49
  end
50
50
  """
51
51
  When I run "rspec spec"
52
- Then I should see "1 example, 1 failure"
53
- And I should see "Missing template"
52
+ Then the output should contain "1 example, 1 failure"
53
+ And the output should contain "Missing template"
54
54
 
55
55
  Scenario: render_views on and off in diff contexts
56
56
  Given a file named "spec/controllers/widgets_controller_spec.rb" with:
@@ -73,7 +73,7 @@ Feature: render views
73
73
  describe "index" do
74
74
  it "renders the RSpec generated template" do
75
75
  get :index
76
- response.body.should =~ /generated by RSpec/
76
+ response.body.should == ""
77
77
  end
78
78
  end
79
79
  end
@@ -93,11 +93,11 @@ Feature: render views
93
93
  describe "index" do
94
94
  it "renders the RSpec generated template" do
95
95
  get :index
96
- response.body.should =~ /generated by RSpec/
96
+ response.body.should == ""
97
97
  end
98
98
  end
99
99
  end
100
100
  end
101
101
  """
102
102
  When I run "rspec spec"
103
- Then I should see "4 examples, 0 failures"
103
+ Then the output should contain "4 examples, 0 failures"
@@ -16,7 +16,7 @@ Feature: URL helpers in mailer examples
16
16
  end
17
17
  """
18
18
  When I run "rspec spec"
19
- Then I should see "1 example, 0 failures"
19
+ Then the output should contain "1 example, 0 failures"
20
20
 
21
21
  Scenario: using URL helpers without default options
22
22
  Given a file named "config/initializers/mailer_defaults.rb" with:
@@ -35,4 +35,4 @@ Feature: URL helpers in mailer examples
35
35
  end
36
36
  """
37
37
  When I run "rspec spec"
38
- Then I should see "1 example, 0 failures"
38
+ Then the output should contain "1 example, 0 failures"
@@ -17,7 +17,7 @@ Feature: be_routable matcher
17
17
  """
18
18
 
19
19
  When I run "rspec spec/routing/widgets_routing_spec.rb"
20
- Then I should see "1 example, 0 failures"
20
+ Then the output should contain "1 example, 0 failures"
21
21
 
22
22
  Scenario: specify routeable route should not be routable (fails)
23
23
  Given a file named "spec/routing/widgets_routing_spec.rb" with:
@@ -32,7 +32,7 @@ Feature: be_routable matcher
32
32
  """
33
33
 
34
34
  When I run "rspec spec/routing/widgets_routing_spec.rb"
35
- Then I should see "1 example, 1 failure"
35
+ Then the output should contain "1 example, 1 failure"
36
36
 
37
37
  Scenario: specify non-routeable route should not be routable (passes)
38
38
  Given a file named "spec/routing/widgets_routing_spec.rb" with:
@@ -47,7 +47,7 @@ Feature: be_routable matcher
47
47
  """
48
48
 
49
49
  When I run "rspec spec/routing/widgets_routing_spec.rb"
50
- Then I should see "1 example, 0 failures"
50
+ Then the output should contain "1 example, 0 failures"
51
51
 
52
52
  Scenario: specify non-routeable route should be routable (fails)
53
53
  Given a file named "spec/routing/widgets_routing_spec.rb" with:
@@ -62,7 +62,7 @@ Feature: be_routable matcher
62
62
  """
63
63
 
64
64
  When I run "rspec spec/routing/widgets_routing_spec.rb"
65
- Then I should see "1 example, 1 failure"
65
+ Then the output should contain "1 example, 1 failure"
66
66
 
67
67
  Scenario: be_routable in a controller spec
68
68
  Given a file named "spec/controllers/widgets_controller_spec.rb" with:
@@ -77,4 +77,4 @@ Feature: be_routable matcher
77
77
  """
78
78
 
79
79
  When I run "rspec spec/controllers/widgets_controller_spec.rb"
80
- Then I should see "1 example, 0 failures"
80
+ Then the output should contain "1 example, 0 failures"
@@ -22,4 +22,4 @@ Feature: be_a_new matcher
22
22
  end
23
23
  """
24
24
  When I run "rspec spec/models/widget_spec.rb"
25
- Then I should see "4 examples, 0 failures"
25
+ Then the output should contain "4 examples, 0 failures"
@@ -29,4 +29,4 @@ Feature: errors_on
29
29
  end
30
30
  """
31
31
  When I run "rspec spec/models/widget_spec.rb"
32
- Then I should see "4 examples, 0 failures"
32
+ Then the output should contain "4 examples, 0 failures"
@@ -21,7 +21,7 @@ Feature: transactional examples
21
21
  end
22
22
  """
23
23
  When I run "rspec spec/models/widget_spec.rb"
24
- Then I should see "3 examples, 0 failures"
24
+ Then the output should contain "3 examples, 0 failures"
25
25
 
26
26
  Scenario: run in transactions (explicit)
27
27
  Given a file named "spec/models/widget_spec.rb" with:
@@ -48,7 +48,7 @@ Feature: transactional examples
48
48
  end
49
49
  """
50
50
  When I run "rspec spec/models/widget_spec.rb"
51
- Then I should see "3 examples, 0 failures"
51
+ Then the output should contain "3 examples, 0 failures"
52
52
 
53
53
  Scenario: disable transactions (explicit)
54
54
  Given a file named "spec/models/widget_spec.rb" with:
@@ -77,7 +77,7 @@ Feature: transactional examples
77
77
  end
78
78
  """
79
79
  When I run "rspec spec/models/widget_spec.rb"
80
- Then I should see "3 examples, 0 failures"
80
+ Then the output should contain "3 examples, 0 failures"
81
81
 
82
82
  Scenario: run in transactions with fixture
83
83
  Given a file named "spec/models/thing_spec.rb" with:
@@ -97,7 +97,7 @@ Feature: transactional examples
97
97
  name: MyString
98
98
  """
99
99
  When I run "rspec spec/models/thing_spec.rb"
100
- Then I should see "1 example, 0 failures"
100
+ Then the output should contain "1 example, 0 failures"
101
101
 
102
102
 
103
103
 
@@ -1,22 +1,4 @@
1
- require 'bundler'
2
- Bundler.setup
3
-
4
1
  require 'aruba'
5
- require 'rspec/expectations'
6
-
7
- module ArubaOverrides
8
- def detect_ruby_script(cmd)
9
- if cmd =~ /^rspec /
10
- "bundle exec ../../../rspec-core/bin/#{cmd}"
11
- elsif cmd =~ /^ruby /
12
- "bundle exec #{cmd}"
13
- else
14
- super(cmd)
15
- end
16
- end
17
- end
18
-
19
- World(ArubaOverrides)
20
2
 
21
3
  unless File.directory?('./tmp/example_app')
22
4
  system "rake generate:app generate:stuff"
@@ -22,7 +22,7 @@ Feature: view spec
22
22
  end
23
23
  """
24
24
  When I run "rspec spec/views"
25
- Then I should see "1 example, 0 failures"
25
+ Then the output should contain "1 example, 0 failures"
26
26
 
27
27
  Scenario: passing spec with before and nesting
28
28
  Given a file named "spec/views/widgets/index.html.erb_spec.rb" with:
@@ -49,7 +49,7 @@ Feature: view spec
49
49
  end
50
50
  """
51
51
  When I run "rspec spec/views"
52
- Then I should see "1 example, 0 failures"
52
+ Then the output should contain "1 example, 0 failures"
53
53
 
54
54
  Scenario: passing spec with explicit template rendering
55
55
  Given a file named "spec/views/widgets/widget.html.erb_spec.rb" with:
@@ -71,7 +71,7 @@ Feature: view spec
71
71
  <h2><%= @widget.name %></h2>
72
72
  """
73
73
  When I run "rspec spec/views"
74
- Then I should see "1 example, 0 failures"
74
+ Then the output should contain "1 example, 0 failures"
75
75
 
76
76
  Scenario: passing spec with rendering of locals in a partial
77
77
  Given a file named "spec/views/widgets/_widget.html.erb_spec.rb" with:
@@ -93,7 +93,7 @@ Feature: view spec
93
93
  <h3><%= widget.name %></h3>
94
94
  """
95
95
  When I run "rspec spec/views"
96
- Then I should see "1 example, 0 failures"
96
+ Then the output should contain "1 example, 0 failures"
97
97
 
98
98
  Scenario: passing spec with rendering of locals in an implicit partial
99
99
  Given a file named "spec/views/widgets/_widget.html.erb_spec.rb" with:
@@ -115,7 +115,7 @@ Feature: view spec
115
115
  <h3><%= widget.name %></h3>
116
116
  """
117
117
  When I run "rspec spec/views"
118
- Then I should see "1 example, 0 failures"
118
+ Then the output should contain "1 example, 0 failures"
119
119
 
120
120
  Scenario: passing spec with rendering of text
121
121
  Given a file named "spec/views/widgets/direct.html.erb_spec.rb" with:
@@ -132,7 +132,7 @@ Feature: view spec
132
132
  end
133
133
  """
134
134
  When I run "rspec spec/views"
135
- Then I should see "1 example, 0 failures"
135
+ Then the output should contain "1 example, 0 failures"
136
136
 
137
137
  Scenario: passing spec with rendering of Prototype helper update
138
138
  Given a file named "spec/views/widgets/prototype_update.html.erb_spec.rb" with:
@@ -151,4 +151,4 @@ Feature: view spec
151
151
  end
152
152
  """
153
153
  When I run "rspec spec/views"
154
- Then I should see "1 example, 0 failures"
154
+ Then the output should contain "1 example, 0 failures"
@@ -3,13 +3,12 @@ require 'generators/rspec'
3
3
  module Rspec
4
4
  module Generators
5
5
  class HelperGenerator < Base
6
- include Rails::Generators::ResourceHelpers
7
6
  class_option :helpers, :type => :boolean, :default => true
8
7
 
9
8
  def create_helper_files
10
9
  return unless options[:helpers]
11
10
 
12
- template 'helper_spec.rb', File.join('spec/helpers', class_path, "#{table_name}_helper_spec.rb")
11
+ template 'helper_spec.rb', File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
13
12
  end
14
13
  end
15
14
  end
@@ -1,15 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  # Specs in this file have access to a helper object that includes
4
- # the <%= controller_class_name %>Helper. For example:
4
+ # the <%= class_name %>Helper. For example:
5
5
  #
6
- # describe <%= controller_class_name %>Helper do
6
+ # describe <%= class_name %>Helper do
7
7
  # describe "string concat" do
8
8
  # it "concats two strings with spaces" do
9
9
  # helper.concat_strings("this","that").should == "this that"
10
10
  # end
11
11
  # end
12
12
  # end
13
- describe <%= controller_class_name %>Helper do
13
+ describe <%= class_name %>Helper do
14
14
  pending "add some examples to (or delete) #{__FILE__}"
15
15
  end
@@ -19,20 +19,6 @@ DESC
19
19
  directory 'spec'
20
20
  end
21
21
 
22
- def copy_lib_files
23
- directory 'lib'
24
- end
25
-
26
- def copy_initializer_files
27
- inside "config" do
28
- empty_directory "initializers", :verbose => false
29
-
30
- inside "initializers" do
31
- template "rspec_generator.rb.tt", "rspec_generator.rb"
32
- end
33
- end
34
- end
35
-
36
22
  def copy_autotest_files
37
23
  directory 'autotest'
38
24
  end
@@ -33,12 +33,9 @@ module Rspec
33
33
  copy_view :show
34
34
  end
35
35
 
36
- def copy_helper_files
37
- return unless options[:helper_specs]
38
-
39
- template "helper_spec.rb",
40
- File.join('spec/helpers', controller_class_path, "#{controller_file_name}_helper_spec.rb")
41
-
36
+ # Invoke the helper using the controller name (pluralized)
37
+ hook_for :helper, :as => :scaffold do |invoked|
38
+ invoke invoked, [ controller_name ]
42
39
  end
43
40
 
44
41
  def copy_routing_files
@@ -3,6 +3,10 @@ module RSpec
3
3
  class Railtie < ::Rails::Railtie
4
4
  config.generators.integration_tool :rspec
5
5
  config.generators.test_framework :rspec
6
+
7
+ rake_tasks do
8
+ load "rspec/rails/tasks/rspec.rake"
9
+ end
6
10
  end
7
11
  end
8
12
  end
@@ -4,3 +4,4 @@ require 'rspec/rails/example/helper_example_group'
4
4
  require 'rspec/rails/example/view_example_group'
5
5
  require 'rspec/rails/example/mailer_example_group'
6
6
  require 'rspec/rails/example/routing_example_group'
7
+ require 'rspec/rails/example/model_example_group'
@@ -96,6 +96,7 @@ module RSpec::Rails
96
96
  end
97
97
 
98
98
  included do
99
+ metadata[:type] = :controller
99
100
  before do
100
101
  @routes = ::Rails.application.routes
101
102
  ActionController::Base.allow_forgery_protection = false
@@ -56,6 +56,7 @@ module RSpec::Rails
56
56
  end
57
57
 
58
58
  included do
59
+ metadata[:type] = :helper
59
60
  before do
60
61
  controller.controller_path = _controller_path
61
62
  end
@@ -9,6 +9,7 @@ if defined?(ActionMailer)
9
9
  include RSpec::Matchers
10
10
 
11
11
  included do
12
+ metadata[:type] = :mailer
12
13
  include ::Rails.application.routes.url_helpers
13
14
  options = ::Rails.configuration.action_mailer.default_url_options
14
15
  options.each { |key, value| default_url_options[key] = value } if options
@@ -0,0 +1,14 @@
1
+ module RSpec::Rails
2
+ module ModelExampleGroup
3
+ extend ActiveSupport::Concern
4
+ extend RSpec::Rails::ModuleInclusion
5
+
6
+ include RSpec::Matchers
7
+
8
+ included do
9
+ metadata[:type] = :model
10
+ end
11
+
12
+ RSpec.configure &include_self_when_dir_matches('spec','models')
13
+ end
14
+ end
@@ -36,6 +36,8 @@ module RSpec::Rails
36
36
  end
37
37
 
38
38
  included do
39
+ metadata[:type] = :request
40
+
39
41
  before do
40
42
  @router = ::Rails.application.routes
41
43
  end
@@ -14,6 +14,8 @@ module RSpec::Rails
14
14
  end
15
15
 
16
16
  included do
17
+ metadata[:type] = :routing
18
+
17
19
  before do
18
20
  @routes = ::Rails.application.routes
19
21
  end
@@ -98,6 +98,8 @@ module RSpec::Rails
98
98
  end
99
99
 
100
100
  included do
101
+ metadata[:type] = :view
102
+
101
103
  before do
102
104
  controller.controller_path = _controller_path
103
105
  # this won't be necessary if/when
@@ -1,38 +1,10 @@
1
- begin
2
- require 'rspec/core'
3
- require 'rspec/core/rake_task'
4
- rescue MissingSourceFile
5
- module RSpec
6
- module Core
7
- class RakeTask
8
- def initialize(name)
9
- task name do
10
- # if rspec-rails is a configured gem, this will output helpful material and exit ...
11
- require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
12
-
13
- # ... otherwise, do this:
14
- raise <<-MSG
15
-
16
- #{"*" * 80}
17
- * You are trying to run an rspec rake task defined in
18
- * #{__FILE__},
19
- * but rspec can not be found in vendor/gems, vendor/plugins or system gems.
20
- #{"*" * 80}
21
- MSG
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
28
-
29
- Rake.application.instance_variable_get('@tasks').delete('default')
30
-
1
+ require 'rspec/core'
2
+ require 'rspec/core/rake_task'
3
+ Rake.application.instance_variable_get('@tasks')['default'].prerequisites.delete('test')
31
4
  spec_prereq = Rails.root.join('config', 'database.yml').exist? ? "db:test:prepare" : :noop
32
- task :noop do
33
- end
34
-
5
+ task :noop do; end
35
6
  task :default => :spec
7
+
36
8
  task :stats => "spec:statsetup"
37
9
 
38
10
  desc "Run all specs in spec directory (excluding plugin specs)"
@@ -32,7 +32,7 @@ module RSpec
32
32
  def find_all(*args)
33
33
  path_set.find_all(*args).collect do |template|
34
34
  ::ActionView::Template.new(
35
- "Template source generated by RSpec.",
35
+ "",
36
36
  template.identifier,
37
37
  template.handler,
38
38
  {
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec-rails}
8
- s.version = "2.0.0.beta.16"
8
+ s.version = "2.0.0.beta.17"
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-07-06}
12
+ s.date = %q{2010-07-11}
13
13
  s.description = %q{RSpec-2 for Rails-3}
14
14
  s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -47,8 +47,6 @@ Gem::Specification.new do |s|
47
47
  "lib/generators/rspec/install/install_generator.rb",
48
48
  "lib/generators/rspec/install/templates/.rspec",
49
49
  "lib/generators/rspec/install/templates/autotest/discover.rb",
50
- "lib/generators/rspec/install/templates/config/initializers/rspec_generator.rb.tt",
51
- "lib/generators/rspec/install/templates/lib/tasks/rspec.rake",
52
50
  "lib/generators/rspec/install/templates/spec/spec_helper.rb",
53
51
  "lib/generators/rspec/integration/integration_generator.rb",
54
52
  "lib/generators/rspec/integration/templates/request_spec.rb",
@@ -76,6 +74,7 @@ Gem::Specification.new do |s|
76
74
  "lib/rspec/rails/example/controller_example_group.rb",
77
75
  "lib/rspec/rails/example/helper_example_group.rb",
78
76
  "lib/rspec/rails/example/mailer_example_group.rb",
77
+ "lib/rspec/rails/example/model_example_group.rb",
79
78
  "lib/rspec/rails/example/request_example_group.rb",
80
79
  "lib/rspec/rails/example/routing_example_group.rb",
81
80
  "lib/rspec/rails/example/view_example_group.rb",
@@ -92,6 +91,7 @@ Gem::Specification.new do |s|
92
91
  "lib/rspec/rails/module_inclusion.rb",
93
92
  "lib/rspec/rails/monkey.rb",
94
93
  "lib/rspec/rails/monkey/action_mailer/test_case.rb",
94
+ "lib/rspec/rails/tasks/rspec.rake",
95
95
  "lib/rspec/rails/version.rb",
96
96
  "lib/rspec/rails/view_assigns.rb",
97
97
  "lib/rspec/rails/view_rendering.rb",
@@ -99,6 +99,7 @@ Gem::Specification.new do |s|
99
99
  "spec/rspec/rails/example/controller_example_group_spec.rb",
100
100
  "spec/rspec/rails/example/helper_example_group_spec.rb",
101
101
  "spec/rspec/rails/example/mailer_example_group_spec.rb",
102
+ "spec/rspec/rails/example/model_example_group_spec.rb",
102
103
  "spec/rspec/rails/example/request_example_group_spec.rb",
103
104
  "spec/rspec/rails/example/routing_example_group_spec.rb",
104
105
  "spec/rspec/rails/example/view_example_group_spec.rb",
@@ -121,18 +122,35 @@ Gem::Specification.new do |s|
121
122
  s.homepage = %q{http://github.com/rspec/rspec-rails}
122
123
  s.post_install_message = %q{**************************************************
123
124
 
124
- Thank you for installing rspec-rails-2.0.0.beta.16!
125
+ Thank you for installing rspec-rails-2.0.0.beta.17!
125
126
 
126
- This version of rspec-rails only works with
127
- versions of rails >= 3.0.0.pre.
127
+ This version of rspec-rails only works with versions of rails >= 3.0.0.beta.4.
128
128
 
129
- Be sure to run the following command in each of your
130
- Rails apps if you're upgrading:
129
+ To configure your app to use rspec-rails, add a declaration to your Gemfile.
130
+ If you are using Bundler's grouping feature in your Gemfile, be sure to include
131
+ rspec-rails in the :development group as well as the :test group so that you
132
+ can access its generators and rake tasks.
133
+
134
+ group :development, :test do
135
+ gem "rspec-rails", ">= 2.0.0.beta.17"
136
+ end
137
+
138
+ Be sure to run the following command in each of your Rails apps if you're
139
+ upgrading:
131
140
 
132
141
  script/rails generate rspec:install
133
142
 
134
- Also, be sure to look at Upgrade.markdown to see
135
- what might have changed since the last release.
143
+ Even if you've run it before, this ensures that you have the latest updates
144
+ to spec/spec_helper.rb and any other support files.
145
+
146
+ Previous versions of rspec-rails-2.0.0.beta installed files that are no
147
+ longer being used, so please remove these files if you have them:
148
+
149
+ lib/tasks/rspec.rake
150
+ config/initializers/rspec_generator.rb
151
+
152
+ Lastly, be sure to look at Upgrade.markdown to see what might have changed
153
+ since the last release.
136
154
 
137
155
  **************************************************
138
156
  }
@@ -140,11 +158,12 @@ Gem::Specification.new do |s|
140
158
  s.require_paths = ["lib"]
141
159
  s.rubyforge_project = %q{rspec}
142
160
  s.rubygems_version = %q{1.3.7}
143
- s.summary = %q{rspec-rails-2.0.0.beta.16}
161
+ s.summary = %q{rspec-rails-2.0.0.beta.17}
144
162
  s.test_files = [
145
163
  "spec/rspec/rails/example/controller_example_group_spec.rb",
146
164
  "spec/rspec/rails/example/helper_example_group_spec.rb",
147
165
  "spec/rspec/rails/example/mailer_example_group_spec.rb",
166
+ "spec/rspec/rails/example/model_example_group_spec.rb",
148
167
  "spec/rspec/rails/example/request_example_group_spec.rb",
149
168
  "spec/rspec/rails/example/routing_example_group_spec.rb",
150
169
  "spec/rspec/rails/example/view_example_group_spec.rb",
@@ -11,5 +11,12 @@ module RSpec::Rails
11
11
  end
12
12
  group.included_modules.should include(RSpec::Rails::Matchers::RoutingMatchers)
13
13
  end
14
+
15
+ it "adds :type => :controller to the metadata" do
16
+ group = RSpec::Core::ExampleGroup.describe do
17
+ include ControllerExampleGroup
18
+ end
19
+ group.metadata[:type].should eq(:controller)
20
+ end
14
21
  end
15
22
  end
@@ -14,6 +14,13 @@ module RSpec::Rails
14
14
  helper_spec.__send__(:_controller_path).should == "foos"
15
15
  end
16
16
 
17
+ it "adds :type => :helper to the metadata" do
18
+ group = RSpec::Core::ExampleGroup.describe do
19
+ include HelperExampleGroup
20
+ end
21
+ group.metadata[:type].should eq(:helper)
22
+ end
23
+
17
24
  describe "#helper" do
18
25
  it "returns the instance of AV::Base provided by AV::TC::Behavior" do
19
26
  helper_spec = Object.new.extend HelperExampleGroup::InstanceMethods
@@ -2,7 +2,6 @@ require "spec_helper"
2
2
 
3
3
  module RSpec::Rails
4
4
  describe MailerExampleGroup do
5
-
6
5
  module ::Rails; end
7
6
  before do
8
7
  Rails.stub_chain(:application, :routes, :url_helpers).and_return(Rails)
@@ -11,5 +10,12 @@ module RSpec::Rails
11
10
 
12
11
  it { should be_included_in_files_in('./spec/mailers/') }
13
12
  it { should be_included_in_files_in('.\\spec\\mailers\\') }
13
+
14
+ it "adds :type => :mailer to the metadata" do
15
+ group = RSpec::Core::ExampleGroup.describe do
16
+ include MailerExampleGroup
17
+ end
18
+ group.metadata[:type].should eq(:mailer)
19
+ end
14
20
  end
15
21
  end
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ module RSpec::Rails
4
+ describe ModelExampleGroup do
5
+ it { should be_included_in_files_in('./spec/models/') }
6
+ it { should be_included_in_files_in('.\\spec\\models\\') }
7
+
8
+ it "adds :type => :model to the metadata" do
9
+ group = RSpec::Core::ExampleGroup.describe do
10
+ include ModelExampleGroup
11
+ end
12
+ group.metadata[:type].should eq(:model)
13
+ end
14
+ end
15
+ end
@@ -4,5 +4,12 @@ module RSpec::Rails
4
4
  describe RequestExampleGroup do
5
5
  it { should be_included_in_files_in('./spec/requests/') }
6
6
  it { should be_included_in_files_in('.\\spec\\requests\\') }
7
+
8
+ it "adds :type => :request to the metadata" do
9
+ group = RSpec::Core::ExampleGroup.describe do
10
+ include RequestExampleGroup
11
+ end
12
+ group.metadata[:type].should eq(:request)
13
+ end
7
14
  end
8
15
  end
@@ -4,5 +4,12 @@ module RSpec::Rails
4
4
  describe RoutingExampleGroup do
5
5
  it { should be_included_in_files_in('./spec/routing/') }
6
6
  it { should be_included_in_files_in('.\\spec\\routing\\') }
7
+
8
+ it "adds :type => :routing to the metadata" do
9
+ group = RSpec::Core::ExampleGroup.describe do
10
+ include RoutingExampleGroup
11
+ end
12
+ group.metadata[:type].should eq(:routing)
13
+ end
7
14
  end
8
15
  end
@@ -5,6 +5,13 @@ module RSpec::Rails
5
5
  it { should be_included_in_files_in('./spec/views/') }
6
6
  it { should be_included_in_files_in('.\\spec\\views\\') }
7
7
 
8
+ it "adds :type => :view to the metadata" do
9
+ group = RSpec::Core::ExampleGroup.describe do
10
+ include ViewExampleGroup
11
+ end
12
+ group.metadata[:type].should eq(:view)
13
+ end
14
+
8
15
  describe "#render" do
9
16
  let(:view_spec) do
10
17
  Class.new do
@@ -26,7 +26,7 @@ describe "render_template" do
26
26
  end
27
27
  end
28
28
 
29
- context "given a string" do
29
+ context "given a symbol" do
30
30
  it "converts to_s and delegates to assert_template" do
31
31
  self.should_receive(:assert_template).with("template_name", "this message")
32
32
  "response".should render_template(:template_name, "this message")
@@ -1,6 +1,3 @@
1
- require 'bundler'
2
- Bundler.setup
3
-
4
1
  require 'active_record'
5
2
  require 'action_controller'
6
3
  require 'action_mailer'
@@ -5,8 +5,10 @@ gem 'rails', :path => "../../vendor/rails"
5
5
 
6
6
  gem 'sqlite3-ruby', :require => 'sqlite3'
7
7
 
8
- gem "rspec-rails", :path => "../../../rspec-rails"
9
- gem "rspec", :path => "../../../rspec"
10
- gem "rspec-core", :path => "../../../rspec-core"
11
- gem "rspec-expectations", :path => "../../../rspec-expectations"
12
- gem "rspec-mocks", :path => "../../../rspec-mocks"
8
+ group :development, :test do
9
+ gem "rspec-rails", :path => "../../../rspec-rails"
10
+ gem "rspec", :path => "../../../rspec"
11
+ gem "rspec-core", :path => "../../../rspec-core"
12
+ gem "rspec-expectations", :path => "../../../rspec-expectations"
13
+ gem "rspec-mocks", :path => "../../../rspec-mocks"
14
+ end
@@ -1,5 +1,6 @@
1
1
  generate('rspec:install')
2
- generate('controller wombats index')
2
+ generate('controller wombats index') # plural
3
+ generate('controller welcome index') # singular
3
4
  generate('integration_test widgets')
4
5
  generate('mailer Notifications signup')
5
6
  generate('model thing name:string')
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196419
4
+ hash: 62196417
5
5
  prerelease: true
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
9
  - 0
10
10
  - beta
11
- - 16
12
- version: 2.0.0.beta.16
11
+ - 17
12
+ version: 2.0.0.beta.17
13
13
  platform: ruby
14
14
  authors:
15
15
  - David Chelimsky
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-07-06 00:00:00 -05:00
21
+ date: 2010-07-11 00:00:00 -05:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -95,8 +95,6 @@ files:
95
95
  - lib/generators/rspec/install/install_generator.rb
96
96
  - lib/generators/rspec/install/templates/.rspec
97
97
  - lib/generators/rspec/install/templates/autotest/discover.rb
98
- - lib/generators/rspec/install/templates/config/initializers/rspec_generator.rb.tt
99
- - lib/generators/rspec/install/templates/lib/tasks/rspec.rake
100
98
  - lib/generators/rspec/install/templates/spec/spec_helper.rb
101
99
  - lib/generators/rspec/integration/integration_generator.rb
102
100
  - lib/generators/rspec/integration/templates/request_spec.rb
@@ -124,6 +122,7 @@ files:
124
122
  - lib/rspec/rails/example/controller_example_group.rb
125
123
  - lib/rspec/rails/example/helper_example_group.rb
126
124
  - lib/rspec/rails/example/mailer_example_group.rb
125
+ - lib/rspec/rails/example/model_example_group.rb
127
126
  - lib/rspec/rails/example/request_example_group.rb
128
127
  - lib/rspec/rails/example/routing_example_group.rb
129
128
  - lib/rspec/rails/example/view_example_group.rb
@@ -140,6 +139,7 @@ files:
140
139
  - lib/rspec/rails/module_inclusion.rb
141
140
  - lib/rspec/rails/monkey.rb
142
141
  - lib/rspec/rails/monkey/action_mailer/test_case.rb
142
+ - lib/rspec/rails/tasks/rspec.rake
143
143
  - lib/rspec/rails/version.rb
144
144
  - lib/rspec/rails/view_assigns.rb
145
145
  - lib/rspec/rails/view_rendering.rb
@@ -147,6 +147,7 @@ files:
147
147
  - spec/rspec/rails/example/controller_example_group_spec.rb
148
148
  - spec/rspec/rails/example/helper_example_group_spec.rb
149
149
  - spec/rspec/rails/example/mailer_example_group_spec.rb
150
+ - spec/rspec/rails/example/model_example_group_spec.rb
150
151
  - spec/rspec/rails/example/request_example_group_spec.rb
151
152
  - spec/rspec/rails/example/routing_example_group_spec.rb
152
153
  - spec/rspec/rails/example/view_example_group_spec.rb
@@ -172,18 +173,35 @@ licenses: []
172
173
  post_install_message: |
173
174
  **************************************************
174
175
 
175
- Thank you for installing rspec-rails-2.0.0.beta.16!
176
+ Thank you for installing rspec-rails-2.0.0.beta.17!
176
177
 
177
- This version of rspec-rails only works with
178
- versions of rails >= 3.0.0.pre.
178
+ This version of rspec-rails only works with versions of rails >= 3.0.0.beta.4.
179
179
 
180
- Be sure to run the following command in each of your
181
- Rails apps if you're upgrading:
180
+ To configure your app to use rspec-rails, add a declaration to your Gemfile.
181
+ If you are using Bundler's grouping feature in your Gemfile, be sure to include
182
+ rspec-rails in the :development group as well as the :test group so that you
183
+ can access its generators and rake tasks.
184
+
185
+ group :development, :test do
186
+ gem "rspec-rails", ">= 2.0.0.beta.17"
187
+ end
188
+
189
+ Be sure to run the following command in each of your Rails apps if you're
190
+ upgrading:
182
191
 
183
192
  script/rails generate rspec:install
184
193
 
185
- Also, be sure to look at Upgrade.markdown to see
186
- what might have changed since the last release.
194
+ Even if you've run it before, this ensures that you have the latest updates
195
+ to spec/spec_helper.rb and any other support files.
196
+
197
+ Previous versions of rspec-rails-2.0.0.beta installed files that are no
198
+ longer being used, so please remove these files if you have them:
199
+
200
+ lib/tasks/rspec.rake
201
+ config/initializers/rspec_generator.rb
202
+
203
+ Lastly, be sure to look at Upgrade.markdown to see what might have changed
204
+ since the last release.
187
205
 
188
206
  **************************************************
189
207
 
@@ -217,11 +235,12 @@ rubyforge_project: rspec
217
235
  rubygems_version: 1.3.7
218
236
  signing_key:
219
237
  specification_version: 3
220
- summary: rspec-rails-2.0.0.beta.16
238
+ summary: rspec-rails-2.0.0.beta.17
221
239
  test_files:
222
240
  - spec/rspec/rails/example/controller_example_group_spec.rb
223
241
  - spec/rspec/rails/example/helper_example_group_spec.rb
224
242
  - spec/rspec/rails/example/mailer_example_group_spec.rb
243
+ - spec/rspec/rails/example/model_example_group_spec.rb
225
244
  - spec/rspec/rails/example/request_example_group_spec.rb
226
245
  - spec/rspec/rails/example/routing_example_group_spec.rb
227
246
  - spec/rspec/rails/example/view_example_group_spec.rb
@@ -1,6 +0,0 @@
1
- <%= app_name %>.configure do
2
- config.generators do |g|
3
- g.integration_tool :rspec
4
- g.test_framework :rspec
5
- end
6
- end if defined? <%= app_name %>