spec/learn_open/opener_spec.rb in learn-open-1.2.21 vs spec/learn_open/opener_spec.rb in learn-open-1.2.22
- old
+ new
@@ -10,10 +10,15 @@
before do
create_home_dir
create_netrc_file
create_learn_config_file
+
+ allow(LearnOpen::GitSSHConnector)
+ .to receive(:call)
+ .with(git_server: instance_of(String), environment: anything)
+ .and_return(true)
end
context "Initializer" do
it "sets the lesson" do
opener = LearnOpen::Opener.new("ttt-2-board-rb-v-000","", false)
@@ -45,10 +50,14 @@
expect(learn_web_client)
.to receive(:fork_repo)
.with(repo_name: "rails-dynamic-request-lab-cb-000")
+ expect(LearnOpen::GitSSHConnector)
+ .to receive(:call)
+ .with(git_server: instance_of(String), environment: instance_of(LearnOpen::Environments::MacEnvironment))
+
opener = LearnOpen::Opener.new(nil, "atom", true,
learn_web_client: learn_web_client,
git_adapter: git_adapter,
environment_vars: {"SHELL" => "/usr/local/bin/fish"},
system_adapter: system_adapter,
@@ -158,11 +167,11 @@
.to receive(:puts)
.with("WARNING: You are attempting to open a lesson that is beyond your current lesson.")
expect(io)
.to receive(:print)
- .with("Are you sure you want to continue? [Yn]: ")
+ .with("Are you sure you want to continue? [Y/n]: ")
expect(io)
.to receive(:gets)
.and_return("yes")
@@ -254,10 +263,39 @@
end
end
end
context "Logging" do
let(:environment) {{ "SHELL" => "/usr/local/bin/fish", "JUPYTER_CONTAINER" => "true" }}
+
+ it "logs if an SSH connection cannot be made" do
+ allow(LearnOpen::LessonDownloader).to receive(:call).and_return(:ssh_unauthenticated)
+
+ allow(system_adapter).to receive_messages(
+ open_editor: :noop,
+ spawn: :noop,
+ watch_dir: :noop,
+ open_login_shell: :noop,
+ change_context_directory: :noop,
+ run_command: :noop,
+ )
+
+ io = StringIO.new
+
+ opener = LearnOpen::Opener.new("ruby_lab", "atom", false,
+ learn_web_client: learn_web_client,
+ git_adapter: git_adapter,
+ environment_vars: environment,
+ system_adapter: system_adapter,
+ io: io)
+ opener.run
+ io.rewind
+ expect(io.read).to eq(<<-EOF)
+Looking for lesson...
+Failed to obtain an SSH connection!
+ EOF
+ end
+
it "prints the right things" do
allow(learn_web_client).to receive(:fork_repo)
allow(git_adapter).to receive(:clone).and_call_original
@@ -741,9 +779,10 @@
Opening lesson...
Installing pip dependencies...
Done.
EOF
end
+
it "runs npm install if lab is a node lab" do
expect(system_adapter)
.to receive(:open_editor)
.with("atom", path: ".")