Skip to content

Instantly share code, notes, and snippets.

@igrep
Last active October 16, 2017 08:22
Show Gist options
  • Select an option

  • Save igrep/bff4d45660055c566c24 to your computer and use it in GitHub Desktop.

Select an option

Save igrep/bff4d45660055c566c24 to your computer and use it in GitHub Desktop.
RSpec 3.0から3.3まで一気に上げたので独断と偏見で選んだ注目すべき新機能を紹介する ref: http://qiita.com/igrep/items/cd1d2ba8ce5ccb6f5f44
RSpec.configure do |c|
c.example_status_persistence_file_path = "./tmp/rspec-example-status.txt"
end
RSpec.describe Client do
let(:response) { Client.make_request }
it "returns a successful JSON response" do
expect(response.status).to eq(200)
expect(response.headers).to include("Content-Type" => "application/json")
expect(response.body).to eq('{"message":"Success"}')
end
end
RSpec.describe Client do
let(:response) { Client.make_request }
it "returns a successful JSON response" do
expect(response.status).to eq(200)
expect(response.headers).to include("Content-Type" => "application/json")
expect(response.body).to eq('{"message":"Success"}')
end
end
RSpec.describe Client do
let(:response) { Client.make_request }
it "returns a successful JSON response", :aggregate_failures do
expect(response.status).to eq(200)
expect(response.headers).to include("Content-Type" => "application/json")
expect(response.body).to eq('{"message":"Success"}')
end
end
RSpec.describe Client do
let(:response) { Client.make_request }
it "returns a successful JSON response", :aggregate_failures do
expect(response.status).to eq(200)
expect(response.headers).to include("Content-Type" => "application/json")
expect(response.body).to eq('{"message":"Success"}')
end
end
RSpec.configure do |c|
c.define_derived_metadata do |meta|
meta[:aggregate_failures] = true unless meta.key?(:aggregate_failures)
end
end
RSpec.configure do |c|
c.define_derived_metadata do |meta|
meta[:aggregate_failures] = true unless meta.key?(:aggregate_failures)
end
end
# ここに書けばこのブロック内すべてのexampleが`aggregate_failures`されます。
RSpec.describe Client, aggregate_failures: false do
let(:response) { Client.make_request }
# もちろん個別に指定してもOK!
it "returns a successful JSON response", aggregate_failures: false do
expect(response.status).to eq(200)
expect(response.headers).to include("Content-Type" => "application/json")
expect(response.body).to eq('{"message":"Success"}')
end
end
# ここに書けばこのブロック内すべてのexampleが`aggregate_failures`されます。
RSpec.describe Client, aggregate_failures: false do
let(:response) { Client.make_request }
# もちろん個別に指定してもOK!
it "returns a successful JSON response", aggregate_failures: false do
expect(response.status).to eq(200)
expect(response.headers).to include("Content-Type" => "application/json")
expect(response.body).to eq('{"message":"Success"}')
end
end
expect { subject_method }.to raise_error
def just_hello
puts "hello"
frined.accept_hello_of(self)
rescue Exception
warn "I JUST WANT TO SAY HELLO!! DON'T DISTURB!!"
end
it 'says hello to no other person' do
expect(friend).not_to receive(:accept_hello_of)
x.just_hello
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment