Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[padrino-gen] Adjust to RSpec3, and little fix #1705

Merged
merged 2 commits into from Jun 30, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 21 additions & 16 deletions padrino-gen/lib/padrino-gen/generators/components/tests/rspec.rb
Expand Up @@ -24,13 +24,15 @@ def app(app = nil, &blk)
RSPEC_CONTROLLER_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_CONTROLLER_TEST)
require 'spec_helper'

describe "!NAME!Controller" do
before do
get "/"
end
RSpec.describe "!NAME!Controller" do
pending "add some examples to \#{__FILE__}" do
before do
get "/"
end

it "returns hello world" do
last_response.body.should == "Hello World"
it "http status code to be ok" do
expect(last_response).to be_ok
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tyabe Sorry, I overlooked this test. Has a different meaning between this test and other tests.
I guess this should probably be something like expect(last_response.body).to eq('Hello World').

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense. I'll restore it.

end
end
end
TEST
Expand All @@ -39,15 +41,15 @@ def app(app = nil, &blk)
begin
require 'rspec/core/rake_task'

spec_tasks = Dir['spec/*/'].inject([]) do |result, d|
spec_tasks = Dir['spec/*/'].each_with_object([]) do |d, result|
result << File.basename(d) unless Dir["\#{d}*"].empty?
result
end

spec_tasks.each do |folder|
desc "Run the spec suite in \#{folder}"
RSpec::Core::RakeTask.new("spec:\#{folder}") do |t|
t.pattern = "./spec/\#{folder}/**/*_spec.rb"
t.rspec_opts = %w(-fs --color)
t.rspec_opts = "--color"
end
end

Expand All @@ -61,20 +63,23 @@ def app(app = nil, &blk)
RSPEC_MODEL_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(RSPEC_MODEL_TEST)
require 'spec_helper'

describe !NAME! do
RSpec.describe !NAME! do
pending "add some examples to (or delete) \#{__FILE__}"
end
TEST

RSPEC_HELPER_TEST = (<<-TEST) unless defined?(RSPEC_HELPER_TEST)
require 'spec_helper'

describe "!NAME!" do
let(:helpers){ Class.new }
before { helpers.extend !NAME! }
subject { helpers }
RSpec.describe "!NAME!" do
pending "add some examples to (or delete) \#{__FILE__}" do
let(:helpers){ Class.new }
before { helpers.extend !NAME! }
subject { helpers }

it "should return nil" do
expect(subject.foo).to be_nil
it "should return nil" do
expect(subject.foo).to be_nil
end
end
end
TEST
Expand Down