Chiew Chung        @theworldinunion
Edward Middleton   @e14n
'rspec/core/rake_task'
RSpec.configure do |c|
   # ....




command line
./.rspec
~/.rspec
describe "something" do
 context "in some context" do
  it "does something" do
    # ...
  end
 end
end
# in spec/spec_helper.rb
RSpec.configure do |c|
 c.filter_run :focus => true
end

# in any spec file
describe "something" ...
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 =...
actual.should == expected # object equality
actual.should equal(expected) # object identity




actual.should eq(expected)...
def eat_cheese
 simple_matcher("eat cheese") do |actual|
  actual.eat?(:cheese)
 end
end



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

RSpec::Matchers.define :e...
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 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 の変更点
Upcoming SlideShare
Loading in...5
×

RSpec 1.x -> 2.0 の変更点

4,488
-1

Published on

RSpec 1.x -> 2.0 の変更点

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,488
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
34
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

RSpec 1.x -> 2.0 の変更点

  1. 1. Chiew Chung @theworldinunion Edward Middleton @e14n
  2. 2. 'rspec/core/rake_task'
  3. 3. RSpec.configure do |c| # .... command line ./.rspec ~/.rspec
  4. 4. describe "something" do context "in some context" do it "does something" do # ... end end end
  5. 5. # 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
  6. 6. RSpec.configure do |c| c.filter_run :focus => true c.run_all_when_everything_filtered = true end
  7. 7. # 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
  8. 8. actual.should == expected # object equality actual.should equal(expected) # object identity actual.should eq(expected) # object equality actual.should be(expected) # object identity
  9. 9. 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
  10. 10. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×