Permalink
Browse files

clean up the running_example speecs a bit

  • Loading branch information...
1 parent 5cfdcd3 commit 81be9385e6415a6a7d61c4f097a1a9f4e27a95ec @dchelimsky dchelimsky committed Mar 11, 2010
Showing with 22 additions and 22 deletions.
  1. +3 −2 rspec-expectations.gemspec
  2. +19 −20 spec/rspec/matchers/matcher_spec.rb
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["David Chelimsky", "Chad Humphries"]
- s.date = %q{2010-03-08}
+ s.date = %q{2010-03-10}
s.description = %q{rspec expectations (should[_not] and matchers)}
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
s.extra_rdoc_files = [
@@ -102,7 +102,8 @@ Gem::Specification.new do |s|
"spec/rspec/matchers/throw_symbol_spec.rb",
"spec/spec_helper.rb",
"spec/suite.rb",
- "spec/support/classes.rb"
+ "spec/support/classes.rb",
+ "specs.watchr"
]
s.homepage = %q{http://github.com/rspec/expectations}
s.post_install_message = %q{**************************************************
@@ -284,38 +284,37 @@ def assert_equal(a,b)
matcher.expecting('value').matches?('value').should be_true
matcher.expecting('value').matches?('other value').should be_false
end
-
- context "can access running_example" do
- it "works with matcher using dsl" do
- Rspec::Matchers.define(:something) do
+
+ context "defined using the dsl" do
+ it "can access the running_example" do
+ Rspec::Matchers.define(:__access_running_example) do
match do |actual|
actual == running_example
end
end
- running_example.should something
+ running_example.should __access_running_example
end
-
- it "works within matcher using #new" do
+ end
+
+ context "defined using #new" do
+ it "can access the running_example" do
@matcher = Rspec::Matchers::Matcher.new(:something) {}
- @matcher.send(:running_example).should == running_example
+ @matcher.send(:running_example).should eq(running_example)
end
+ end
+
+ context "wrapped in a method" do
- module ::FakeMatcher
- include Rspec::Matchers
-
- def do_something
- Matcher.new(:do_something) do
- match do |actual|
- !running_example.nil?
- end
+ def access_running_example
+ Matcher.new(:access_running_example) do
+ match do |actual|
+ actual == running_example
end
end
end
- include FakeMatcher
-
- it "works when defined with api" do
- "this string".should do_something
+ it "can access the running_example" do
+ running_example.should access_running_example
end
end
end

0 comments on commit 81be938

Please sign in to comment.