rspec-rails 2.14.1 → 2.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +9 -0
  3. data/lib/autotest/rails_rspec2.rb +1 -0
  4. data/lib/generators/rspec/install/templates/spec/spec_helper.rb.tt +6 -1
  5. data/lib/rspec/rails/adapters.rb +1 -0
  6. data/lib/rspec/rails/example/controller_example_group.rb +2 -1
  7. data/lib/rspec/rails/matchers/have_extension.rb +1 -0
  8. data/lib/rspec/rails/matchers/routing_matchers.rb +4 -0
  9. data/lib/rspec/rails/mocks.rb +6 -0
  10. data/lib/rspec/rails/tasks/rspec.rake +12 -5
  11. data/lib/rspec/rails/version.rb +1 -1
  12. metadata +38 -214
  13. data/features/Autotest.md +0 -24
  14. data/features/Generators.md +0 -24
  15. data/features/GettingStarted.md +0 -84
  16. data/features/README.md +0 -56
  17. data/features/RailsVersions.md +0 -4
  18. data/features/Transactions.md +0 -84
  19. data/features/Upgrade.md +0 -121
  20. data/features/controller_specs/Cookies.md +0 -57
  21. data/features/controller_specs/README.md +0 -45
  22. data/features/controller_specs/anonymous_controller.feature +0 -378
  23. data/features/controller_specs/bypass_rescue.feature +0 -75
  24. data/features/controller_specs/controller_spec.feature +0 -58
  25. data/features/controller_specs/engine_routes.feature +0 -51
  26. data/features/controller_specs/isolation_from_views.feature +0 -87
  27. data/features/controller_specs/render_views.feature +0 -114
  28. data/features/feature_specs/feature_spec.feature +0 -34
  29. data/features/helper_specs/helper_spec.feature +0 -122
  30. data/features/mailer_specs/url_helpers.feature +0 -38
  31. data/features/matchers/README.md +0 -18
  32. data/features/matchers/new_record_matcher.feature +0 -41
  33. data/features/matchers/redirect_to_matcher.feature +0 -40
  34. data/features/matchers/relation_match_array.feature +0 -27
  35. data/features/matchers/render_template_matcher.feature +0 -49
  36. data/features/mocks/mock_model.feature +0 -147
  37. data/features/mocks/stub_model.feature +0 -58
  38. data/features/model_specs/README.md +0 -21
  39. data/features/model_specs/errors_on.feature +0 -51
  40. data/features/model_specs/records.feature +0 -27
  41. data/features/model_specs/transactional_examples.feature +0 -109
  42. data/features/request_specs/request_spec.feature +0 -49
  43. data/features/routing_specs/README.md +0 -16
  44. data/features/routing_specs/be_routable_matcher.feature +0 -80
  45. data/features/routing_specs/engine_routes.feature +0 -38
  46. data/features/routing_specs/named_routes.feature +0 -18
  47. data/features/routing_specs/route_to_matcher.feature +0 -90
  48. data/features/step_definitions/additional_cli_steps.rb +0 -4
  49. data/features/step_definitions/model_steps.rb +0 -3
  50. data/features/support/env.rb +0 -53
  51. data/features/support/rails_versions.rb +0 -4
  52. data/features/support/rubinius.rb +0 -6
  53. data/features/view_specs/inferred_controller_path.feature +0 -45
  54. data/features/view_specs/stub_template.feature +0 -51
  55. data/features/view_specs/view_spec.feature +0 -206
  56. data/spec/autotest/rails_rspec2_spec.rb +0 -36
  57. data/spec/generators/rspec/controller/controller_generator_spec.rb +0 -97
  58. data/spec/generators/rspec/helper/helper_generator_spec.rb +0 -30
  59. data/spec/generators/rspec/install/install_generator_spec.rb +0 -30
  60. data/spec/generators/rspec/integration/integration_generator_spec.rb +0 -44
  61. data/spec/generators/rspec/mailer/mailer_generator_spec.rb +0 -48
  62. data/spec/generators/rspec/model/model_generator_spec.rb +0 -52
  63. data/spec/generators/rspec/observer/observer_generator_spec.rb +0 -21
  64. data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +0 -138
  65. data/spec/generators/rspec/view/view_generator_spec.rb +0 -41
  66. data/spec/rspec/rails/assertion_adapter_spec.rb +0 -28
  67. data/spec/rspec/rails/assertion_delegator_spec.rb +0 -43
  68. data/spec/rspec/rails/configuration_spec.rb +0 -26
  69. data/spec/rspec/rails/deprecations_spec.rb +0 -18
  70. data/spec/rspec/rails/example/controller_example_group_spec.rb +0 -100
  71. data/spec/rspec/rails/example/feature_example_group_spec.rb +0 -56
  72. data/spec/rspec/rails/example/helper_example_group_spec.rb +0 -64
  73. data/spec/rspec/rails/example/mailer_example_group_spec.rb +0 -21
  74. data/spec/rspec/rails/example/model_example_group_spec.rb +0 -15
  75. data/spec/rspec/rails/example/request_example_group_spec.rb +0 -17
  76. data/spec/rspec/rails/example/routing_example_group_spec.rb +0 -32
  77. data/spec/rspec/rails/example/view_example_group_spec.rb +0 -235
  78. data/spec/rspec/rails/extensions/active_model/errors_on_spec.rb +0 -23
  79. data/spec/rspec/rails/extensions/active_record/base_spec.rb +0 -42
  80. data/spec/rspec/rails/fixture_support_spec.rb +0 -17
  81. data/spec/rspec/rails/matchers/be_a_new_spec.rb +0 -142
  82. data/spec/rspec/rails/matchers/be_new_record_spec.rb +0 -33
  83. data/spec/rspec/rails/matchers/be_routable_spec.rb +0 -41
  84. data/spec/rspec/rails/matchers/be_valid_spec.rb +0 -44
  85. data/spec/rspec/rails/matchers/errors_on_spec.rb +0 -38
  86. data/spec/rspec/rails/matchers/has_spec.rb +0 -29
  87. data/spec/rspec/rails/matchers/have_rendered_spec.rb +0 -93
  88. data/spec/rspec/rails/matchers/redirect_to_spec.rb +0 -80
  89. data/spec/rspec/rails/matchers/relation_match_array_spec.rb +0 -31
  90. data/spec/rspec/rails/matchers/route_to_spec.rb +0 -151
  91. data/spec/rspec/rails/minitest_lifecycle_adapter_spec.rb +0 -31
  92. data/spec/rspec/rails/mocks/mock_model_spec.rb +0 -401
  93. data/spec/rspec/rails/mocks/stub_model_spec.rb +0 -154
  94. data/spec/rspec/rails/setup_and_teardown_adapter_spec.rb +0 -32
  95. data/spec/rspec/rails/view_rendering_spec.rb +0 -111
  96. data/spec/spec_helper.rb +0 -32
  97. data/spec/support/ar_classes.rb +0 -42
  98. data/spec/support/helpers.rb +0 -34
  99. data/spec/support/matchers.rb +0 -9
  100. data/spec/support/null_object.rb +0 -6
@@ -1,58 +0,0 @@
1
- Feature: controller spec
2
-
3
- Scenario: simple passing example
4
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
5
- """ruby
6
- require "spec_helper"
7
-
8
- describe WidgetsController do
9
- describe "GET index" do
10
- it "has a 200 status code" do
11
- get :index
12
- expect(response.status).to eq(200)
13
- end
14
- end
15
- end
16
- """
17
- When I run `rspec spec`
18
- Then the example should pass
19
-
20
- Scenario: controller is exposed to global before hooks
21
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
22
- """ruby
23
- require "spec_helper"
24
-
25
- RSpec.configure {|c| c.before { expect(controller).not_to be_nil }}
26
-
27
- describe WidgetsController do
28
- describe "GET index" do
29
- it "doesn't matter" do
30
- end
31
- end
32
- end
33
- """
34
- When I run `rspec spec`
35
- Then the example should pass
36
-
37
- Scenario: controller is extended with a helper module
38
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
39
- """ruby
40
- require "spec_helper"
41
-
42
- module MyHelper
43
- def my_variable
44
- end
45
- end
46
-
47
- RSpec.configure {|c| c.include MyHelper }
48
-
49
- describe WidgetsController do
50
- let(:my_variable) { 'is a value' }
51
-
52
- describe 'something' do
53
- specify { expect(my_variable).to eq 'is a value' }
54
- end
55
- end
56
- """
57
- When I run `rspec spec`
58
- Then the example should pass
@@ -1,51 +0,0 @@
1
- Feature: engine routes for controllers
2
-
3
- Controller specs can specify the routeset that will be used for the example
4
- group. This is most useful when testing Rails engines.
5
-
6
- @unsupported-on-rails-3-0
7
- Scenario: specify engine route
8
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
9
- """ruby
10
- require "spec_helper"
11
-
12
- # A very simple Rails engine
13
- module MyEngine
14
- class Engine < ::Rails::Engine
15
- isolate_namespace MyEngine
16
- end
17
-
18
- Engine.routes.draw do
19
- resources :widgets, :only => [:show] do
20
- get :random, :on => :collection
21
- end
22
- end
23
-
24
- class WidgetsController < ::ActionController::Base
25
- def random
26
- @random_widget = Widget.all.shuffle.first
27
- redirect_to widget_path(@random_widget)
28
- end
29
-
30
- def show
31
- @widget = Widget.find(params[:id])
32
- render :text => @widget.name
33
- end
34
- end
35
- end
36
-
37
- describe MyEngine::WidgetsController do
38
- routes { MyEngine::Engine.routes }
39
-
40
- it "redirects to a random widget" do
41
- widget1 = Widget.create!(:name => "Widget 1")
42
- widget2 = Widget.create!(:name => "Widget 2")
43
-
44
- get :random
45
- expect(response).to be_redirect
46
- expect(response).to redirect_to(assigns(:random_widget))
47
- end
48
- end
49
- """
50
- When I run `rspec spec`
51
- Then the examples should all pass
@@ -1,87 +0,0 @@
1
- Feature: views are stubbed by default
2
-
3
- By default, controller specs stub views with a template that renders an empty
4
- string instead of the views in the app. This allows you specify which view
5
- template an action should try to render regardless of whether the template
6
- compiles cleanly.
7
-
8
- NOTE: unlike rspec-rails-1.x, the real template must exist.
9
-
10
- Scenario: expect template that is rendered by controller action (passes)
11
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
12
- """ruby
13
- require "spec_helper"
14
-
15
- describe WidgetsController do
16
- describe "index" do
17
- it "renders the index template" do
18
- get :index
19
- expect(response).to render_template("index")
20
- expect(response.body).to eq ""
21
- end
22
- it "renders the widgets/index template" do
23
- get :index
24
- expect(response).to render_template("widgets/index")
25
- expect(response.body).to eq ""
26
- end
27
- end
28
- end
29
- """
30
- When I run `rspec spec`
31
- Then the examples should all pass
32
-
33
- Scenario: expect template that is not rendered by controller action (fails)
34
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
35
- """ruby
36
- require "spec_helper"
37
-
38
- describe WidgetsController do
39
- describe "index" do
40
- it "renders the 'new' template" do
41
- get :index
42
- expect(response).to render_template("new")
43
- end
44
- end
45
- end
46
- """
47
- When I run `rspec spec`
48
- Then the output should contain "1 example, 1 failure"
49
-
50
- Scenario: expect empty templates to render when view path is changed at runtime (passes)
51
- Given a file named "spec/controllers/things_controller_spec.rb" with:
52
- """ruby
53
- require "spec_helper"
54
-
55
- describe ThingsController do
56
- describe "custom_action" do
57
- it "renders an empty custom_action template" do
58
- controller.prepend_view_path 'app/views'
59
- controller.append_view_path 'app/views'
60
- get :custom_action
61
- expect(response).to render_template("custom_action")
62
- expect(response.body).to eq ""
63
- end
64
- end
65
- end
66
- """
67
- When I run `rspec spec`
68
- Then the examples should all pass
69
-
70
- Scenario: expect template to render the real template with render_views when view path is changed at runtime
71
- Given a file named "spec/controllers/things_controller_spec.rb" with:
72
- """ruby
73
- require "spec_helper"
74
-
75
- describe ThingsController do
76
- render_views
77
-
78
- it "renders the real custom_action template" do
79
- controller.prepend_view_path 'app/views'
80
- get :custom_action
81
- expect(response).to render_template("custom_action")
82
- expect(response.body).to match(/template for a custom action/)
83
- end
84
- end
85
- """
86
- When I run `rspec spec`
87
- Then the examples should all pass
@@ -1,114 +0,0 @@
1
- Feature: render_views
2
-
3
- You can tell a controller example group to render views with the
4
- `render_views` declaration in any individual group, or globally.
5
-
6
- Scenario: render_views directly in a single group
7
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
8
- """ruby
9
- require "spec_helper"
10
-
11
- describe WidgetsController do
12
- render_views
13
-
14
- describe "GET index" do
15
- it "says 'Listing widgets'" do
16
- get :index
17
- expect(response.body).to match /Listing widgets/m
18
- end
19
- end
20
- end
21
- """
22
- When I run `rspec spec`
23
- Then the examples should all pass
24
-
25
- Scenario: render_views on and off in nested groups
26
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
27
- """ruby
28
- require "spec_helper"
29
-
30
- describe WidgetsController do
31
- context "with render_views" do
32
- render_views
33
-
34
- describe "GET index" do
35
- it "renders the actual template" do
36
- get :index
37
- expect(response.body).to match /Listing widgets/m
38
- end
39
- end
40
-
41
- context "with render_views(false) nested in a group with render_views" do
42
- render_views false
43
-
44
- describe "GET index" do
45
- it "renders the RSpec generated template" do
46
- get :index
47
- expect(response.body).to eq("")
48
- end
49
- end
50
- end
51
- end
52
-
53
- context "without render_views" do
54
- describe "GET index" do
55
- it "renders the RSpec generated template" do
56
- get :index
57
- expect(response.body).to eq("")
58
- end
59
- end
60
- end
61
-
62
- context "with render_views again" do
63
- render_views
64
-
65
- describe "GET index" do
66
- it "renders the actual template" do
67
- get :index
68
- expect(response.body).to match /Listing widgets/m
69
- end
70
- end
71
- end
72
- end
73
- """
74
- When I run `rspec spec --order default --format documentation`
75
- Then the output should contain:
76
- """ruby
77
- WidgetsController
78
- with render_views
79
- GET index
80
- renders the actual template
81
- with render_views(false) nested in a group with render_views
82
- GET index
83
- renders the RSpec generated template
84
- without render_views
85
- GET index
86
- renders the RSpec generated template
87
- with render_views again
88
- GET index
89
- renders the actual template
90
- """
91
-
92
- Scenario: render_views globally
93
- Given a file named "spec/support/render_views.rb" with:
94
- """ruby
95
- RSpec.configure do |config|
96
- config.render_views
97
- end
98
- """
99
- And a file named "spec/controllers/widgets_controller_spec.rb" with:
100
- """ruby
101
- require "spec_helper"
102
-
103
- describe WidgetsController do
104
- describe "GET index" do
105
- it "renders the index template" do
106
- get :index
107
- expect(response.body).to match /Listing widgets/m
108
- end
109
- end
110
- end
111
- """
112
- When I run `rspec spec`
113
- Then the examples should all pass
114
-
@@ -1,34 +0,0 @@
1
- Feature: feature spec
2
-
3
- Feature specs are high-level tests meant to exercise slices of functionality
4
- through an application. They should drive the application only via its
5
- external interface, usually web pages.
6
-
7
- Feature specs require the [capybara](http://github.com/jnicklas/capybara)
8
- gem, version 2.0.0 or later. Refer to the [capybara API
9
- documentation](http://rubydoc.info/github/jnicklas/capybara/master) for more
10
- information on the methods and matchers that can be used in feature specs.
11
-
12
- The `feature` and `scenario` DSL correspond to `describe` and `it`,
13
- respectively. These methods are simply aliases that allow feature specs to
14
- read more as [customer tests](http://c2.com/cgi/wiki?CustomerTest) and
15
- [acceptance tests](http://c2.com/cgi/wiki?AcceptanceTest).
16
-
17
- Scenario: specify creating a Widget by driving the application with capybara
18
- Given a file named "spec/features/widget_management_spec.rb" with:
19
- """ruby
20
- require "spec_helper"
21
-
22
- feature "Widget management" do
23
- scenario "User creates a new widget" do
24
- visit "/widgets/new"
25
-
26
- fill_in "Name", :with => "My Widget"
27
- click_button "Create Widget"
28
-
29
- expect(page).to have_text("Widget was successfully created.")
30
- end
31
- end
32
- """
33
- When I run `rspec spec/features/widget_management_spec.rb`
34
- Then the example should pass
@@ -1,122 +0,0 @@
1
- Feature: helper spec
2
-
3
- Helper specs live in `spec/helpers`, or any example group with `:type =>
4
- :helper`.
5
-
6
- Helper specs expose a `helper` object, which includes the helper module being
7
- specified, the `ApplicationHelper` module (if there is one) and all of the
8
- helpers built into Rails. It does not include the other helper modules in
9
- your app.
10
-
11
- To access the helper methods you're specifying, simply call them directly
12
- on the `helper` object.
13
-
14
- NOTE: helper methods defined in controllers are not included.
15
-
16
- Scenario: helper method that returns a value
17
- Given a file named "spec/helpers/application_helper_spec.rb" with:
18
- """ruby
19
- require "spec_helper"
20
-
21
- describe ApplicationHelper do
22
- describe "#page_title" do
23
- it "returns the default title" do
24
- expect(helper.page_title).to eq("RSpec is your friend")
25
- end
26
- end
27
- end
28
- """
29
- And a file named "app/helpers/application_helper.rb" with:
30
- """ruby
31
- module ApplicationHelper
32
- def page_title
33
- "RSpec is your friend"
34
- end
35
- end
36
- """
37
- When I run `rspec spec/helpers/application_helper_spec.rb`
38
- Then the examples should all pass
39
-
40
- Scenario: helper method that accesses an instance variable
41
- Given a file named "spec/helpers/application_helper_spec.rb" with:
42
- """ruby
43
- require "spec_helper"
44
-
45
- describe ApplicationHelper do
46
- describe "#page_title" do
47
- it "returns the instance variable" do
48
- assign(:title, "My Title")
49
- expect(helper.page_title).to eql("My Title")
50
- end
51
- end
52
- end
53
- """
54
- And a file named "app/helpers/application_helper.rb" with:
55
- """ruby
56
- module ApplicationHelper
57
- def page_title
58
- @title || nil
59
- end
60
- end
61
- """
62
- When I run `rspec spec/helpers/application_helper_spec.rb`
63
- Then the examples should all pass
64
-
65
- Scenario: application helper is included in helper object
66
- Given a file named "spec/helpers/widgets_helper_spec.rb" with:
67
- """ruby
68
- require "spec_helper"
69
-
70
- describe WidgetsHelper do
71
- describe "#widget_title" do
72
- it "includes the app name" do
73
- assign(:title, "This Widget")
74
- expect(helper.widget_title).to eq("The App: This Widget")
75
- end
76
- end
77
- end
78
- """
79
- And a file named "app/helpers/application_helper.rb" with:
80
- """ruby
81
- module ApplicationHelper
82
- def app_name
83
- "The App"
84
- end
85
- end
86
- """
87
- And a file named "app/helpers/widgets_helper.rb" with:
88
- """ruby
89
- module WidgetsHelper
90
- def widget_title
91
- "#{app_name}: #{@title}"
92
- end
93
- end
94
- """
95
- When I run `rspec spec/helpers/widgets_helper_spec.rb`
96
- Then the examples should all pass
97
-
98
- Scenario: url helpers are defined
99
- Given a file named "spec/helpers/widgets_helper_spec.rb" with:
100
- """ruby
101
- require "spec_helper"
102
-
103
- describe WidgetsHelper do
104
- describe "#link_to_widget" do
105
- it "links to a widget using its name" do
106
- widget = Widget.create!(:name => "This Widget")
107
- expect(helper.link_to_widget(widget)).to include("This Widget")
108
- expect(helper.link_to_widget(widget)).to include(widget_path(widget))
109
- end
110
- end
111
- end
112
- """
113
- And a file named "app/helpers/widgets_helper.rb" with:
114
- """ruby
115
- module WidgetsHelper
116
- def link_to_widget(widget)
117
- link_to(widget.name, widget_path(widget))
118
- end
119
- end
120
- """
121
- When I run `rspec spec/helpers/widgets_helper_spec.rb`
122
- Then the examples should all pass