Skip to content

Commit

Permalink
Cobble a passing mspec test together
Browse files Browse the repository at this point in the history
This is very much in the PoC state
  • Loading branch information
herwinw committed Jan 17, 2025
1 parent 0e6798f commit 1d90406
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,13 @@ jobs:
SPEC_TIMEOUT: 480
SOME_TESTS: true
run: rake docker_test_asan
mspec:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: install ruby
run: sudo apt-get install -y ruby ruby-bundler
- name: install rspec
run: cd test/mspec && sudo bundle install
- name: run very limited hacked mspec test
run: cd test/mspec && bundle exec rspec -I. matchers/be_an_instance_of_spec.rb
4 changes: 4 additions & 0 deletions test/mspec/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

gem "rake", "~> 12.3"
gem "rspec", "~> 3.0"
26 changes: 26 additions & 0 deletions test/mspec/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.4.4)
rake (12.3.3)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)

PLATFORMS
java
ruby

DEPENDENCIES
rake (~> 12.3)
rspec (~> 3.0)
4 changes: 2 additions & 2 deletions test/mspec/helpers/fixture_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'
require 'mspec/guards'
require 'mspec/helpers'
#require 'mspec/guards'
#require 'mspec/helpers'

RSpec.describe Object, "#fixture" do
before :each do
Expand Down
21 changes: 19 additions & 2 deletions test/mspec/matchers/be_an_instance_of_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
#require 'mspec/expectations/expectations'
#require 'mspec/matchers'
class BeAnInstanceOfMatcher
attr_reader :failure_message, :negative_failure_message

def initialize(klass)
@wrapped = BeInstanceOfExpectation.new(klass)
@klass = klass
end

def matches?(subject)
@wrapped.match(subject)
true
rescue SpecFailedException => e
@failure_message = ["Expected #{subject.inspect} (#{subject.class})", "to be an instance of #{@klass}"]
@negative_failure_message = ["Expected #{subject.inspect} (#{subject.class})", "not to be an instance of #{@klass}"]
nil
end
end

module BeAnInOfSpecs
class A
Expand Down
4 changes: 2 additions & 2 deletions test/mspec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
config.raise_errors_for_deprecations!
end

require 'mspec'
require_relative '../spec_helper'

# Remove this when MRI has intelligent warnings
$VERBOSE = nil unless $VERBOSE
Expand Down Expand Up @@ -63,7 +63,7 @@ def ensure_mspec_method(method)
end

PublicMSpecMatchers = Class.new {
include MSpecMatchers
# include MSpecMatchers
public :raise_error
}.new

Expand Down

0 comments on commit 1d90406

Please sign in to comment.