Skip to content

Commit

Permalink
update rspec, serverspec, specinfra (and related monkeypatches)
Browse files Browse the repository at this point in the history
Signed-off-by: Phan Le <[email protected]>
  • Loading branch information
John Foley committed Jun 5, 2014
1 parent 24ff1f0 commit ff7285a
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ group :development, :test do
gemspec path: 'bosh-dev'
gemspec path: 'bosh-stemcell'

gem 'rspec', '3.0.0.beta1'
gem 'rspec', '~> 3.0'
gem 'rspec-its'

gem 'rubocop', require: false
Expand Down
39 changes: 20 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -365,27 +365,27 @@ GEM
resque (>= 1.0)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (3.0.0.beta1)
rspec-core (= 3.0.0.beta1)
rspec-expectations (= 3.0.0.beta1)
rspec-mocks (= 3.0.0.beta1)
rspec-core (3.0.0.beta1)
rspec-support (= 3.0.0.beta1)
rspec-expectations (3.0.0.beta1)
diff-lcs (>= 1.1.3, < 2.0)
rspec-support (= 3.0.0.beta1)
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-core (3.0.0)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-instafail (0.2.4)
rspec-its (1.0.1)
rspec-core (>= 2.99.0.beta1)
rspec-expectations (>= 2.99.0.beta1)
rspec-mocks (3.0.0.beta1)
rspec-support (= 3.0.0.beta1)
rspec-support (3.0.0.beta1)
rubocop (0.22.0)
json (>= 1.7.7, < 2)
parser (~> 2.1.9)
powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
rspec-mocks (3.0.0)
rspec-support (~> 3.0.0)
rspec-support (3.0.0)
rubocop (0.10.0)
backports (~> 3.3.3)
parser (= 2.0.0.pre2)
powerpack (= 0.0.1)
rainbow (>= 1.1.4)
ruby-atmos-pure (1.0.5)
log4r (>= 1.1.9)
ruby-hmac (>= 0.4.0)
Expand Down Expand Up @@ -495,7 +495,8 @@ DEPENDENCIES
rake (~> 10.0)
redis
rest-client
rspec (= 3.0.0.beta1)
rspec (~> 3.0)
rspec-instafail
rspec-its
rubocop
ruby_gntp
Expand Down
2 changes: 2 additions & 0 deletions bosh-director/bosh-director.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Gem::Specification.new do |s|
s.add_dependency 'membrane', '~>0.0.2'
s.add_dependency 'semi_semantic', '~>1.1.0'

s.add_development_dependency 'timecop'

s.bindir = 'bin'
s.executables << 'bosh-director'
s.executables << 'bosh-director-console'
Expand Down
30 changes: 16 additions & 14 deletions bosh-director/spec/unit/jobs/snapshot_deployment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,22 @@ module Bosh::Director
let(:fake_nats) { double('nats') }

it 'sends an alert over NATS on hm.director.alert' do
fake_nats.should_receive(:publish).with('hm.director.alert', json_match(
eq(
{
'id' => 'director',
'severity' => 3,
'title' => 'director - snapshot failure',
'summary' => "failed to snapshot #{job}/#{index}: hello",
'created_at' => anything,
}
))
)

Bosh::Director::Config.stub(:nats => fake_nats)
subject.send_alert(fake_instance, 'hello')
Timecop.freeze do
fake_nats.should_receive(:publish).with('hm.director.alert', json_match(
eq(
{
'id' => 'director',
'severity' => 3,
'title' => 'director - snapshot failure',
'summary' => "failed to snapshot #{job}/#{index}: hello",
'created_at' => Time.now.to_i,
}
))
)

Bosh::Director::Config.stub(:nats => fake_nats)
subject.send_alert(fake_instance, 'hello')
end
end
end
end
Expand Down
39 changes: 8 additions & 31 deletions bosh-stemcell/Berksfile.lock
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
{
"sources": {
"golang": {
"locked_version": "1.1.2"
},
"stemcell-golang": {
"path": "./sites-cookbooks/stemcell-golang"
},
"git": {
"locked_version": "2.8.4"
},
"dmg": {
"locked_version": "2.0.8"
},
"build-essential": {
"locked_version": "1.4.2"
},
"windows": {
"locked_version": "1.11.0"
},
"chef_handler": {
"locked_version": "1.1.4"
},
"yum": {
"locked_version": "2.4.4"
},
"runit": {
"locked_version": "1.4.6"
}
}
}
DEPENDENCIES
golang
stemcell-golang
path: sites-cookbooks/stemcell-golang

GRAPH
golang (1.3.0)
stemcell-golang (0.0.1)
7 changes: 3 additions & 4 deletions bosh-stemcell/lib/monkeypatch/serverspec/backend/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class Exec
def run_command(cmd, opts={})
cmd = build_command(cmd)
cmd = add_pre_command(cmd)
cmd = build_command(cmd)
# In ruby 1.9, it is possible to use Open3.capture3, but not in 1.8
# stdout, stderr, status = Open3.capture3(cmd)

if use_chroot?
chroot_stdout = `#{chroot_cmd(cmd)} 2>&1`
Expand All @@ -43,12 +44,10 @@ def run_command(cmd, opts={})
stdout = run_with_no_ruby_environment { `#{cmd} 2>&1` }
exit_status = $?.exitstatus
end
# In ruby 1.9, it is possible to use Open3.capture3, but not in 1.8
#stdout, stderr, status = Open3.capture3(cmd)

if @example
@example.metadata[:command] = cmd
@example.metadata[:stdout] = stdout
@example.metadata[:stdout] = stdout
end

CommandResult.new :stdout => stdout, :exit_status => exit_status
Expand Down
42 changes: 1 addition & 41 deletions bosh-stemcell/spec/support/serverspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,7 @@

# `example` method monkey path
unless SpecInfra::VERSION == '1.15.0'
raise "Unexpected SpecInfra version #{SpecInfra::VERSION}"
end

RSpec.configure do |c|
# RSpec 3.0 explicitly passes in example method into
# before(:each) so we delete non-compatible before each
# added in `lib/specinfra.rb`.
c.hooks[:before][:each].pop

# c.before do # before
c.before do |example| # after
if respond_to?(:backend) && backend.respond_to?(:set_example)
backend.set_example(example)
end
end
end

SpecInfra::Helper::Configuration.class_eval do
# Rspec 3.0 removed `example`method but introduced `RSpec.current_example`
def subject
# example.metadata[:subject] = described_class # before
RSpec.current_example.metadata[:subject] = described_class # after
build_configurations
super
end
end

SpecInfra::Backend::Exec.class_eval do
alias_method :check_os_with_broken_ubuntu_detection, :check_os

# SpecInfra does not properly detect lsb_release
# so we have to correct family that is returned
# Used to return 'Distributor ID:\tUbuntu\n' as family.
def check_os
result = check_os_with_broken_ubuntu_detection
family = result[:family]
if family.include?('Distributor ID:')
result[:family] = family.split(/\s+/, 3).last.strip
end
result
end
raise "Unexpected Specinfra version #{SpecInfra::VERSION}"
end

# Exec monkey path
Expand Down
Binary file removed vendor/cache/rspec-3.0.0.beta1.gem
Binary file not shown.
Binary file added vendor/cache/rspec-3.0.0.gem
Binary file not shown.
Binary file removed vendor/cache/rspec-core-3.0.0.beta1.gem
Binary file not shown.
Binary file added vendor/cache/rspec-core-3.0.0.gem
Binary file not shown.
Binary file removed vendor/cache/rspec-expectations-3.0.0.beta1.gem
Binary file not shown.
Binary file added vendor/cache/rspec-expectations-3.0.0.gem
Binary file not shown.
Binary file removed vendor/cache/rspec-mocks-3.0.0.beta1.gem
Binary file not shown.
Binary file added vendor/cache/rspec-mocks-3.0.0.gem
Binary file not shown.
Binary file removed vendor/cache/rspec-support-3.0.0.beta1.gem
Binary file not shown.
Binary file added vendor/cache/rspec-support-3.0.0.gem
Binary file not shown.

0 comments on commit ff7285a

Please sign in to comment.