| |   |
| 0 | | # Used just for us to develop rspec with Autotest |
| 1 | | # We could symbolic link rspec/vendor/plugins/rspec => rspec/., but |
| 2 | | # this leads to a problem with subversion on windows. Autotest |
| 3 | | # uses Ruby's load path, which contains ".", so this is a workaround |
| 4 | | # (albeit, an unclean one) |
| 5 | | require File.dirname(__FILE__) + "/../lib/autotest/discover.rb" |
| toggle raw diff |
--- a/vendor/plugins/rspec/autotest/discover.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# Used just for us to develop rspec with Autotest
-# We could symbolic link rspec/vendor/plugins/rspec => rspec/., but
-# this leads to a problem with subversion on windows. Autotest
-# uses Ruby's load path, which contains ".", so this is a workaround
-# (albeit, an unclean one)
-require File.dirname(__FILE__) + "/../lib/autotest/discover.rb" |
| |   |
| 0 | | require "test/unit" |
| 1 | | require File.dirname(__FILE__) + '/../../../../spec_helper.rb' |
| 2 | | |
| 3 | | module TestSuiteAdapterSpecHelper |
| 4 | | def create_adapter(group) |
| 5 | | Test::Unit::TestSuiteAdapter.new(group) |
| 6 | | end |
| 7 | | end |
| 8 | | |
| 9 | | describe "TestSuiteAdapter#size" do |
| 10 | | include TestSuiteAdapterSpecHelper |
| 11 | | it "should return the number of examples in the example group" do |
| 12 | | group = Class.new(Spec::ExampleGroup) do |
| 13 | | describe("some examples") |
| 14 | | it("bar") {} |
| 15 | | it("baz") {} |
| 16 | | end |
| 17 | | adapter = create_adapter(group) |
| 18 | | adapter.size.should == 2 |
| 19 | | end |
| 20 | | end |
| 21 | | |
| 22 | | describe "TestSuiteAdapter#delete" do |
| 23 | | include TestSuiteAdapterSpecHelper |
| 24 | | it "should do nothing" do |
| 25 | | group = Class.new(Spec::ExampleGroup) do |
| 26 | | describe("Some Examples") |
| 27 | | it("does something") {} |
| 28 | | end |
| 29 | | adapter = create_adapter(group) |
| 30 | | adapter.delete(adapter.examples.first) |
| 31 | | adapter.should be_empty |
| 32 | | end |
| 33 | | end |
| toggle raw diff |
--- a/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec_with_test_unit.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require "test/unit"
-require File.dirname(__FILE__) + '/../../../../spec_helper.rb'
-
-module TestSuiteAdapterSpecHelper
- def create_adapter(group)
- Test::Unit::TestSuiteAdapter.new(group)
- end
-end
-
-describe "TestSuiteAdapter#size" do
- include TestSuiteAdapterSpecHelper
- it "should return the number of examples in the example group" do
- group = Class.new(Spec::ExampleGroup) do
- describe("some examples")
- it("bar") {}
- it("baz") {}
- end
- adapter = create_adapter(group)
- adapter.size.should == 2
- end
-end
-
-describe "TestSuiteAdapter#delete" do
- include TestSuiteAdapterSpecHelper
- it "should do nothing" do
- group = Class.new(Spec::ExampleGroup) do
- describe("Some Examples")
- it("does something") {}
- end
- adapter = create_adapter(group)
- adapter.delete(adapter.examples.first)
- adapter.should be_empty
- end
-end |
| |   |
| 0 | | describe "Mock" do |
| 1 | | before do |
| 2 | | @mock = mock("test mock") |
| 3 | | end |
| 4 | | |
| 5 | | specify "when one example has an expectation (non-mock) inside the block passed to the mock" do |
| 6 | | @mock.should_receive(:msg) do |b| |
| 7 | | b.should be_true #this call exposes the problem |
| 8 | | end |
| 9 | | @mock.msg(false) rescue nil |
| 10 | | end |
| 11 | | |
| 12 | | specify "then the next example should behave as expected instead of saying" do |
| 13 | | @mock.should_receive(:foobar) |
| 14 | | @mock.foobar |
| 15 | | @mock.rspec_verify |
| 16 | | begin |
| 17 | | @mock.foobar |
| 18 | | rescue => e |
| 19 | | e.message.should == "Mock 'test mock' received unexpected message :foobar with (no args)" |
| 20 | | end |
| 21 | | end |
| 22 | | end |
| 23 | | |
| toggle raw diff |
--- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_10263.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-describe "Mock" do
- before do
- @mock = mock("test mock")
- end
-
- specify "when one example has an expectation (non-mock) inside the block passed to the mock" do
- @mock.should_receive(:msg) do |b|
- b.should be_true #this call exposes the problem
- end
- @mock.msg(false) rescue nil
- end
-
- specify "then the next example should behave as expected instead of saying" do
- @mock.should_receive(:foobar)
- @mock.foobar
- @mock.rspec_verify
- begin
- @mock.foobar
- rescue => e
- e.message.should == "Mock 'test mock' received unexpected message :foobar with (no args)"
- end
- end
-end
- |
| |   |
| 0 | | ## |
| 1 | | # A wrapper that allows instance variables to be manipulated using +[]+ and |
| 2 | | # +[]=+ |
| 3 | | |
| 4 | | module Spec |
| 5 | | module Rails |
| 6 | | module Example |
| 7 | | class IvarProxy #:nodoc: |
| 8 | | |
| 9 | | ## |
| 10 | | # Wraps +object+ allowing its instance variables to be manipulated. |
| 11 | | |
| 12 | | def initialize(object) |
| 13 | | @object = object |
| 14 | | end |
| 15 | | |
| 16 | | ## |
| 17 | | # Retrieves +ivar+ from the wrapped object. |
| 18 | | |
| 19 | | def [](ivar) |
| 20 | | get_variable "@#{ivar}" |
| 21 | | end |
| 22 | | |
| 23 | | ## |
| 24 | | # Sets +ivar+ to +val+ on the wrapped object. |
| 25 | | |
| 26 | | def []=(ivar, val) |
| 27 | | set_variable "@#{ivar}", val |
| 28 | | end |
| 29 | | |
| 30 | | def each |
| 31 | | @object.instance_variables.each do |variable_full_name| |
| 32 | | variable_name = variable_full_name[1...variable_full_name.length] |
| 33 | | yield variable_name, get_variable(variable_full_name) |
| 34 | | end |
| 35 | | end |
| 36 | | |
| 37 | | def delete(key) |
| 38 | | var_name = "@#{key}" |
| 39 | | if @object.instance_variables.include?(var_name) |
| 40 | | @object.send(:remove_instance_variable, var_name) |
| 41 | | else |
| 42 | | return nil |
| 43 | | end |
| 44 | | end |
| 45 | | |
| 46 | | def has_key?(key) |
| 47 | | @object.instance_variables.include?("@#{key}") |
| 48 | | end |
| 49 | | |
| 50 | | protected |
| 51 | | def get_variable(name) |
| 52 | | @object.instance_variable_get name |
| 53 | | end |
| 54 | | |
| 55 | | def set_variable(name, value) |
| 56 | | @object.instance_variable_set name, value |
| 57 | | end |
| 58 | | end |
| 59 | | end |
| 60 | | end |
| 61 | | end |
| toggle raw diff |
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/ivar_proxy.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-##
-# A wrapper that allows instance variables to be manipulated using +[]+ and
-# +[]=+
-
-module Spec
- module Rails
- module Example
- class IvarProxy #:nodoc:
-
- ##
- # Wraps +object+ allowing its instance variables to be manipulated.
-
- def initialize(object)
- @object = object
- end
-
- ##
- # Retrieves +ivar+ from the wrapped object.
-
- def [](ivar)
- get_variable "@#{ivar}"
- end
-
- ##
- # Sets +ivar+ to +val+ on the wrapped object.
-
- def []=(ivar, val)
- set_variable "@#{ivar}", val
- end
-
- def each
- @object.instance_variables.each do |variable_full_name|
- variable_name = variable_full_name[1...variable_full_name.length]
- yield variable_name, get_variable(variable_full_name)
- end
- end
-
- def delete(key)
- var_name = "@#{key}"
- if @object.instance_variables.include?(var_name)
- @object.send(:remove_instance_variable, var_name)
- else
- return nil
- end
- end
-
- def has_key?(key)
- @object.instance_variables.include?("@#{key}")
- end
-
- protected
- def get_variable(name)
- @object.instance_variable_get name
- end
-
- def set_variable(name, value)
- @object.instance_variable_set name, value
- end
- end
- end
- end
-end |
| |   |
| 0 | | require File.dirname(__FILE__) + '/../../spec_helper' |
| 1 | | |
| 2 | | describe "IvarProxy setup", :shared => true do |
| 3 | | before do |
| 4 | | @object = Object.new |
| 5 | | @proxy = Spec::Rails::Example::IvarProxy.new(@object) |
| 6 | | end |
| 7 | | end |
| 8 | | |
| 9 | | describe "IvarProxy" do |
| 10 | | it_should_behave_like "IvarProxy setup" |
| 11 | | |
| 12 | | it "has [] accessor" do |
| 13 | | @proxy['foo'] = 'bar' |
| 14 | | @object.instance_variable_get(:@foo).should == 'bar' |
| 15 | | @proxy['foo'].should == 'bar' |
| 16 | | end |
| 17 | | |
| 18 | | it "iterates through each element like a Hash" do |
| 19 | | values = { |
| 20 | | 'foo' => 1, |
| 21 | | 'bar' => 2, |
| 22 | | 'baz' => 3 |
| 23 | | } |
| 24 | | @proxy['foo'] = values['foo'] |
| 25 | | @proxy['bar'] = values['bar'] |
| 26 | | @proxy['baz'] = values['baz'] |
| 27 | | |
| 28 | | @proxy.each do |key, value| |
| 29 | | key.should == key |
| 30 | | value.should == values[key] |
| 31 | | end |
| 32 | | end |
| 33 | | |
| 34 | | it "detects the presence of a key" do |
| 35 | | @proxy['foo'] = 'bar' |
| 36 | | @proxy.has_key?('foo').should == true |
| 37 | | @proxy.has_key?('bar').should == false |
| 38 | | end |
| 39 | | end |
| 40 | | |
| 41 | | describe "IvarProxy", "#delete" do |
| 42 | | it_should_behave_like "IvarProxy setup" |
| 43 | | |
| 44 | | it "deletes the element with key" do |
| 45 | | @proxy['foo'] = 'bar' |
| 46 | | @proxy.delete('foo').should == 'bar' |
| 47 | | @proxy['foo'].should be_nil |
| 48 | | end |
| 49 | | |
| 50 | | it "deletes nil instance variables" do |
| 51 | | @proxy['foo'] = nil |
| 52 | | @object.instance_variables.should include("@foo") |
| 53 | | @proxy.delete('foo').should == nil |
| 54 | | @proxy['foo'].should be_nil |
| 55 | | @object.instance_variables.should_not include("@foo") |
| 56 | | end |
| 57 | | |
| 58 | | it "returns nil when key does not exist" do |
| 59 | | @proxy['foo'].should be_nil |
| 60 | | @proxy.delete('foo').should == nil |
| 61 | | @proxy['foo'].should be_nil |
| 62 | | end |
| 63 | | end |
| toggle raw diff |
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/ivar_proxy_spec.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-describe "IvarProxy setup", :shared => true do
- before do
- @object = Object.new
- @proxy = Spec::Rails::Example::IvarProxy.new(@object)
- end
-end
-
-describe "IvarProxy" do
- it_should_behave_like "IvarProxy setup"
-
- it "has [] accessor" do
- @proxy['foo'] = 'bar'
- @object.instance_variable_get(:@foo).should == 'bar'
- @proxy['foo'].should == 'bar'
- end
-
- it "iterates through each element like a Hash" do
- values = {
- 'foo' => 1,
- 'bar' => 2,
- 'baz' => 3
- }
- @proxy['foo'] = values['foo']
- @proxy['bar'] = values['bar']
- @proxy['baz'] = values['baz']
-
- @proxy.each do |key, value|
- key.should == key
- value.should == values[key]
- end
- end
-
- it "detects the presence of a key" do
- @proxy['foo'] = 'bar'
- @proxy.has_key?('foo').should == true
- @proxy.has_key?('bar').should == false
- end
-end
-
-describe "IvarProxy", "#delete" do
- it_should_behave_like "IvarProxy setup"
-
- it "deletes the element with key" do
- @proxy['foo'] = 'bar'
- @proxy.delete('foo').should == 'bar'
- @proxy['foo'].should be_nil
- end
-
- it "deletes nil instance variables" do
- @proxy['foo'] = nil
- @object.instance_variables.should include("@foo")
- @proxy.delete('foo').should == nil
- @proxy['foo'].should be_nil
- @object.instance_variables.should_not include("@foo")
- end
-
- it "returns nil when key does not exist" do
- @proxy['foo'].should be_nil
- @proxy.delete('foo').should == nil
- @proxy['foo'].should be_nil
- end
-end |