rspec-rails 2.0.0.beta.17 → 2.0.0.beta.18
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +4 -2
- data/VERSION +1 -1
- data/features/view_specs/view_spec.feature +31 -0
- data/lib/autotest/rails_rspec2.rb +2 -2
- data/lib/generators/rspec/controller/controller_generator.rb +1 -1
- data/lib/generators/rspec/helper/templates/helper_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/routing_spec.rb +3 -3
- data/lib/rspec/rails/example/controller_example_group.rb +2 -2
- data/lib/rspec/rails/example/view_example_group.rb +33 -2
- data/lib/rspec/rails/extensions/active_record/base.rb +1 -1
- data/lib/rspec/rails/fixture_support.rb +3 -3
- data/lib/rspec/rails/matchers/have_extension.rb +1 -1
- data/lib/rspec/rails/mocks.rb +35 -9
- data/lib/rspec/rails/view_rendering.rb +1 -1
- data/rspec-rails.gemspec +5 -5
- data/spec/rspec/rails/example/view_example_group_spec.rb +83 -0
- data/spec/rspec/rails/matchers/errors_on_spec.rb +2 -2
- data/spec/rspec/rails/matchers/route_to_spec.rb +1 -1
- data/spec/rspec/rails/mocks/mock_model_spec.rb +35 -12
- data/spec/rspec/rails/mocks/stub_model_spec.rb +9 -9
- metadata +7 -7
data/README.markdown
CHANGED
@@ -65,8 +65,10 @@ Request specs live in spec/requests.
|
|
65
65
|
|
66
66
|
describe "widgets resource" do
|
67
67
|
describe "GET index" do
|
68
|
-
|
69
|
-
|
68
|
+
it "contains the widgets header" do
|
69
|
+
get "/widgets/index"
|
70
|
+
response.should have_selector("h1", :content => "Widgets")
|
71
|
+
end
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.beta.
|
1
|
+
2.0.0.beta.18
|
@@ -152,3 +152,34 @@ Feature: view spec
|
|
152
152
|
"""
|
153
153
|
When I run "rspec spec/views"
|
154
154
|
Then the output should contain "1 example, 0 failures"
|
155
|
+
|
156
|
+
Scenario: spec with view that accesses helper_method helpers
|
157
|
+
Given a file named "app/views/secrets/index.html.erb" with:
|
158
|
+
"""
|
159
|
+
<%- if admin? %>
|
160
|
+
<h1>Secret admin area</h1>
|
161
|
+
<%- end %>
|
162
|
+
"""
|
163
|
+
And a file named "spec/views/secrets/index.html.erb_spec.rb" with:
|
164
|
+
"""
|
165
|
+
require 'spec_helper'
|
166
|
+
|
167
|
+
describe 'secrets/index.html.erb' do
|
168
|
+
before do
|
169
|
+
controller.singleton_class.class_eval do
|
170
|
+
protected
|
171
|
+
def admin?
|
172
|
+
true
|
173
|
+
end
|
174
|
+
helper_method :admin?
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'checks for admin access' do
|
179
|
+
render
|
180
|
+
rendered.should contain('Secret admin area')
|
181
|
+
end
|
182
|
+
end
|
183
|
+
"""
|
184
|
+
When I run "rspec spec/views/secrets"
|
185
|
+
Then the output should contain "1 example, 0 failures"
|
@@ -29,9 +29,9 @@ Autotest.add_hook :initialize do |at|
|
|
29
29
|
%w{config/ coverage/ db/ doc/ log/ public/ script/ tmp/ vendor/rails vendor/plugins vendor/gems}.each do |exception|
|
30
30
|
at.add_exception("^#{exception}")
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
at.clear_mappings
|
34
|
-
|
34
|
+
|
35
35
|
at.add_mapping(%r%^(test|spec)/fixtures/(.*).yml$%) { |_, m|
|
36
36
|
["spec/models/#{m[2].singularize}_spec.rb"] + at.files_matching(%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%)
|
37
37
|
}
|
@@ -22,15 +22,15 @@ describe <%= controller_class_name %>Controller do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "recognizes and generates #create" do
|
25
|
-
{ :post => "/<%= table_name %>" }.should route_to(:controller => "<%= table_name %>", :action => "create")
|
25
|
+
{ :post => "/<%= table_name %>" }.should route_to(:controller => "<%= table_name %>", :action => "create")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "recognizes and generates #update" do
|
29
|
-
{ :put => "/<%= table_name %>/1" }.should route_to(:controller => "<%= table_name %>", :action => "update", :id => "1")
|
29
|
+
{ :put => "/<%= table_name %>/1" }.should route_to(:controller => "<%= table_name %>", :action => "update", :id => "1")
|
30
30
|
end
|
31
31
|
|
32
32
|
it "recognizes and generates #destroy" do
|
33
|
-
{ :delete => "/<%= table_name %>/1" }.should route_to(:controller => "<%= table_name %>", :action => "destroy", :id => "1")
|
33
|
+
{ :delete => "/<%= table_name %>/1" }.should route_to(:controller => "<%= table_name %>", :action => "destroy", :id => "1")
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
@@ -4,7 +4,7 @@ module RSpec::Rails
|
|
4
4
|
# == Examples
|
5
5
|
#
|
6
6
|
# == with stubs
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# describe WidgetsController do
|
9
9
|
# describe "GET index" do
|
10
10
|
# it "assigns all widgets to @widgets" do
|
@@ -69,7 +69,7 @@ module RSpec::Rails
|
|
69
69
|
# describe WidgetsController do
|
70
70
|
# render_views
|
71
71
|
# ...
|
72
|
-
#
|
72
|
+
#
|
73
73
|
module ControllerExampleGroup
|
74
74
|
extend ActiveSupport::Concern
|
75
75
|
extend RSpec::Rails::ModuleInclusion
|
@@ -28,9 +28,24 @@ module RSpec::Rails
|
|
28
28
|
include Webrat::Matchers
|
29
29
|
include RSpec::Rails::Matchers::RenderTemplate
|
30
30
|
|
31
|
+
module ClassMethods
|
32
|
+
def _default_helper
|
33
|
+
base = metadata[:behaviour][:description].split('/').first
|
34
|
+
(base.camelize + 'Helper').constantize if base
|
35
|
+
rescue NameError
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def _default_helpers
|
40
|
+
helpers = [_default_helper].compact
|
41
|
+
helpers << ApplicationHelper if Object.const_defined?('ApplicationHelper')
|
42
|
+
helpers
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
31
46
|
module InstanceMethods
|
32
47
|
# :call-seq:
|
33
|
-
# render
|
48
|
+
# render
|
34
49
|
# render(:template => "widgets/new.html.erb")
|
35
50
|
# render({:partial => "widgets/widget.html.erb"}, {... locals ...})
|
36
51
|
# render({:partial => "widgets/widget.html.erb"}, {... locals ...}) do ... end
|
@@ -73,13 +88,20 @@ module RSpec::Rails
|
|
73
88
|
_view
|
74
89
|
end
|
75
90
|
|
91
|
+
# Provides access to the params hash that will be available within the
|
92
|
+
# view:
|
93
|
+
#
|
94
|
+
# params[:foo] = 'bar'
|
95
|
+
def params
|
96
|
+
controller.params
|
97
|
+
end
|
98
|
+
|
76
99
|
# Deprecated. Use +view+ instead.
|
77
100
|
def template
|
78
101
|
RSpec.deprecate("template","view")
|
79
102
|
view
|
80
103
|
end
|
81
104
|
|
82
|
-
|
83
105
|
# Deprecated. Use +rendered+ instead.
|
84
106
|
def response
|
85
107
|
RSpec.deprecate("response", "rendered")
|
@@ -95,12 +117,21 @@ module RSpec::Rails
|
|
95
117
|
def _controller_path
|
96
118
|
_default_file_to_render.split("/")[0..-2].join("/")
|
97
119
|
end
|
120
|
+
|
121
|
+
def _include_controller_helpers
|
122
|
+
helpers = controller._helpers
|
123
|
+
view.singleton_class.class_eval do
|
124
|
+
include helpers unless included_modules.include?(helpers)
|
125
|
+
end
|
126
|
+
end
|
98
127
|
end
|
99
128
|
|
100
129
|
included do
|
101
130
|
metadata[:type] = :view
|
131
|
+
helper *_default_helpers
|
102
132
|
|
103
133
|
before do
|
134
|
+
_include_controller_helpers
|
104
135
|
controller.controller_path = _controller_path
|
105
136
|
# this won't be necessary if/when
|
106
137
|
# https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4903
|
@@ -9,13 +9,13 @@ module RSpec
|
|
9
9
|
included do
|
10
10
|
if RSpec.configuration.use_transactional_fixtures
|
11
11
|
# TODO - figure out how to move this outside the included block
|
12
|
-
include ActiveRecord::TestFixtures
|
12
|
+
include ActiveRecord::TestFixtures
|
13
13
|
|
14
|
-
self.fixture_path = RSpec.configuration.fixture_path
|
14
|
+
self.fixture_path = RSpec.configuration.fixture_path
|
15
15
|
self.use_transactional_fixtures = RSpec.configuration.use_transactional_fixtures
|
16
16
|
self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures
|
17
17
|
fixtures RSpec.configuration.global_fixtures if RSpec.configuration.global_fixtures
|
18
|
-
end
|
18
|
+
end
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -10,7 +10,7 @@ module RSpec #:nodoc:
|
|
10
10
|
return failure_message_for_should_without_errors_on_extensions
|
11
11
|
end
|
12
12
|
alias_method_chain :failure_message_for_should, :errors_on_extensions
|
13
|
-
|
13
|
+
|
14
14
|
def description_with_errors_on_extensions
|
15
15
|
return "have #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}" if @collection_name == :errors_on
|
16
16
|
return "have #{relativities[@relativity]}#{@expected} error on :#{@args[0]}" if @collection_name == :error_on
|
data/lib/rspec/rails/mocks.rb
CHANGED
@@ -27,11 +27,40 @@ module RSpec
|
|
27
27
|
self.stub(:id) { nil }
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
|
-
# Creates a mock object instance for a +
|
32
|
-
# methods stubbed out. Additional methods may be easily stubbed
|
33
|
-
# add_stubs) if +stubs+ is passed.
|
34
|
-
|
30
|
+
|
31
|
+
# Creates a mock object instance for a +string_or_model_class+ with
|
32
|
+
# common methods stubbed out. Additional methods may be easily stubbed
|
33
|
+
# (via add_stubs) if +stubs+ is passed.
|
34
|
+
#
|
35
|
+
# +model_class+ can be any of:
|
36
|
+
#
|
37
|
+
# * A String representing a Class that does not exist
|
38
|
+
# * A String representing a Class that extends ActiveModel::Naming
|
39
|
+
# * A Class that extends ActiveModel::Naming
|
40
|
+
def mock_model(string_or_model_class, options_and_stubs = {})
|
41
|
+
if String === string_or_model_class
|
42
|
+
if Object.const_defined?(string_or_model_class)
|
43
|
+
model_class = Object.const_get(string_or_model_class)
|
44
|
+
else
|
45
|
+
model_class = Object.const_set(string_or_model_class, Class.new do
|
46
|
+
extend ActiveModel::Naming
|
47
|
+
end)
|
48
|
+
end
|
49
|
+
else
|
50
|
+
model_class = string_or_model_class
|
51
|
+
end
|
52
|
+
|
53
|
+
unless model_class.kind_of? ActiveModel::Naming
|
54
|
+
raise ArgumentError.new <<-EOM
|
55
|
+
The mock_model method can only accept as its first argument:
|
56
|
+
* A String representing a Class that does not exist
|
57
|
+
* A String representing a Class that extends ActiveModel::Naming
|
58
|
+
* A Class that extends ActiveModel::Naming
|
59
|
+
|
60
|
+
It received #{model_class.inspect}
|
61
|
+
EOM
|
62
|
+
end
|
63
|
+
|
35
64
|
id = options_and_stubs.has_key?(:id) ? options_and_stubs[:id] : next_id
|
36
65
|
options_and_stubs = options_and_stubs.reverse_merge({
|
37
66
|
:id => id,
|
@@ -65,10 +94,6 @@ module RSpec
|
|
65
94
|
def @object.to_s
|
66
95
|
"#{model_class.name}_#{id}"
|
67
96
|
end
|
68
|
-
|
69
|
-
def @object.model_name
|
70
|
-
"#{model_class}"
|
71
|
-
end
|
72
97
|
CODE
|
73
98
|
yield m if block_given?
|
74
99
|
m
|
@@ -152,3 +177,4 @@ end
|
|
152
177
|
RSpec.configure do |c|
|
153
178
|
c.include RSpec::Rails::Mocks
|
154
179
|
end
|
180
|
+
|
data/rspec-rails.gemspec
CHANGED
@@ -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.
|
8
|
+
s.version = "2.0.0.beta.18"
|
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-
|
12
|
+
s.date = %q{2010-07-21}
|
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 = [
|
@@ -122,7 +122,7 @@ Gem::Specification.new do |s|
|
|
122
122
|
s.homepage = %q{http://github.com/rspec/rspec-rails}
|
123
123
|
s.post_install_message = %q{**************************************************
|
124
124
|
|
125
|
-
Thank you for installing rspec-rails-2.0.0.beta.
|
125
|
+
Thank you for installing rspec-rails-2.0.0.beta.18!
|
126
126
|
|
127
127
|
This version of rspec-rails only works with versions of rails >= 3.0.0.beta.4.
|
128
128
|
|
@@ -132,7 +132,7 @@ Gem::Specification.new do |s|
|
|
132
132
|
can access its generators and rake tasks.
|
133
133
|
|
134
134
|
group :development, :test do
|
135
|
-
gem "rspec-rails", ">= 2.0.0.beta.
|
135
|
+
gem "rspec-rails", ">= 2.0.0.beta.18"
|
136
136
|
end
|
137
137
|
|
138
138
|
Be sure to run the following command in each of your Rails apps if you're
|
@@ -158,7 +158,7 @@ Gem::Specification.new do |s|
|
|
158
158
|
s.require_paths = ["lib"]
|
159
159
|
s.rubyforge_project = %q{rspec}
|
160
160
|
s.rubygems_version = %q{1.3.7}
|
161
|
-
s.summary = %q{rspec-rails-2.0.0.beta.
|
161
|
+
s.summary = %q{rspec-rails-2.0.0.beta.18}
|
162
162
|
s.test_files = [
|
163
163
|
"spec/rspec/rails/example/controller_example_group_spec.rb",
|
164
164
|
"spec/rspec/rails/example/helper_example_group_spec.rb",
|
@@ -12,6 +12,73 @@ module RSpec::Rails
|
|
12
12
|
group.metadata[:type].should eq(:view)
|
13
13
|
end
|
14
14
|
|
15
|
+
describe 'automatic inclusion of helpers' do
|
16
|
+
module ::ThingsHelper; end
|
17
|
+
|
18
|
+
it 'includes the helper with the same name' do
|
19
|
+
group = RSpec::Core::ExampleGroup.describe 'things/show.html.erb'
|
20
|
+
group.should_receive(:helper).with(ThingsHelper)
|
21
|
+
group.class_eval do
|
22
|
+
include ViewExampleGroup
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'operates normally when no helper with the same name exists' do
|
27
|
+
raise 'unexpected constant found' if Object.const_defined?('ClocksHelper')
|
28
|
+
lambda {
|
29
|
+
RSpec::Core::ExampleGroup.describe 'clocks/show.html.erb' do
|
30
|
+
include ViewExampleGroup
|
31
|
+
end
|
32
|
+
}.should_not raise_error
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'application helper exists' do
|
36
|
+
before do
|
37
|
+
if !Object.const_defined? 'ApplicationHelper'
|
38
|
+
module ::ApplicationHelper; end
|
39
|
+
@application_helper_defined = true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
after do
|
44
|
+
if @application_helper_defined
|
45
|
+
Object.__send__ :remove_const, 'ApplicationHelper'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'includes the application helper' do
|
50
|
+
group = RSpec::Core::Example.describe 'bars/new.html.erb'
|
51
|
+
group.should_receive(:helper).with(ApplicationHelper)
|
52
|
+
group.class_eval do
|
53
|
+
include ViewExampleGroup
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'no application helper exists' do
|
59
|
+
before do
|
60
|
+
if Object.const_defined? 'ApplicationHelper'
|
61
|
+
@application_helper = ApplicationHelper
|
62
|
+
Object.__send__ :remove_const, 'ApplicationHelper'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
after do
|
67
|
+
if @application_helper
|
68
|
+
ApplicationHelper = @application_helper
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'operates normally' do
|
73
|
+
lambda {
|
74
|
+
RSpec::Core::ExampleGroup.describe 'foos/edit.html.erb' do
|
75
|
+
include ViewExampleGroup
|
76
|
+
end
|
77
|
+
}.should_not raise_error
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
15
82
|
describe "#render" do
|
16
83
|
let(:view_spec) do
|
17
84
|
Class.new do
|
@@ -54,6 +121,22 @@ module RSpec::Rails
|
|
54
121
|
end
|
55
122
|
end
|
56
123
|
|
124
|
+
describe '#params' do
|
125
|
+
let(:view_spec) do
|
126
|
+
Class.new do
|
127
|
+
include ViewExampleGroup::InstanceMethods
|
128
|
+
def controller
|
129
|
+
@controller ||= Object.new
|
130
|
+
end
|
131
|
+
end.new
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'delegates to the controller' do
|
135
|
+
view_spec.controller.should_receive(:params).and_return({})
|
136
|
+
view_spec.params[:foo] = 1
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
57
140
|
describe "#_controller_path" do
|
58
141
|
let(:view_spec) do
|
59
142
|
Class.new do
|
@@ -4,7 +4,7 @@ describe "error_on" do
|
|
4
4
|
it "should provide a description including the name of what the error is on" do
|
5
5
|
have(1).error_on(:whatever).description.should == "have 1 error on :whatever"
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should provide a failure message including the number actually given" do
|
9
9
|
lambda {
|
10
10
|
[].should have(1).error_on(:whatever)
|
@@ -16,7 +16,7 @@ describe "errors_on" do
|
|
16
16
|
it "should provide a description including the name of what the error is on" do
|
17
17
|
have(2).errors_on(:whatever).description.should == "have 2 errors on :whatever"
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should provide a failure message including the number actually given" do
|
21
21
|
lambda {
|
22
22
|
[1].should have(3).errors_on(:whatever)
|
@@ -2,6 +2,41 @@ require 'spec_helper'
|
|
2
2
|
require File.dirname(__FILE__) + '/ar_classes'
|
3
3
|
|
4
4
|
describe "mock_model(RealModel)" do
|
5
|
+
|
6
|
+
context "given a String" do
|
7
|
+
context "that does not represent an existing constant" do
|
8
|
+
it "class says it's name" do
|
9
|
+
model = mock_model("Foo")
|
10
|
+
model.class.name.should eq("Foo")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "that represents an existing constant" do
|
15
|
+
context "that extends ActiveModel::Naming" do
|
16
|
+
it "treats the constant as the class" do
|
17
|
+
model = mock_model("MockableModel")
|
18
|
+
model.class.name.should eq("MockableModel")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "that does not extend ActiveModel::Naming" do
|
23
|
+
it "raises with a helpful message" do
|
24
|
+
expect do
|
25
|
+
mock_model("String")
|
26
|
+
end.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "given a class that does not extend ActiveModel::Naming" do
|
33
|
+
it "raises with a helpful message" do
|
34
|
+
expect do
|
35
|
+
mock_model(String)
|
36
|
+
end.to raise_error(ArgumentError)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
5
40
|
describe "with #id stubbed" do
|
6
41
|
before(:each) do
|
7
42
|
@model = mock_model(MockableModel, :id => 1)
|
@@ -105,17 +140,6 @@ describe "mock_model(RealModel)" do
|
|
105
140
|
end
|
106
141
|
end
|
107
142
|
|
108
|
-
describe "#model_name" do
|
109
|
-
before(:each) do
|
110
|
-
@model = mock_model(SubMockableModel)
|
111
|
-
end
|
112
|
-
|
113
|
-
it "says its model_name" do
|
114
|
-
@model.model_name.should == "SubMockableModel"
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
143
|
describe "#destroyed?" do
|
120
144
|
context "default" do
|
121
145
|
it "returns false" do
|
@@ -199,6 +223,5 @@ describe "mock_model(RealModel)" do
|
|
199
223
|
def model
|
200
224
|
mock_model(MockableModel, :id => nil)
|
201
225
|
end
|
202
|
-
|
203
226
|
end
|
204
227
|
end
|
@@ -6,28 +6,28 @@ describe "stub_model" do
|
|
6
6
|
it "should have an id" do
|
7
7
|
stub_model(MockableModel).id.should be > 0
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should say it is not a new record" do
|
11
11
|
stub_model(MockableModel).should_not be_new_record
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should accept a stub id" do
|
16
16
|
stub_model(MockableModel, :id => 37).id.should == 37
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "should say it is a new record when id is set to nil" do
|
20
20
|
stub_model(MockableModel, :id => nil).should be_new_record
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should accept any arbitrary stub" do
|
24
24
|
stub_model(MockableModel, :foo => "bar").foo.should == "bar"
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
it "should accept a stub for save" do
|
28
28
|
stub_model(MockableModel, :save => false).save.should be(false)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
describe "#as_new_record" do
|
32
32
|
it "should say it is a new record" do
|
33
33
|
stub_model(MockableModel).as_new_record.should be_new_record
|
@@ -37,20 +37,20 @@ describe "stub_model" do
|
|
37
37
|
stub_model(MockableModel).as_new_record.id.should be(nil)
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
pending "should raise when hitting the db" do
|
42
42
|
lambda do
|
43
43
|
model = stub_model(MockableModel, :changed => true, :attributes_with_quotes => {'this' => 'that'})
|
44
44
|
model.save
|
45
45
|
end.should raise_error(RSpec::Rails::IllegalDataAccessException, /stubbed models are not allowed to access the database/)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
it "should increment the id" do
|
49
49
|
first = stub_model(MockableModel)
|
50
50
|
second = stub_model(MockableModel)
|
51
51
|
second.id.should == (first.id + 1)
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
describe "as association" do
|
55
55
|
before(:each) do
|
56
56
|
@real = AssociatedModel.create!
|
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:
|
4
|
+
hash: 62196423
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 2.0.0.beta.
|
11
|
+
- 18
|
12
|
+
version: 2.0.0.beta.18
|
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-
|
21
|
+
date: 2010-07-21 00:00:00 -05:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -173,7 +173,7 @@ licenses: []
|
|
173
173
|
post_install_message: |
|
174
174
|
**************************************************
|
175
175
|
|
176
|
-
Thank you for installing rspec-rails-2.0.0.beta.
|
176
|
+
Thank you for installing rspec-rails-2.0.0.beta.18!
|
177
177
|
|
178
178
|
This version of rspec-rails only works with versions of rails >= 3.0.0.beta.4.
|
179
179
|
|
@@ -183,7 +183,7 @@ post_install_message: |
|
|
183
183
|
can access its generators and rake tasks.
|
184
184
|
|
185
185
|
group :development, :test do
|
186
|
-
gem "rspec-rails", ">= 2.0.0.beta.
|
186
|
+
gem "rspec-rails", ">= 2.0.0.beta.18"
|
187
187
|
end
|
188
188
|
|
189
189
|
Be sure to run the following command in each of your Rails apps if you're
|
@@ -235,7 +235,7 @@ rubyforge_project: rspec
|
|
235
235
|
rubygems_version: 1.3.7
|
236
236
|
signing_key:
|
237
237
|
specification_version: 3
|
238
|
-
summary: rspec-rails-2.0.0.beta.
|
238
|
+
summary: rspec-rails-2.0.0.beta.18
|
239
239
|
test_files:
|
240
240
|
- spec/rspec/rails/example/controller_example_group_spec.rb
|
241
241
|
- spec/rspec/rails/example/helper_example_group_spec.rb
|