Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make Rspec 3 compliant #7

Closed
wants to merge 1 commit into from

6 participants

@shin1ohno

As of RSpec 3, we can't call example in test.
see discussion: rspec/rspec-core#666

Rough but work at least...

@shin1ohno shin1ohno Make Rspec 3 compliant
As of RSpec 3, we can't call example in test.
see discussion: rspec/rspec-core#666
61dc733
@r7kamura
Owner

Thanks, anyway I'll give it a read :eyes:

@takashi takashi referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@AknEp

+1

@yuya373 yuya373 referenced this pull request
Closed

For Rspec3 #17

@taiki45

FYI: You can use autodoc with both RSpec3 and RSpec2 from v0.4.0.

@shin1ohno

@taiki45 Good to hear that. should I close this PR?

@taiki45

@shin1ohno Yes, you can :wink: :wine_glass:

@shin1ohno

:beer: to rspec 3 cmpatible version!

@shin1ohno shin1ohno closed this
@shin1ohno shin1ohno deleted the shin1ohno:rspec3 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 19, 2013
  1. @shin1ohno

    Make Rspec 3 compliant

    shin1ohno authored
    As of RSpec 3, we can't call example in test.
    see discussion: rspec/rspec-core#666
This page is out of date. Refresh to see the latest.
View
9 lib/autodoc/document.rb
@@ -11,13 +11,14 @@ def self.render(*args)
new(*args).render
end
- def initialize(context)
+ def initialize(context, example)
@context = context
+ @example = example
end
def pathname
@path ||= begin
- payload = @context.example.file_path.gsub(%r<\./spec/requests/(.+)_spec\.rb>, '\1.md')
+ payload = @example.file_path.gsub(%r<\./spec/requests/(.+)_spec\.rb>, '\1.md')
Pathname.new(Autodoc.configuration.path) + payload
end
end
@@ -173,12 +174,12 @@ def description
if @context.respond_to?(:description)
@context.description.strip_heredoc
else
- "#{@context.example.description.capitalize}."
+ "#{@example.description.capitalize}."
end
end
def path
- @context.example.full_description[%r<(GET|POST|PUT|DELETE) ([^ ]+)>, 2]
+ @example.full_description[%r<(GET|POST|PUT|DELETE) ([^ ]+)>, 2]
end
def parameters_section
View
4 lib/autodoc/documents.rb
@@ -6,8 +6,8 @@ def initialize
@table = Hash.new {|table, key| table[key] = [] }
end
- def append(context)
- document = Autodoc::Document.new(context.clone)
+ def append(context, example)
+ document = Autodoc::Document.new(context.clone, example.clone)
@table[document.pathname] << document
end
View
7 lib/autodoc/rspec.rb
@@ -1,7 +1,12 @@
require "rspec"
RSpec.configuration.after(:each, autodoc: true) do
- Autodoc.documents.append(self)
+ example = if RSpec.respond_to?(:current_example) #RSpec 3~
+ RSpec.current_example
+ else
+ self.example
+ end
+ Autodoc.documents.append(self, example)
end
RSpec.configuration.after(:suite) do
View
2  spec/requests/entries_spec.rb
@@ -29,7 +29,7 @@
end
describe "GET /entries" do
- context "with Rack::Test", :autodoc do
+ context "with Rack::Test", autodoc: true do
it "returns entries" do
get "/entries", params, env
last_response.status.should == 200
View
4 spec/requests/recipes_spec.rb
@@ -14,7 +14,7 @@
Recipe.create(name: "test", type: 2)
end
- context "with valid condition (using Rack::Test)", :autodoc do
+ context "with valid condition (using Rack::Test)", autodoc: true do
before do
env["Content-Type"] = "application/json"
end
@@ -67,7 +67,7 @@
end
end
- context "with valid condition", :autodoc do
+ context "with valid condition", autodoc: true do
let(:description) do
<<-EOS
Creates
View
3  spec/spec_helper.rb
@@ -1,7 +1,6 @@
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../../spec/dummy/config/environment", __FILE__)
require "rspec/rails"
-require "rspec/autorun"
Autodoc.configuration.toc = true
Autodoc.configuration.path = "spec/dummy/doc"
@@ -16,6 +15,4 @@
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
-
- config.treat_symbols_as_metadata_keys_with_true_values = true
end
Something went wrong with that request. Please try again.