Skip to content

Commit

Permalink
Introduce controller type for specs
Browse files Browse the repository at this point in the history
  • Loading branch information
lexun committed Feb 18, 2015
1 parent 5d09e12 commit 4b3f850
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
5 changes: 1 addition & 4 deletions spec/lib/launchpad/gui/controllers/main_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe Launchpad::MainController do
describe Launchpad::MainController, type: :controller do
let(:stage_class) { described_class::Stage }
let(:stage_double) { double 'stage' }

Expand All @@ -9,9 +9,6 @@
end

before do
described_class.define_singleton_method(:initialize) {}
described_class.define_singleton_method(:new) { allocate }

allow(stage_class).to receive(:new).and_return stage_double
messages.each { |message| allow(stage_double).to receive message }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe Launchpad::OptionsController do
describe Launchpad::OptionsController, type: :controller do
subject do
described_class.new.tap do |controller|
controller.instance_variable_set :@stage, stage_double
Expand All @@ -9,11 +9,6 @@

let(:stage_double) { double 'stage', close: true }

before do
described_class.define_singleton_method(:initialize) {}
described_class.define_singleton_method(:new) { allocate }
end

describe '#cancel' do
before { subject.cancel }

Expand Down
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@
RSpec.configure do |config|
# Exit the javafx toolkit after running specs
config.after(:suite) { JavaFXImpl::PlatformImpl.tkExit }

# Remove jrubyfx controller overrides
config.before(:example, type: :controller) do
described_class.define_singleton_method(:initialize) {}
described_class.define_singleton_method(:new) { allocate }
end
end

0 comments on commit 4b3f850

Please sign in to comment.