rspec_candy 0.1.0
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.
- data/.gitignore +8 -0
- data/README.md +7 -0
- data/Rakefile +18 -0
- data/lib/rspec_candy/helpers/disposable_copy.rb +16 -0
- data/lib/rspec_candy/helpers/it_should_act_like.rb +39 -0
- data/lib/rspec_candy/helpers/new_with_stubs.rb +16 -0
- data/lib/rspec_candy/helpers/rails/create_without_callbacks.rb +25 -0
- data/lib/rspec_candy/helpers/rails/it_should_run_callbacks.rb +111 -0
- data/lib/rspec_candy/helpers/rails/prevent_storage.rb +20 -0
- data/lib/rspec_candy/helpers/should_receive_and_execute.rb +38 -0
- data/lib/rspec_candy/helpers/should_receive_and_return.rb +17 -0
- data/lib/rspec_candy/helpers/should_receive_chain.rb +43 -0
- data/lib/rspec_candy/helpers/stub_any_instance.rb +25 -0
- data/lib/rspec_candy/helpers/stub_existing.rb +20 -0
- data/lib/rspec_candy/switcher.rb +44 -0
- data/lib/rspec_candy/version.rb +3 -0
- data/lib/rspec_candy.rb +16 -0
- data/rspec_candy.gemspec +19 -0
- data/spec/rspec1/Gemfile +13 -0
- data/spec/rspec1/Rakefile +11 -0
- data/spec/rspec1/app_root/config/boot.rb +114 -0
- data/spec/rspec1/app_root/config/database.yml +21 -0
- data/spec/rspec1/app_root/config/environment.rb +14 -0
- data/spec/rspec1/app_root/config/environments/in_memory.rb +0 -0
- data/spec/rspec1/app_root/config/environments/mysql.rb +0 -0
- data/spec/rspec1/app_root/config/environments/postgresql.rb +0 -0
- data/spec/rspec1/app_root/config/environments/sqlite.rb +0 -0
- data/spec/rspec1/app_root/config/environments/sqlite3.rb +0 -0
- data/spec/rspec1/app_root/config/initializers/state_machine.rb +1 -0
- data/spec/rspec1/app_root/config/routes.rb +4 -0
- data/spec/rspec1/app_root/log/.gitignore +1 -0
- data/spec/rspec1/rcov.opts +2 -0
- data/spec/rspec1/spec.opts +4 -0
- data/spec/rspec1/spec_helper.rb +24 -0
- data/spec/rspec2/.rspec +2 -0
- data/spec/rspec2/Gemfile +13 -0
- data/spec/rspec2/Rakefile +11 -0
- data/spec/rspec2/app_root/.gitignore +4 -0
- data/spec/rspec2/app_root/config/application.rb +32 -0
- data/spec/rspec2/app_root/config/boot.rb +13 -0
- data/spec/rspec2/app_root/config/database.yml +21 -0
- data/spec/rspec2/app_root/config/environment.rb +5 -0
- data/spec/rspec2/app_root/config/environments/in_memory.rb +0 -0
- data/spec/rspec2/app_root/config/environments/mysql.rb +0 -0
- data/spec/rspec2/app_root/config/environments/postgresql.rb +0 -0
- data/spec/rspec2/app_root/config/environments/sqlite.rb +0 -0
- data/spec/rspec2/app_root/config/environments/sqlite3.rb +0 -0
- data/spec/rspec2/app_root/config/environments/test.rb +35 -0
- data/spec/rspec2/app_root/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rspec2/app_root/config/initializers/inflections.rb +10 -0
- data/spec/rspec2/app_root/config/initializers/mime_types.rb +5 -0
- data/spec/rspec2/app_root/config/initializers/secret_token.rb +7 -0
- data/spec/rspec2/app_root/config/initializers/session_store.rb +8 -0
- data/spec/rspec2/app_root/config/initializers/state_machine.rb +1 -0
- data/spec/rspec2/app_root/config/locales/en.yml +5 -0
- data/spec/rspec2/app_root/config/routes.rb +58 -0
- data/spec/rspec2/app_root/log/.gitkeep +0 -0
- data/spec/rspec2/rcov.opts +2 -0
- data/spec/rspec2/spec_helper.rb +25 -0
- data/spec/shared/app_root/app/controllers/application_controller.rb +2 -0
- data/spec/shared/app_root/app/models/model.rb +19 -0
- data/spec/shared/app_root/app/models/state_machine_model.rb +30 -0
- data/spec/shared/app_root/config/initializers/state_machine.rb +1 -0
- data/spec/shared/app_root/db/migrate/001_create_model.rb +13 -0
- data/spec/shared/app_root/db/migrate/002_create_state_machine_model.rb +13 -0
- data/spec/shared/rspec_candy/helpers/disposable_copy_spec.rb +45 -0
- data/spec/shared/rspec_candy/helpers/it_should_act_like_spec.rb +139 -0
- data/spec/shared/rspec_candy/helpers/new_with_stubs_spec.rb +41 -0
- data/spec/shared/rspec_candy/helpers/rails/create_without_callbacks_spec.rb +41 -0
- data/spec/shared/rspec_candy/helpers/rails/it_should_run_callbacks_spec.rb +142 -0
- data/spec/shared/rspec_candy/helpers/rails/prevent_storage_spec.rb +85 -0
- data/spec/shared/rspec_candy/helpers/should_receive_and_execute_spec.rb +32 -0
- data/spec/shared/rspec_candy/helpers/should_receive_and_return_spec.rb +30 -0
- data/spec/shared/rspec_candy/helpers/should_receive_chain_spec.rb +99 -0
- data/spec/shared/rspec_candy/helpers/stub_any_instance_spec.rb +32 -0
- data/spec/shared/rspec_candy/helpers/stub_existing_spec.rb +27 -0
- data/spec/shared/support/matchers/pass_as_describe_block.rb +32 -0
- data/spec/shared/support/matchers/pass_as_example.rb +30 -0
- data/template/spec_candy.rails2.rb +171 -0
- data/template/spec_candy.rails3.rb +175 -0
- metadata +159 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
|
5
|
+
|
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Add new inflection rules using the following format
|
|
4
|
+
# (all these examples are active by default):
|
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
|
8
|
+
# inflect.irregular 'person', 'people'
|
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
|
10
|
+
# end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
|
7
|
+
HasDefaultSpecApp::Application.config.secret_token = 'cb014a08a45243e7143f31e04774c342c1fba329fd594ae1a480d8283b1a851f425dc08044311fb4be6d000b6e6681de7c76d19148419a5ffa0a9f84556d3b33'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
HasDefaultSpecApp::Application.config.session_store :cookie_store, :key => '_app_root_session'
|
|
4
|
+
|
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
|
6
|
+
# which shouldn't be used to store highly confidential information
|
|
7
|
+
# (create the session table with "rails generate session_migration")
|
|
8
|
+
# HasDefaultSpecApp::Application.config.session_store :active_record_store
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Bundler.require(:state_machine) if ENV['REQUIRE_STATE_MACHINE'] == 'true'
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
HasDefaultSpecApp::Application.routes.draw do
|
|
2
|
+
# The priority is based upon order of creation:
|
|
3
|
+
# first created -> highest priority.
|
|
4
|
+
|
|
5
|
+
# Sample of regular route:
|
|
6
|
+
# match 'products/:id' => 'catalog#view'
|
|
7
|
+
# Keep in mind you can assign values other than :controller and :action
|
|
8
|
+
|
|
9
|
+
# Sample of named route:
|
|
10
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
|
11
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
|
12
|
+
|
|
13
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
|
14
|
+
# resources :products
|
|
15
|
+
|
|
16
|
+
# Sample resource route with options:
|
|
17
|
+
# resources :products do
|
|
18
|
+
# member do
|
|
19
|
+
# get 'short'
|
|
20
|
+
# post 'toggle'
|
|
21
|
+
# end
|
|
22
|
+
#
|
|
23
|
+
# collection do
|
|
24
|
+
# get 'sold'
|
|
25
|
+
# end
|
|
26
|
+
# end
|
|
27
|
+
|
|
28
|
+
# Sample resource route with sub-resources:
|
|
29
|
+
# resources :products do
|
|
30
|
+
# resources :comments, :sales
|
|
31
|
+
# resource :seller
|
|
32
|
+
# end
|
|
33
|
+
|
|
34
|
+
# Sample resource route with more complex sub-resources
|
|
35
|
+
# resources :products do
|
|
36
|
+
# resources :comments
|
|
37
|
+
# resources :sales do
|
|
38
|
+
# get 'recent', :on => :collection
|
|
39
|
+
# end
|
|
40
|
+
# end
|
|
41
|
+
|
|
42
|
+
# Sample resource route within a namespace:
|
|
43
|
+
# namespace :admin do
|
|
44
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
|
45
|
+
# # (app/controllers/admin/products_controller.rb)
|
|
46
|
+
# resources :products
|
|
47
|
+
# end
|
|
48
|
+
|
|
49
|
+
# You can have the root of your site routed with "root"
|
|
50
|
+
# just remember to delete public/index.html.
|
|
51
|
+
# root :to => "welcome#index"
|
|
52
|
+
|
|
53
|
+
# See how all your routes lay out with "rake routes"
|
|
54
|
+
|
|
55
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
|
56
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
|
57
|
+
match ':controller(/:action(/:id(.:format)))'
|
|
58
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
$: << File.join(File.dirname(__FILE__), "/../lib" )
|
|
2
|
+
|
|
3
|
+
# Set the default environment to sqlite3's in_memory database
|
|
4
|
+
ENV['RAILS_ENV'] ||= 'in_memory'
|
|
5
|
+
ENV['RAILS_ROOT'] = 'app_root'
|
|
6
|
+
|
|
7
|
+
# Load the Rails environment and testing framework
|
|
8
|
+
require "#{File.dirname(__FILE__)}/app_root/config/environment"
|
|
9
|
+
require 'rspec/rails'
|
|
10
|
+
|
|
11
|
+
# Load dependencies
|
|
12
|
+
require 'rspec_candy'
|
|
13
|
+
|
|
14
|
+
# Require support code
|
|
15
|
+
Dir["../shared/support/**/*.rb"].each {|f| require f}
|
|
16
|
+
|
|
17
|
+
# Run the migrations
|
|
18
|
+
print "\033[30m" # dark gray text
|
|
19
|
+
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
|
|
20
|
+
print "\033[0m"
|
|
21
|
+
|
|
22
|
+
RSpec.configure do |config|
|
|
23
|
+
config.use_transactional_fixtures = true
|
|
24
|
+
config.use_instantiated_fixtures = false
|
|
25
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Model < ActiveRecord::Base
|
|
2
|
+
|
|
3
|
+
after_create :after_create_callback
|
|
4
|
+
after_save :after_save_callback1, :after_save_callback2
|
|
5
|
+
before_save :before_save_callback1, :before_save_callback2
|
|
6
|
+
|
|
7
|
+
if respond_to? :around_save
|
|
8
|
+
around_save :around_save_callback1, :around_save_callback2
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def after_create_callback; end
|
|
12
|
+
def after_save_callback1; end
|
|
13
|
+
def after_save_callback2; end
|
|
14
|
+
def before_save_callback1; end
|
|
15
|
+
def before_save_callback2; end
|
|
16
|
+
def around_save_callback1; yield; end
|
|
17
|
+
def around_save_callback2; yield; end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class StateMachineModel < ActiveRecord::Base
|
|
2
|
+
|
|
3
|
+
if respond_to?(:state_machine)
|
|
4
|
+
|
|
5
|
+
state_machine :initial => :state1 do
|
|
6
|
+
|
|
7
|
+
state :state1
|
|
8
|
+
|
|
9
|
+
state :state2
|
|
10
|
+
|
|
11
|
+
state :state3
|
|
12
|
+
|
|
13
|
+
event :event do
|
|
14
|
+
transition :state1 => :state2
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
event :another_event do
|
|
18
|
+
transition :state1 => :state3
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
after_transition :state1 => :state2, :do => :event_callback
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def event_callback
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Bundler.require(:state_machine) if ENV['REQUIRE_STATE_MACHINE'] == 'true'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe RSpecCandy::Helpers::DisposableCopy do
|
|
4
|
+
|
|
5
|
+
describe Class do
|
|
6
|
+
|
|
7
|
+
describe '.disposable_copy' do
|
|
8
|
+
|
|
9
|
+
it 'should return a class' do
|
|
10
|
+
Model.disposable_copy.should be_a(Class)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should return a class with the same name as the original class' do
|
|
14
|
+
Model.disposable_copy.name.should == 'Model'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'should return a class that instantiates objects that are also instances of the original class' do
|
|
18
|
+
instance = Model.disposable_copy.new
|
|
19
|
+
instance.should be_a(Model)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'should return a class that can be modified without changing the original class' do
|
|
23
|
+
copy = Model.disposable_copy
|
|
24
|
+
copy.class_eval do
|
|
25
|
+
def foo
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
copy.new.should respond_to(:foo)
|
|
29
|
+
Model.new.should_not respond_to(:foo)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'should take a block with is evaluated in the context of the disposable class' do
|
|
33
|
+
copy = Model.disposable_copy do
|
|
34
|
+
def foo
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
copy.new.should respond_to(:foo)
|
|
38
|
+
Model.new.should_not respond_to(:foo)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe RSpecCandy::Helpers::StubAnyInstance do
|
|
4
|
+
describe 'RSpec example group' do
|
|
5
|
+
|
|
6
|
+
describe '#it_should_act_like' do
|
|
7
|
+
|
|
8
|
+
it 'should run a shared example group and pass if all is well' do
|
|
9
|
+
<<-describe_block.should pass_as_describe_block
|
|
10
|
+
shared_examples_for "a passing spec" do
|
|
11
|
+
it 'should pass' do
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "passing" do
|
|
16
|
+
it_should_act_like "a passing spec"
|
|
17
|
+
end
|
|
18
|
+
describe_block
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should run a shared example group and pass if something is wrong' do
|
|
22
|
+
<<-describe_block.should fail_as_describe_block
|
|
23
|
+
shared_examples_for "a failing spec" do
|
|
24
|
+
it 'should fail' do
|
|
25
|
+
0.should == 1
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "failing" do
|
|
30
|
+
it_should_act_like "a failing spec"
|
|
31
|
+
end
|
|
32
|
+
describe_block
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should scope the reused examples so definitions of #let and #subject do not bleed into the calling example group' do
|
|
36
|
+
|
|
37
|
+
<<-describe_block.should pass_as_describe_block
|
|
38
|
+
shared_examples_for "a spec that lets something" do
|
|
39
|
+
let(:foo) { "foo" }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "scoping" do
|
|
43
|
+
it_should_act_like "a spec that lets something"
|
|
44
|
+
|
|
45
|
+
let(:foo) { "bar" }
|
|
46
|
+
|
|
47
|
+
it_should_act_like "a spec that lets something"
|
|
48
|
+
|
|
49
|
+
it 'should not be affected by the previous it_should_act_like' do
|
|
50
|
+
foo.should == "bar"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
describe_block
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should allow to parametrize the reused example group by calling it with a hash, whose keys will become #let variables' do
|
|
58
|
+
|
|
59
|
+
shared_examples = <<-shared_examples
|
|
60
|
+
shared_examples_for "a spec passing foo and bar" do
|
|
61
|
+
it 'should see foo=1' do
|
|
62
|
+
foo.should == 1
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'should see bar=2' do
|
|
66
|
+
bar.should == 2
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
shared_examples
|
|
70
|
+
|
|
71
|
+
<<-describe_block.should pass_as_describe_block
|
|
72
|
+
|
|
73
|
+
#{shared_examples}
|
|
74
|
+
|
|
75
|
+
describe "a spec passing the right params" do
|
|
76
|
+
it_should_act_like "a spec passing foo and bar", :foo => 1, :bar => 2
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe_block
|
|
80
|
+
|
|
81
|
+
<<-describe_block.should fail_as_describe_block
|
|
82
|
+
|
|
83
|
+
#{shared_examples}
|
|
84
|
+
|
|
85
|
+
describe "a spec passing the wrong params" do
|
|
86
|
+
it_should_act_like "a spec passing foo and bar", :foo => 1, :bar => 3
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe_block
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'should allow to parametrize the reused example group by calling it with a block, which will become a #let variable called "block"' do
|
|
93
|
+
shared_examples = <<-shared_examples
|
|
94
|
+
shared_examples_for "a spec passing a block" do
|
|
95
|
+
it 'should get a block evaling as 1' do
|
|
96
|
+
block.call.should == 1
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
shared_examples
|
|
100
|
+
|
|
101
|
+
<<-describe_block.should pass_as_describe_block
|
|
102
|
+
#{shared_examples}
|
|
103
|
+
|
|
104
|
+
describe "a spec passing the right block" do
|
|
105
|
+
it_should_act_like "a spec passing a block" do
|
|
106
|
+
1
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
describe_block
|
|
110
|
+
|
|
111
|
+
<<-describe_block.should fail_as_describe_block
|
|
112
|
+
#{shared_examples}
|
|
113
|
+
|
|
114
|
+
describe "a spec passing the right block" do
|
|
115
|
+
it_should_act_like "a spec passing a block" do
|
|
116
|
+
2
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
describe_block
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
if RSpecCandy::Switcher.rspec_version == :rspec2
|
|
123
|
+
it 'should print a deprecation warning' do
|
|
124
|
+
result = RSpecRemote.run_describe_block(<<-describe_block)
|
|
125
|
+
shared_examples "a lazy spec" do
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
describe 'spec' do
|
|
129
|
+
it_should_act_like "a lazy spec"
|
|
130
|
+
end
|
|
131
|
+
describe_block
|
|
132
|
+
result.should include('"it_should_act_like" is deprecated')
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
end
|
|
139
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe RSpecCandy::Helpers::NewWithStubs do
|
|
4
|
+
|
|
5
|
+
describe Class do
|
|
6
|
+
|
|
7
|
+
describe '#new_with_stubs'
|
|
8
|
+
|
|
9
|
+
it 'should instantiate a class with an empty constructor and stub out the given methods' do
|
|
10
|
+
klass = Class.new do
|
|
11
|
+
def initialize
|
|
12
|
+
end
|
|
13
|
+
def foo
|
|
14
|
+
'stubbed foo'
|
|
15
|
+
end
|
|
16
|
+
def bar
|
|
17
|
+
'unstubbed bar'
|
|
18
|
+
end
|
|
19
|
+
def unstubbed_method
|
|
20
|
+
'unstubbed result'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
instance = klass.new_with_stubs(:foo => 'stubbed foo', :bar => 'stubbed bar')
|
|
24
|
+
instance.foo.should == 'stubbed foo'
|
|
25
|
+
instance.bar.should == 'stubbed bar'
|
|
26
|
+
instance.unstubbed_method.should == 'unstubbed result'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should raise an error when trying to stub non-existing methods' do
|
|
30
|
+
klass = Class.new do
|
|
31
|
+
def initialize
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
expect do
|
|
35
|
+
klass.new_with_stubs(:foo => 'foo')
|
|
36
|
+
end.to raise_error(/Attempted to stub non-existing method/)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|