Skip to content

Commit

Permalink
Fix described_class support for new RSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
psyho committed Nov 28, 2014
1 parent b7040d2 commit 4a8adb7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/bogus/rspec/syntax.rb
Expand Up @@ -8,6 +8,9 @@ class RSpecSyntax
def_delegators :context, :before, :after, :described_class

def described_class=(value)
# for new RSpec (> 3.0)
context.metadata[:described_class] = value
# for old RSpec (< 3.0)
context.example.metadata[:example_group][:described_class] = value
end

Expand Down
16 changes: 16 additions & 0 deletions spec/bogus/rspec/syntax_spec.rb
@@ -0,0 +1,16 @@
require 'spec_helper'

describe Bogus::RSpecSyntax do
context = self
let(:syntax) { Bogus::RSpecSyntax.new(context) }

it "gets the described class" do
expect(syntax.described_class).to eq(Bogus::RSpecSyntax)
end

it "can set the described class" do
syntax.described_class = Object

expect(described_class).to eq(Object)
end
end

0 comments on commit 4a8adb7

Please sign in to comment.