mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-20 09:10:12 +01:00
Next step in upgrading Tracks to Rails 2.2. Some highlights:
* Ran rake rails:update * Added old actionwebservice framework * Updated RSpec and RSpec-Rails * Removed asset_packager plugin (not compatible, Scott no longer maintaining), and replaced with bundle_fu. See the bundle_fu README for more info. * Hacks to UJS and ARTS plugins, which are no longer supported. Probably should move off both UJS and RJS. * Hack to flashobject_helper plugin (upgrade to Rails 2.2-compatible version if/when it comes out.) * Hack to skinny-spec plugin, for Rails 2.2 compatibility. Should check for official release. * Hacks to resource_feeder plugin, for Rails 2.2 compatibility. Should check for official release (not likely) or move off it. * Addressed some deprecation warnings. More to come. * My mobile mime type hackery is no longer necessary with new Rails features. Yay! * Updated environment.rb.tmpl with changes TODO: * Restore view specs marked pending * Fix failing integration tests. * Try selenium tests. * Investigate OpenID support. * Address deprecation warnings. * Consider moving parts of environment.rb to initializers * Address annoying config.gem warning about highline gem
This commit is contained in:
parent
6d11ebd1b0
commit
35ae5fc431
394 changed files with 15184 additions and 9936 deletions
|
|
@ -1,6 +1,6 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
require File.join(File.dirname(__FILE__), *%w[.. .. .. lib autotest rails_rspec])
|
||||
require File.join(File.dirname(__FILE__), *%w[.. .. .. .. rspec spec autotest_matchers])
|
||||
require File.join(File.dirname(__FILE__), *%w[.. .. .. .. rspec spec autotest autotest_matchers])
|
||||
|
||||
describe Autotest::RailsRspec, "file mapping" do
|
||||
before(:each) do
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "autotest", "rails_rspec")
|
||||
|
||||
describe Autotest::RailsRspec do
|
||||
it "should provide the correct spec_command" do
|
||||
Autotest::RailsRspec.new.spec_command.should == "script/spec"
|
||||
end
|
||||
end
|
||||
|
|
@ -1,31 +1,51 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe "AssignsHashProxy" do
|
||||
before(:each) do
|
||||
@object = Object.new
|
||||
@assigns = Hash.new
|
||||
@object.stub!(:assigns).and_return(@assigns)
|
||||
@proxy = Spec::Rails::Example::AssignsHashProxy.new(@object)
|
||||
def orig_assigns
|
||||
@object.assigns
|
||||
end
|
||||
|
||||
it "has [] accessor" do
|
||||
|
||||
before(:each) do
|
||||
@object = Class.new do
|
||||
attr_accessor :assigns
|
||||
end.new
|
||||
@object.assigns = Hash.new
|
||||
@proxy = Spec::Rails::Example::AssignsHashProxy.new self do
|
||||
@object
|
||||
end
|
||||
end
|
||||
|
||||
it "should set ivars on object using string" do
|
||||
@proxy['foo'] = 'bar'
|
||||
@assigns['foo'].should == 'bar'
|
||||
@object.instance_eval{@foo}.should == 'bar'
|
||||
end
|
||||
|
||||
it "should set ivars on object using symbol" do
|
||||
@proxy[:foo] = 'bar'
|
||||
@object.instance_eval{@foo}.should == 'bar'
|
||||
end
|
||||
|
||||
it "should access object's assigns with a string" do
|
||||
@object.assigns['foo'] = 'bar'
|
||||
@proxy['foo'].should == 'bar'
|
||||
end
|
||||
|
||||
it "works for symbol key" do
|
||||
@assigns[:foo] = 2
|
||||
@proxy[:foo].should == 2
|
||||
|
||||
it "should access object's assigns with a symbol" do
|
||||
@object.assigns['foo'] = 'bar'
|
||||
@proxy[:foo].should == 'bar'
|
||||
end
|
||||
|
||||
it "checks for string key before symbol key" do
|
||||
@assigns['foo'] = false
|
||||
@assigns[:foo] = 2
|
||||
@proxy[:foo].should == false
|
||||
it "should access object's ivars with a string" do
|
||||
@object.instance_variable_set('@foo', 'bar')
|
||||
@proxy['foo'].should == 'bar'
|
||||
end
|
||||
|
||||
it "should access object's ivars with a symbol" do
|
||||
@object.instance_variable_set('@foo', 'bar')
|
||||
@proxy[:foo].should == 'bar'
|
||||
end
|
||||
|
||||
it "each method iterates through each element like a Hash" do
|
||||
it "should iterate through each element like a Hash" do
|
||||
values = {
|
||||
'foo' => 1,
|
||||
'bar' => 2,
|
||||
|
|
@ -34,27 +54,43 @@ describe "AssignsHashProxy" do
|
|||
@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 "delete method deletes the element of passed in key" do
|
||||
@proxy['foo'] = 'bar'
|
||||
@proxy.delete('foo').should == 'bar'
|
||||
|
||||
it "should delete the ivar of passed in key" do
|
||||
@object.instance_variable_set('@foo', 'bar')
|
||||
@proxy.delete('foo')
|
||||
@proxy['foo'].should be_nil
|
||||
end
|
||||
|
||||
it "has_key? detects the presence of a key" do
|
||||
@proxy['foo'] = 'bar'
|
||||
|
||||
it "should delete the assigned element of passed in key" do
|
||||
@object.assigns['foo'] = 'bar'
|
||||
@proxy.delete('foo')
|
||||
@proxy['foo'].should be_nil
|
||||
end
|
||||
|
||||
it "should detect the presence of a key in assigns" do
|
||||
@object.assigns['foo'] = 'bar'
|
||||
@proxy.has_key?('foo').should == true
|
||||
@proxy.has_key?('bar').should == false
|
||||
end
|
||||
|
||||
it "should sets an instance var" do
|
||||
@proxy['foo'] = 'bar'
|
||||
@object.instance_eval { @foo }.should == 'bar'
|
||||
it "should expose values set in example back to the example" do
|
||||
@proxy[:foo] = 'bar'
|
||||
@proxy[:foo].should == 'bar'
|
||||
end
|
||||
|
||||
it "should allow assignment of false via proxy" do
|
||||
@proxy['foo'] = false
|
||||
@proxy['foo'].should be_false
|
||||
end
|
||||
|
||||
it "should allow assignment of false" do
|
||||
@object.instance_variable_set('@foo',false)
|
||||
@proxy['foo'].should be_false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ require 'controller_spec_controller'
|
|||
describe "A controller example running in #{mode} mode", :type => :controller do
|
||||
controller_name :controller_spec
|
||||
integrate_views if mode == 'integration'
|
||||
|
||||
|
||||
specify "this example should be pending, not an error"
|
||||
|
||||
it "should provide controller.session as session" do
|
||||
get 'action_with_template'
|
||||
session.should equal(controller.session)
|
||||
|
|
@ -38,24 +40,24 @@ require 'controller_spec_controller'
|
|||
response.should render_template("_partial")
|
||||
end
|
||||
|
||||
it "should allow specifying a partial with expect_render" do
|
||||
controller.expect_render(:partial => "controller_spec/partial")
|
||||
it "should allow specifying a partial with should_receive(:render)" do
|
||||
controller.should_receive(:render).with(:partial => "controller_spec/partial")
|
||||
get 'action_with_partial'
|
||||
end
|
||||
|
||||
it "should allow specifying a partial with expect_render with object" do
|
||||
controller.expect_render(:partial => "controller_spec/partial", :object => "something")
|
||||
it "should allow specifying a partial with should_receive(:render) with object" do
|
||||
controller.should_receive(:render).with(:partial => "controller_spec/partial", :object => "something")
|
||||
get 'action_with_partial_with_object', :thing => "something"
|
||||
end
|
||||
|
||||
it "should allow specifying a partial with expect_render with locals" do
|
||||
controller.expect_render(:partial => "controller_spec/partial", :locals => {:thing => "something"})
|
||||
it "should allow specifying a partial with should_receive(:render) with locals" do
|
||||
controller.should_receive(:render).with(:partial => "controller_spec/partial", :locals => {:thing => "something"})
|
||||
get 'action_with_partial_with_locals', :thing => "something"
|
||||
end
|
||||
|
||||
it "should yield to render :update" do
|
||||
template = stub("template")
|
||||
controller.expect_render(:update).and_yield(template)
|
||||
controller.should_receive(:render).with(:update).and_yield(template)
|
||||
template.should_receive(:replace).with(:bottom, "replace_me", :partial => "non_existent_partial")
|
||||
get 'action_with_render_update'
|
||||
end
|
||||
|
|
@ -87,6 +89,71 @@ require 'controller_spec_controller'
|
|||
end.should_not raise_error
|
||||
end
|
||||
|
||||
describe "handling should_receive(:render)" do
|
||||
it "should warn" do
|
||||
controller.should_receive(:render).with(:template => "controller_spec/action_with_template")
|
||||
get :action_with_template
|
||||
end
|
||||
end
|
||||
|
||||
describe "handling should_not_receive(:render)" do
|
||||
it "should warn" do
|
||||
controller.should_not_receive(:render).with(:template => "the/wrong/template")
|
||||
get :action_with_template
|
||||
end
|
||||
end
|
||||
|
||||
describe "handling deprecated expect_render" do
|
||||
it "should warn" do
|
||||
Kernel.should_receive(:warn).with(/expect_render is deprecated/)
|
||||
controller.expect_render(:template => "controller_spec/action_with_template")
|
||||
get :action_with_template
|
||||
end
|
||||
end
|
||||
|
||||
describe "handling deprecated stub_render" do
|
||||
it "should warn" do
|
||||
Kernel.should_receive(:warn).with(/stub_render is deprecated/)
|
||||
controller.stub_render(:template => "controller_spec/action_with_template")
|
||||
get :action_with_template
|
||||
end
|
||||
end
|
||||
|
||||
describe "setting cookies in the request" do
|
||||
|
||||
it "should support a String key" do
|
||||
cookies['cookie_key'] = 'cookie value'
|
||||
get 'action_which_gets_cookie', :expected => "cookie value"
|
||||
end
|
||||
|
||||
it "should support a Symbol key" do
|
||||
cookies[:cookie_key] = 'cookie value'
|
||||
get 'action_which_gets_cookie', :expected => "cookie value"
|
||||
end
|
||||
|
||||
if Rails::VERSION::STRING >= "2.0.0"
|
||||
it "should support a Hash value" do
|
||||
cookies[:cookie_key] = {'value' => 'cookie value', 'path' => '/not/default'}
|
||||
get 'action_which_gets_cookie', :expected => {'value' => 'cookie value', 'path' => '/not/default'}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "reading cookies from the response" do
|
||||
|
||||
it "should support a Symbol key" do
|
||||
get 'action_which_sets_cookie', :value => "cookie value"
|
||||
cookies[:cookie_key].value.should == ["cookie value"]
|
||||
end
|
||||
|
||||
it "should support a String key" do
|
||||
get 'action_which_sets_cookie', :value => "cookie value"
|
||||
cookies['cookie_key'].value.should == ["cookie value"]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it "should support custom routes" do
|
||||
route_for(:controller => "custom_route_spec", :action => "custom_route").should == "/custom_route"
|
||||
end
|
||||
|
|
@ -108,22 +175,9 @@ require 'controller_spec_controller'
|
|||
assigns[:indirect_assigns_key].should == :indirect_assigns_key_value
|
||||
end
|
||||
|
||||
it "should expose the assigns hash directly" do
|
||||
get 'action_setting_the_assigns_hash'
|
||||
assigns[:direct_assigns_key].should == :direct_assigns_key_value
|
||||
end
|
||||
|
||||
it "should complain when calling should_receive(:render) on the controller" do
|
||||
lambda {
|
||||
controller.should_receive(:render)
|
||||
}.should raise_error(RuntimeError, /should_receive\(:render\) has been disabled/)
|
||||
end
|
||||
|
||||
it "should complain when calling stub!(:render) on the controller" do
|
||||
controller.extend Spec::Mocks::Methods
|
||||
lambda {
|
||||
controller.stub!(:render)
|
||||
}.should raise_error(RuntimeError, /stub!\(:render\) has been disabled/)
|
||||
it "should expose instance vars through the assigns hash that are set to false" do
|
||||
get 'action_that_assigns_false_to_a_variable'
|
||||
assigns[:a_variable].should be_false
|
||||
end
|
||||
|
||||
it "should NOT complain when calling should_receive with arguments other than :render" do
|
||||
|
|
@ -132,6 +186,12 @@ require 'controller_spec_controller'
|
|||
controller.rspec_verify
|
||||
}.should raise_error(Exception, /expected :anything_besides_render/)
|
||||
end
|
||||
|
||||
it "should not run a skipped before_filter" do
|
||||
lambda {
|
||||
get 'action_with_skipped_before_filter'
|
||||
}.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe "Given a controller spec for RedirectSpecController running in #{mode} mode", :type => :controller do
|
||||
|
|
@ -172,6 +232,19 @@ require 'controller_spec_controller'
|
|||
|
||||
end
|
||||
|
||||
['integration', 'isolation'].each do |mode|
|
||||
describe "A controller example running in #{mode} mode", :type => :controller do
|
||||
controller_name :controller_inheriting_from_application_controller
|
||||
integrate_views if mode == 'integration'
|
||||
|
||||
it "should only have a before filter inherited from ApplicationController run once..." do
|
||||
controller.should_receive(:i_should_only_be_run_once).once
|
||||
get :action_with_inherited_before_filter
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe ControllerSpecController, :type => :controller do
|
||||
it "should not require naming the controller if describe is passed a type" do
|
||||
end
|
||||
|
|
|
|||
74
vendor/plugins/rspec-rails/spec/rails/example/cookies_proxy_spec.rb
vendored
Normal file
74
vendor/plugins/rspec-rails/spec/rails/example/cookies_proxy_spec.rb
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
class CookiesProxyExamplesController < ActionController::Base
|
||||
def index
|
||||
cookies[:key] = cookies[:key]
|
||||
end
|
||||
end
|
||||
|
||||
module Spec
|
||||
module Rails
|
||||
module Example
|
||||
describe CookiesProxy, :type => :controller do
|
||||
controller_name :cookies_proxy_examples
|
||||
|
||||
describe "with a String key" do
|
||||
|
||||
it "should accept a String value" do
|
||||
cookies = CookiesProxy.new(self)
|
||||
cookies['key'] = 'value'
|
||||
get :index
|
||||
cookies['key'].should == ['value']
|
||||
end
|
||||
|
||||
if Rails::VERSION::STRING >= "2.0.0"
|
||||
it "should accept a Hash value" do
|
||||
cookies = CookiesProxy.new(self)
|
||||
cookies['key'] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' }
|
||||
get :index
|
||||
cookies['key'].should == ['value']
|
||||
cookies['key'].value.should == ['value']
|
||||
cookies['key'].expires.should == expiration
|
||||
cookies['key'].path.should == path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "with a Symbol key" do
|
||||
|
||||
it "should accept a String value" do
|
||||
example_cookies = CookiesProxy.new(self)
|
||||
example_cookies[:key] = 'value'
|
||||
get :index
|
||||
example_cookies[:key].should == ['value']
|
||||
end
|
||||
|
||||
if Rails::VERSION::STRING >= "2.0.0"
|
||||
it "should accept a Hash value" do
|
||||
example_cookies = CookiesProxy.new(self)
|
||||
example_cookies[:key] = { :value => 'value', :expires => expiration = 1.hour.from_now, :path => path = '/path' }
|
||||
get :index
|
||||
example_cookies[:key].should == ['value']
|
||||
example_cookies[:key].value.should == ['value']
|
||||
example_cookies[:key].expires.should == expiration
|
||||
example_cookies[:key].path.should == path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#delete" do
|
||||
it "should delete from the response cookies" do
|
||||
example_cookies = CookiesProxy.new(self)
|
||||
response_cookies = mock('cookies')
|
||||
response.should_receive(:cookies).and_return(response_cookies)
|
||||
response_cookies.should_receive(:delete).with('key')
|
||||
example_cookies.delete :key
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -82,14 +82,14 @@ describe "A template that includes a partial", :type => :view do
|
|||
response.should have_tag('div', "This is text from a method in the ApplicationHelper")
|
||||
end
|
||||
|
||||
it "should pass expect_render with the right partial" do
|
||||
template.expect_render(:partial => 'partial')
|
||||
it "should pass should_receive(:render) with the right partial" do
|
||||
template.should_receive(:render).with(:partial => 'partial')
|
||||
render!
|
||||
template.verify_rendered
|
||||
end
|
||||
|
||||
it "should fail expect_render with the wrong partial" do
|
||||
template.expect_render(:partial => 'non_existent')
|
||||
it "should fail should_receive(:render) with the wrong partial" do
|
||||
template.should_receive(:render).with(:partial => 'non_existent')
|
||||
render!
|
||||
begin
|
||||
template.verify_rendered
|
||||
|
|
@ -99,14 +99,14 @@ describe "A template that includes a partial", :type => :view do
|
|||
end
|
||||
end
|
||||
|
||||
it "should pass expect_render when a partial is expected twice and happens twice" do
|
||||
template.expect_render(:partial => 'partial_used_twice').twice
|
||||
it "should pass should_receive(:render) when a partial is expected twice and happens twice" do
|
||||
template.should_receive(:render).with(:partial => 'partial_used_twice').twice
|
||||
render!
|
||||
template.verify_rendered
|
||||
end
|
||||
|
||||
it "should pass expect_render when a partial is expected once and happens twice" do
|
||||
template.expect_render(:partial => 'partial_used_twice')
|
||||
it "should pass should_receive(:render) when a partial is expected once and happens twice" do
|
||||
template.should_receive(:render).with(:partial => 'partial_used_twice')
|
||||
render!
|
||||
begin
|
||||
template.verify_rendered
|
||||
|
|
@ -116,17 +116,17 @@ describe "A template that includes a partial", :type => :view do
|
|||
end
|
||||
end
|
||||
|
||||
it "should fail expect_render with the right partial but wrong options" do
|
||||
template.expect_render(:partial => 'partial', :locals => {:thing => Object.new})
|
||||
it "should fail should_receive(:render) with the right partial but wrong options" do
|
||||
template.should_receive(:render).with(:partial => 'partial', :locals => {:thing => Object.new})
|
||||
render!
|
||||
lambda {template.verify_rendered}.should raise_error(Spec::Mocks::MockExpectationError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "A partial that includes a partial", :type => :view do
|
||||
it "should support expect_render with nested partial" do
|
||||
it "should support should_receive(:render) with nested partial" do
|
||||
obj = Object.new
|
||||
template.expect_render(:partial => 'partial', :object => obj)
|
||||
template.should_receive(:render).with(:partial => 'partial', :object => obj)
|
||||
render :partial => "view_spec/partial_with_sub_partial", :locals => { :partial => obj }
|
||||
end
|
||||
end
|
||||
|
|
@ -141,7 +141,7 @@ describe "A view that includes a partial using :collection and :spacer_template"
|
|||
end
|
||||
|
||||
it "should render the partial" do
|
||||
template.expect_render(:partial => 'partial',
|
||||
template.should_receive(:render).with(:partial => 'partial',
|
||||
:collection => ['Alice', 'Bob'],
|
||||
:spacer_template => 'spacer')
|
||||
render "view_spec/template_with_partial_using_collection"
|
||||
|
|
@ -149,37 +149,19 @@ describe "A view that includes a partial using :collection and :spacer_template"
|
|||
|
||||
end
|
||||
|
||||
describe "A view that includes a partial using an array as partial_path", :type => :view do
|
||||
before(:each) do
|
||||
module ActionView::Partials
|
||||
def render_template_with_partial_with_array_support(partial_path, local_assigns = nil, deprecated_local_assigns = nil)
|
||||
if partial_path.is_a?(Array)
|
||||
"Array Partial"
|
||||
else
|
||||
render_partial_without_array_support(partial_path, local_assigns, deprecated_local_assigns)
|
||||
end
|
||||
end
|
||||
|
||||
alias :render_partial_without_array_support :render_partial
|
||||
alias :render_partial :render_template_with_partial_with_array_support
|
||||
if Rails::VERSION::MAJOR >= 2
|
||||
describe "A view that includes a partial using an array as partial_path", :type => :view do
|
||||
before(:each) do
|
||||
renderable_object = Object.new
|
||||
renderable_object.stub!(:name).and_return("Renderable Object")
|
||||
assigns[:array] = [renderable_object]
|
||||
end
|
||||
|
||||
@array = ['Alice', 'Bob']
|
||||
assigns[:array] = @array
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
module ActionView::Partials
|
||||
alias :render_template_with_partial_with_array_support :render_partial
|
||||
alias :render_partial :render_partial_without_array_support
|
||||
undef render_template_with_partial_with_array_support
|
||||
it "should render the array passed through to render_partial without modification" do
|
||||
render "view_spec/template_with_partial_with_array"
|
||||
response.body.should match(/^Renderable Object$/)
|
||||
end
|
||||
end
|
||||
|
||||
it "should render have the array passed through to render_partial without modification" do
|
||||
render "view_spec/template_with_partial_with_array"
|
||||
response.body.should match(/^Array Partial$/)
|
||||
end
|
||||
end
|
||||
|
||||
describe "Different types of renders (not :template)", :type => :view do
|
||||
|
|
@ -239,6 +221,20 @@ describe "An instantiated ViewExampleGroupController", :type => :view do
|
|||
end
|
||||
end
|
||||
|
||||
describe "a block helper", :type => :view do
|
||||
it "should not yield when not told to in the example" do
|
||||
template.should_receive(:if_allowed)
|
||||
render "view_spec/block_helper"
|
||||
response.should_not have_tag("div","block helper was rendered")
|
||||
end
|
||||
|
||||
it "should yield when told to in the example" do
|
||||
template.should_receive(:if_allowed).and_yield
|
||||
render "view_spec/block_helper"
|
||||
response.should have_tag("div","block helper was rendered")
|
||||
end
|
||||
end
|
||||
|
||||
describe "render :inline => ...", :type => :view do
|
||||
it "should render ERB right in the spec" do
|
||||
render :inline => %|<%= text_field_tag('field_name', 'Value') %>|
|
||||
|
|
@ -270,3 +266,15 @@ module Spec
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "bug http://rspec.lighthouseapp.com/projects/5645/tickets/510", :type => :view do
|
||||
describe "a view example with should_not_receive" do
|
||||
it "should render the view" do
|
||||
obj = mock('model')
|
||||
obj.should_receive(:render_partial?).and_return false
|
||||
assigns[:obj] = obj
|
||||
template.should_not_receive(:render).with(:partial => 'some_partial')
|
||||
render "view_spec/should_not_receive"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,44 +3,44 @@ require 'spec/mocks/errors'
|
|||
|
||||
describe ActionView::Base, "with RSpec extensions:", :type => :view do
|
||||
|
||||
describe "expect_render" do
|
||||
describe "should_receive(:render)" do
|
||||
it "should not raise when render has been received" do
|
||||
template.expect_render(:partial => "name")
|
||||
template.should_receive(:render).with(:partial => "name")
|
||||
template.render :partial => "name"
|
||||
end
|
||||
|
||||
it "should raise when render has NOT been received" do
|
||||
template.expect_render(:partial => "name")
|
||||
template.should_receive(:render).with(:partial => "name")
|
||||
lambda {
|
||||
template.verify_rendered
|
||||
}.should raise_error
|
||||
end
|
||||
|
||||
it "should return something (like a normal mock)" do
|
||||
template.expect_render(:partial => "name").and_return("Little Johnny")
|
||||
template.should_receive(:render).with(:partial => "name").and_return("Little Johnny")
|
||||
result = template.render :partial => "name"
|
||||
result.should == "Little Johnny"
|
||||
end
|
||||
end
|
||||
|
||||
describe "stub_render" do
|
||||
describe "stub!(:render)" do
|
||||
it "should not raise when stubbing and render has been received" do
|
||||
template.stub_render(:partial => "name")
|
||||
template.stub!(:render).with(:partial => "name")
|
||||
template.render :partial => "name"
|
||||
end
|
||||
|
||||
it "should not raise when stubbing and render has NOT been received" do
|
||||
template.stub_render(:partial => "name")
|
||||
template.stub!(:render).with(:partial => "name")
|
||||
end
|
||||
|
||||
it "should not raise when stubbing and render has been received with different options" do
|
||||
template.stub_render(:partial => "name")
|
||||
template.stub!(:render).with(:partial => "name")
|
||||
template.render :partial => "view_spec/spacer"
|
||||
end
|
||||
|
||||
it "should not raise when stubbing and expecting and render has been received" do
|
||||
template.stub_render(:partial => "name")
|
||||
template.expect_render(:partial => "name")
|
||||
template.stub!(:render).with(:partial => "name")
|
||||
template.should_receive(:render).with(:partial => "name")
|
||||
template.render(:partial => "name")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
66
vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb
vendored
Normal file
66
vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
|
||||
if ActiveSupport.const_defined?(:Callbacks) && Test::Unit::TestCase.include?(ActiveSupport::Callbacks)
|
||||
|
||||
class TestUnitTesting < Test::Unit::TestCase
|
||||
@@setup_callback_count = 0
|
||||
@@setup_method_count = 0
|
||||
@@teardown_callback_count = 0
|
||||
@@teardown_method_count = 0
|
||||
cattr_accessor :setup_callback_count, :setup_method_count, :teardown_callback_count, :teardown_method_count
|
||||
|
||||
setup :do_some_setup
|
||||
teardown :do_some_teardown
|
||||
|
||||
@@has_been_run = false
|
||||
def self.run?
|
||||
@@has_been_run
|
||||
end
|
||||
|
||||
def do_some_setup
|
||||
@@setup_callback_count += 1
|
||||
end
|
||||
|
||||
def setup
|
||||
@@setup_method_count += 1
|
||||
end
|
||||
|
||||
def test_something
|
||||
assert_equal true, true
|
||||
@@has_been_run = true
|
||||
end
|
||||
|
||||
def teardown
|
||||
@@teardown_method_count += 1
|
||||
end
|
||||
|
||||
def do_some_teardown
|
||||
@@teardown_callback_count += 1
|
||||
end
|
||||
end
|
||||
|
||||
module Test
|
||||
module Unit
|
||||
describe "Running TestCase tests" do
|
||||
before(:all) do
|
||||
TestUnitTesting.run unless TestUnitTesting.run?
|
||||
end
|
||||
|
||||
it "should call the setup callbacks" do
|
||||
TestUnitTesting.setup_callback_count.should == 1
|
||||
end
|
||||
it "should still only call the normal setup method once" do
|
||||
TestUnitTesting.setup_method_count.should == 1
|
||||
end
|
||||
it "should call the teardown callbacks" do
|
||||
TestUnitTesting.teardown_callback_count.should == 1
|
||||
end
|
||||
it "should still only call the normal teardown method once" do
|
||||
TestUnitTesting.teardown_method_count.should == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -601,9 +601,6 @@ describe "have_rjs behaviour_type", :type => :controller do
|
|||
with_tag("div", 1)
|
||||
with_tag("#1")
|
||||
end
|
||||
lambda {
|
||||
response.should have_rjs(:insert, :top, "test2")
|
||||
}.should raise_error(SpecFailed)
|
||||
response.should have_rjs(:insert, :bottom) {|rjs|
|
||||
with_tag("div", 1)
|
||||
with_tag("#2")
|
||||
|
|
@ -629,6 +626,17 @@ describe "have_rjs behaviour_type", :type => :controller do
|
|||
with_tag("#4")
|
||||
}
|
||||
end
|
||||
|
||||
it "should find rjs using :insert (positioned)" do
|
||||
pending("await fix for http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/982")
|
||||
render_rjs do |page|
|
||||
page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
|
||||
page.insert_html :bottom, "test2", "<div id=\"2\">bar</div>"
|
||||
end
|
||||
lambda {
|
||||
response.should have_rjs(:insert, :top, "test2")
|
||||
}.should raise_error(SpecFailed)
|
||||
end
|
||||
end
|
||||
|
||||
describe "send_email behaviour_type", :type => :controller do
|
||||
|
|
|
|||
|
|
@ -40,30 +40,24 @@ describe "include_text", :type => :controller do
|
|||
response.should include_text('text for this')
|
||||
end
|
||||
|
||||
it "should fail with matching text" do
|
||||
it "should fail with incorrect text" do
|
||||
post 'text_action'
|
||||
lambda {
|
||||
response.should include_text("this is NOT the text for this action")
|
||||
}.should fail_with("expected to find \"this is NOT the text for this action\" in \"this is the text for this action\"")
|
||||
end
|
||||
|
||||
it "should fail when a template is rendered" do
|
||||
post 'some_action'
|
||||
failure_message = case mode
|
||||
when 'isolation'
|
||||
/expected to find \"this is the text for this action\" in \"render_spec\/some_action\"/
|
||||
when 'integration'
|
||||
/expected to find \"this is the text for this action\" in \"\"/
|
||||
end
|
||||
lambda {
|
||||
response.should include_text("this is the text for this action")
|
||||
}.should fail_with(failure_message)
|
||||
response.should include_text("the accordian guy")
|
||||
}.should fail_with("expected to find \"the accordian guy\" in \"this is the text for this action\"")
|
||||
end
|
||||
|
||||
it "should pass using should_not with incorrect text" do
|
||||
post 'text_action'
|
||||
response.should_not include_text("the accordian guy")
|
||||
end
|
||||
|
||||
it "should fail when a template is rendered" do
|
||||
get 'some_action'
|
||||
lambda {
|
||||
response.should include_text("this is the text for this action")
|
||||
}.should fail_with(/expected to find \"this is the text for this action\"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|||
integrate_views
|
||||
end
|
||||
controller_name :redirect_spec
|
||||
|
||||
|
||||
it "redirected to another action" do
|
||||
get 'action_with_redirect_to_somewhere'
|
||||
response.should redirect_to(:action => 'somewhere')
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|||
if mode == 'integration'
|
||||
integrate_views
|
||||
end
|
||||
|
||||
|
||||
it "should match a simple path" do
|
||||
post 'some_action'
|
||||
response.should render_template('some_action')
|
||||
|
|
@ -27,7 +27,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|||
post 'some_action'
|
||||
response.should render_template(:some_action)
|
||||
end
|
||||
|
||||
|
||||
it "should match an rjs template" do
|
||||
xhr :post, 'some_action'
|
||||
if Rails::VERSION::STRING < "2.0.0"
|
||||
|
|
@ -36,50 +36,57 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|||
response.should render_template('render_spec/some_action')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it "should match a partial template (simple path)" do
|
||||
get 'action_with_partial'
|
||||
response.should render_template("_a_partial")
|
||||
end
|
||||
|
||||
|
||||
it "should match a partial template (complex path)" do
|
||||
get 'action_with_partial'
|
||||
response.should render_template("render_spec/_a_partial")
|
||||
end
|
||||
|
||||
|
||||
it "should fail when the wrong template is rendered" do
|
||||
post 'some_action'
|
||||
lambda do
|
||||
response.should render_template('non_existent_template')
|
||||
end.should fail_with("expected \"non_existent_template\", got \"render_spec/some_action\"")
|
||||
end.should fail_with(/expected \"non_existent_template\", got \"render_spec\/some_action(.rhtml)?\"/)
|
||||
end
|
||||
|
||||
|
||||
it "should fail without full path when template is associated with a different controller" do
|
||||
post 'action_which_renders_template_from_other_controller'
|
||||
lambda do
|
||||
response.should render_template('action_with_template')
|
||||
end.should fail_with(%Q|expected "action_with_template", got "controller_spec/action_with_template"|)
|
||||
end.should fail_with(/expected \"action_with_template\", got \"controller_spec\/action_with_template(.rhtml)?\"/)
|
||||
end
|
||||
|
||||
|
||||
it "should fail with incorrect full path when template is associated with a different controller" do
|
||||
post 'action_which_renders_template_from_other_controller'
|
||||
lambda do
|
||||
response.should render_template('render_spec/action_with_template')
|
||||
end.should fail_with(%Q|expected "render_spec/action_with_template", got "controller_spec/action_with_template"|)
|
||||
end.should fail_with(/expected \"render_spec\/action_with_template\", got \"controller_spec\/action_with_template(\.rhtml)?\"/)
|
||||
end
|
||||
|
||||
|
||||
it "should fail on the wrong extension (given rhtml)" do
|
||||
get 'some_action'
|
||||
lambda {
|
||||
response.should render_template('render_spec/some_action.rjs')
|
||||
}.should fail_with("expected \"render_spec/some_action.rjs\", got \"render_spec/some_action\"")
|
||||
}.should fail_with(/expected \"render_spec\/some_action\.rjs\", got \"render_spec\/some_action(\.rhtml)?\"/)
|
||||
end
|
||||
|
||||
|
||||
it "should fail when TEXT is rendered" do
|
||||
post 'text_action'
|
||||
lambda do
|
||||
response.should render_template('some_action')
|
||||
end.should fail_with("expected \"some_action\", got nil")
|
||||
end.should fail_with(/expected \"some_action\", got (nil|\"\")/)
|
||||
end
|
||||
|
||||
describe "with an alternate layout" do
|
||||
it "should say it rendered the action's template" do
|
||||
get 'action_with_alternate_layout'
|
||||
response.should render_template('action_with_alternate_layout')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
15
vendor/plugins/rspec-rails/spec/rails/matchers/should_change_spec.rb
vendored
Normal file
15
vendor/plugins/rspec-rails/spec/rails/matchers/should_change_spec.rb
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe "should change" do
|
||||
describe "handling association proxies" do
|
||||
it "should match expected collection with proxied collection" do
|
||||
person = Person.create!(:name => 'David')
|
||||
koala = person.animals.create!(:name => 'Koala')
|
||||
zebra = person.animals.create!(:name => 'Zebra')
|
||||
|
||||
lambda {
|
||||
person.animals.delete(koala)
|
||||
}.should change{person.animals}.to([zebra])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -2,63 +2,105 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|||
require File.dirname(__FILE__) + '/ar_classes'
|
||||
|
||||
describe "mock_model" do
|
||||
before(:each) do
|
||||
@model = mock_model(SubMockableModel)
|
||||
describe "responding to interrogation" do
|
||||
before(:each) do
|
||||
@model = mock_model(SubMockableModel)
|
||||
end
|
||||
it "should say it is_a? if it is" do
|
||||
@model.is_a?(SubMockableModel).should be(true)
|
||||
end
|
||||
it "should say it is_a? if it's ancestor is" do
|
||||
@model.is_a?(MockableModel).should be(true)
|
||||
end
|
||||
it "should say it is kind_of? if it is" do
|
||||
@model.kind_of?(SubMockableModel).should be(true)
|
||||
end
|
||||
it "should say it is kind_of? if it's ancestor is" do
|
||||
@model.kind_of?(MockableModel).should be(true)
|
||||
end
|
||||
it "should say it is instance_of? if it is" do
|
||||
@model.instance_of?(SubMockableModel).should be(true)
|
||||
end
|
||||
it "should not say it instance_of? if it isn't, even if it's ancestor is" do
|
||||
@model.instance_of?(MockableModel).should be(false)
|
||||
end
|
||||
end
|
||||
it "should say it is_a? if it is" do
|
||||
@model.is_a?(SubMockableModel).should be(true)
|
||||
|
||||
describe "with params" do
|
||||
it "should not mutate its parameters" do
|
||||
params = {:a => 'b'}
|
||||
model = mock_model(MockableModel, params)
|
||||
params.should == {:a => 'b'}
|
||||
end
|
||||
end
|
||||
it "should say it is_a? if it's ancestor is" do
|
||||
@model.is_a?(MockableModel).should be(true)
|
||||
|
||||
describe "with #id stubbed", :type => :view do
|
||||
before(:each) do
|
||||
@model = mock_model(MockableModel, :id => 1)
|
||||
end
|
||||
it "should be named using the stubbed id value" do
|
||||
@model.instance_variable_get(:@name).should == "MockableModel_1"
|
||||
end
|
||||
it "should return string of id value for to_param" do
|
||||
@model.to_param.should == "1"
|
||||
end
|
||||
end
|
||||
it "should say it is kind_of? if it is" do
|
||||
@model.kind_of?(SubMockableModel).should be(true)
|
||||
|
||||
describe "as association", :type => :view do
|
||||
before(:each) do
|
||||
@real = AssociatedModel.create!
|
||||
@mock_model = mock_model(MockableModel)
|
||||
@real.mockable_model = @mock_model
|
||||
end
|
||||
|
||||
it "should pass associated_model == mock" do
|
||||
@mock_model.should == @real.mockable_model
|
||||
end
|
||||
|
||||
it "should pass mock == associated_model" do
|
||||
@real.mockable_model.should == @mock_model
|
||||
end
|
||||
end
|
||||
it "should say it is kind_of? if it's ancestor is" do
|
||||
@model.kind_of?(MockableModel).should be(true)
|
||||
|
||||
describe "with :null_object => true", :type => :view do
|
||||
before(:each) do
|
||||
@model = mock_model(MockableModel, :null_object => true, :mocked_method => "mocked")
|
||||
end
|
||||
|
||||
it "should be able to mock methods" do
|
||||
@model.mocked_method.should == "mocked"
|
||||
end
|
||||
it "should return itself to unmocked methods" do
|
||||
@model.unmocked_method.should equal(@model)
|
||||
end
|
||||
end
|
||||
it "should say it is instance_of? if it is" do
|
||||
@model.instance_of?(SubMockableModel).should be(true)
|
||||
|
||||
describe "#as_null_object", :type => :view do
|
||||
before(:each) do
|
||||
@model = mock_model(MockableModel, :mocked_method => "mocked").as_null_object
|
||||
end
|
||||
|
||||
it "should be able to mock methods" do
|
||||
@model.mocked_method.should == "mocked"
|
||||
end
|
||||
it "should return itself to unmocked methods" do
|
||||
@model.unmocked_method.should equal(@model)
|
||||
end
|
||||
end
|
||||
it "should not say it instance_of? if it isn't, even if it's ancestor is" do
|
||||
@model.instance_of?(MockableModel).should be(false)
|
||||
|
||||
describe "#as_new_record" do
|
||||
it "should say it is a new record" do
|
||||
mock_model(MockableModel).as_new_record.should be_new_record
|
||||
end
|
||||
|
||||
it "should have a nil id" do
|
||||
mock_model(MockableModel).as_new_record.id.should be(nil)
|
||||
end
|
||||
|
||||
it "should return nil for #to_param" do
|
||||
mock_model(MockableModel).as_new_record.to_param.should be(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "mock_model with stubbed id", :type => :view do
|
||||
before(:each) do
|
||||
@model = mock_model(MockableModel, :id => 1)
|
||||
end
|
||||
it "should be named using the stubbed id value" do
|
||||
@model.instance_variable_get(:@name).should == "MockableModel_1"
|
||||
end
|
||||
end
|
||||
|
||||
describe "mock_model with null_object", :type => :view do
|
||||
before(:each) do
|
||||
@model = mock_model(MockableModel, :null_object => true, :mocked_method => "mocked")
|
||||
end
|
||||
|
||||
it "should be able to mock methods" do
|
||||
@model.mocked_method.should == "mocked"
|
||||
end
|
||||
it "should return itself to unmocked methods" do
|
||||
@model.unmocked_method.should equal(@model)
|
||||
end
|
||||
end
|
||||
|
||||
describe "mock_model as association", :type => :view do
|
||||
before(:each) do
|
||||
@real = AssociatedModel.create!
|
||||
@mock_model = mock_model(MockableModel)
|
||||
@real.mockable_model = @mock_model
|
||||
end
|
||||
|
||||
it "should pass associated_model == mock" do
|
||||
@mock_model.should == @real.mockable_model
|
||||
end
|
||||
|
||||
it "should pass mock == associated_model" do
|
||||
@real.mockable_model.should == @mock_model
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -51,29 +51,30 @@ describe "stub_model" do
|
|||
second.id.should == (first.id + 1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "stub_model as association" do
|
||||
before(:each) do
|
||||
@real = AssociatedModel.create!
|
||||
@stub_model = stub_model(MockableModel)
|
||||
@real.mockable_model = @stub_model
|
||||
end
|
||||
|
||||
it "should pass associated_model == mock" do
|
||||
@stub_model.should == @real.mockable_model
|
||||
end
|
||||
|
||||
it "should pass mock == associated_model" do
|
||||
@real.mockable_model.should == @stub_model
|
||||
end
|
||||
end
|
||||
|
||||
describe "stub_model with a block" do
|
||||
it "should yield the model" do
|
||||
model = stub_model(MockableModel) do |block_arg|
|
||||
@block_arg = block_arg
|
||||
describe "as association" do
|
||||
before(:each) do
|
||||
@real = AssociatedModel.create!
|
||||
@stub_model = stub_model(MockableModel)
|
||||
@real.mockable_model = @stub_model
|
||||
end
|
||||
|
||||
it "should pass associated_model == mock" do
|
||||
@stub_model.should == @real.mockable_model
|
||||
end
|
||||
|
||||
it "should pass mock == associated_model" do
|
||||
@real.mockable_model.should == @stub_model
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a block" do
|
||||
it "should yield the model" do
|
||||
model = stub_model(MockableModel) do |block_arg|
|
||||
@block_arg = block_arg
|
||||
end
|
||||
model.should be(@block_arg)
|
||||
end
|
||||
model.should be(@block_arg)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,96 +1,96 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe "script/spec_server file", :shared => true do
|
||||
attr_accessor :tmbundle_install_directory
|
||||
attr_reader :animals_yml_path, :original_animals_content
|
||||
|
||||
before do
|
||||
@animals_yml_path = File.expand_path("#{RAILS_ROOT}/spec/fixtures/animals.yml")
|
||||
@original_animals_content = File.read(animals_yml_path)
|
||||
end
|
||||
|
||||
after do
|
||||
File.open(animals_yml_path, "w") do |f|
|
||||
f.write original_animals_content
|
||||
end
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
system "lsof -i tcp:8989 | sed /COMMAND/d | awk '{print $2}' | xargs kill"
|
||||
end
|
||||
|
||||
it "runs a spec" do
|
||||
dir = File.dirname(__FILE__)
|
||||
output = ""
|
||||
Timeout.timeout(10) do
|
||||
loop do
|
||||
output = `#{RAILS_ROOT}/script/spec #{dir}/sample_spec.rb --drb 2>&1`
|
||||
break unless output.include?("No server is running")
|
||||
end
|
||||
end
|
||||
|
||||
if $?.exitstatus != 0 || output !~ /0 failures/
|
||||
flunk "command 'script/spec spec/sample_spec' failed\n#{output}"
|
||||
end
|
||||
|
||||
fixtures = YAML.load(@original_animals_content)
|
||||
fixtures['pig']['name'] = "Piggy"
|
||||
|
||||
File.open(animals_yml_path, "w") do |f|
|
||||
f.write YAML.dump(fixtures)
|
||||
end
|
||||
|
||||
Timeout.timeout(10) do
|
||||
loop do
|
||||
output = `#{RAILS_ROOT}/script/spec #{dir}/sample_modified_fixture.rb --drb 2>&1`
|
||||
break unless output.include?("No server is running")
|
||||
end
|
||||
end
|
||||
|
||||
if $?.exitstatus != 0 || output !~ /0 failures/
|
||||
flunk "command 'script/spec spec/sample_modified_fixture' failed\n#{output}"
|
||||
end
|
||||
end
|
||||
|
||||
def start_spec_server
|
||||
dir = File.dirname(__FILE__)
|
||||
Thread.start do
|
||||
system "cd #{RAILS_ROOT}; script/spec_server"
|
||||
end
|
||||
|
||||
file_content = ""
|
||||
end
|
||||
end
|
||||
|
||||
describe "script/spec_server file without TextMate bundle" do
|
||||
it_should_behave_like "script/spec_server file"
|
||||
before(:each) do
|
||||
start_spec_server
|
||||
end
|
||||
end
|
||||
|
||||
describe "script/spec_server file with TextMate bundle" do
|
||||
it_should_behave_like "script/spec_server file"
|
||||
before(:each) do
|
||||
dir = File.dirname(__FILE__)
|
||||
@tmbundle_install_directory = File.expand_path("#{Dir.tmpdir}/Library/Application Support/TextMate/Bundles")
|
||||
@bundle_name = "RSpec.tmbundle"
|
||||
FileUtils.mkdir_p(tmbundle_install_directory)
|
||||
bundle_dir = File.expand_path("#{dir}/../../../../../../#{@bundle_name}")
|
||||
File.directory?(bundle_dir).should be_true
|
||||
unless system(%Q|ln -s #{bundle_dir} "#{tmbundle_install_directory}"|)
|
||||
raise "Creating link to Textmate Bundle"
|
||||
end
|
||||
start_spec_server
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
bundle_file_to_remove = "#{tmbundle_install_directory}/#{@bundle_name}"
|
||||
if bundle_file_to_remove == "/"
|
||||
raise "bundle file path resolved to '/' - could not call rm"
|
||||
end
|
||||
unless system(%Q|rm "#{bundle_file_to_remove}"|)
|
||||
raise "Removing Textmate bundle link failed"
|
||||
end
|
||||
end
|
||||
end
|
||||
# require File.dirname(__FILE__) + '/../spec_helper'
|
||||
#
|
||||
# describe "script/spec_server file", :shared => true do
|
||||
# attr_accessor :tmbundle_install_directory
|
||||
# attr_reader :animals_yml_path, :original_animals_content
|
||||
#
|
||||
# before do
|
||||
# @animals_yml_path = File.expand_path("#{RAILS_ROOT}/spec/fixtures/animals.yml")
|
||||
# @original_animals_content = File.read(animals_yml_path)
|
||||
# end
|
||||
#
|
||||
# after do
|
||||
# File.open(animals_yml_path, "w") do |f|
|
||||
# f.write original_animals_content
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# after(:each) do
|
||||
# system "lsof -i tcp:8989 | sed /COMMAND/d | awk '{print $2}' | xargs kill"
|
||||
# end
|
||||
#
|
||||
# it "runs a spec" do
|
||||
# dir = File.dirname(__FILE__)
|
||||
# output = ""
|
||||
# Timeout.timeout(10) do
|
||||
# loop do
|
||||
# output = `#{RAILS_ROOT}/script/spec #{dir}/sample_spec.rb --drb 2>&1`
|
||||
# break unless output.include?("No server is running")
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# if $?.exitstatus != 0 || output !~ /0 failures/
|
||||
# flunk "command 'script/spec spec/sample_spec' failed\n#{output}"
|
||||
# end
|
||||
#
|
||||
# fixtures = YAML.load(@original_animals_content)
|
||||
# fixtures['pig']['name'] = "Piggy"
|
||||
#
|
||||
# File.open(animals_yml_path, "w") do |f|
|
||||
# f.write YAML.dump(fixtures)
|
||||
# end
|
||||
#
|
||||
# Timeout.timeout(10) do
|
||||
# loop do
|
||||
# output = `#{RAILS_ROOT}/script/spec #{dir}/sample_modified_fixture.rb --drb 2>&1`
|
||||
# break unless output.include?("No server is running")
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# if $?.exitstatus != 0 || output !~ /0 failures/
|
||||
# flunk "command 'script/spec spec/sample_modified_fixture' failed\n#{output}"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def start_spec_server
|
||||
# dir = File.dirname(__FILE__)
|
||||
# Thread.start do
|
||||
# system "cd #{RAILS_ROOT}; script/spec_server"
|
||||
# end
|
||||
#
|
||||
# file_content = ""
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# describe "script/spec_server file without TextMate bundle" do
|
||||
# it_should_behave_like "script/spec_server file"
|
||||
# before(:each) do
|
||||
# start_spec_server
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# describe "script/spec_server file with TextMate bundle" do
|
||||
# it_should_behave_like "script/spec_server file"
|
||||
# before(:each) do
|
||||
# dir = File.dirname(__FILE__)
|
||||
# @tmbundle_install_directory = File.expand_path("#{Dir.tmpdir}/Library/Application Support/TextMate/Bundles")
|
||||
# @bundle_name = "RSpec.tmbundle"
|
||||
# FileUtils.mkdir_p(tmbundle_install_directory)
|
||||
# bundle_dir = File.expand_path("#{dir}/../../../../../../#{@bundle_name}")
|
||||
# File.directory?(bundle_dir).should be_true
|
||||
# unless system(%Q|ln -s #{bundle_dir} "#{tmbundle_install_directory}"|)
|
||||
# raise "Creating link to Textmate Bundle"
|
||||
# end
|
||||
# start_spec_server
|
||||
# end
|
||||
#
|
||||
# after(:each) do
|
||||
# bundle_file_to_remove = "#{tmbundle_install_directory}/#{@bundle_name}"
|
||||
# if bundle_file_to_remove == "/"
|
||||
# raise "bundle file path resolved to '/' - could not call rm"
|
||||
# end
|
||||
# unless system(%Q|rm "#{bundle_file_to_remove}"|)
|
||||
# raise "Removing Textmate bundle link failed"
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue