Skip to content

Commit

Permalink
Merge branch 'thomas-holmes-remove-mocks'
Browse files Browse the repository at this point in the history
  • Loading branch information
alindeman committed Mar 3, 2014
2 parents bf8b1e9 + 8e9081a commit a8eee18
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 1,050 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
@@ -1,6 +1,11 @@
### 3.0.0.rc1 Development
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.0.0.beta2...master)

Breaking Changes for 3.0.0:

* Extracts the `mock_model` and `stub_model` methods to the
`rspec-activemodel-mocks` gem. (Thomas Holmes)

### 3.0.0.beta2 / 2014-02-17
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.0.0.beta1...v3.0.0.beta2)

Expand Down
2 changes: 1 addition & 1 deletion features/matchers/render_template_matcher.feature
Expand Up @@ -36,7 +36,7 @@ Feature: render_template matcher
describe "gadgets/index" do
it "renders the index template" do
assign(:gadgets, [stub_model(Gadget)])
assign(:gadgets, [Gadget.create!])
render
expect(view).to render_template(:index)
Expand Down
147 changes: 0 additions & 147 deletions features/mocks/mock_model.feature

This file was deleted.

58 changes: 0 additions & 58 deletions features/mocks/stub_model.feature

This file was deleted.

6 changes: 3 additions & 3 deletions features/view_specs/stub_template.feature
Expand Up @@ -11,8 +11,8 @@ Feature: stub template
describe "gadgets/list" do
it "renders the gadget partial for each gadget" do
assign(:gadgets, [
mock_model(Gadget, :id => 1, :name => "First"),
mock_model(Gadget, :id => 2, :name => "Second")
double(:name => "First"),
double(:name => "Second")
])
stub_template "gadgets/_gadget.html.erb" => "<%= gadget.name %><br/>"
render
Expand All @@ -36,7 +36,7 @@ Feature: stub template
describe "gadgets/edit" do
before(:each) do
@gadget = assign(:gadget, stub_model(Gadget))
@gadget = assign(:gadget, Gadget.create!)
end
it "renders the form partial" do
Expand Down
14 changes: 7 additions & 7 deletions features/view_specs/view_spec.feature
Expand Up @@ -10,8 +10,8 @@ Feature: view spec
describe "widgets/index" do
it "displays all the widgets" do
assign(:widgets, [
stub_model(Widget, :name => "slicer"),
stub_model(Widget, :name => "dicer")
Widget.create!(:name => "slicer"),
Widget.create!(:name => "dicer")
])
render
Expand All @@ -34,8 +34,8 @@ Feature: view spec
context "with 2 widgets" do
before(:each) do
assign(:widgets, [
stub_model(Widget, :name => "slicer"),
stub_model(Widget, :name => "dicer")
Widget.create!(:name => "slicer"),
Widget.create!(:name => "dicer")
])
end
Expand All @@ -58,7 +58,7 @@ Feature: view spec
describe "rendering the widget template" do
it "displays the widget" do
assign(:widget, stub_model(Widget, :name => "slicer"))
assign(:widget, Widget.create!(:name => "slicer"))
render :template => "widgets/widget.html.erb"
Expand Down Expand Up @@ -112,7 +112,7 @@ Feature: view spec
describe "rendering locals in a partial" do
it "displays the widget" do
widget = stub_model(Widget, :name => "slicer")
widget = Widget.create!(:name => "slicer")
render :partial => "widgets/widget.html.erb", :locals => {:widget => widget}
Expand All @@ -134,7 +134,7 @@ Feature: view spec
describe "rendering locals in a partial" do
it "displays the widget" do
widget = stub_model(Widget, :name => "slicer")
widget = Widget.create!(:name => "slicer")
render "widgets/widget", :widget => widget
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/rspec/scaffold/templates/edit_spec.rb
Expand Up @@ -3,7 +3,7 @@
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "<%= ns_table_name %>/edit" do
before(:each) do
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
:<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<% end -%>
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/rspec/scaffold/templates/index_spec.rb
Expand Up @@ -5,7 +5,7 @@
before(:each) do
assign(:<%= table_name %>, [
<% [1,2].each_with_index do |id, model_index| -%>
stub_model(<%= class_name %><%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : ',' %>
<%= class_name %>.create!(<%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : '' %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
:<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<% end -%>
Expand Down
4 changes: 2 additions & 2 deletions lib/generators/rspec/scaffold/templates/new_spec.rb
Expand Up @@ -3,11 +3,11 @@
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "<%= ns_table_name %>/new" do
before(:each) do
assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? ').as_new_record)' : ',' %>
assign(:<%= ns_file_name %>, <%= class_name %>.new(<%= '))' if output_attributes.empty? %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
:<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<% end -%>
<%= !output_attributes.empty? ? " ).as_new_record)\n end" : " end" %>
<%= !output_attributes.empty? ? " ))\n end" : " end" %>
it "renders new <%= ns_file_name %> form" do
render
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/rspec/scaffold/templates/show_spec.rb
Expand Up @@ -3,7 +3,7 @@
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "<%= ns_table_name %>/show" do
before(:each) do
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, stub_model(<%= class_name %><%= output_attributes.empty? ? '))' : ',' %>
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
:<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<% end -%>
Expand Down
1 change: 0 additions & 1 deletion lib/rspec/rails.rb
Expand Up @@ -12,6 +12,5 @@
require 'rspec/rails/adapters'
require 'rspec/rails/matchers'
require 'rspec/rails/fixture_support'
require 'rspec/rails/mocks'
require 'rspec/rails/example'
require 'rspec/rails/vendor/capybara'

0 comments on commit a8eee18

Please sign in to comment.