Created
February 23, 2012 04:03
-
-
Save kinopyo/1889982 to your computer and use it in GitHub Desktop.
Rspec Array Matching =~
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "finds upcoming published lessons" do | |
upcoming1 = Factory :lesson, start_at: 1.day.from_now | |
upcoming2 = Factory :lesson, start_at: 2.days.from_now | |
past = Factory :lesson, start_at: 1.day.ago | |
draft = Factory :lesson, visibility: 'draft' | |
Lesson.upcoming.should include(upcoming1, upcoming2) | |
Lesson.upcoming.should_not include(past, draft) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "finds upcoming published lessons" do | |
upcoming1 = Factory :lesson, start_at: 1.day.from_now | |
upcoming2 = Factory :lesson, start_at: 2.days.from_now | |
past = Factory :lesson, start_at: 1.day.ago | |
draft = Factory :lesson, visibility: 'draft' | |
Lesson.upcoming.should =~ [upcoming1, upcoming2] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/dchelimsky/rspec/blob/master/lib/spec/matchers/match_array.rb | |
[1,2,3].should =~ [1,2,3] # => would pass | |
[1,2,3].should =~ [2,3,1] # => would pass | |
[1,2,3,4].should =~ [1,2,3] # => would fail | |
[1,2,2,3].should =~ [1,2,3] # => would fail | |
[1,2,3].should =~ [1,2,3,4] # => would fail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment