rspec-rails 2.13.1 → 2.13.2

Sign up to get free protection for your applications and to get access to all the features.
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,154 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "stub_model" do
4
-
5
- shared_examples_for "stub model" do
6
- describe "with a block" do
7
- it "yields the model" do
8
- model = stub_model(model_class) do |block_arg|
9
- @block_arg = block_arg
10
- end
11
- model.should be(@block_arg)
12
- end
13
- end
14
-
15
- describe "#persisted?" do
16
- context "default" do
17
- it "returns true" do
18
- model = stub_model(model_class)
19
- model.should be_persisted
20
- end
21
- end
22
-
23
- context "with as_new_record" do
24
- it "returns false" do
25
- model = stub_model(model_class).as_new_record
26
- model.should_not be_persisted
27
- end
28
- end
29
- end
30
-
31
- it "increments the value returned by to_param" do
32
- first = stub_model(model_class)
33
- second = stub_model(model_class)
34
- second.to_param.to_i.should == (first.to_param.to_i + 1)
35
- end
36
-
37
- describe "#blank?" do
38
- it "is false" do
39
- stub_model(model_class).should_not be_blank
40
- end
41
- end
42
- end
43
-
44
- context "with ActiveModel (not ActiveRecord)" do
45
- it_behaves_like "stub model" do
46
- def model_class
47
- NonActiveRecordModel
48
- end
49
- end
50
- end
51
-
52
- context "with an ActiveRecord model" do
53
- let(:model_class) { MockableModel }
54
-
55
- it_behaves_like "stub model"
56
-
57
- describe "#new_record?" do
58
- context "default" do
59
- it "returns false" do
60
- model = stub_model(model_class)
61
- model.new_record?.should be_false
62
- end
63
- end
64
-
65
- context "with as_new_record" do
66
- it "returns true" do
67
- model = stub_model(model_class).as_new_record
68
- model.new_record?.should be_true
69
- end
70
- end
71
- end
72
-
73
- describe "defaults" do
74
- it "has an id" do
75
- stub_model(MockableModel).id.should be > 0
76
- end
77
-
78
- it "says it is not a new record" do
79
- stub_model(MockableModel).should_not be_new_record
80
- end
81
- end
82
-
83
- describe "#as_new_record" do
84
- it "has a nil id" do
85
- stub_model(MockableModel).as_new_record.id.should be(nil)
86
- end
87
- end
88
-
89
- it "raises when hitting the db" do
90
- lambda do
91
- stub_model(MockableModel).connection
92
- end.should raise_error(RSpec::Rails::IllegalDataAccessException, /stubbed models are not allowed to access the database/)
93
- end
94
-
95
- it "increments the id" do
96
- first = stub_model(model_class)
97
- second = stub_model(model_class)
98
- second.id.should == (first.id + 1)
99
- end
100
-
101
- it "accepts a stub id" do
102
- stub_model(MockableModel, :id => 37).id.should == 37
103
- end
104
-
105
- it "says it is a new record when id is set to nil" do
106
- stub_model(MockableModel, :id => nil).should be_new_record
107
- end
108
-
109
- it "accepts a stub for save" do
110
- stub_model(MockableModel, :save => false).save.should be(false)
111
- end
112
-
113
- describe "alternate primary key" do
114
- it "has the correct primary_key name" do
115
- stub_model(AlternatePrimaryKeyModel).class.primary_key.to_s.should eq('my_id')
116
- end
117
-
118
- it "has a primary_key" do
119
- stub_model(AlternatePrimaryKeyModel).my_id.should be > 0
120
- end
121
-
122
- it "says it is not a new record" do
123
- stub_model(AlternatePrimaryKeyModel) do |m|
124
- m.should_not be_new_record
125
- end
126
- end
127
-
128
- it "says it is a new record if primary_key is nil" do
129
- stub_model(AlternatePrimaryKeyModel, :my_id => nil).should be_new_record
130
- end
131
-
132
- it "accepts a stub for the primary_key" do
133
- stub_model(AlternatePrimaryKeyModel, :my_id => 5).my_id.should == 5
134
- end
135
- end
136
-
137
- describe "as association" do
138
- before(:each) do
139
- @real = AssociatedModel.create!
140
- @stub_model = stub_model(MockableModel)
141
- @real.mockable_model = @stub_model
142
- end
143
-
144
- it "passes associated_model == mock" do
145
- @stub_model.should == @real.mockable_model
146
- end
147
-
148
- it "passes mock == associated_model" do
149
- @real.mockable_model.should == @stub_model
150
- end
151
- end
152
-
153
- end
154
- end
@@ -1,29 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe RSpec::Rails, "version" do
4
- def clear_memoized_version
5
- if RSpec::Rails.instance_variable_defined?(:@rails_version)
6
- RSpec::Rails.send(:remove_instance_variable, :@rails_version)
7
- end
8
- end
9
-
10
- before { clear_memoized_version }
11
- after { clear_memoized_version }
12
-
13
- describe "#rails_version_satisfied_by?" do
14
- it "checks whether the gem version constraint is satisfied by the Rails version" do
15
- ::Rails.stub(:version).and_return(Gem::Version.new("4.0.0"))
16
-
17
- expect(RSpec::Rails.rails_version_satisfied_by?(">=3.2.0")).to be_true
18
- expect(RSpec::Rails.rails_version_satisfied_by?("~>4.0.0")).to be_true
19
- expect(RSpec::Rails.rails_version_satisfied_by?("~>3.2.0")).to be_false
20
- end
21
-
22
- it "operates correctly when the Rails version is a string (pre-Rails 4.0)" do
23
- ::Rails.stub(:version).and_return("3.2.1")
24
-
25
- expect(RSpec::Rails.rails_version_satisfied_by?("~>3.2.0")).to be_true
26
- expect(RSpec::Rails.rails_version_satisfied_by?("~>3.1.0")).to be_false
27
- end
28
- end
29
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RSpec::Rails::SetupAndTeardownAdapter do
4
- describe "::setup" do
5
- it "registers before hooks in the order setup is received" do
6
- klass = Class.new do
7
- include RSpec::Rails::SetupAndTeardownAdapter
8
- def self.foo; "foo"; end
9
- def self.bar; "bar"; end
10
- end
11
- klass.should_receive(:before).ordered { |&block| block.call.should eq "foo" }
12
- klass.should_receive(:before).ordered { |&block| block.call.should eq "bar" }
13
-
14
- klass.setup :foo
15
- klass.setup :bar
16
- end
17
-
18
- it "registers prepend_before hooks for the Rails' setup methods" do
19
- klass = Class.new do
20
- include RSpec::Rails::SetupAndTeardownAdapter
21
- def self.setup_fixtures; "setup fixtures" end
22
- def self.setup_controller_request_and_response; "setup controller" end
23
- end
24
-
25
- klass.should_receive(:prepend_before) { |&block| block.call.should eq "setup fixtures" }
26
- klass.should_receive(:prepend_before) { |&block| block.call.should eq "setup controller" }
27
-
28
- klass.setup :setup_fixtures
29
- klass.setup :setup_controller_request_and_response
30
- end
31
- end
32
- end
@@ -1,111 +0,0 @@
1
- require "spec_helper"
2
-
3
- module RSpec::Rails
4
- describe ViewRendering do
5
- let(:group) do
6
- RSpec::Core::ExampleGroup.describe do
7
- def controller
8
- ActionController::Base.new
9
- end
10
- include ViewRendering
11
- end
12
- end
13
-
14
- context "default" do
15
- context "ActionController::Base" do
16
- it "does not render views" do
17
- group.new.render_views?.should be_false
18
- end
19
-
20
- it "does not render views in a nested group" do
21
- group.describe{}.new.render_views?.should be_false
22
- end
23
- end
24
-
25
- context "ActionController::Metal" do
26
- it "renders views" do
27
- group.new.tap do |example|
28
- def example.controller
29
- ActionController::Metal.new
30
- end
31
- example.render_views?.should be_true
32
- end
33
- end
34
- end
35
- end
36
-
37
- describe "#render_views" do
38
- context "with no args" do
39
- it "tells examples to render views" do
40
- group.render_views
41
- group.new.render_views?.should be_true
42
- end
43
- end
44
-
45
- context "with true" do
46
- it "tells examples to render views" do
47
- group.render_views true
48
- group.new.render_views?.should be_true
49
- end
50
- end
51
-
52
- context "with false" do
53
- it "tells examples not to render views" do
54
- group.render_views false
55
- group.new.render_views?.should be_false
56
- end
57
-
58
- it "overrides the global config if render_views is enabled there" do
59
- RSpec.configuration.stub(:render_views?).and_return true
60
- group.render_views false
61
- group.new.render_views?.should be_false
62
- end
63
- end
64
-
65
- context "in a nested group" do
66
- let(:nested_group) do
67
- group.describe{}
68
- end
69
-
70
- context "with no args" do
71
- it "tells examples to render views" do
72
- nested_group.render_views
73
- nested_group.new.render_views?.should be_true
74
- end
75
- end
76
-
77
- context "with true" do
78
- it "tells examples to render views" do
79
- nested_group.render_views true
80
- nested_group.new.render_views?.should be_true
81
- end
82
- end
83
-
84
- context "with false" do
85
- it "tells examples not to render views" do
86
- nested_group.render_views false
87
- nested_group.new.render_views?.should be_false
88
- end
89
- end
90
-
91
- it "leaves the parent group as/is" do
92
- group.render_views
93
- nested_group.render_views false
94
- group.new.render_views?.should be_true
95
- end
96
-
97
- it "overrides the value inherited from the parent group" do
98
- group.render_views
99
- nested_group.render_views false
100
- nested_group.new.render_views?.should be_false
101
- end
102
-
103
- it "passes override to children" do
104
- group.render_views
105
- nested_group.render_views false
106
- nested_group.describe{}.new.render_views?.should be_false
107
- end
108
- end
109
- end
110
- end
111
- end
@@ -1,31 +0,0 @@
1
- require 'rails/all'
2
-
3
- module RSpecRails
4
- class Application < ::Rails::Application
5
- end
6
- end
7
-
8
- require 'rspec/rails'
9
- require 'ammeter/init'
10
-
11
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
12
-
13
- class RSpec::Core::ExampleGroup
14
- def self.run_all(reporter=nil)
15
- run(reporter || RSpec::Mocks::Mock.new('reporter').as_null_object)
16
- end
17
- end
18
-
19
- RSpec.configure do |config|
20
- config.treat_symbols_as_metadata_keys_with_true_values = true
21
- config.filter_run :focus
22
- config.run_all_when_everything_filtered = true
23
- config.before(:each) do
24
- @real_world = RSpec.world
25
- RSpec.instance_variable_set(:@world, RSpec::Core::World.new)
26
- end
27
- config.after(:each) do
28
- RSpec.instance_variable_set(:@world, @real_world)
29
- end
30
- config.order = :random
31
- end
@@ -1,42 +0,0 @@
1
- ActiveRecord::Base.establish_connection(
2
- :adapter => 'sqlite3',
3
- :database => ':memory:'
4
- )
5
-
6
- module Connections
7
- def self.extended(host)
8
- host.connection.execute <<-eosql
9
- CREATE TABLE #{host.table_name} (
10
- #{host.primary_key} integer PRIMARY KEY AUTOINCREMENT,
11
- associated_model_id integer,
12
- mockable_model_id integer,
13
- nonexistent_model_id integer
14
- )
15
- eosql
16
- end
17
- end
18
-
19
- class NonActiveRecordModel
20
- extend ActiveModel::Naming
21
- include ActiveModel::Conversion
22
- end
23
-
24
- class MockableModel < ActiveRecord::Base
25
- extend Connections
26
- has_one :associated_model
27
- end
28
-
29
- class SubMockableModel < MockableModel
30
- end
31
-
32
- class AssociatedModel < ActiveRecord::Base
33
- extend Connections
34
- belongs_to :mockable_model
35
- belongs_to :nonexistent_model, :class_name => "Other"
36
- end
37
-
38
- class AlternatePrimaryKeyModel < ActiveRecord::Base
39
- self.primary_key = :my_id
40
- extend Connections
41
- attr_accessor :my_id
42
- end
@@ -1,20 +0,0 @@
1
- module Helpers
2
- def stub_metadata(additional_metadata)
3
- stub_metadata = metadata_with(additional_metadata)
4
- RSpec::Core::ExampleGroup.stub(:metadata) { stub_metadata }
5
- end
6
-
7
- def metadata_with(additional_metadata)
8
- m = RSpec::Core::Metadata.new
9
- m.process("example group")
10
-
11
- group_metadata = additional_metadata.delete(:example_group)
12
- if group_metadata
13
- m[:example_group].merge!(group_metadata)
14
- end
15
- m.merge!(additional_metadata)
16
- m
17
- end
18
-
19
- RSpec.configure {|c| c.include self}
20
- end
@@ -1,9 +0,0 @@
1
- RSpec::Matchers::define :be_included_in_files_in do |path|
2
- match do |mod|
3
- stub_metadata(
4
- :example_group => {:file_path => "#{path}whatever_spec.rb:15"}
5
- )
6
- group = RSpec::Core::ExampleGroup.describe
7
- group.included_modules.include?(mod)
8
- end
9
- end
@@ -1,6 +0,0 @@
1
- class NullObject
2
- private
3
-
4
- def method_missing(method, *args, &blk)
5
- end
6
- end