rspec-rails 2.13.1 → 2.13.2

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 (103) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +12 -1
  3. data/README.md +1 -1
  4. data/lib/generators/rspec.rb +1 -2
  5. data/lib/generators/rspec/install/install_generator.rb +0 -2
  6. data/lib/generators/rspec/install/templates/spec/spec_helper.rb.tt +1 -1
  7. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +1 -1
  8. data/lib/rspec/rails.rb +1 -1
  9. data/lib/rspec/rails/example/controller_example_group.rb +4 -2
  10. data/lib/rspec/rails/example/rails_example_group.rb +1 -2
  11. data/lib/rspec/rails/example/view_example_group.rb +1 -1
  12. data/lib/rspec/rails/fixture_support.rb +1 -1
  13. data/lib/rspec/rails/version.rb +1 -1
  14. metadata +5 -182
  15. data/features/Autotest.md +0 -24
  16. data/features/Generators.md +0 -8
  17. data/features/GettingStarted.md +0 -84
  18. data/features/README.md +0 -56
  19. data/features/RailsVersions.md +0 -4
  20. data/features/Transactions.md +0 -84
  21. data/features/Upgrade.md +0 -121
  22. data/features/controller_specs/Cookies.md +0 -57
  23. data/features/controller_specs/README.md +0 -45
  24. data/features/controller_specs/anonymous_controller.feature +0 -378
  25. data/features/controller_specs/bypass_rescue.feature +0 -75
  26. data/features/controller_specs/controller_spec.feature +0 -35
  27. data/features/controller_specs/engine_routes.feature +0 -51
  28. data/features/controller_specs/isolation_from_views.feature +0 -87
  29. data/features/controller_specs/render_views.feature +0 -114
  30. data/features/feature_specs/feature_spec.feature +0 -34
  31. data/features/helper_specs/helper_spec.feature +0 -122
  32. data/features/mailer_specs/url_helpers.feature +0 -38
  33. data/features/matchers/README.md +0 -18
  34. data/features/matchers/new_record_matcher.feature +0 -41
  35. data/features/matchers/redirect_to_matcher.feature +0 -40
  36. data/features/matchers/relation_match_array.feature +0 -22
  37. data/features/matchers/render_template_matcher.feature +0 -49
  38. data/features/mocks/mock_model.feature +0 -147
  39. data/features/mocks/stub_model.feature +0 -58
  40. data/features/model_specs/README.md +0 -21
  41. data/features/model_specs/errors_on.feature +0 -51
  42. data/features/model_specs/transactional_examples.feature +0 -109
  43. data/features/request_specs/request_spec.feature +0 -49
  44. data/features/routing_specs/README.md +0 -16
  45. data/features/routing_specs/be_routable_matcher.feature +0 -80
  46. data/features/routing_specs/engine_routes.feature +0 -38
  47. data/features/routing_specs/named_routes.feature +0 -18
  48. data/features/routing_specs/route_to_matcher.feature +0 -90
  49. data/features/step_definitions/additional_cli_steps.rb +0 -4
  50. data/features/step_definitions/model_steps.rb +0 -3
  51. data/features/support/env.rb +0 -53
  52. data/features/support/rails_versions.rb +0 -4
  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/lib/rspec/rails/rails_version.rb +0 -17
  57. data/spec/autotest/rails_rspec2_spec.rb +0 -36
  58. data/spec/generators/rspec/controller/controller_generator_spec.rb +0 -97
  59. data/spec/generators/rspec/helper/helper_generator_spec.rb +0 -30
  60. data/spec/generators/rspec/install/install_generator_spec.rb +0 -30
  61. data/spec/generators/rspec/integration/integration_generator_spec.rb +0 -44
  62. data/spec/generators/rspec/mailer/mailer_generator_spec.rb +0 -48
  63. data/spec/generators/rspec/model/model_generator_spec.rb +0 -52
  64. data/spec/generators/rspec/observer/observer_generator_spec.rb +0 -21
  65. data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +0 -138
  66. data/spec/generators/rspec/view/view_generator_spec.rb +0 -41
  67. data/spec/rspec/rails/assertion_adapter_spec.rb +0 -28
  68. data/spec/rspec/rails/assertion_delegator_spec.rb +0 -43
  69. data/spec/rspec/rails/configuration_spec.rb +0 -26
  70. data/spec/rspec/rails/deprecations_spec.rb +0 -18
  71. data/spec/rspec/rails/example/controller_example_group_spec.rb +0 -100
  72. data/spec/rspec/rails/example/feature_example_group_spec.rb +0 -56
  73. data/spec/rspec/rails/example/helper_example_group_spec.rb +0 -64
  74. data/spec/rspec/rails/example/mailer_example_group_spec.rb +0 -21
  75. data/spec/rspec/rails/example/model_example_group_spec.rb +0 -15
  76. data/spec/rspec/rails/example/request_example_group_spec.rb +0 -17
  77. data/spec/rspec/rails/example/routing_example_group_spec.rb +0 -32
  78. data/spec/rspec/rails/example/view_example_group_spec.rb +0 -220
  79. data/spec/rspec/rails/extensions/active_model/errors_on_spec.rb +0 -23
  80. data/spec/rspec/rails/extensions/active_record/base_spec.rb +0 -42
  81. data/spec/rspec/rails/extensions/active_record/records_spec.rb +0 -9
  82. data/spec/rspec/rails/fixture_support_spec.rb +0 -17
  83. data/spec/rspec/rails/matchers/be_a_new_spec.rb +0 -142
  84. data/spec/rspec/rails/matchers/be_new_record_spec.rb +0 -33
  85. data/spec/rspec/rails/matchers/be_routable_spec.rb +0 -41
  86. data/spec/rspec/rails/matchers/be_valid_spec.rb +0 -44
  87. data/spec/rspec/rails/matchers/errors_on_spec.rb +0 -38
  88. data/spec/rspec/rails/matchers/has_spec.rb +0 -29
  89. data/spec/rspec/rails/matchers/have_rendered_spec.rb +0 -93
  90. data/spec/rspec/rails/matchers/redirect_to_spec.rb +0 -80
  91. data/spec/rspec/rails/matchers/relation_match_array_spec.rb +0 -31
  92. data/spec/rspec/rails/matchers/route_to_spec.rb +0 -151
  93. data/spec/rspec/rails/minitest_lifecycle_adapter_spec.rb +0 -22
  94. data/spec/rspec/rails/mocks/mock_model_spec.rb +0 -379
  95. data/spec/rspec/rails/mocks/stub_model_spec.rb +0 -154
  96. data/spec/rspec/rails/rails_version_spec.rb +0 -29
  97. data/spec/rspec/rails/setup_and_teardown_adapter_spec.rb +0 -32
  98. data/spec/rspec/rails/view_rendering_spec.rb +0 -111
  99. data/spec/spec_helper.rb +0 -31
  100. data/spec/support/ar_classes.rb +0 -42
  101. data/spec/support/helpers.rb +0 -20
  102. data/spec/support/matchers.rb +0 -9
  103. data/spec/support/null_object.rb +0 -6
@@ -1,38 +0,0 @@
1
- Feature: URL helpers in mailer examples
2
-
3
- Scenario: using URL helpers with default options
4
- Given a file named "config/initializers/mailer_defaults.rb" with:
5
- """ruby
6
- Rails.configuration.action_mailer.default_url_options = { :host => 'example.com' }
7
- """
8
- And a file named "spec/mailers/notifications_spec.rb" with:
9
- """ruby
10
- require 'spec_helper'
11
-
12
- describe Notifications do
13
- it 'should have access to URL helpers' do
14
- expect { gadgets_url }.not_to raise_error
15
- end
16
- end
17
- """
18
- When I run `rspec spec`
19
- Then the examples should all pass
20
-
21
- Scenario: using URL helpers without default options
22
- Given a file named "config/initializers/mailer_defaults.rb" with:
23
- """ruby
24
- # no default options
25
- """
26
- And a file named "spec/mailers/notifications_spec.rb" with:
27
- """ruby
28
- require 'spec_helper'
29
-
30
- describe Notifications do
31
- it 'should have access to URL helpers' do
32
- expect { gadgets_url :host => 'example.com' }.not_to raise_error
33
- expect { gadgets_url }.to raise_error
34
- end
35
- end
36
- """
37
- When I run `rspec spec`
38
- Then the examples should all pass
@@ -1,18 +0,0 @@
1
- rspec-rails offers a number of custom matchers, most of which are
2
- rspec-compatible wrappers for Rails' assertions.
3
-
4
- ### redirects
5
-
6
- # delegates to assert_redirected_to
7
- expect(response).to redirect_to(path)
8
-
9
- ### templates
10
-
11
- # delegates to assert_template
12
- expect(response).to render_template(template_name)
13
-
14
- ### assigned objects
15
-
16
- # passes if assigns(:widget) is an instance of Widget
17
- # and it is not persisted
18
- expect(assigns(:widget)).to be_a_new(Widget)
@@ -1,41 +0,0 @@
1
- Feature: be_a_new matcher
2
-
3
- The `be_a_new` matcher accepts a class and passes if the subject is an
4
- instance of that class that returns false to persisted?
5
-
6
- You can also chain `with` on `be_a_new` with a hash of attributes to specify
7
- the subject has equal attributes.
8
-
9
- Scenario: example spec with four be_a_new possibilities
10
- Given a file named "spec/models/widget_spec.rb" with:
11
- """ruby
12
- require "spec_helper"
13
-
14
- describe Widget do
15
- context "when initialized" do
16
- subject(:widget) { Widget.new }
17
-
18
- it "is a new widget" do
19
- expect(widget).to be_a_new(Widget)
20
- end
21
-
22
- it "is not a new string" do
23
- expect(widget).not_to be_a_new(String)
24
- end
25
- end
26
-
27
- context "when saved" do
28
- subject(:widget) { Widget.create }
29
-
30
- it "is not a new widget" do
31
- expect(widget).not_to be_a_new(Widget)
32
- end
33
-
34
- it "is not a new string" do
35
- expect(widget).not_to be_a_new(String)
36
- end
37
- end
38
- end
39
- """
40
- When I run `rspec spec/models/widget_spec.rb`
41
- Then the examples should all pass
@@ -1,40 +0,0 @@
1
- Feature: redirect_to matcher
2
-
3
- The `redirect_to` matcher is used to specify that a request redirects to a
4
- given template or action. It delegates to
5
- [`assert_redirected_to`](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/ResponseAssertions.html#method-i-assert_redirected_to).
6
-
7
- It is available in controller specs (spec/controllers) and request
8
- specs (spec/requests).
9
-
10
- Scenario: redirect_to with four possible options
11
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
12
- """ruby
13
- require "spec_helper"
14
-
15
- describe WidgetsController do
16
-
17
- describe "#create" do
18
- subject { post :create, :widget => { :name => "Foo" } }
19
-
20
- it "redirects to widget_url(@widget)" do
21
- expect(subject).to redirect_to(widget_url(assigns(:widget)))
22
- end
23
-
24
- it "redirects_to :action => :show" do
25
- expect(subject).to redirect_to :action => :show,
26
- :id => assigns(:widget).id
27
- end
28
-
29
- it "redirects_to(@widget)" do
30
- expect(subject).to redirect_to(assigns(:widget))
31
- end
32
-
33
- it "redirects_to /widgets/:id" do
34
- expect(subject).to redirect_to("/widgets/#{assigns(:widget).id}")
35
- end
36
- end
37
- end
38
- """
39
- When I run `rspec spec/controllers/widgets_controller_spec.rb`
40
- Then the examples should all pass
@@ -1,22 +0,0 @@
1
- Feature: ActiveRecord::Relation match array
2
-
3
- The `match_array` matcher can be used with an `ActiveRecord::Relation`
4
- (scope). The assertion will pass if the scope would return all of the
5
- elements specified in the array on the right hand side.
6
-
7
- Scenario: example spec with relation match_array matcher
8
- Given a file named "spec/models/widget_spec.rb" with:
9
- """ruby
10
- require "spec_helper"
11
-
12
- describe Widget do
13
- let!(:widgets) { Array.new(3) { Widget.create } }
14
- subject { Widget.scoped }
15
-
16
- it "returns all widgets in any order" do
17
- expect(subject).to match_array(widgets)
18
- end
19
- end
20
- """
21
- When I run `rspec spec/models/widget_spec.rb`
22
- Then the examples should all pass
@@ -1,49 +0,0 @@
1
- Feature: render_template matcher
2
-
3
- The `render_template` matcher is used to specify that a request renders a
4
- given template. It delegates to
5
- [`assert_template`](http://api.rubyonrails.org/classes/ActionController/TemplateAssertions.html#method-i-assert_template)
6
-
7
- It is available in controller specs (spec/controllers) and request
8
- specs (spec/requests).
9
-
10
- NOTE: use `redirect_to(:action => 'new')` for redirects, not `render_template`.
11
-
12
- Scenario: render_template with three possible options
13
- Given a file named "spec/controllers/gadgets_spec.rb" with:
14
- """ruby
15
- require "spec_helper"
16
-
17
- describe GadgetsController do
18
- describe "GET #index" do
19
- subject { get :index }
20
-
21
- it "renders the index template" do
22
- expect(subject).to render_template(:index)
23
- expect(subject).to render_template("index")
24
- expect(subject).to render_template("gadgets/index")
25
- end
26
- end
27
- end
28
- """
29
- When I run `rspec spec/controllers/gadgets_spec.rb`
30
- Then the examples should all pass
31
-
32
- Scenario: render_template in a view spec
33
- Given a file named "spec/views/gadgets/index.html.erb_spec.rb" with:
34
- """ruby
35
- require "spec_helper"
36
-
37
- describe "gadgets/index" do
38
- it "renders the index template" do
39
- assign(:gadgets, [stub_model(Gadget)])
40
- render
41
-
42
- expect(view).to render_template(:index)
43
- expect(view).to render_template("index")
44
- expect(view).to render_template("gadgets/index")
45
- end
46
- end
47
- """
48
- When I run `rspec spec/views`
49
- Then the examples should all pass
@@ -1,147 +0,0 @@
1
- Feature: mock_model
2
-
3
- The `mock_model` method generates a test double that acts like an instance of
4
- `ActiveModel`. This is different from the `stub_model` method which generates
5
- an instance of a real model class.
6
-
7
- The benefit of `mock_model` over `stub_model` is that it is a true double, so
8
- the examples are not dependent on the behavior (or mis-behavior), or even the
9
- existence of any other code. If you're working on a controller spec and you
10
- need a model that doesn't exist, you can pass `mock_model` a string and the
11
- generated object will act as though its an instance of the class named by
12
- that string.
13
-
14
- Scenario: passing a string that represents a non-existent constant
15
- Given a file named "spec/models/car_spec.rb" with:
16
- """ruby
17
- require "spec_helper"
18
-
19
- describe "mock_model('Car') with no Car constant in existence" do
20
- it "generates a constant" do
21
- expect(Object.const_defined?(:Car)).to be_false
22
- mock_model("Car")
23
- expect(Object.const_defined?(:Car)).to be_true
24
- end
25
-
26
- describe "generates an object that ..." do
27
- it "returns the correct name" do
28
- car = mock_model("Car")
29
- expect(car.class.name).to eq("Car")
30
- end
31
-
32
- it "says it is a Car" do
33
- car = mock_model("Car")
34
- expect(car).to be_a(Car)
35
- end
36
- end
37
- end
38
- """
39
- When I run `rspec spec/models/car_spec.rb`
40
- Then the examples should all pass
41
-
42
- Scenario: passing a string that represents an existing constant
43
- Given a file named "spec/models/widget_spec.rb" with:
44
- """ruby
45
- require "spec_helper"
46
-
47
- describe Widget do
48
- it "uses the existing constant" do
49
- widget = mock_model("Widget")
50
- expect(widget).to be_a(Widget)
51
- end
52
- end
53
- """
54
- When I run `rspec spec/models/widget_spec.rb`
55
- Then the examples should all pass
56
-
57
- Scenario: passing a class that does not extend ActiveModel::Naming
58
- Given a file named "spec/models/string_spec.rb" with:
59
- """ruby
60
- require "spec_helper"
61
-
62
- describe String do
63
- it "raises" do
64
- expect { mock_model(String) }.to raise_exception
65
- end
66
- end
67
- """
68
- When I run `rspec spec/models/string_spec.rb`
69
- Then the examples should all pass
70
-
71
- Scenario: passing an Active Record constant
72
- Given a file named "spec/models/widget_spec.rb" with:
73
- """ruby
74
- require "spec_helper"
75
-
76
- describe Widget do
77
- let(:widget) { mock_model(Widget) }
78
-
79
- it "is valid by default" do
80
- expect(widget).to be_valid
81
- end
82
-
83
- it "is not a new record by default" do
84
- expect(widget).not_to be_new_record
85
- end
86
-
87
- it "can be converted to a new record" do
88
- expect(widget.as_new_record).to be_new_record
89
- end
90
-
91
- it "sets :id to nil upon destroy" do
92
- widget.destroy
93
- expect(widget.id).to be_nil
94
- end
95
- end
96
- """
97
- When I run `rspec spec/models/widget_spec.rb`
98
- Then the examples should all pass
99
-
100
- Scenario: passing an Active Record constant with method stubs
101
- Given a file named "spec/models/widget_spec.rb" with:
102
- """ruby
103
- require "spec_helper"
104
-
105
- describe "mock_model(Widget) with stubs" do
106
- let(:widget) do
107
- mock_model Widget, :foo => "bar",
108
- :save => true,
109
- :update_attributes => false
110
- end
111
-
112
- it "supports stubs for methods that don't exist in ActiveModel or ActiveRecord" do
113
- expect(widget.foo).to eq("bar")
114
- end
115
-
116
- it "supports stubs for methods that do exist" do
117
- expect(widget.save).to eq(true)
118
- expect(widget.update_attributes).to be_false
119
- end
120
-
121
- describe "#errors" do
122
- context "with update_attributes => false" do
123
- it "is not empty" do
124
- expect(widget.errors).not_to be_empty
125
- end
126
- end
127
- end
128
- end
129
- """
130
- When I run `rspec spec/models/widget_spec.rb`
131
- Then the examples should all pass
132
-
133
- Scenario: mock_model outside rails
134
- Given a file named "mock_model_outside_rails_spec.rb" with:
135
- """ruby
136
- require 'rspec/rails/mocks'
137
-
138
- describe "Foo" do
139
- it "is mockable" do
140
- foo = mock_model("Foo")
141
- expect(foo.id).to eq(1001)
142
- expect(foo.to_param).to eq("1001")
143
- end
144
- end
145
- """
146
- When I run `rspec mock_model_outside_rails_spec.rb`
147
- Then the examples should all pass
@@ -1,58 +0,0 @@
1
- Feature: stub_model
2
-
3
- The stub_model method generates an instance of a Active Model model.
4
-
5
- While you can use stub_model in any example (model, view, controller,
6
- helper), it is especially useful in view examples, which are inherently
7
- more state-based than interaction-based.
8
-
9
- Scenario: passing an Active Record constant with a hash of stubs
10
- Given a file named "spec/models/widget_spec.rb" with:
11
- """ruby
12
- require "spec_helper"
13
-
14
- describe "stub_model(Widget) with a hash of stubs" do
15
- let(:widget) do
16
- stub_model Widget, :id => 5, :random_attribute => true
17
- end
18
-
19
- it "stubs :id" do
20
- expect(widget.id).to eql(5)
21
- end
22
-
23
- it "stubs :random_attribute" do
24
- expect(widget.random_attribute).to be_true
25
- end
26
-
27
- it "returns false for new_record? if :id is set" do
28
- expect(widget).not_to be_new_record
29
- end
30
-
31
- it "can be converted to a new record" do
32
- widget.as_new_record
33
- expect(widget).to be_new_record
34
- end
35
- end
36
- """
37
- When I run `rspec spec/models/widget_spec.rb`
38
- Then the examples should all pass
39
-
40
- Scenario: passing an Active Record constant with a block of stubs
41
- Given a file named "spec/models/widget_spec.rb" with:
42
- """ruby
43
- require "spec_helper"
44
-
45
- describe "stub_model(Widget) with a block of stubs" do
46
- let(:widget) do
47
- stub_model Widget do |widget|
48
- widget.id = 5
49
- end
50
- end
51
-
52
- it "stubs :id" do
53
- expect(widget.id).to eql(5)
54
- end
55
- end
56
- """
57
- When I run `rspec spec/models/widget_spec.rb`
58
- Then the examples should all pass
@@ -1,21 +0,0 @@
1
- Model specs live in `spec/models` or any example group with
2
- `:type => :model`.
3
-
4
- A model spec is a thin wrapper for an ActiveSupport::TestCase, and includes all
5
- of the behavior and assertions that it provides, in addition to RSpec's own
6
- behavior and expectations.
7
-
8
- ## Examples
9
-
10
- require "spec_helper"
11
-
12
- describe Post do
13
- context "with 2 or more comments" do
14
- it "orders them in reverse chronologically" do
15
- post = Post.create!
16
- comment1 = post.comments.create!(:body => "first comment")
17
- comment2 = post.comments.create!(:body => "second comment")
18
- expect(post.reload.comments).to eq([comment2, comment1])
19
- end
20
- end
21
- end
@@ -1,51 +0,0 @@
1
- Feature: errors_on
2
-
3
- Scenario: with one validation error
4
- Given a file named "spec/models/widget_spec.rb" with:
5
- """ruby
6
- require "spec_helper"
7
-
8
- class ValidatingWidget < ActiveRecord::Base
9
- self.table_name = :widgets
10
- validates_presence_of :name
11
-
12
- # In Rails 4, mass assignment protection is implemented on controllers
13
- attr_accessible :name if RSpec::Rails.rails_version_satisfied_by?('< 4.0.0.beta1')
14
-
15
- validates_length_of :name, :minimum => 10, :on => :publication
16
- end
17
-
18
- describe ValidatingWidget do
19
- it "fails validation with no name (using error_on)" do
20
- expect(ValidatingWidget.new).to have(1).error_on(:name)
21
- end
22
-
23
- it "fails validation with no name (using errors_on)" do
24
- expect(ValidatingWidget.new).to have(1).errors_on(:name)
25
- end
26
-
27
- it "fails validation with no name expecting a specific message" do
28
- expect(ValidatingWidget.new.errors_on(:name)).to include("can't be blank")
29
- end
30
-
31
- it "fails validation with a short name (using a validation context)" do
32
- expect(ValidatingWidget.new(:name => "too short")).
33
- to have(1).errors_on(:name, :context => :publication)
34
- end
35
-
36
- it "passes validation with a longer name (using a validation context)" do
37
- expect(ValidatingWidget.new(:name => "a longer name")).
38
- to have(0).errors_on(:name, :context => :publication)
39
- end
40
-
41
- it "passes validation with a name (using 0)" do
42
- expect(ValidatingWidget.new(:name => "liquid nitrogen")).to have(0).errors_on(:name)
43
- end
44
-
45
- it "passes validation with a name (using :no)" do
46
- expect(ValidatingWidget.new(:name => "liquid nitrogen")).to have(:no).errors_on(:name)
47
- end
48
- end
49
- """
50
- When I run `rspec spec/models/widget_spec.rb`
51
- Then the examples should all pass