File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 33module AnnotateRb
44 class Runner
55 class << self
6+ attr_reader :runner
7+
68 def run ( args )
7- new . run ( args )
9+ self . runner = new
10+
11+ runner . run ( args )
12+
13+ self . runner = nil
814 end
15+
16+ def running?
17+ !!runner
18+ end
19+
20+ private
21+
22+ attr_writer :runner
923 end
1024
1125 def run ( args )
Original file line number Diff line number Diff line change 8484 expect ( command_double ) . to have_received ( :call )
8585 end
8686 end
87+
88+ describe ".running?" do
89+ context "when an instance is not running" do
90+ it "is false" do
91+ expect ( AnnotateRb ::Runner ) . not_to be_running
92+ end
93+ end
94+
95+ context "when an instance is running" do
96+ it "is true" do
97+ expect ( AnnotateRb ::Runner ) . not_to be_running
98+
99+ double = instance_double ( described_class )
100+
101+ allow ( described_class ) . to receive ( :new ) . and_return ( double )
102+
103+ expect ( double ) . to receive ( :run ) do |original_method , *args |
104+ expect ( AnnotateRb ::Runner ) . to be_running
105+
106+ true
107+ end
108+
109+ AnnotateRb ::Runner . run ( { } )
110+ end
111+ end
112+ end
87113end
You can’t perform that action at this time.
0 commit comments