aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-07 23:39:18 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-07 23:39:18 -0300
commita83efa4a1f5214e36ef121ec6181905c2cd48a15 (patch)
tree2f7abd8584c8886f1833b8141e386041db3b3c8d /railties/test
parent57e298fcd5db0be473d4a5f644d2f5e96a62b11c (diff)
downloadrails-a83efa4a1f5214e36ef121ec6181905c2cd48a15.tar.gz
rails-a83efa4a1f5214e36ef121ec6181905c2cd48a15.tar.bz2
rails-a83efa4a1f5214e36ef121ec6181905c2cd48a15.zip
Stop using mocha on console_test
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/commands/console_test.rb55
1 files changed, 40 insertions, 15 deletions
diff --git a/railties/test/commands/console_test.rb b/railties/test/commands/console_test.rb
index 1273f9d4c2..f765143f1d 100644
--- a/railties/test/commands/console_test.rb
+++ b/railties/test/commands/console_test.rb
@@ -6,7 +6,13 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
include EnvHelpers
class FakeConsole
- def self.start; end
+ def self.started?
+ @started
+ end
+
+ def self.start
+ @started = true
+ end
end
def test_sandbox_option
@@ -25,17 +31,18 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
end
def test_start
- FakeConsole.expects(:start)
start
+
+ assert app.console.started?
assert_match(/Loading \w+ environment \(Rails/, output)
end
def test_start_with_sandbox
- app.expects(:sandbox=).with(true)
- FakeConsole.expects(:start)
-
start ["--sandbox"]
+
+ assert app.console.started?
+ assert app.sandbox
assert_match(/Loading \w+ environment in sandbox \(Rails/, output)
end
@@ -64,7 +71,7 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
end
def test_console_defaults_to_IRB
- app = build_app(console: nil)
+ app = build_app(nil)
assert_equal IRB, Rails::Console.new(app).console
end
@@ -115,8 +122,12 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
end
def test_rails_env_is_dev_when_argument_is_dev_and_dev_env_is_present
- Rails::Console.stubs(:available_environments).returns(['dev'])
- options = Rails::Console.parse_arguments(['dev'])
+ stubbed_console = Class.new(Rails::Console) do
+ def available_environments
+ ['dev']
+ end
+ end
+ options = stubbed_console.parse_arguments(['dev'])
assert_match('dev', options[:environment])
end
@@ -131,15 +142,29 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
end
def app
- @app ||= build_app(console: FakeConsole)
+ @app ||= build_app(FakeConsole)
end
- def build_app(config)
- config = mock("config", config)
- app = mock("app", config: config)
- app.stubs(:sandbox=).returns(nil)
- app.expects(:load_console)
- app
+ def build_app(console)
+ mocked_console = Class.new do
+ attr_reader :sandbox, :console
+
+ def initialize(console)
+ @console = console
+ end
+
+ def config
+ self
+ end
+
+ def sandbox=(arg)
+ @sandbox = arg
+ end
+
+ def load_console
+ end
+ end
+ mocked_console.new(console)
end
def parse_arguments(args)