SlideShare a Scribd company logo
Chiew Chung        @theworldinunion
Edward Middleton   @e14n
RSpec 1.x -> 2.0 の変更点
RSpec 1.x -> 2.0 の変更点
RSpec 1.x -> 2.0 の変更点
RSpec 1.x -> 2.0 の変更点
RSpec 1.x -> 2.0 の変更点
RSpec 1.x -> 2.0 の変更点
RSpec 1.x -> 2.0 の変更点
'rspec/core/rake_task'
RSpec 1.x -> 2.0 の変更点
RSpec.configure do |c|
   # ....




command line
./.rspec
~/.rspec
describe "something" do
 context "in some context" do
  it "does something" do
    # ...
  end
 end
end
RSpec 1.x -> 2.0 の変更点
RSpec 1.x -> 2.0 の変更点
# in spec/spec_helper.rb
RSpec.configure do |c|
 c.filter_run :focus => true
end

# in any spec file
describe "something" do
 it "does something", :focus => true do
   # ....
 end
end
RSpec.configure do |c|
 c.filter_run :focus => true
 c.run_all_when_everything_filtered = true
end
# in spec/spec_helper.rb
RSpec.configure do |c|
 c.exclusion_filter = { :ruby => lambda {|version|
  !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
 }}
end

# in any spec file
describe "something" do
 it "does something", :ruby => 1.8 do
   # ....
 end

 it "does something", :ruby => 1.9 do
   # ....
 end
end
RSpec 1.x -> 2.0 の変更点
RSpec 1.x -> 2.0 の変更点
actual.should == expected # object equality
actual.should equal(expected) # object identity




actual.should eq(expected) # object equality
actual.should be(expected) # object identity
RSpec 1.x -> 2.0 の変更点
def eat_cheese
 simple_matcher("eat cheese") do |actual|
  actual.eat?(:cheese)
 end
end



RSpec::Matchers.define :eat_cheese do
 match do |actual|
  actual.eat?(:cheese)
 end
end
RSpec::Matchers.define :eat_cheese do
 match do |actual|
  actual.should eat?(:cheese)
 end
end

RSpec::Matchers.define :eat_cheese do
 include MyCheesyAssertions
 match_unless_raises
Test::Unit::AssertionFailedError do |actual|
  assert_eats_chesse actual
 end
end
RSpec 1.x -> 2.0 の変更点

More Related Content

PDF
ZendCon 2017 - Build a Bot Workshop - Async Primer
PDF
Modern Perl Toolchain
PDF
Ansible 2.0
PDF
Babushka
PDF
Simplifying Code: Monster to Elegant in 5 Steps
KEY
You're Doing It Wrong
KEY
Rails Antipatterns | Open Session with Chad Pytel
ZendCon 2017 - Build a Bot Workshop - Async Primer
Modern Perl Toolchain
Ansible 2.0
Babushka
Simplifying Code: Monster to Elegant in 5 Steps
You're Doing It Wrong
Rails Antipatterns | Open Session with Chad Pytel

What's hot (9)

PDF
Extracting ruby gem
PPT
My GAE apps.
PDF
DataEngConf SF16 - Routing Billions of Analytics Events with High Deliverability
PPT
Auto Build
PDF
搭建高品質開源項目的應用實踐
PPTX
ZfDayIt 2014 - There is a module for everything
PPTX
Explore the Rake Gem
PPTX
Break through the serverless barriers with Durable Functions
Extracting ruby gem
My GAE apps.
DataEngConf SF16 - Routing Billions of Analytics Events with High Deliverability
Auto Build
搭建高品質開源項目的應用實踐
ZfDayIt 2014 - There is a module for everything
Explore the Rake Gem
Break through the serverless barriers with Durable Functions
Ad

Viewers also liked (16)

PDF
Read 96
ODP
Orixe humanos
PPTX
ΤΕΙ Θεσσαλονίκης, Τμήμα Μηχανικών Πληροφορικής: Μεταπτυχιακό Πρόγραμμα Σπουδώ...
PPTX
A célula e o adn
PPTX
Σύντομη εισαγωγή στην τεχνολογία GPU και την CUDA
PDF
Cosmovisão guia 01
PPTX
PPTX
Implicacións éticas do coñecemento da pegada xenética
PPTX
Xeomorfoloxia
PPTX
FlexUnit4でテスト駆動開発
PPT
Ek4
PPTX
Μοντέλο Client/Server, Διαδικτυακές υπηρεσίες και Cloud computing
PDF
Swiz フレームワーク for Flex and Actionscript
PPTX
Implicacións éticas do coñecemento da pegada xenética
ODP
Implicacións eticas pegada_xenetica
PPTX
Σύντομη εισαγωγή στο MapReduce
Read 96
Orixe humanos
ΤΕΙ Θεσσαλονίκης, Τμήμα Μηχανικών Πληροφορικής: Μεταπτυχιακό Πρόγραμμα Σπουδώ...
A célula e o adn
Σύντομη εισαγωγή στην τεχνολογία GPU και την CUDA
Cosmovisão guia 01
Implicacións éticas do coñecemento da pegada xenética
Xeomorfoloxia
FlexUnit4でテスト駆動開発
Ek4
Μοντέλο Client/Server, Διαδικτυακές υπηρεσίες και Cloud computing
Swiz フレームワーク for Flex and Actionscript
Implicacións éticas do coñecemento da pegada xenética
Implicacións eticas pegada_xenetica
Σύντομη εισαγωγή στο MapReduce
Ad

Similar to RSpec 1.x -> 2.0 の変更点 (20)

PDF
RSpec 3.0: Under the Covers
PDF
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
PDF
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
PDF
Blocks by Lachs Cox
KEY
A tour on ruby and friends
DOCX
Complet vector.dep.inc# This code depends on make tool being .docx
PDF
Ruby on Rails - Introduction
PDF
2010 Smith Scripting101
PDF
Does your configuration code smell?
PPT
name name2 n2.ppt
PPT
ppt2
PPT
name name2 n
PPT
ppt30
PPT
ppt18
PPT
Ruby for Perl Programmers
PPT
name name2 n2
PPT
name name2 n
PPT
ppt21
PPT
name name2 n
PPT
ppt17
RSpec 3.0: Under the Covers
PuppetConf 2017: Puppet Tasks: Taming ssh in a "for" loop- Alex Dreyer, Puppet
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
Blocks by Lachs Cox
A tour on ruby and friends
Complet vector.dep.inc# This code depends on make tool being .docx
Ruby on Rails - Introduction
2010 Smith Scripting101
Does your configuration code smell?
name name2 n2.ppt
ppt2
name name2 n
ppt30
ppt18
Ruby for Perl Programmers
name name2 n2
name name2 n
ppt21
name name2 n
ppt17

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Electronic commerce courselecture one. Pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPT
Teaching material agriculture food technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Empathic Computing: Creating Shared Understanding
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Machine learning based COVID-19 study performance prediction
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
20250228 LYD VKU AI Blended-Learning.pptx
A Presentation on Artificial Intelligence
Mobile App Security Testing_ A Comprehensive Guide.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Advanced methodologies resolving dimensionality complications for autism neur...
Electronic commerce courselecture one. Pdf
Review of recent advances in non-invasive hemoglobin estimation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Teaching material agriculture food technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
Empathic Computing: Creating Shared Understanding
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Machine learning based COVID-19 study performance prediction
NewMind AI Weekly Chronicles - August'25 Week I
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx

RSpec 1.x -> 2.0 の変更点

  • 1. Chiew Chung @theworldinunion Edward Middleton @e14n
  • 11. RSpec.configure do |c| # .... command line ./.rspec ~/.rspec
  • 12. describe "something" do context "in some context" do it "does something" do # ... end end end
  • 15. # in spec/spec_helper.rb RSpec.configure do |c| c.filter_run :focus => true end # in any spec file describe "something" do it "does something", :focus => true do # .... end end
  • 16. RSpec.configure do |c| c.filter_run :focus => true c.run_all_when_everything_filtered = true end
  • 17. # in spec/spec_helper.rb RSpec.configure do |c| c.exclusion_filter = { :ruby => lambda {|version| !(RUBY_VERSION.to_s =~ /^#{version.to_s}/) }} end # in any spec file describe "something" do it "does something", :ruby => 1.8 do # .... end it "does something", :ruby => 1.9 do # .... end end
  • 20. actual.should == expected # object equality actual.should equal(expected) # object identity actual.should eq(expected) # object equality actual.should be(expected) # object identity
  • 22. def eat_cheese simple_matcher("eat cheese") do |actual| actual.eat?(:cheese) end end RSpec::Matchers.define :eat_cheese do match do |actual| actual.eat?(:cheese) end end
  • 23. RSpec::Matchers.define :eat_cheese do match do |actual| actual.should eat?(:cheese) end end RSpec::Matchers.define :eat_cheese do include MyCheesyAssertions match_unless_raises Test::Unit::AssertionFailedError do |actual| assert_eats_chesse actual end end