Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.

Commit c650e44

Browse files
committed
Update to rspec 3.5
1 parent ffc0af0 commit c650e44

File tree

6 files changed

+118
-15
lines changed

6 files changed

+118
-15
lines changed

Rakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
require "bundler/gem_tasks"
22

3-
# require "rspec/core/rake_task"
4-
# RSpec::Core::RakeTask.new(:spec)
3+
require "rspec/core/rake_task"
4+
RSpec::Core::RakeTask.new(:spec)
55

6-
require "spec/rake/spectask"
7-
Spec::Rake::SpecTask.new
6+
# require "spec/rake/spectask"
7+
# Spec::Rake::SpecTask.new
88

99
FileList['tasks/**/*.rake'].each { |task| import task }
1010

dm-rails.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
2222
spec.add_runtime_dependency('actionpack', '>= 3.0', '< 6.0')
2323
spec.add_runtime_dependency('railties', '>= 3.0', '< 6.0')
2424

25-
spec.add_development_dependency('rake', '~> 0.9.2')
26-
spec.add_development_dependency('rspec', '~> 1.3.2')
25+
spec.add_development_dependency('rake', '~> 0.9.2')
26+
spec.add_development_dependency('rspec')
2727
end

spec/models/fake.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def _super_attributes=(*args)
2323
def attributes=(*args)
2424
self.send(:_super_attributes=, *args)
2525
end
26+
27+
def properties
28+
end
2629
end
2730
include super_module
2831

spec/spec.opts

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/spec_helper.rb

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
$:.unshift File.expand_path File.dirname(__FILE__) + '../lib'
23
require 'dm-core/spec/setup'
34
require 'dm-core/spec/lib/adapter_helpers'
@@ -7,13 +8,114 @@
78
DataMapper::Spec.setup
89
DataMapper.finalize
910

10-
Spec::Runner.configure do |config|
11+
# This file was generated by the `rspec --init` command. Conventionally, all
12+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
13+
# The generated `.rspec` file contains `--require spec_helper` which will cause
14+
# this file to always be loaded, without a need to explicitly require it in any
15+
# files.
16+
#
17+
# Given that it is always loaded, you are encouraged to keep this file as
18+
# light-weight as possible. Requiring heavyweight dependencies from this file
19+
# will add to the boot time of your test suite on EVERY test run, even for an
20+
# individual file that may not need all of that loaded. Instead, consider making
21+
# a separate helper file that requires the additional dependencies and performs
22+
# the additional setup, and require it from the spec files that actually need
23+
# it.
24+
#
25+
# The `.rspec` file also contains a few flags that are not defaults but that
26+
# users commonly want.
27+
#
28+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
29+
RSpec.configure do |config|
1130

1231
config.extend(DataMapper::Spec::Adapters::Helpers)
1332
config.include(DataMapper::Spec::PendingHelpers)
1433

1534
config.after :all do
1635
DataMapper::Spec.cleanup_models
1736
end
37+
38+
# rspec-expectations config goes here. You can use an alternate
39+
# assertion/expectation library such as wrong or the stdlib/minitest
40+
# assertions if you prefer.
41+
config.expect_with :rspec do |expectations|
42+
# This option will default to `true` in RSpec 4. It makes the `description`
43+
# and `failure_message` of custom matchers include text for helper methods
44+
# defined using `chain`, e.g.:
45+
# be_bigger_than(2).and_smaller_than(4).description
46+
# # => "be bigger than 2 and smaller than 4"
47+
# ...rather than:
48+
# # => "be bigger than 2"
49+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
50+
end
51+
52+
# rspec-mocks config goes here. You can use an alternate test double
53+
# library (such as bogus or mocha) by changing the `mock_with` option here.
54+
config.mock_with :rspec do |mocks|
55+
# Prevents you from mocking or stubbing a method that does not exist on
56+
# a real object. This is generally recommended, and will default to
57+
# `true` in RSpec 4.
58+
mocks.verify_partial_doubles = true
59+
end
60+
61+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
62+
# have no way to turn it off -- the option exists only for backwards
63+
# compatibility in RSpec 3). It causes shared context metadata to be
64+
# inherited by the metadata hash of host groups and examples, rather than
65+
# triggering implicit auto-inclusion in groups with matching metadata.
66+
config.shared_context_metadata_behavior = :apply_to_host_groups
67+
68+
# The settings below are suggested to provide a good initial experience
69+
# with RSpec, but feel free to customize to your heart's content.
70+
=begin
71+
# This allows you to limit a spec run to individual examples or groups
72+
# you care about by tagging them with `:focus` metadata. When nothing
73+
# is tagged with `:focus`, all examples get run. RSpec also provides
74+
# aliases for `it`, `describe`, and `context` that include `:focus`
75+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
76+
config.filter_run_when_matching :focus
77+
78+
# Allows RSpec to persist some state between runs in order to support
79+
# the `--only-failures` and `--next-failure` CLI options. We recommend
80+
# you configure your source control system to ignore this file.
81+
config.example_status_persistence_file_path = "spec/examples.txt"
82+
83+
# Limits the available syntax to the non-monkey patched syntax that is
84+
# recommended. For more details, see:
85+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
86+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
87+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
88+
config.disable_monkey_patching!
89+
90+
# This setting enables warnings. It's recommended, but in some cases may
91+
# be too noisy due to issues in dependencies.
92+
config.warnings = true
93+
94+
# Many RSpec users commonly either run the entire suite or an individual
95+
# file, and it's useful to allow more verbose output when running an
96+
# individual spec file.
97+
if config.files_to_run.one?
98+
# Use the documentation formatter for detailed output,
99+
# unless a formatter has already been configured
100+
# (e.g. via a command-line flag).
101+
config.default_formatter = 'doc'
102+
end
103+
104+
# Print the 10 slowest examples and example groups at the
105+
# end of the spec run, to help surface which specs are running
106+
# particularly slow.
107+
config.profile_examples = 10
108+
109+
# Run specs in random order to surface order dependencies. If you find an
110+
# order dependency and want to debug it, you can fix the order by providing
111+
# the seed, which is printed after each run.
112+
# --seed 1234
113+
config.order = :random
18114
115+
# Seed global randomization in this process using the `--seed` CLI option.
116+
# Setting this allows you to use `--seed` to deterministically reproduce
117+
# test failures related to randomization by passing the same `--seed` value
118+
# as the one that triggered the failure.
119+
Kernel.srand config.seed
120+
=end
19121
end

spec/unit/multiparameter_attributes_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@
107107
with('a string', '1.5', '1.5'.to_i, '1.5'.to_f).
108108
and_return(attributes['composite'])
109109

110-
composite_property = mock(::DataMapper::Property)
111-
composite_property.stub!(:primitive).and_return(::Rails::DataMapper::Models::Composite)
110+
composite_property = instance_double(::DataMapper::Property)
111+
allow(composite_property).to receive(:primitive).and_return(::Rails::DataMapper::Models::Composite)
112112

113113
resource = ::Rails::DataMapper::Models::Fake.new
114-
resource.stub!(:properties).and_return('composite' => composite_property)
114+
allow(resource).to receive(:properties).and_return('composite' => composite_property)
115115

116116
resource.should_receive(:_super_attributes=).with(attributes)
117117

@@ -126,11 +126,11 @@
126126
::Rails::DataMapper::Models::Composite.
127127
should_receive(:new).with('a string').and_raise(composite_exception)
128128

129-
composite_property = mock(::DataMapper::Property)
130-
composite_property.stub!(:primitive).and_return(::Rails::DataMapper::Models::Composite)
129+
composite_property = instance_double(::DataMapper::Property)
130+
allow(composite_property).to receive(:primitive).and_return(::Rails::DataMapper::Models::Composite)
131131

132132
resource = ::Rails::DataMapper::Models::Fake.new
133-
resource.stub!(:properties).and_return('composite' => composite_property)
133+
allow(resource).to receive(:properties).and_return('composite' => composite_property)
134134

135135
lambda { resource.attributes = multiparameter_hash }.
136136
should raise_error(::Rails::DataMapper::MultiparameterAssignmentErrors) { |ex|

0 commit comments

Comments
 (0)